1
0
mirror of synced 2026-07-08 09:30:02 +00:00
Files
playwright-java/README.md
Yury Semikhatsky 0e3b273fbf chore: roll driver to 1.61.0-beta-1781285686000
Ported upstream changes:
- #40843 page.localStorage()/sessionStorage() (WebStorage API)
- #40849 context.credentials() WebAuthn virtual authenticator
- #40932 APIResponse.securityDetails()/serverAddr()
- #41162 ScreencastFrame.timestamp()
- #40916 screencast cursor and size options
- #40844 comma-separated testIdAttribute (getByTestId now uses internal:testid)
- #40718 waitForEventInfo replaced with fire-and-forget __waitInfo__
- #40780 protocol Page.close split into close and runBeforeUnload
- #40801 Frame.expect failures are now protocol errors with errorDetails
- #41014 connectOverCDP allowed for WebKit, artifactsDir option
2026-06-12 12:25:16 -07:00

2.8 KiB

🎭 Playwright for Java

javadoc maven version Join Discord

Website | API reference

Playwright is a Java library to automate Chromium, Firefox and WebKit with a single API. Playwright is built to enable cross-browser web automation that is ever-green, capable, reliable and fast.

Linux macOS Windows
Chromium 149.0.7827.55
WebKit 26.5
Firefox 151.0

Documentation

https://playwright.dev/java/docs/intro

API Reference

https://playwright.dev/java/docs/api/class-playwright

Example

This code snippet navigates to Playwright homepage in Chromium, Firefox and WebKit, and saves 3 screenshots.

import com.microsoft.playwright.*;

import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;

public class PageScreenshot {
  public static void main(String[] args) {
    try (Playwright playwright = Playwright.create()) {
      List<BrowserType> browserTypes = Arrays.asList(
        playwright.chromium(),
        playwright.webkit(),
        playwright.firefox()
      );
      for (BrowserType browserType : browserTypes) {
        try (Browser browser = browserType.launch()) {
          BrowserContext context = browser.newContext();
          Page page = context.newPage();
          page.navigate("https://playwright.dev/");
          page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("screenshot-" + browserType.name() + ".png")));
        }
      }
    }
  }
}

Other languages

More comfortable in another programming language? Playwright is also available in