public interface Playwright extends AutoCloseable
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();
}
}
}
| Modifier and Type | Method and Description |
|---|---|
BrowserType |
chromium()
This object can be used to launch or connect to Chromium, returning instances of
Browser. |
void |
close()
Terminates this instance of Playwright, will also close all created browsers if they are still running.
|
static Playwright |
create()
Launches new Playwright driver process and connects to it.
|
BrowserType |
firefox()
This object can be used to launch or connect to Firefox, returning instances of
Browser. |
Selectors |
selectors()
Selectors can be used to install custom selector engines.
|
BrowserType |
webkit()
This object can be used to launch or connect to WebKit, returning instances of
Browser. |
BrowserType chromium()
Browser.BrowserType firefox()
Browser.Selectors selectors()
BrowserType webkit()
Browser.void close()
close in interface AutoCloseablestatic Playwright create()
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();
}Copyright © 2021. All rights reserved.