Skip to content

Commit 17cc3b8

Browse files
authored
docs: abridge readme, redirect to playwright.dev (#1766)
1 parent 43016df commit 17cc3b8

File tree

1 file changed

+10
-127
lines changed

1 file changed

+10
-127
lines changed

README.md

Lines changed: 10 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -28,41 +28,15 @@ Headless execution is supported for all the browsers on all platforms. Check out
2828
* [Contributing](#contributing)
2929
* [Is Playwright for Java ready?](#is-playwright-for-java-ready)
3030

31-
## Usage
32-
33-
Playwright requires **Java 8** or newer.
34-
35-
#### Add Maven dependency
36-
37-
Playwright is distributed as a set of [Maven](https://maven.apache.org/what-is-maven.html) modules. The easiest way to use it is to add one dependency to your Maven `pom.xml` file as described below. If you're not familiar with Maven please refer to its [documentation](https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html).
38-
39-
To run Playwright simply add following dependency to your Maven project:
40-
41-
```xml
42-
<dependency>
43-
<groupId>com.microsoft.playwright</groupId>
44-
<artifactId>playwright</artifactId>
45-
<version>1.41.0</version>
46-
</dependency>
47-
```
48-
49-
To run Playwright using Gradle add following dependency to your build.gradle file:
50-
51-
```gradle
52-
dependencies {
53-
implementation group: 'com.microsoft.playwright', name: 'playwright', version: '1.41.0'
54-
}
55-
```
56-
57-
#### Is Playwright thread-safe?
31+
## Documentation
5832

59-
No, Playwright is not thread safe, i.e. all its methods as well as methods on all objects created by it (such as BrowserContext, Browser, Page etc.) are expected to be called on the same thread where Playwright object was created or proper synchronization should be implemented to ensure only one thread calls Playwright methods at any given time. Having said that it's okay to create multiple Playwright instances each on its own thread.
33+
[https://playwright.dev/java/docs/intro](https://playwright.dev/java/docs/intro)
6034

61-
## Examples
35+
## API Reference
6236

63-
You can find Maven project with the examples [here](./examples).
37+
[https://playwright.dev/java/docs/api/class-playwright](https://playwright.dev/java/docs/api/class-playwright)
6438

65-
#### Page screenshot
39+
## Example
6640

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

@@ -94,100 +68,9 @@ public class PageScreenshot {
9468
}
9569
```
9670

97-
#### Mobile and geolocation
98-
99-
This snippet emulates Mobile Chromium on a device at a given geolocation, navigates to openstreetmap.org, performs action and takes a screenshot.
100-
101-
```java
102-
import com.microsoft.playwright.options.*;
103-
import com.microsoft.playwright.*;
104-
105-
import java.nio.file.Paths;
106-
107-
import static java.util.Arrays.asList;
108-
109-
public class MobileAndGeolocation {
110-
public static void main(String[] args) {
111-
try (Playwright playwright = Playwright.create()) {
112-
Browser browser = playwright.chromium().launch();
113-
BrowserContext context = browser.newContext(new Browser.NewContextOptions()
114-
.setUserAgent("Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3765.0 Mobile Safari/537.36")
115-
.setViewportSize(411, 731)
116-
.setDeviceScaleFactor(2.625)
117-
.setIsMobile(true)
118-
.setHasTouch(true)
119-
.setLocale("en-US")
120-
.setGeolocation(41.889938, 12.492507)
121-
.setPermissions(asList("geolocation")));
122-
Page page = context.newPage();
123-
page.navigate("https://www.openstreetmap.org/");
124-
page.click("a[data-bs-original-title=\"Show My Location\"]");
125-
page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("colosseum-pixel2.png")));
126-
}
127-
}
128-
}
129-
```
130-
131-
#### Evaluate JavaScript in browser
132-
133-
This code snippet navigates to example.com in Firefox, and executes a script in the page context.
134-
135-
```java
136-
import com.microsoft.playwright.*;
137-
138-
public class EvaluateInBrowserContext {
139-
public static void main(String[] args) {
140-
try (Playwright playwright = Playwright.create()) {
141-
Browser browser = playwright.firefox().launch();
142-
BrowserContext context = browser.newContext();
143-
Page page = context.newPage();
144-
page.navigate("https://www.example.com/");
145-
Object dimensions = page.evaluate("() => {\n" +
146-
" return {\n" +
147-
" width: document.documentElement.clientWidth,\n" +
148-
" height: document.documentElement.clientHeight,\n" +
149-
" deviceScaleFactor: window.devicePixelRatio\n" +
150-
" }\n" +
151-
"}");
152-
System.out.println(dimensions);
153-
}
154-
}
155-
}
156-
```
157-
158-
#### Intercept network requests
159-
160-
This code snippet sets up request routing for a WebKit page to log all network requests.
161-
162-
```java
163-
import com.microsoft.playwright.*;
164-
165-
public class InterceptNetworkRequests {
166-
public static void main(String[] args) {
167-
try (Playwright playwright = Playwright.create()) {
168-
Browser browser = playwright.webkit().launch();
169-
BrowserContext context = browser.newContext();
170-
Page page = context.newPage();
171-
page.route("**", route -> {
172-
System.out.println(route.request().url());
173-
route.resume();
174-
});
175-
page.navigate("http://todomvc.com");
176-
}
177-
}
178-
}
179-
```
180-
181-
## Documentation
182-
183-
Check out our official [documentation site](https://playwright.dev/java).
184-
185-
You can also browse [javadoc online](https://www.javadoc.io/doc/com.microsoft.playwright/playwright/latest/index.html).
186-
187-
## Contributing
188-
189-
Follow [the instructions](https://github.com/microsoft/playwright-java/blob/main/CONTRIBUTING.md#getting-code) to build the project from source and install the driver.
190-
191-
## Is Playwright for Java ready?
71+
## Other languages
19272

193-
Yes, Playwright for Java is ready. v1.10.0 is the first stable release. Going forward we will adhere to [semantic versioning](https://semver.org/) of the API.
73+
More comfortable in another programming language? [Playwright](https://playwright.dev) is also available in
74+
- [Node.js (JavaScript / TypeScript)](https://playwright.dev/docs/intro),
75+
- [Python](https://playwright.dev/python/docs/intro).
76+
- [.NET](https://playwright.dev/dotnet/docs/intro),

0 commit comments

Comments
 (0)