2020-09-25 10:37:17 -07:00
# 🎭 [Playwright](https://github.com/microsoft/playwright) for Java
2020-10-22 17:45:14 -07:00
### _The project is in early developement phase, some of the APIs are not implemented yet, others may change._
## Usage
Follow [the instructions ](https://github.com/microsoft/playwright-java/blob/master/CONTRIBUTING.md#getting-code ) to build the project from source and install driver.
Simple example:
```java
package com.microsoft.playwright.example;
import com.microsoft.playwright.*;
2020-12-03 18:41:46 +01:00
import java.nio.file.Paths;
2020-10-22 22:41:34 -07:00
2020-10-22 17:45:14 -07:00
public class Main {
public static void main(String[] args) {
Playwright playwright = Playwright.create();
2020-10-22 22:41:34 -07:00
Browser browser = playwright.chromium().launch();
2020-10-22 17:45:14 -07:00
BrowserContext context = browser.newContext(
new Browser.NewContextOptions().withViewport(800, 600));
Page page = context.newPage();
2020-10-22 22:41:34 -07:00
page.navigate("https://webkit.org");
2020-10-22 17:45:14 -07:00
page.click("text=check feature status");
2020-12-03 18:41:46 +01:00
page.screenshot(new Page.ScreenshotOptions().withPath(Paths.get("s.png")));
2020-10-22 17:45:14 -07:00
browser.close();
}
}
```
Original Playwright [documentation ](https://playwright.dev/ ). We will convert it to Javadoc eventually.