GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Playwright for Java
  • Docs
  • API
  • Node.js
  • Python
  • .NET
  • Community
  • Classes
  • APIRequestContext
  • APIResponse
  • Browser
  • BrowserContext
  • BrowserType
  • CDPSession

This view

  • Original page
  • New address

GeezerVison is showing playwright.dev — Playwright | Playwright Java

Playwright module provides a method to launch a browser instance. The following is a typical example of using Playwright to drive automation:

import com.microsoft.playwright.*;

public class Example {
public static void main(String[] args) {
try (Playwright playwright = Playwright.create()) {
BrowserType chromium = playwright.chromium();
Browser browser = chromium.launch();
Page page = browser.newPage();
page.navigate("http://example.com");
// other actions...
browser.close();
}
}
}

Methods​

close​

Added in: v1.9 playwright.close

Terminates this instance of Playwright, will also close all created browsers if they are still running.

Usage

Playwright.close();

create​

Added in: v1.10 playwright.create

Launches new Playwright driver process and connects to it. Playwright.close() should be called when the instance is no longer needed.

Playwright playwright = Playwright.create();
Browser browser = playwright.webkit().launch();
Page page = browser.newPage();
page.navigate("https://www.w3.org/");
playwright.close();

Usage

Playwright.create();
Playwright.create(options);

Arguments

  • options Playwright.CreateOptions (optional)
    • setEnv Map<String, String> (optional) Added in: v1.13#

      Additional environment variables that will be passed to the driver process. By default driver process inherits environment variables of the Playwright process.

Returns

  • Playwright#

Properties​

chromium()​

Added before v1.9 playwright.chromium()

This object can be used to launch or connect to Chromium, returning instances of Browser.

Usage

Playwright.chromium()

Returns

  • BrowserType

firefox()​

Added before v1.9 playwright.firefox()

This object can be used to launch or connect to Firefox, returning instances of Browser.

Usage

Playwright.firefox()

Returns

  • BrowserType

request()​

Added in: v1.16 playwright.request()

Exposes API that can be used for the Web API testing.

Usage

Playwright.request()

Returns

  • APIRequest

selectors()​

Added before v1.9 playwright.selectors()

Selectors can be used to install custom selector engines. See extensibility for more information.

Usage

Playwright.selectors()

Returns

  • Selectors

webkit()​

Added before v1.9 playwright.webkit()

This object can be used to launch or connect to WebKit, returning instances of Browser.

Usage

Playwright.webkit()

Returns

  • BrowserType
  • Methods
    • close
    • create
  • Properties
    • chromium()
    • firefox()
    • request()
    • selectors()
    • webkit()
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.