Playwright for .NET

website·Indexed 43 days ago

https://playwright.dev/

Documentation for Playwright for .NET, a framework for end-to-end testing and automation. It includes guides on network monitoring, mocking APIs, capturing screenshots and videos, using the Trace Viewer GUI, and integrating with test runners like MSTest, NUnit, and xUnit. The API supports browser automation, Web API testing via APIRequestContext, and interaction with web page dialogs, frames, and WebView2.

Tokens
1.1M
Snippets
6.9K
Records
8.3K
Agent score
65%

What's inside Playwright

  1. Overview of virtual WebAuthn authenticator (Credentials)

    Credentials is a virtual WebAuthn authenticator scoped to a BrowserContext. It enables tests to register passkeys and respond to navigator.credentials.create() and navigator.credentials.get() ceremonies within a page without needing a real hardware security key. To activate the virtual authenticator, you must call InstallAsync() before the page interacts with navigator.credentials.
  2. Overview of APIRequestContext for Web API testing

    The APIRequestContext class is used for Web API testing in Playwright. It allows developers to trigger API endpoints, configure micro-services, and prepare environments for end-to-end tests using standard HTTP verbs.

    There are two ways to obtain an APIRequestContext:

    1. Associated with a Browser Context: Accessible via browserContext.request or page.request. These share the same cookie jar as the BrowserContext.
    2. Standalone/Isolated: Created via apiRequest.newContext(). This instance has its own isolated cookie storage and does not share cookies with the browser.
  3. Overview of Playwright Mouse class

    The Mouse class in Playwright Python allows for precise mouse control. It operates using main-frame CSS pixels relative to the top-left corner of the viewport. Every page object has its own Mouse instance accessible via page.mouse.
  4. Overview of the Playwright Mouse class

    The Mouse class allows for low-level mouse control. It operates using main-frame CSS pixels relative to the top-left corner of the viewport. Every page object has its own Mouse instance accessible via page.mouse. To debug mouse movements, use the Trace viewer or Playwright Inspector, which will display a red dot at the location of every mouse action.
  5. Overview of TestStepInfo

    TestStepInfo provides information and control utilities for a currently running test step. It is passed as an argument to the callback function within test.step().
    import { test, expect } from '@playwright/test';
    
    test('basic test', async ({ page, browserName }) => {
      await test.step('check some behavior', async step => {
        // 'step' is an instance of TestStepInfo
        step.skip(browserName === 'webkit', 'The feature is not available in WebKit');
      });
    });
  6. Overview of the Playwright Mouse class

    The Mouse class allows for low-level mouse control in Playwright. It operates using main-frame CSS pixels relative to the top-left corner of the viewport. Every page object has its own Mouse instance accessible via page.mouse. To debug mouse movements, use the Trace viewer or Playwright Inspector, which display a red dot at the location of every mouse action.
    // Example: Using ‘page.mouse’ to trace a 100x100 square.
    await page.mouse.move(0, 0);
    await page.mouse.down();
    await page.mouse.move(0, 100);
    await page.mouse.move(100, 100);
    await page.mouse.move(100, 0);
    await page.mouse.move(0, 0);
    await page.mouse.up();
  7. Overview of Playwright Java Clock API

    The Clock API allows developers to manipulate and control time within tests to validate time-dependent features (like timeouts, scheduled tasks, and rendering time) without waiting for real-time execution. It overrides native global classes and functions including Date, setTimeout, clearTimeout, setInterval, clearInterval, requestAnimationFrame, cancelAnimationFrame, requestIdleCallback, cancelIdleCallback, performance, and Event.timeStamp.
  8. Overview of Playwright TestCase class

    TestCase corresponds to every test() call in a test file. If a single test() is running across multiple projects or is repeated multiple times, it will have multiple TestCase objects within the corresponding projects' suites.
  9. Overview of Playwright Keyboard API

    The Keyboard class provides an API for managing a virtual keyboard in Playwright. It allows for high-level text entry via type() or fine-grained control over keyboard events using down(), up(), and insert_text(). This is useful for simulating complex user interactions like selecting text with Shift and arrow keys or triggering keyboard shortcuts.
    # Example: Select and delete text
    page.keyboard.type("Hello World!")
    page.keyboard.press("ArrowLeft")
    page.keyboard.down("Shift")
    for i in range(6):
        page.keyboard.press("ArrowLeft")
    page.keyboard.up("Shift")
    page.keyboard.press("Backspace")
    # Result text: "Hello!"
  10. Overview of Playwright CLI for coding agents

    The Playwright CLI is a command-line interface for browser automation designed for coding agents (such as Claude Code or Copilot). It focuses on token efficiency by using concise CLI output and installable skills, reducing the amount of context needed in the model's window. Key architectural features include a daemon architecture for persistent browser processes (eliminating startup costs per command) and ref-based interactions using accessibility snapshots for deterministic element targeting.
  11. Overview of playwright-cli for coding agents

    playwright-cli is a command-line interface for browser automation optimized for coding agents (such as Claude Code and GitHub Copilot). It provides token-efficient browser control via concise CLI commands and installable skills, avoiding the need to load large tool schemas or verbose accessibility trees into the model's context window.
  12. Overview of playwright-cli for coding agents

    playwright-cli is a command-line interface for browser automation designed for coding agents (such as Claude Code and GitHub Copilot). It focuses on token efficiency by using concise CLI commands and installable skills, avoiding the need to load large tool schemas or verbose accessibility trees into the model's context window. This differs from the Playwright MCP, which is better suited for specialized agentic loops requiring persistent state and iterative reasoning over page structure.