1
0
mirror of synced 2026-05-23 11:13:15 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Yury Semikhatsky e5de3898ad chore: mark 1.32.0 (#1251) 2023-03-27 15:58:05 -07:00
69 changed files with 345 additions and 1802 deletions
+6 -11
View File
@@ -1,4 +1,4 @@
name: Docker
name: Test Docker
on:
push:
paths:
@@ -18,18 +18,13 @@ on:
- release-*
jobs:
test:
name: Test
timeout-minutes: 120
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
flavor: [focal, jammy]
timeout-minutes: 60
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- name: Build Docker image
run: bash utils/docker/build.sh --amd64 ${{ matrix.flavor }} playwright-java:localbuild-${{ matrix.flavor }}
run: bash utils/docker/build.sh --amd64 focal playwright-java:localbuild-focal
- name: Test
run: |
CONTAINER_ID="$(docker run --rm --ipc=host -v $(pwd):/root/playwright --name playwright-docker-test -d -t playwright-java:localbuild-${{ matrix.flavor }} /bin/bash)"
CONTAINER_ID="$(docker run --rm --ipc=host -v $(pwd):/root/playwright --name playwright-docker-test -d -t playwright-java:localbuild-focal /bin/bash)"
docker exec "${CONTAINER_ID}" /root/playwright/tools/test-local-installation/create_project_and_run_tests.sh
+5 -5
View File
@@ -11,9 +11,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom
| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->115.0.5790.75<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit <!-- GEN:webkit-version -->17.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->115.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Chromium <!-- GEN:chromium-version -->112.0.5615.29<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit <!-- GEN:webkit-version -->16.4<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->111.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
Headless execution is supported for all the browsers on all platforms. Check out [system requirements](https://playwright.dev/java/docs/next/intro/#system-requirements) for details.
@@ -65,7 +65,7 @@ You can find Maven project with the examples [here](./examples).
#### Page screenshot
This code snippet navigates to Playwright homepage in Chromium, Firefox and WebKit, and saves 3 screenshots.
This code snippet navigates to whatsmyuseragent.org in Chromium, Firefox and WebKit, and saves 3 screenshots.
```java
import com.microsoft.playwright.*;
@@ -86,7 +86,7 @@ public class PageScreenshot {
try (Browser browser = browserType.launch()) {
BrowserContext context = browser.newContext();
Page page = context.newPage();
page.navigate("https://playwright.dev/");
page.navigate("http://whatsmyuseragent.org/");
page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("screenshot-" + browserType.name() + ".png")));
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.36.0</version>
<version>1.32.0</version>
</parent>
<artifactId>driver-bundle</artifactId>
@@ -194,11 +194,7 @@ public class DriverJar extends Driver {
}
}
if (name.contains("mac os x")) {
if (arch.equals("aarch64")) {
return "mac-arm64";
} else {
return "mac";
}
return "mac";
}
throw new RuntimeException("Unexpected os.name value: " + name);
}
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.36.0</version>
<version>1.32.0</version>
</parent>
<artifactId>driver</artifactId>
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>org.example</groupId>
<artifactId>examples</artifactId>
<version>1.36.0</version>
<version>1.32.0</version>
<name>Playwright Client Examples</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -34,7 +34,7 @@ public class PageScreenshot {
try (Browser browser = browserType.launch()) {
BrowserContext context = browser.newContext();
Page page = context.newPage();
page.navigate("https://playwright.dev/");
page.navigate("http://whatsmyuseragent.org/");
page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("screenshot-" + browserType.name() + ".png")));
}
}
@@ -24,7 +24,7 @@ public class WebKitScreenshot {
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.webkit().launch();
Page page = browser.newPage();
page.navigate("https://playwright.dev/");
page.navigate("http://whatsmyuseragent.org/");
page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("example.png")));
}
}
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.36.0</version>
<version>1.32.0</version>
</parent>
<artifactId>playwright</artifactId>
@@ -42,12 +42,11 @@ public interface APIRequest {
*/
public String baseURL;
/**
* An object containing additional HTTP headers to be sent with every request. Defaults to none.
* An object containing additional HTTP headers to be sent with every request.
*/
public Map<String, String> extraHTTPHeaders;
/**
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>. If
* no origin is specified, the username and password are sent to any servers upon unauthorized responses.
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>.
*/
public HttpCredentials httpCredentials;
/**
@@ -100,22 +99,20 @@ public interface APIRequest {
return this;
}
/**
* An object containing additional HTTP headers to be sent with every request. Defaults to none.
* An object containing additional HTTP headers to be sent with every request.
*/
public NewContextOptions setExtraHTTPHeaders(Map<String, String> extraHTTPHeaders) {
this.extraHTTPHeaders = extraHTTPHeaders;
return this;
}
/**
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>. If
* no origin is specified, the username and password are sent to any servers upon unauthorized responses.
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>.
*/
public NewContextOptions setHttpCredentials(String username, String password) {
return setHttpCredentials(new HttpCredentials(username, password));
}
/**
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>. If
* no origin is specified, the username and password are sent to any servers upon unauthorized responses.
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>.
*/
public NewContextOptions setHttpCredentials(HttpCredentials httpCredentials) {
this.httpCredentials = httpCredentials;
@@ -66,7 +66,7 @@ public interface Browser extends AutoCloseable {
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* corresponding URL. Unset by default. Examples:
* corresponding URL. Examples:
* <ul>
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
* http://localhost:3000/bar.html}</li>
@@ -78,7 +78,7 @@ public interface Browser extends AutoCloseable {
*/
public String baseURL;
/**
* Toggles bypassing page's Content-Security-Policy. Defaults to {@code false}.
* Toggles bypassing page's Content-Security-Policy.
*/
public Boolean bypassCSP;
/**
@@ -88,12 +88,11 @@ public interface Browser extends AutoCloseable {
*/
public Optional<ColorScheme> colorScheme;
/**
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#devices">emulating devices with device scale factor</a>.
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}.
*/
public Double deviceScaleFactor;
/**
* An object containing additional HTTP headers to be sent with every request. Defaults to none.
* An object containing additional HTTP headers to be sent with every request.
*/
public Map<String, String> extraHTTPHeaders;
/**
@@ -104,13 +103,11 @@ public interface Browser extends AutoCloseable {
public Optional<ForcedColors> forcedColors;
public Geolocation geolocation;
/**
* Specifies if viewport supports touch events. Defaults to false. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#devices">mobile emulation</a>.
* Specifies if viewport supports touch events. Defaults to false.
*/
public Boolean hasTouch;
/**
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>. If
* no origin is specified, the username and password are sent to any servers upon unauthorized responses.
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>.
*/
public HttpCredentials httpCredentials;
/**
@@ -118,35 +115,30 @@ public interface Browser extends AutoCloseable {
*/
public Boolean ignoreHTTPSErrors;
/**
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. isMobile is a part of device,
* so you don't actually need to set it manually. Defaults to {@code false} and is not supported in Firefox. Learn more
* about <a href="https://playwright.dev/java/docs/emulation#isMobile">mobile emulation</a>.
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. Defaults to {@code false}. Not
* supported in Firefox.
*/
public Boolean isMobile;
/**
* Whether or not to enable JavaScript in the context. Defaults to {@code true}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#javascript-enabled">disabling JavaScript</a>.
* Whether or not to enable JavaScript in the context. Defaults to {@code true}.
*/
public Boolean javaScriptEnabled;
/**
* Specify user locale, for example {@code en-GB}, {@code de-DE}, etc. Locale will affect {@code navigator.language} value,
* {@code Accept-Language} request header value as well as number and date formatting rules. Defaults to the system default
* locale. Learn more about emulation in our <a
* href="https://playwright.dev/java/docs/emulation#locale--timezone">emulation guide</a>.
* {@code Accept-Language} request header value as well as number and date formatting rules.
*/
public String locale;
/**
* Whether to emulate network being offline. Defaults to {@code false}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#offline">network emulation</a>.
* Whether to emulate network being offline. Defaults to {@code false}.
*/
public Boolean offline;
/**
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
* BrowserContext.grantPermissions()} for more details. Defaults to none.
* BrowserContext.grantPermissions()} for more details.
*/
public List<String> permissions;
/**
* Network proxy settings to use with this context. Defaults to none.
* Network proxy settings to use with this context.
*
* <p> <strong>NOTE:</strong> For Chromium on Windows the browser needs to be launched with the global proxy for this option to work. If all contexts
* override the proxy, global proxy will be never used and can be any string, for example {@code launch({ proxy: { server:
@@ -221,14 +213,13 @@ public interface Browser extends AutoCloseable {
/**
* If set to true, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors
* that imply single target DOM element will throw when more than one element matches the selector. This option does not
* affect any Locator APIs (Locators are always strict). Defaults to {@code false}. See {@code Locator} to learn more about
* the strict mode.
* affect any Locator APIs (Locators are always strict). See {@code Locator} to learn more about the strict mode.
*/
public Boolean strictSelectors;
/**
* Changes the timezone of the context. See <a
* href="https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1">ICU's
* metaZones.txt</a> for a list of supported timezone IDs. Defaults to the system timezone.
* metaZones.txt</a> for a list of supported timezone IDs.
*/
public String timezoneId;
/**
@@ -236,9 +227,8 @@ public interface Browser extends AutoCloseable {
*/
public String userAgent;
/**
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the
* consistent viewport emulation. Learn more about <a href="https://playwright.dev/java/docs/emulation#viewport">viewport
* emulation</a>.
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent
* viewport emulation.
*
* <p> <strong>NOTE:</strong> The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the
* operating system. It makes the execution of the tests non-deterministic.
@@ -257,7 +247,7 @@ public interface Browser extends AutoCloseable {
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* corresponding URL. Unset by default. Examples:
* corresponding URL. Examples:
* <ul>
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
* http://localhost:3000/bar.html}</li>
@@ -272,7 +262,7 @@ public interface Browser extends AutoCloseable {
return this;
}
/**
* Toggles bypassing page's Content-Security-Policy. Defaults to {@code false}.
* Toggles bypassing page's Content-Security-Policy.
*/
public NewContextOptions setBypassCSP(boolean bypassCSP) {
this.bypassCSP = bypassCSP;
@@ -288,15 +278,14 @@ public interface Browser extends AutoCloseable {
return this;
}
/**
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#devices">emulating devices with device scale factor</a>.
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}.
*/
public NewContextOptions setDeviceScaleFactor(double deviceScaleFactor) {
this.deviceScaleFactor = deviceScaleFactor;
return this;
}
/**
* An object containing additional HTTP headers to be sent with every request. Defaults to none.
* An object containing additional HTTP headers to be sent with every request.
*/
public NewContextOptions setExtraHTTPHeaders(Map<String, String> extraHTTPHeaders) {
this.extraHTTPHeaders = extraHTTPHeaders;
@@ -319,23 +308,20 @@ public interface Browser extends AutoCloseable {
return this;
}
/**
* Specifies if viewport supports touch events. Defaults to false. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#devices">mobile emulation</a>.
* Specifies if viewport supports touch events. Defaults to false.
*/
public NewContextOptions setHasTouch(boolean hasTouch) {
this.hasTouch = hasTouch;
return this;
}
/**
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>. If
* no origin is specified, the username and password are sent to any servers upon unauthorized responses.
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>.
*/
public NewContextOptions setHttpCredentials(String username, String password) {
return setHttpCredentials(new HttpCredentials(username, password));
}
/**
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>. If
* no origin is specified, the username and password are sent to any servers upon unauthorized responses.
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>.
*/
public NewContextOptions setHttpCredentials(HttpCredentials httpCredentials) {
this.httpCredentials = httpCredentials;
@@ -349,17 +335,15 @@ public interface Browser extends AutoCloseable {
return this;
}
/**
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. isMobile is a part of device,
* so you don't actually need to set it manually. Defaults to {@code false} and is not supported in Firefox. Learn more
* about <a href="https://playwright.dev/java/docs/emulation#isMobile">mobile emulation</a>.
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. Defaults to {@code false}. Not
* supported in Firefox.
*/
public NewContextOptions setIsMobile(boolean isMobile) {
this.isMobile = isMobile;
return this;
}
/**
* Whether or not to enable JavaScript in the context. Defaults to {@code true}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#javascript-enabled">disabling JavaScript</a>.
* Whether or not to enable JavaScript in the context. Defaults to {@code true}.
*/
public NewContextOptions setJavaScriptEnabled(boolean javaScriptEnabled) {
this.javaScriptEnabled = javaScriptEnabled;
@@ -367,17 +351,14 @@ public interface Browser extends AutoCloseable {
}
/**
* Specify user locale, for example {@code en-GB}, {@code de-DE}, etc. Locale will affect {@code navigator.language} value,
* {@code Accept-Language} request header value as well as number and date formatting rules. Defaults to the system default
* locale. Learn more about emulation in our <a
* href="https://playwright.dev/java/docs/emulation#locale--timezone">emulation guide</a>.
* {@code Accept-Language} request header value as well as number and date formatting rules.
*/
public NewContextOptions setLocale(String locale) {
this.locale = locale;
return this;
}
/**
* Whether to emulate network being offline. Defaults to {@code false}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#offline">network emulation</a>.
* Whether to emulate network being offline. Defaults to {@code false}.
*/
public NewContextOptions setOffline(boolean offline) {
this.offline = offline;
@@ -385,14 +366,14 @@ public interface Browser extends AutoCloseable {
}
/**
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
* BrowserContext.grantPermissions()} for more details. Defaults to none.
* BrowserContext.grantPermissions()} for more details.
*/
public NewContextOptions setPermissions(List<String> permissions) {
this.permissions = permissions;
return this;
}
/**
* Network proxy settings to use with this context. Defaults to none.
* Network proxy settings to use with this context.
*
* <p> <strong>NOTE:</strong> For Chromium on Windows the browser needs to be launched with the global proxy for this option to work. If all contexts
* override the proxy, global proxy will be never used and can be any string, for example {@code launch({ proxy: { server:
@@ -402,7 +383,7 @@ public interface Browser extends AutoCloseable {
return setProxy(new Proxy(server));
}
/**
* Network proxy settings to use with this context. Defaults to none.
* Network proxy settings to use with this context.
*
* <p> <strong>NOTE:</strong> For Chromium on Windows the browser needs to be launched with the global proxy for this option to work. If all contexts
* override the proxy, global proxy will be never used and can be any string, for example {@code launch({ proxy: { server:
@@ -535,8 +516,7 @@ public interface Browser extends AutoCloseable {
/**
* If set to true, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors
* that imply single target DOM element will throw when more than one element matches the selector. This option does not
* affect any Locator APIs (Locators are always strict). Defaults to {@code false}. See {@code Locator} to learn more about
* the strict mode.
* affect any Locator APIs (Locators are always strict). See {@code Locator} to learn more about the strict mode.
*/
public NewContextOptions setStrictSelectors(boolean strictSelectors) {
this.strictSelectors = strictSelectors;
@@ -545,7 +525,7 @@ public interface Browser extends AutoCloseable {
/**
* Changes the timezone of the context. See <a
* href="https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1">ICU's
* metaZones.txt</a> for a list of supported timezone IDs. Defaults to the system timezone.
* metaZones.txt</a> for a list of supported timezone IDs.
*/
public NewContextOptions setTimezoneId(String timezoneId) {
this.timezoneId = timezoneId;
@@ -559,9 +539,8 @@ public interface Browser extends AutoCloseable {
return this;
}
/**
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the
* consistent viewport emulation. Learn more about <a href="https://playwright.dev/java/docs/emulation#viewport">viewport
* emulation</a>.
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent
* viewport emulation.
*
* <p> <strong>NOTE:</strong> The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the
* operating system. It makes the execution of the tests non-deterministic.
@@ -570,9 +549,8 @@ public interface Browser extends AutoCloseable {
return setViewportSize(new ViewportSize(width, height));
}
/**
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the
* consistent viewport emulation. Learn more about <a href="https://playwright.dev/java/docs/emulation#viewport">viewport
* emulation</a>.
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent
* viewport emulation.
*
* <p> <strong>NOTE:</strong> The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the
* operating system. It makes the execution of the tests non-deterministic.
@@ -592,7 +570,7 @@ public interface Browser extends AutoCloseable {
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* corresponding URL. Unset by default. Examples:
* corresponding URL. Examples:
* <ul>
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
* http://localhost:3000/bar.html}</li>
@@ -604,7 +582,7 @@ public interface Browser extends AutoCloseable {
*/
public String baseURL;
/**
* Toggles bypassing page's Content-Security-Policy. Defaults to {@code false}.
* Toggles bypassing page's Content-Security-Policy.
*/
public Boolean bypassCSP;
/**
@@ -614,12 +592,11 @@ public interface Browser extends AutoCloseable {
*/
public Optional<ColorScheme> colorScheme;
/**
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#devices">emulating devices with device scale factor</a>.
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}.
*/
public Double deviceScaleFactor;
/**
* An object containing additional HTTP headers to be sent with every request. Defaults to none.
* An object containing additional HTTP headers to be sent with every request.
*/
public Map<String, String> extraHTTPHeaders;
/**
@@ -630,13 +607,11 @@ public interface Browser extends AutoCloseable {
public Optional<ForcedColors> forcedColors;
public Geolocation geolocation;
/**
* Specifies if viewport supports touch events. Defaults to false. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#devices">mobile emulation</a>.
* Specifies if viewport supports touch events. Defaults to false.
*/
public Boolean hasTouch;
/**
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>. If
* no origin is specified, the username and password are sent to any servers upon unauthorized responses.
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>.
*/
public HttpCredentials httpCredentials;
/**
@@ -644,35 +619,30 @@ public interface Browser extends AutoCloseable {
*/
public Boolean ignoreHTTPSErrors;
/**
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. isMobile is a part of device,
* so you don't actually need to set it manually. Defaults to {@code false} and is not supported in Firefox. Learn more
* about <a href="https://playwright.dev/java/docs/emulation#isMobile">mobile emulation</a>.
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. Defaults to {@code false}. Not
* supported in Firefox.
*/
public Boolean isMobile;
/**
* Whether or not to enable JavaScript in the context. Defaults to {@code true}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#javascript-enabled">disabling JavaScript</a>.
* Whether or not to enable JavaScript in the context. Defaults to {@code true}.
*/
public Boolean javaScriptEnabled;
/**
* Specify user locale, for example {@code en-GB}, {@code de-DE}, etc. Locale will affect {@code navigator.language} value,
* {@code Accept-Language} request header value as well as number and date formatting rules. Defaults to the system default
* locale. Learn more about emulation in our <a
* href="https://playwright.dev/java/docs/emulation#locale--timezone">emulation guide</a>.
* {@code Accept-Language} request header value as well as number and date formatting rules.
*/
public String locale;
/**
* Whether to emulate network being offline. Defaults to {@code false}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#offline">network emulation</a>.
* Whether to emulate network being offline. Defaults to {@code false}.
*/
public Boolean offline;
/**
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
* BrowserContext.grantPermissions()} for more details. Defaults to none.
* BrowserContext.grantPermissions()} for more details.
*/
public List<String> permissions;
/**
* Network proxy settings to use with this context. Defaults to none.
* Network proxy settings to use with this context.
*
* <p> <strong>NOTE:</strong> For Chromium on Windows the browser needs to be launched with the global proxy for this option to work. If all contexts
* override the proxy, global proxy will be never used and can be any string, for example {@code launch({ proxy: { server:
@@ -747,14 +717,13 @@ public interface Browser extends AutoCloseable {
/**
* If set to true, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors
* that imply single target DOM element will throw when more than one element matches the selector. This option does not
* affect any Locator APIs (Locators are always strict). Defaults to {@code false}. See {@code Locator} to learn more about
* the strict mode.
* affect any Locator APIs (Locators are always strict). See {@code Locator} to learn more about the strict mode.
*/
public Boolean strictSelectors;
/**
* Changes the timezone of the context. See <a
* href="https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1">ICU's
* metaZones.txt</a> for a list of supported timezone IDs. Defaults to the system timezone.
* metaZones.txt</a> for a list of supported timezone IDs.
*/
public String timezoneId;
/**
@@ -762,9 +731,8 @@ public interface Browser extends AutoCloseable {
*/
public String userAgent;
/**
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the
* consistent viewport emulation. Learn more about <a href="https://playwright.dev/java/docs/emulation#viewport">viewport
* emulation</a>.
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent
* viewport emulation.
*
* <p> <strong>NOTE:</strong> The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the
* operating system. It makes the execution of the tests non-deterministic.
@@ -783,7 +751,7 @@ public interface Browser extends AutoCloseable {
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* corresponding URL. Unset by default. Examples:
* corresponding URL. Examples:
* <ul>
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
* http://localhost:3000/bar.html}</li>
@@ -798,7 +766,7 @@ public interface Browser extends AutoCloseable {
return this;
}
/**
* Toggles bypassing page's Content-Security-Policy. Defaults to {@code false}.
* Toggles bypassing page's Content-Security-Policy.
*/
public NewPageOptions setBypassCSP(boolean bypassCSP) {
this.bypassCSP = bypassCSP;
@@ -814,15 +782,14 @@ public interface Browser extends AutoCloseable {
return this;
}
/**
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#devices">emulating devices with device scale factor</a>.
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}.
*/
public NewPageOptions setDeviceScaleFactor(double deviceScaleFactor) {
this.deviceScaleFactor = deviceScaleFactor;
return this;
}
/**
* An object containing additional HTTP headers to be sent with every request. Defaults to none.
* An object containing additional HTTP headers to be sent with every request.
*/
public NewPageOptions setExtraHTTPHeaders(Map<String, String> extraHTTPHeaders) {
this.extraHTTPHeaders = extraHTTPHeaders;
@@ -845,23 +812,20 @@ public interface Browser extends AutoCloseable {
return this;
}
/**
* Specifies if viewport supports touch events. Defaults to false. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#devices">mobile emulation</a>.
* Specifies if viewport supports touch events. Defaults to false.
*/
public NewPageOptions setHasTouch(boolean hasTouch) {
this.hasTouch = hasTouch;
return this;
}
/**
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>. If
* no origin is specified, the username and password are sent to any servers upon unauthorized responses.
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>.
*/
public NewPageOptions setHttpCredentials(String username, String password) {
return setHttpCredentials(new HttpCredentials(username, password));
}
/**
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>. If
* no origin is specified, the username and password are sent to any servers upon unauthorized responses.
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>.
*/
public NewPageOptions setHttpCredentials(HttpCredentials httpCredentials) {
this.httpCredentials = httpCredentials;
@@ -875,17 +839,15 @@ public interface Browser extends AutoCloseable {
return this;
}
/**
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. isMobile is a part of device,
* so you don't actually need to set it manually. Defaults to {@code false} and is not supported in Firefox. Learn more
* about <a href="https://playwright.dev/java/docs/emulation#isMobile">mobile emulation</a>.
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. Defaults to {@code false}. Not
* supported in Firefox.
*/
public NewPageOptions setIsMobile(boolean isMobile) {
this.isMobile = isMobile;
return this;
}
/**
* Whether or not to enable JavaScript in the context. Defaults to {@code true}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#javascript-enabled">disabling JavaScript</a>.
* Whether or not to enable JavaScript in the context. Defaults to {@code true}.
*/
public NewPageOptions setJavaScriptEnabled(boolean javaScriptEnabled) {
this.javaScriptEnabled = javaScriptEnabled;
@@ -893,17 +855,14 @@ public interface Browser extends AutoCloseable {
}
/**
* Specify user locale, for example {@code en-GB}, {@code de-DE}, etc. Locale will affect {@code navigator.language} value,
* {@code Accept-Language} request header value as well as number and date formatting rules. Defaults to the system default
* locale. Learn more about emulation in our <a
* href="https://playwright.dev/java/docs/emulation#locale--timezone">emulation guide</a>.
* {@code Accept-Language} request header value as well as number and date formatting rules.
*/
public NewPageOptions setLocale(String locale) {
this.locale = locale;
return this;
}
/**
* Whether to emulate network being offline. Defaults to {@code false}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#offline">network emulation</a>.
* Whether to emulate network being offline. Defaults to {@code false}.
*/
public NewPageOptions setOffline(boolean offline) {
this.offline = offline;
@@ -911,14 +870,14 @@ public interface Browser extends AutoCloseable {
}
/**
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
* BrowserContext.grantPermissions()} for more details. Defaults to none.
* BrowserContext.grantPermissions()} for more details.
*/
public NewPageOptions setPermissions(List<String> permissions) {
this.permissions = permissions;
return this;
}
/**
* Network proxy settings to use with this context. Defaults to none.
* Network proxy settings to use with this context.
*
* <p> <strong>NOTE:</strong> For Chromium on Windows the browser needs to be launched with the global proxy for this option to work. If all contexts
* override the proxy, global proxy will be never used and can be any string, for example {@code launch({ proxy: { server:
@@ -928,7 +887,7 @@ public interface Browser extends AutoCloseable {
return setProxy(new Proxy(server));
}
/**
* Network proxy settings to use with this context. Defaults to none.
* Network proxy settings to use with this context.
*
* <p> <strong>NOTE:</strong> For Chromium on Windows the browser needs to be launched with the global proxy for this option to work. If all contexts
* override the proxy, global proxy will be never used and can be any string, for example {@code launch({ proxy: { server:
@@ -1061,8 +1020,7 @@ public interface Browser extends AutoCloseable {
/**
* If set to true, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors
* that imply single target DOM element will throw when more than one element matches the selector. This option does not
* affect any Locator APIs (Locators are always strict). Defaults to {@code false}. See {@code Locator} to learn more about
* the strict mode.
* affect any Locator APIs (Locators are always strict). See {@code Locator} to learn more about the strict mode.
*/
public NewPageOptions setStrictSelectors(boolean strictSelectors) {
this.strictSelectors = strictSelectors;
@@ -1071,7 +1029,7 @@ public interface Browser extends AutoCloseable {
/**
* Changes the timezone of the context. See <a
* href="https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1">ICU's
* metaZones.txt</a> for a list of supported timezone IDs. Defaults to the system timezone.
* metaZones.txt</a> for a list of supported timezone IDs.
*/
public NewPageOptions setTimezoneId(String timezoneId) {
this.timezoneId = timezoneId;
@@ -1085,9 +1043,8 @@ public interface Browser extends AutoCloseable {
return this;
}
/**
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the
* consistent viewport emulation. Learn more about <a href="https://playwright.dev/java/docs/emulation#viewport">viewport
* emulation</a>.
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent
* viewport emulation.
*
* <p> <strong>NOTE:</strong> The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the
* operating system. It makes the execution of the tests non-deterministic.
@@ -1096,9 +1053,8 @@ public interface Browser extends AutoCloseable {
return setViewportSize(new ViewportSize(width, height));
}
/**
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the
* consistent viewport emulation. Learn more about <a href="https://playwright.dev/java/docs/emulation#viewport">viewport
* emulation</a>.
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent
* viewport emulation.
*
* <p> <strong>NOTE:</strong> The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the
* operating system. It makes the execution of the tests non-deterministic.
@@ -58,51 +58,6 @@ public interface BrowserContext extends AutoCloseable {
*/
void offClose(Consumer<BrowserContext> handler);
/**
* Emitted when JavaScript within the page calls one of console API methods, e.g. {@code console.log} or {@code
* console.dir}. Also emitted if the page throws an error or a warning.
*
* <p> The arguments passed into {@code console.log} and the page are available on the {@code ConsoleMessage} event handler
* argument.
*
* <p> **Usage**
* <pre>{@code
* context.onConsoleMessage(msg -> {
* for (int i = 0; i < msg.args().size(); ++i)
* System.out.println(i + ": " + msg.args().get(i).jsonValue());
* });
* page.evaluate("() => console.log('hello', 5, { foo: 'bar' })");
* }</pre>
*/
void onConsoleMessage(Consumer<ConsoleMessage> handler);
/**
* Removes handler that was previously added with {@link #onConsoleMessage onConsoleMessage(handler)}.
*/
void offConsoleMessage(Consumer<ConsoleMessage> handler);
/**
* Emitted when a JavaScript dialog appears, such as {@code alert}, {@code prompt}, {@code confirm} or {@code
* beforeunload}. Listener **must** either {@link Dialog#accept Dialog.accept()} or {@link Dialog#dismiss Dialog.dismiss()}
* the dialog - otherwise the page will <a
* href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking">freeze</a> waiting for the
* dialog, and actions like click will never finish.
*
* <p> **Usage**
* <pre>{@code
* context.onDialog(dialog -> {
* dialog.accept();
* });
* }</pre>
*
* <p> <strong>NOTE:</strong> When no {@link Page#onDialog Page.onDialog()} or {@link BrowserContext#onDialog BrowserContext.onDialog()} listeners are
* present, all dialogs are automatically dismissed.
*/
void onDialog(Consumer<Dialog> handler);
/**
* Removes handler that was previously added with {@link #onDialog onDialog(handler)}.
*/
void offDialog(Consumer<Dialog> handler);
/**
* The event is emitted when a new Page is created in the BrowserContext. The page may still be loading. The event will
* also fire for popup pages. See also {@link Page#onPopup Page.onPopup()} to receive events about popups relevant to a
@@ -340,33 +295,6 @@ public interface BrowserContext extends AutoCloseable {
return this;
}
}
class WaitForConsoleMessageOptions {
/**
* Receives the {@code ConsoleMessage} object and resolves to truthy value when the waiting should resolve.
*/
public Predicate<ConsoleMessage> predicate;
/**
* Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The
* default value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
*/
public Double timeout;
/**
* Receives the {@code ConsoleMessage} object and resolves to truthy value when the waiting should resolve.
*/
public WaitForConsoleMessageOptions setPredicate(Predicate<ConsoleMessage> predicate) {
this.predicate = predicate;
return this;
}
/**
* Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The
* default value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
*/
public WaitForConsoleMessageOptions setTimeout(double timeout) {
this.timeout = timeout;
return this;
}
}
class WaitForPageOptions {
/**
* Receives the {@code Page} object and resolves to truthy value when the waiting should resolve.
@@ -403,9 +331,6 @@ public interface BrowserContext extends AutoCloseable {
* browserContext.addCookies(Arrays.asList(cookieObject1, cookieObject2));
* }</pre>
*
* @param cookies Adds cookies to the browser context.
*
* <p> For the cookie to apply to all subdomains as well, prefix domain with a dot, like this: ".example.com".
* @since v1.8
*/
void addCookies(List<Cookie> cookies);
@@ -1317,28 +1242,6 @@ public interface BrowserContext extends AutoCloseable {
* @since v1.32
*/
void waitForCondition(BooleanSupplier condition, WaitForConditionOptions options);
/**
* Performs action and waits for a {@code ConsoleMessage} to be logged by in the pages in the context. If predicate is
* provided, it passes {@code ConsoleMessage} value into the {@code predicate} function and waits for {@code
* predicate(message)} to return a truthy value. Will throw an error if the page is closed before the {@link
* BrowserContext#onConsoleMessage BrowserContext.onConsoleMessage()} event is fired.
*
* @param callback Callback that performs the action triggering the event.
* @since v1.34
*/
default ConsoleMessage waitForConsoleMessage(Runnable callback) {
return waitForConsoleMessage(null, callback);
}
/**
* Performs action and waits for a {@code ConsoleMessage} to be logged by in the pages in the context. If predicate is
* provided, it passes {@code ConsoleMessage} value into the {@code predicate} function and waits for {@code
* predicate(message)} to return a truthy value. Will throw an error if the page is closed before the {@link
* BrowserContext#onConsoleMessage BrowserContext.onConsoleMessage()} event is fired.
*
* @param callback Callback that performs the action triggering the event.
* @since v1.34
*/
ConsoleMessage waitForConsoleMessage(WaitForConsoleMessageOptions options, Runnable callback);
/**
* Performs action and waits for a new {@code Page} to be created in the context. If predicate is provided, it passes
* {@code Page} value into the {@code predicate} function and waits for {@code predicate(event)} to return a truthy value.
@@ -382,7 +382,7 @@ public interface BrowserType {
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* corresponding URL. Unset by default. Examples:
* corresponding URL. Examples:
* <ul>
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
* http://localhost:3000/bar.html}</li>
@@ -394,7 +394,7 @@ public interface BrowserType {
*/
public String baseURL;
/**
* Toggles bypassing page's Content-Security-Policy. Defaults to {@code false}.
* Toggles bypassing page's Content-Security-Policy.
*/
public Boolean bypassCSP;
/**
@@ -414,8 +414,7 @@ public interface BrowserType {
*/
public Optional<ColorScheme> colorScheme;
/**
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#devices">emulating devices with device scale factor</a>.
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}.
*/
public Double deviceScaleFactor;
/**
@@ -440,7 +439,7 @@ public interface BrowserType {
*/
public Path executablePath;
/**
* An object containing additional HTTP headers to be sent with every request. Defaults to none.
* An object containing additional HTTP headers to be sent with every request.
*/
public Map<String, String> extraHTTPHeaders;
/**
@@ -463,8 +462,7 @@ public interface BrowserType {
*/
public Boolean handleSIGTERM;
/**
* Specifies if viewport supports touch events. Defaults to false. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#devices">mobile emulation</a>.
* Specifies if viewport supports touch events. Defaults to false.
*/
public Boolean hasTouch;
/**
@@ -475,8 +473,7 @@ public interface BrowserType {
*/
public Boolean headless;
/**
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>. If
* no origin is specified, the username and password are sent to any servers upon unauthorized responses.
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>.
*/
public HttpCredentials httpCredentials;
/**
@@ -494,31 +491,26 @@ public interface BrowserType {
*/
public Boolean ignoreHTTPSErrors;
/**
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. isMobile is a part of device,
* so you don't actually need to set it manually. Defaults to {@code false} and is not supported in Firefox. Learn more
* about <a href="https://playwright.dev/java/docs/emulation#isMobile">mobile emulation</a>.
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. Defaults to {@code false}. Not
* supported in Firefox.
*/
public Boolean isMobile;
/**
* Whether or not to enable JavaScript in the context. Defaults to {@code true}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#javascript-enabled">disabling JavaScript</a>.
* Whether or not to enable JavaScript in the context. Defaults to {@code true}.
*/
public Boolean javaScriptEnabled;
/**
* Specify user locale, for example {@code en-GB}, {@code de-DE}, etc. Locale will affect {@code navigator.language} value,
* {@code Accept-Language} request header value as well as number and date formatting rules. Defaults to the system default
* locale. Learn more about emulation in our <a
* href="https://playwright.dev/java/docs/emulation#locale--timezone">emulation guide</a>.
* {@code Accept-Language} request header value as well as number and date formatting rules.
*/
public String locale;
/**
* Whether to emulate network being offline. Defaults to {@code false}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#offline">network emulation</a>.
* Whether to emulate network being offline. Defaults to {@code false}.
*/
public Boolean offline;
/**
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
* BrowserContext.grantPermissions()} for more details. Defaults to none.
* BrowserContext.grantPermissions()} for more details.
*/
public List<String> permissions;
/**
@@ -586,8 +578,7 @@ public interface BrowserType {
/**
* If set to true, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors
* that imply single target DOM element will throw when more than one element matches the selector. This option does not
* affect any Locator APIs (Locators are always strict). Defaults to {@code false}. See {@code Locator} to learn more about
* the strict mode.
* affect any Locator APIs (Locators are always strict). See {@code Locator} to learn more about the strict mode.
*/
public Boolean strictSelectors;
/**
@@ -598,7 +589,7 @@ public interface BrowserType {
/**
* Changes the timezone of the context. See <a
* href="https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1">ICU's
* metaZones.txt</a> for a list of supported timezone IDs. Defaults to the system timezone.
* metaZones.txt</a> for a list of supported timezone IDs.
*/
public String timezoneId;
/**
@@ -610,9 +601,8 @@ public interface BrowserType {
*/
public String userAgent;
/**
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the
* consistent viewport emulation. Learn more about <a href="https://playwright.dev/java/docs/emulation#viewport">viewport
* emulation</a>.
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent
* viewport emulation.
*
* <p> <strong>NOTE:</strong> The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the
* operating system. It makes the execution of the tests non-deterministic.
@@ -639,7 +629,7 @@ public interface BrowserType {
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* corresponding URL. Unset by default. Examples:
* corresponding URL. Examples:
* <ul>
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
* http://localhost:3000/bar.html}</li>
@@ -654,7 +644,7 @@ public interface BrowserType {
return this;
}
/**
* Toggles bypassing page's Content-Security-Policy. Defaults to {@code false}.
* Toggles bypassing page's Content-Security-Policy.
*/
public LaunchPersistentContextOptions setBypassCSP(boolean bypassCSP) {
this.bypassCSP = bypassCSP;
@@ -696,8 +686,7 @@ public interface BrowserType {
return this;
}
/**
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#devices">emulating devices with device scale factor</a>.
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}.
*/
public LaunchPersistentContextOptions setDeviceScaleFactor(double deviceScaleFactor) {
this.deviceScaleFactor = deviceScaleFactor;
@@ -737,7 +726,7 @@ public interface BrowserType {
return this;
}
/**
* An object containing additional HTTP headers to be sent with every request. Defaults to none.
* An object containing additional HTTP headers to be sent with every request.
*/
public LaunchPersistentContextOptions setExtraHTTPHeaders(Map<String, String> extraHTTPHeaders) {
this.extraHTTPHeaders = extraHTTPHeaders;
@@ -781,8 +770,7 @@ public interface BrowserType {
return this;
}
/**
* Specifies if viewport supports touch events. Defaults to false. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#devices">mobile emulation</a>.
* Specifies if viewport supports touch events. Defaults to false.
*/
public LaunchPersistentContextOptions setHasTouch(boolean hasTouch) {
this.hasTouch = hasTouch;
@@ -799,15 +787,13 @@ public interface BrowserType {
return this;
}
/**
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>. If
* no origin is specified, the username and password are sent to any servers upon unauthorized responses.
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>.
*/
public LaunchPersistentContextOptions setHttpCredentials(String username, String password) {
return setHttpCredentials(new HttpCredentials(username, password));
}
/**
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>. If
* no origin is specified, the username and password are sent to any servers upon unauthorized responses.
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>.
*/
public LaunchPersistentContextOptions setHttpCredentials(HttpCredentials httpCredentials) {
this.httpCredentials = httpCredentials;
@@ -837,17 +823,15 @@ public interface BrowserType {
return this;
}
/**
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. isMobile is a part of device,
* so you don't actually need to set it manually. Defaults to {@code false} and is not supported in Firefox. Learn more
* about <a href="https://playwright.dev/java/docs/emulation#isMobile">mobile emulation</a>.
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. Defaults to {@code false}. Not
* supported in Firefox.
*/
public LaunchPersistentContextOptions setIsMobile(boolean isMobile) {
this.isMobile = isMobile;
return this;
}
/**
* Whether or not to enable JavaScript in the context. Defaults to {@code true}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#javascript-enabled">disabling JavaScript</a>.
* Whether or not to enable JavaScript in the context. Defaults to {@code true}.
*/
public LaunchPersistentContextOptions setJavaScriptEnabled(boolean javaScriptEnabled) {
this.javaScriptEnabled = javaScriptEnabled;
@@ -855,17 +839,14 @@ public interface BrowserType {
}
/**
* Specify user locale, for example {@code en-GB}, {@code de-DE}, etc. Locale will affect {@code navigator.language} value,
* {@code Accept-Language} request header value as well as number and date formatting rules. Defaults to the system default
* locale. Learn more about emulation in our <a
* href="https://playwright.dev/java/docs/emulation#locale--timezone">emulation guide</a>.
* {@code Accept-Language} request header value as well as number and date formatting rules.
*/
public LaunchPersistentContextOptions setLocale(String locale) {
this.locale = locale;
return this;
}
/**
* Whether to emulate network being offline. Defaults to {@code false}. Learn more about <a
* href="https://playwright.dev/java/docs/emulation#offline">network emulation</a>.
* Whether to emulate network being offline. Defaults to {@code false}.
*/
public LaunchPersistentContextOptions setOffline(boolean offline) {
this.offline = offline;
@@ -873,7 +854,7 @@ public interface BrowserType {
}
/**
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
* BrowserContext.grantPermissions()} for more details. Defaults to none.
* BrowserContext.grantPermissions()} for more details.
*/
public LaunchPersistentContextOptions setPermissions(List<String> permissions) {
this.permissions = permissions;
@@ -1005,8 +986,7 @@ public interface BrowserType {
/**
* If set to true, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors
* that imply single target DOM element will throw when more than one element matches the selector. This option does not
* affect any Locator APIs (Locators are always strict). Defaults to {@code false}. See {@code Locator} to learn more about
* the strict mode.
* affect any Locator APIs (Locators are always strict). See {@code Locator} to learn more about the strict mode.
*/
public LaunchPersistentContextOptions setStrictSelectors(boolean strictSelectors) {
this.strictSelectors = strictSelectors;
@@ -1023,7 +1003,7 @@ public interface BrowserType {
/**
* Changes the timezone of the context. See <a
* href="https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1">ICU's
* metaZones.txt</a> for a list of supported timezone IDs. Defaults to the system timezone.
* metaZones.txt</a> for a list of supported timezone IDs.
*/
public LaunchPersistentContextOptions setTimezoneId(String timezoneId) {
this.timezoneId = timezoneId;
@@ -1044,9 +1024,8 @@ public interface BrowserType {
return this;
}
/**
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the
* consistent viewport emulation. Learn more about <a href="https://playwright.dev/java/docs/emulation#viewport">viewport
* emulation</a>.
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent
* viewport emulation.
*
* <p> <strong>NOTE:</strong> The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the
* operating system. It makes the execution of the tests non-deterministic.
@@ -1055,9 +1034,8 @@ public interface BrowserType {
return setViewportSize(new ViewportSize(width, height));
}
/**
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the
* consistent viewport emulation. Learn more about <a href="https://playwright.dev/java/docs/emulation#viewport">viewport
* emulation</a>.
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent
* viewport emulation.
*
* <p> <strong>NOTE:</strong> The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the
* operating system. It makes the execution of the tests non-deterministic.
@@ -56,12 +56,6 @@ public interface ConsoleMessage {
* @since v1.8
*/
String location();
/**
* The page that produced this console message, if any.
*
* @since v1.34
*/
Page page();
/**
* The text of the console message.
*
@@ -81,12 +81,6 @@ public interface Dialog {
* @since v1.8
*/
String message();
/**
* The page that initiated this dialog, if available.
*
* @since v1.34
*/
Page page();
/**
* Returns dialog's type, can be one of {@code alert}, {@code beforeunload}, {@code confirm} or {@code prompt}.
*
@@ -602,15 +602,9 @@ public interface ElementHandle extends JSHandle {
public ScreenshotCaret caret;
/**
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box
* {@code #FF00FF} (customized by {@code maskColor}) that completely covers its bounding box.
* {@code #FF00FF} that completely covers its bounding box.
*/
public List<Locator> mask;
/**
* Specify the color of the overlay box for masked elements, in <a
* href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value">CSS color format</a>. Default color is pink {@code
* #FF00FF}.
*/
public String maskColor;
/**
* Hides default white background and allows capturing screenshots with transparency. Not applicable to {@code jpeg}
* images. Defaults to {@code false}.
@@ -669,21 +663,12 @@ public interface ElementHandle extends JSHandle {
}
/**
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box
* {@code #FF00FF} (customized by {@code maskColor}) that completely covers its bounding box.
* {@code #FF00FF} that completely covers its bounding box.
*/
public ScreenshotOptions setMask(List<Locator> mask) {
this.mask = mask;
return this;
}
/**
* Specify the color of the overlay box for masked elements, in <a
* href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value">CSS color format</a>. Default color is pink {@code
* #FF00FF}.
*/
public ScreenshotOptions setMaskColor(String maskColor) {
this.maskColor = maskColor;
return this;
}
/**
* Hides default white background and allows capturing screenshots with transparency. Not applicable to {@code jpeg}
* images. Defaults to {@code false}.
@@ -1046,8 +1046,8 @@ public interface Frame {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -1076,8 +1076,8 @@ public interface Frame {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -1476,19 +1476,6 @@ public interface Frame {
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public Locator has;
/**
* Matches elements that do not contain an element that matches an inner locator. Inner locator is queried against the
* outer one. For example, {@code article} that does not have {@code div} matches {@code
* <article><span>Playwright</span></article>}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public Locator hasNot;
/**
* Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When
* passed a [string], matching is case-insensitive and searches for a substring.
*/
public Object hasNotText;
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
* [string], matching is case-insensitive and searches for a substring. For example, {@code "Playwright"} matches {@code
@@ -1506,33 +1493,6 @@ public interface Frame {
this.has = has;
return this;
}
/**
* Matches elements that do not contain an element that matches an inner locator. Inner locator is queried against the
* outer one. For example, {@code article} that does not have {@code div} matches {@code
* <article><span>Playwright</span></article>}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public LocatorOptions setHasNot(Locator hasNot) {
this.hasNot = hasNot;
return this;
}
/**
* Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When
* passed a [string], matching is case-insensitive and searches for a substring.
*/
public LocatorOptions setHasNotText(String hasNotText) {
this.hasNotText = hasNotText;
return this;
}
/**
* Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When
* passed a [string], matching is case-insensitive and searches for a substring.
*/
public LocatorOptions setHasNotText(Pattern hasNotText) {
this.hasNotText = hasNotText;
return this;
}
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
* [string], matching is case-insensitive and searches for a substring. For example, {@code "Playwright"} matches {@code
@@ -1791,8 +1751,8 @@ public interface Frame {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -1813,8 +1773,8 @@ public interface Frame {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -2228,8 +2188,8 @@ public interface Frame {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -2277,8 +2237,8 @@ public interface Frame {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -2358,8 +2318,8 @@ public interface Frame {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -2380,8 +2340,8 @@ public interface Frame {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -4889,8 +4849,7 @@ public interface Frame {
* <ul>
* <li> {@code "load"} - wait for the {@code load} event to be fired.</li>
* <li> {@code "domcontentloaded"} - wait for the {@code DOMContentLoaded} event to be fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** wait until there are no network connections for at least {@code 500} ms. Don't
* use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - wait until there are no network connections for at least {@code 500} ms.</li>
* </ul>
* @since v1.8
*/
@@ -4931,8 +4890,7 @@ public interface Frame {
* <ul>
* <li> {@code "load"} - wait for the {@code load} event to be fired.</li>
* <li> {@code "domcontentloaded"} - wait for the {@code DOMContentLoaded} event to be fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** wait until there are no network connections for at least {@code 500} ms. Don't
* use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - wait until there are no network connections for at least {@code 500} ms.</li>
* </ul>
* @since v1.8
*/
@@ -291,19 +291,6 @@ public interface FrameLocator {
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public Locator has;
/**
* Matches elements that do not contain an element that matches an inner locator. Inner locator is queried against the
* outer one. For example, {@code article} that does not have {@code div} matches {@code
* <article><span>Playwright</span></article>}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public Locator hasNot;
/**
* Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When
* passed a [string], matching is case-insensitive and searches for a substring.
*/
public Object hasNotText;
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
* [string], matching is case-insensitive and searches for a substring. For example, {@code "Playwright"} matches {@code
@@ -321,33 +308,6 @@ public interface FrameLocator {
this.has = has;
return this;
}
/**
* Matches elements that do not contain an element that matches an inner locator. Inner locator is queried against the
* outer one. For example, {@code article} that does not have {@code div} matches {@code
* <article><span>Playwright</span></article>}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public LocatorOptions setHasNot(Locator hasNot) {
this.hasNot = hasNot;
return this;
}
/**
* Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When
* passed a [string], matching is case-insensitive and searches for a substring.
*/
public LocatorOptions setHasNotText(String hasNotText) {
this.hasNotText = hasNotText;
return this;
}
/**
* Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When
* passed a [string], matching is case-insensitive and searches for a substring.
*/
public LocatorOptions setHasNotText(Pattern hasNotText) {
this.hasNotText = hasNotText;
return this;
}
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
* [string], matching is case-insensitive and searches for a substring. For example, {@code "Playwright"} matches {@code
@@ -135,7 +135,7 @@ public interface JSHandle {
*
* <p> **Usage**
* <pre>{@code
* JSHandle handle = page.evaluateHandle("() => ({ window, document })");
* JSHandle handle = page.evaluateHandle("() => ({window, document}"););
* Map<String, JSHandle> properties = handle.getProperties();
* JSHandle windowHandle = properties.get("window");
* JSHandle documentHandle = properties.get("document");
@@ -662,19 +662,6 @@ public interface Locator {
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public Locator has;
/**
* Matches elements that do not contain an element that matches an inner locator. Inner locator is queried against the
* outer one. For example, {@code article} that does not have {@code div} matches {@code
* <article><span>Playwright</span></article>}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public Locator hasNot;
/**
* Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When
* passed a [string], matching is case-insensitive and searches for a substring.
*/
public Object hasNotText;
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
* [string], matching is case-insensitive and searches for a substring. For example, {@code "Playwright"} matches {@code
@@ -692,33 +679,6 @@ public interface Locator {
this.has = has;
return this;
}
/**
* Matches elements that do not contain an element that matches an inner locator. Inner locator is queried against the
* outer one. For example, {@code article} that does not have {@code div} matches {@code
* <article><span>Playwright</span></article>}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public FilterOptions setHasNot(Locator hasNot) {
this.hasNot = hasNot;
return this;
}
/**
* Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When
* passed a [string], matching is case-insensitive and searches for a substring.
*/
public FilterOptions setHasNotText(String hasNotText) {
this.hasNotText = hasNotText;
return this;
}
/**
* Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When
* passed a [string], matching is case-insensitive and searches for a substring.
*/
public FilterOptions setHasNotText(Pattern hasNotText) {
this.hasNotText = hasNotText;
return this;
}
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
* [string], matching is case-insensitive and searches for a substring. For example, {@code "Playwright"} matches {@code
@@ -1268,19 +1228,6 @@ public interface Locator {
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public Locator has;
/**
* Matches elements that do not contain an element that matches an inner locator. Inner locator is queried against the
* outer one. For example, {@code article} that does not have {@code div} matches {@code
* <article><span>Playwright</span></article>}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public Locator hasNot;
/**
* Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When
* passed a [string], matching is case-insensitive and searches for a substring.
*/
public Object hasNotText;
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
* [string], matching is case-insensitive and searches for a substring. For example, {@code "Playwright"} matches {@code
@@ -1298,33 +1245,6 @@ public interface Locator {
this.has = has;
return this;
}
/**
* Matches elements that do not contain an element that matches an inner locator. Inner locator is queried against the
* outer one. For example, {@code article} that does not have {@code div} matches {@code
* <article><span>Playwright</span></article>}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public LocatorOptions setHasNot(Locator hasNot) {
this.hasNot = hasNot;
return this;
}
/**
* Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When
* passed a [string], matching is case-insensitive and searches for a substring.
*/
public LocatorOptions setHasNotText(String hasNotText) {
this.hasNotText = hasNotText;
return this;
}
/**
* Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When
* passed a [string], matching is case-insensitive and searches for a substring.
*/
public LocatorOptions setHasNotText(Pattern hasNotText) {
this.hasNotText = hasNotText;
return this;
}
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
* [string], matching is case-insensitive and searches for a substring. For example, {@code "Playwright"} matches {@code
@@ -1407,15 +1327,9 @@ public interface Locator {
public ScreenshotCaret caret;
/**
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box
* {@code #FF00FF} (customized by {@code maskColor}) that completely covers its bounding box.
* {@code #FF00FF} that completely covers its bounding box.
*/
public List<Locator> mask;
/**
* Specify the color of the overlay box for masked elements, in <a
* href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value">CSS color format</a>. Default color is pink {@code
* #FF00FF}.
*/
public String maskColor;
/**
* Hides default white background and allows capturing screenshots with transparency. Not applicable to {@code jpeg}
* images. Defaults to {@code false}.
@@ -1474,21 +1388,12 @@ public interface Locator {
}
/**
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box
* {@code #FF00FF} (customized by {@code maskColor}) that completely covers its bounding box.
* {@code #FF00FF} that completely covers its bounding box.
*/
public ScreenshotOptions setMask(List<Locator> mask) {
this.mask = mask;
return this;
}
/**
* Specify the color of the overlay box for masked elements, in <a
* href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value">CSS color format</a>. Default color is pink {@code
* #FF00FF}.
*/
public ScreenshotOptions setMaskColor(String maskColor) {
this.maskColor = maskColor;
return this;
}
/**
* Hides default white background and allows capturing screenshots with transparency. Not applicable to {@code jpeg}
* images. Defaults to {@code false}.
@@ -2035,10 +1940,9 @@ public interface Locator {
/**
* When locator points to a list of elements, returns array of locators, pointing to respective elements.
*
* <p> <strong>NOTE:</strong> {@link Locator#all Locator.all()} does not wait for elements to match the locator, and instead immediately returns
* whatever is present in the page. When the list of elements changes dynamically, {@link Locator#all Locator.all()} will
* produce unpredictable and flaky results. When the list of elements is stable, but loaded dynamically, wait for the full
* list to finish loading before calling {@link Locator#all Locator.all()}.
* <p> Note that {@link Locator#all Locator.all()} does not wait for elements to match the locator, and instead immediately
* returns whatever is present in the page. To avoid flakiness when elements are loaded dynamically, wait for the loading
* to finish before calling {@link Locator#all Locator.all()}.
*
* <p> **Usage**
* <pre>{@code
@@ -2071,20 +1975,6 @@ public interface Locator {
* @since v1.14
*/
List<String> allTextContents();
/**
* Creates a locator that matches both this locator and the argument locator.
*
* <p> **Usage**
*
* <p> The following example finds a button with a specific title.
* <pre>{@code
* Locator button = page.getByRole(AriaRole.BUTTON).and(page.getByTitle("Subscribe"));
* }</pre>
*
* @param locator Additional locator to match.
* @since v1.34
*/
Locator and(Locator locator);
/**
* Calls <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur">blur</a> on the element.
*
@@ -3854,26 +3744,6 @@ public interface Locator {
* @since v1.14
*/
Locator nth(int index);
/**
* Creates a locator that matches either of the two locators.
*
* <p> **Usage**
*
* <p> Consider a scenario where you'd like to click on a "New email" button, but sometimes a security settings dialog shows up
* instead. In this case, you can wait for either a "New email" button, or a dialog and act accordingly.
* <pre>{@code
* Locator newEmail = page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("New"));
* Locator dialog = page.getByText("Confirm security settings");
* assertThat(newEmail.or(dialog)).isVisible();
* if (dialog.isVisible())
* page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Dismiss")).click();
* newEmail.click();
* }</pre>
*
* @param locator Alternative locator to match.
* @since v1.33
*/
Locator or(Locator locator);
/**
* A page this locator belongs to.
*
@@ -82,15 +82,15 @@ public interface Page extends AutoCloseable {
* Emitted when JavaScript within the page calls one of console API methods, e.g. {@code console.log} or {@code
* console.dir}. Also emitted if the page throws an error or a warning.
*
* <p> The arguments passed into {@code console.log} are available on the {@code ConsoleMessage} event handler argument.
* <p> The arguments passed into {@code console.log} appear as arguments on the event handler.
*
* <p> **Usage**
* <p> An example of handling {@code console} event:
* <pre>{@code
* page.onConsoleMessage(msg -> {
* for (int i = 0; i < msg.args().size(); ++i)
* System.out.println(i + ": " + msg.args().get(i).jsonValue());
* });
* page.evaluate("() => console.log('hello', 5, { foo: 'bar' })");
* page.evaluate("() => console.log('hello', 5, {foo: 'bar'})");
* }</pre>
*/
void onConsoleMessage(Consumer<ConsoleMessage> handler);
@@ -127,16 +127,13 @@ public interface Page extends AutoCloseable {
* the dialog - otherwise the page will <a
* href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking">freeze</a> waiting for the
* dialog, and actions like click will never finish.
*
* <p> **Usage**
* <pre>{@code
* page.onDialog(dialog -> {
* dialog.accept();
* });
* }</pre>
*
* <p> <strong>NOTE:</strong> When no {@link Page#onDialog Page.onDialog()} or {@link BrowserContext#onDialog BrowserContext.onDialog()} listeners are
* present, all dialogs are automatically dismissed.
* <p> <strong>NOTE:</strong> When no {@link Page#onDialog Page.onDialog()} listeners are present, all dialogs are automatically dismissed.
*/
void onDialog(Consumer<Dialog> handler);
/**
@@ -1394,8 +1391,8 @@ public interface Page extends AutoCloseable {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -1416,8 +1413,8 @@ public interface Page extends AutoCloseable {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -1439,8 +1436,8 @@ public interface Page extends AutoCloseable {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -1461,8 +1458,8 @@ public interface Page extends AutoCloseable {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -1489,8 +1486,8 @@ public interface Page extends AutoCloseable {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -1519,8 +1516,8 @@ public interface Page extends AutoCloseable {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -1919,19 +1916,6 @@ public interface Page extends AutoCloseable {
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public Locator has;
/**
* Matches elements that do not contain an element that matches an inner locator. Inner locator is queried against the
* outer one. For example, {@code article} that does not have {@code div} matches {@code
* <article><span>Playwright</span></article>}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public Locator hasNot;
/**
* Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When
* passed a [string], matching is case-insensitive and searches for a substring.
*/
public Object hasNotText;
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
* [string], matching is case-insensitive and searches for a substring. For example, {@code "Playwright"} matches {@code
@@ -1949,33 +1933,6 @@ public interface Page extends AutoCloseable {
this.has = has;
return this;
}
/**
* Matches elements that do not contain an element that matches an inner locator. Inner locator is queried against the
* outer one. For example, {@code article} that does not have {@code div} matches {@code
* <article><span>Playwright</span></article>}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public LocatorOptions setHasNot(Locator hasNot) {
this.hasNot = hasNot;
return this;
}
/**
* Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When
* passed a [string], matching is case-insensitive and searches for a substring.
*/
public LocatorOptions setHasNotText(String hasNotText) {
this.hasNotText = hasNotText;
return this;
}
/**
* Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When
* passed a [string], matching is case-insensitive and searches for a substring.
*/
public LocatorOptions setHasNotText(Pattern hasNotText) {
this.hasNotText = hasNotText;
return this;
}
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
* [string], matching is case-insensitive and searches for a substring. For example, {@code "Playwright"} matches {@code
@@ -2247,8 +2204,8 @@ public interface Page extends AutoCloseable {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -2269,8 +2226,8 @@ public interface Page extends AutoCloseable {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -2397,7 +2354,7 @@ public interface Page extends AutoCloseable {
*/
public ScreenshotCaret caret;
/**
* An object which specifies clipping of the resulting image.
* An object which specifies clipping of the resulting image. Should have the following fields:
*/
public Clip clip;
/**
@@ -2407,15 +2364,9 @@ public interface Page extends AutoCloseable {
public Boolean fullPage;
/**
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box
* {@code #FF00FF} (customized by {@code maskColor}) that completely covers its bounding box.
* {@code #FF00FF} that completely covers its bounding box.
*/
public List<Locator> mask;
/**
* Specify the color of the overlay box for masked elements, in <a
* href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value">CSS color format</a>. Default color is pink {@code
* #FF00FF}.
*/
public String maskColor;
/**
* Hides default white background and allows capturing screenshots with transparency. Not applicable to {@code jpeg}
* images. Defaults to {@code false}.
@@ -2473,13 +2424,13 @@ public interface Page extends AutoCloseable {
return this;
}
/**
* An object which specifies clipping of the resulting image.
* An object which specifies clipping of the resulting image. Should have the following fields:
*/
public ScreenshotOptions setClip(double x, double y, double width, double height) {
return setClip(new Clip(x, y, width, height));
}
/**
* An object which specifies clipping of the resulting image.
* An object which specifies clipping of the resulting image. Should have the following fields:
*/
public ScreenshotOptions setClip(Clip clip) {
this.clip = clip;
@@ -2495,21 +2446,12 @@ public interface Page extends AutoCloseable {
}
/**
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box
* {@code #FF00FF} (customized by {@code maskColor}) that completely covers its bounding box.
* {@code #FF00FF} that completely covers its bounding box.
*/
public ScreenshotOptions setMask(List<Locator> mask) {
this.mask = mask;
return this;
}
/**
* Specify the color of the overlay box for masked elements, in <a
* href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value">CSS color format</a>. Default color is pink {@code
* #FF00FF}.
*/
public ScreenshotOptions setMaskColor(String maskColor) {
this.maskColor = maskColor;
return this;
}
/**
* Hides default white background and allows capturing screenshots with transparency. Not applicable to {@code jpeg}
* images. Defaults to {@code false}.
@@ -2728,8 +2670,8 @@ public interface Page extends AutoCloseable {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -2750,8 +2692,8 @@ public interface Page extends AutoCloseable {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -3262,8 +3204,8 @@ public interface Page extends AutoCloseable {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -3311,8 +3253,8 @@ public interface Page extends AutoCloseable {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -3498,8 +3440,8 @@ public interface Page extends AutoCloseable {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -3520,8 +3462,8 @@ public interface Page extends AutoCloseable {
* <ul>
* <li> {@code "domcontentloaded"} - consider operation to be finished when the {@code DOMContentLoaded} event is fired.</li>
* <li> {@code "load"} - consider operation to be finished when the {@code load} event is fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** consider operation to be finished when there are no network connections for at
* least {@code 500} ms. Don't use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - consider operation to be finished when there are no network connections for at least {@code 500}
* ms.</li>
* <li> {@code "commit"} - consider operation to be finished when network response is received and the document started loading.</li>
* </ul>
*/
@@ -7309,8 +7251,7 @@ public interface Page extends AutoCloseable {
* <ul>
* <li> {@code "load"} - wait for the {@code load} event to be fired.</li>
* <li> {@code "domcontentloaded"} - wait for the {@code DOMContentLoaded} event to be fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** wait until there are no network connections for at least {@code 500} ms. Don't
* use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - wait until there are no network connections for at least {@code 500} ms.</li>
* </ul>
* @since v1.8
*/
@@ -7367,8 +7308,7 @@ public interface Page extends AutoCloseable {
* <ul>
* <li> {@code "load"} - wait for the {@code load} event to be fired.</li>
* <li> {@code "domcontentloaded"} - wait for the {@code DOMContentLoaded} event to be fired.</li>
* <li> {@code "networkidle"} - **DISCOURAGED** wait until there are no network connections for at least {@code 500} ms. Don't
* use this method for testing, rely on web assertions to assess readiness instead.</li>
* <li> {@code "networkidle"} - wait until there are no network connections for at least {@code 500} ms.</li>
* </ul>
* @since v1.8
*/
@@ -154,10 +154,6 @@ public interface Route {
* If set changes the post data of request.
*/
public Object postData;
/**
* Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
*/
public Double timeout;
/**
* If set changes the request URL. New URL must have same protocol as original one.
*/
@@ -199,13 +195,6 @@ public interface Route {
this.postData = postData;
return this;
}
/**
* Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
*/
public FetchOptions setTimeout(double timeout) {
this.timeout = timeout;
return this;
}
/**
* If set changes the request URL. New URL must have same protocol as original one.
*/
@@ -37,29 +37,10 @@ import java.util.regex.Pattern;
* }</pre>
*/
public interface LocatorAssertions {
class IsAttachedOptions {
public Boolean attached;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
public Double timeout;
public IsAttachedOptions setAttached(boolean attached) {
this.attached = attached;
return this;
}
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
public IsAttachedOptions setTimeout(double timeout) {
this.timeout = timeout;
return this;
}
}
class IsCheckedOptions {
public Boolean checked;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
@@ -68,7 +49,7 @@ public interface LocatorAssertions {
return this;
}
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public IsCheckedOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -77,12 +58,12 @@ public interface LocatorAssertions {
}
class IsDisabledOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public IsDisabledOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -92,7 +73,7 @@ public interface LocatorAssertions {
class IsEditableOptions {
public Boolean editable;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
@@ -101,7 +82,7 @@ public interface LocatorAssertions {
return this;
}
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public IsEditableOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -110,12 +91,12 @@ public interface LocatorAssertions {
}
class IsEmptyOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public IsEmptyOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -125,7 +106,7 @@ public interface LocatorAssertions {
class IsEnabledOptions {
public Boolean enabled;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
@@ -134,7 +115,7 @@ public interface LocatorAssertions {
return this;
}
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public IsEnabledOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -143,12 +124,12 @@ public interface LocatorAssertions {
}
class IsFocusedOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public IsFocusedOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -157,12 +138,12 @@ public interface LocatorAssertions {
}
class IsHiddenOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public IsHiddenOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -176,7 +157,7 @@ public interface LocatorAssertions {
*/
public Double ratio;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
@@ -189,7 +170,7 @@ public interface LocatorAssertions {
return this;
}
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public IsInViewportOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -198,13 +179,13 @@ public interface LocatorAssertions {
}
class IsVisibleOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
public Boolean visible;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public IsVisibleOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -222,7 +203,7 @@ public interface LocatorAssertions {
*/
public Boolean ignoreCase;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
/**
@@ -239,7 +220,7 @@ public interface LocatorAssertions {
return this;
}
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public ContainsTextOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -255,12 +236,12 @@ public interface LocatorAssertions {
}
class HasAttributeOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public HasAttributeOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -269,12 +250,12 @@ public interface LocatorAssertions {
}
class HasClassOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public HasClassOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -283,12 +264,12 @@ public interface LocatorAssertions {
}
class HasCountOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public HasCountOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -297,12 +278,12 @@ public interface LocatorAssertions {
}
class HasCSSOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public HasCSSOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -311,12 +292,12 @@ public interface LocatorAssertions {
}
class HasIdOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public HasIdOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -325,12 +306,12 @@ public interface LocatorAssertions {
}
class HasJSPropertyOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public HasJSPropertyOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -344,7 +325,7 @@ public interface LocatorAssertions {
*/
public Boolean ignoreCase;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
/**
@@ -361,7 +342,7 @@ public interface LocatorAssertions {
return this;
}
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public HasTextOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -377,12 +358,12 @@ public interface LocatorAssertions {
}
class HasValueOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public HasValueOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -391,12 +372,12 @@ public interface LocatorAssertions {
}
class HasValuesOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public HasValuesOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -413,32 +394,6 @@ public interface LocatorAssertions {
* @since v1.20
*/
LocatorAssertions not();
/**
* Ensures that {@code Locator} points to an <a href="https://playwright.dev/java/docs/actionability#attached">attached</a>
* DOM node.
*
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByText("Hidden text")).isAttached();
* }</pre>
*
* @since v1.33
*/
default void isAttached() {
isAttached(null);
}
/**
* Ensures that {@code Locator} points to an <a href="https://playwright.dev/java/docs/actionability#attached">attached</a>
* DOM node.
*
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByText("Hidden text")).isAttached();
* }</pre>
*
* @since v1.33
*/
void isAttached(IsAttachedOptions options);
/**
* Ensures the {@code Locator} points to a checked input.
*
@@ -663,7 +618,7 @@ public interface LocatorAssertions {
*
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByText("Welcome")).isVisible();
* assertThat(page.locator(".my-element")).isVisible();
* }</pre>
*
* @since v1.20
@@ -677,7 +632,7 @@ public interface LocatorAssertions {
*
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByText("Welcome")).isVisible();
* assertThat(page.locator(".my-element")).isVisible();
* }</pre>
*
* @since v1.20
@@ -39,12 +39,12 @@ import java.util.regex.Pattern;
public interface PageAssertions {
class HasTitleOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public HasTitleOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -53,12 +53,12 @@ public interface PageAssertions {
}
class HasURLOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
* Time to retry the assertion for.
*/
public HasURLOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -53,8 +53,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
PageImpl ownerPage;
private static final Map<EventType, String> eventSubscriptions() {
Map<EventType, String> result = new HashMap<>();
result.put(EventType.CONSOLE, "console");
result.put(EventType.DIALOG, "dialog");
result.put(EventType.REQUEST, "request");
result.put(EventType.RESPONSE, "response");
result.put(EventType.REQUESTFINISHED, "requestFinished");
@@ -79,8 +77,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
enum EventType {
CLOSE,
CONSOLE,
DIALOG,
PAGE,
REQUEST,
REQUESTFAILED,
@@ -124,26 +120,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
listeners.remove(EventType.CLOSE, handler);
}
@Override
public void onConsoleMessage(Consumer<ConsoleMessage> handler) {
listeners.add(EventType.CONSOLE, handler);
}
@Override
public void offConsoleMessage(Consumer<ConsoleMessage> handler) {
listeners.remove(EventType.CONSOLE, handler);
}
@Override
public void onDialog(Consumer<Dialog> handler) {
listeners.add(EventType.DIALOG, handler);
}
@Override
public void offDialog(Consumer<Dialog> handler) {
listeners.remove(EventType.DIALOG, handler);
}
@Override
public void onPage(Consumer<Page> handler) {
listeners.add(EventType.PAGE, handler);
@@ -445,10 +421,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
@Override
public void setDefaultNavigationTimeout(double timeout) {
setDefaultNavigationTimeoutImpl(timeout);
}
void setDefaultNavigationTimeoutImpl(Double timeout) {
withLogging("BrowserContext.setDefaultNavigationTimeout", () -> {
timeoutSettings.setDefaultNavigationTimeout(timeout);
JsonObject params = new JsonObject();
@@ -459,10 +431,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
@Override
public void setDefaultTimeout(double timeout) {
setDefaultTimeoutImpl(timeout);
}
void setDefaultTimeoutImpl(Double timeout) {
withLogging("BrowserContext.setDefaultTimeout", () -> {
timeoutSettings.setDefaultTimeout(timeout);
JsonObject params = new JsonObject();
@@ -548,18 +516,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
runUntil(() -> {}, new WaitableRace<>(waitables));
}
@Override
public ConsoleMessage waitForConsoleMessage(WaitForConsoleMessageOptions options, Runnable code) {
return withWaitLogging("BrowserContext.waitForConsoleMessage", logger -> waitForConsoleMessageImpl(options, code));
}
private ConsoleMessage waitForConsoleMessageImpl(WaitForConsoleMessageOptions options, Runnable code) {
if (options == null) {
options = new WaitForConsoleMessageOptions();
}
return waitForEventWithTimeout(EventType.CONSOLE, code, options.predicate, options.timeout);
}
private class WaitableContextClose<R> extends WaitableEvent<EventType, R> {
WaitableContextClose() {
super(BrowserContextImpl.this.listeners, EventType.CLOSE);
@@ -588,7 +544,7 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
updateInterceptionPatterns();
}
if (handled == Router.HandleResult.NoMatchingHandler || handled == Router.HandleResult.Fallback) {
route.resume(null, true);
route.resume();
}
}
@@ -598,36 +554,7 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
@Override
protected void handleEvent(String event, JsonObject params) {
if ("dialog".equals(event)) {
String guid = params.getAsJsonObject("dialog").get("guid").getAsString();
DialogImpl dialog = connection.getExistingObject(guid);
boolean hasListeners = false;
if (listeners.hasListeners(EventType.DIALOG)) {
hasListeners = true;
listeners.notify(EventType.DIALOG, dialog);
}
PageImpl page = dialog.page();
if (page != null) {
if (page.listeners.hasListeners(PageImpl.EventType.DIALOG)) {
hasListeners = true;
page.listeners.notify(PageImpl.EventType.DIALOG, dialog);
}
}
// Although we do similar handling on the server side, we still need this logic
// on the client side due to a possible race condition between two async calls:
// a) removing "dialog" listener subscription (client->server)
// b) actual "dialog" event (server->client)
if (!hasListeners) {
if ("beforeunload".equals(dialog.type())) {
try {
dialog.accept();
} catch (PlaywrightException e) {
}
} else {
dialog.dismiss();
}
}
} else if ("route".equals(event)) {
if ("route".equals(event)) {
RouteImpl route = connection.getExistingObject(params.getAsJsonObject("route").get("guid").getAsString());
handleRoute(route);
} else if ("page".equals(event)) {
@@ -643,14 +570,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
if (binding != null) {
bindingCall.call(binding);
}
} else if ("console".equals(event)) {
String guid = params.getAsJsonObject("message").get("guid").getAsString();
ConsoleMessageImpl message = connection.getExistingObject(guid);
listeners.notify(BrowserContextImpl.EventType.CONSOLE, message);
PageImpl page = message.page();
if (page != null) {
page.listeners.notify(PageImpl.EventType.CONSOLE, message);
}
} else if ("request".equals(event)) {
String guid = params.getAsJsonObject("request").get("guid").getAsString();
RequestImpl request = connection.getExistingObject(guid);
@@ -20,7 +20,6 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.microsoft.playwright.ConsoleMessage;
import com.microsoft.playwright.JSHandle;
import com.microsoft.playwright.Page;
import java.util.ArrayList;
import java.util.List;
@@ -28,16 +27,8 @@ import java.util.List;
import static com.microsoft.playwright.impl.Serialization.gson;
public class ConsoleMessageImpl extends ChannelOwner implements ConsoleMessage {
private PageImpl page;
public ConsoleMessageImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
super(parent, type, guid, initializer);
// Note: currently, we only report console messages for pages and they always have a page.
// However, in the future we might report console messages for service workers or something else,
// where page() would be null.
if (initializer.has("page")) {
page = connection.getExistingObject(initializer.getAsJsonObject("page").get("guid").getAsString());
}
}
public String type() {
@@ -64,9 +55,4 @@ public class ConsoleMessageImpl extends ChannelOwner implements ConsoleMessage {
location.get("lineNumber").getAsNumber() + ":" +
location.get("columnNumber").getAsNumber();
}
@Override
public PageImpl page() {
return page;
}
}
@@ -18,18 +18,10 @@ package com.microsoft.playwright.impl;
import com.google.gson.JsonObject;
import com.microsoft.playwright.Dialog;
import com.microsoft.playwright.Page;
class DialogImpl extends ChannelOwner implements Dialog {
private PageImpl page;
DialogImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
super(parent, type, guid, initializer);
// Note: dialogs that open early during page initialization block it.
// Therefore, we must report the dialog without a page to be able to handle it.
if (initializer.has("page")) {
page = connection.getExistingObject(initializer.getAsJsonObject("page").get("guid").getAsString());
}
}
@Override
@@ -58,11 +50,6 @@ class DialogImpl extends ChannelOwner implements Dialog {
return initializer.get("message").getAsString();
}
@Override
public PageImpl page() {
return page;
}
@Override
public String type() {
return initializer.get("type").getAsString();
@@ -357,14 +357,6 @@ public class LocatorAssertionsImpl extends AssertionsBase implements LocatorAsse
return new LocatorAssertionsImpl(actualLocator, !isNot);
}
@Override
public void isAttached(IsAttachedOptions options) {
FrameExpectOptions frameOptions = convertType(options, FrameExpectOptions.class);
boolean attached = options == null || options.attached == null || options.attached == true;
String message = "Locator expected to be " + (attached ? "attached" : "detached");
expectTrue(attached ? "to.be.attached" : "to.be.detached", message, frameOptions);
}
private static Boolean shouldIgnoreCase(Object options) {
if (options == null) {
return null;
@@ -29,21 +29,12 @@ class LocatorImpl implements Locator {
if (options.hasText != null) {
selector += " >> internal:has-text=" + escapeForTextSelector(options.hasText, false);
}
if (options.hasNotText != null) {
selector += " >> internal:has-not-text=" + escapeForTextSelector(options.hasNotText, false);
}
if (options.has != null) {
LocatorImpl locator = (LocatorImpl) options.has;
if (locator.frame != frame)
throw new Error("Inner 'has' locator must belong to the same frame.");
selector += " >> internal:has=" + gson().toJson(locator.selector);
}
if (options.hasNot != null) {
LocatorImpl locator = (LocatorImpl) options.hasNot;
if (locator.frame != frame)
throw new Error("Inner 'hasNot' locator must belong to the same frame.");
selector += " >> internal:has-not=" + gson().toJson(locator.selector);
}
}
this.selector = selector;
}
@@ -91,14 +82,6 @@ class LocatorImpl implements Locator {
return (List<String>) frame.evalOnSelectorAll(selector, "ee => ee.map(e => e.textContent || '')");
}
@Override
public Locator and(Locator locator) {
LocatorImpl other = (LocatorImpl) locator;
if (other.frame != frame)
throw new Error("Locators must belong to the same frame.");
return new LocatorImpl(frame, selector + " >> internal:and=" + gson().toJson(other.selector), null);
}
@Override
public void blur(BlurOptions options) {
frame.withLogging("Locator.blur", () -> blurImpl(options));
@@ -415,14 +398,6 @@ class LocatorImpl implements Locator {
return new LocatorImpl(frame, selector + " >> nth=" + index, null);
}
@Override
public Locator or(Locator locator) {
LocatorImpl other = (LocatorImpl) locator;
if (other.frame != frame)
throw new Error("Locators must belong to the same frame.");
return new LocatorImpl(frame, selector + " >> internal:or=" + gson().toJson(other.selector), null);
}
@Override
public Page page() {
return frame.page();
@@ -51,8 +51,6 @@ public class PageImpl extends ChannelOwner implements Page {
private final Set<FrameImpl> frames = new LinkedHashSet<>();
private static final Map<EventType, String> eventSubscriptions() {
Map<EventType, String> result = new HashMap<>();
result.put(EventType.CONSOLE, "console");
result.put(EventType.DIALOG, "dialog");
result.put(EventType.REQUEST, "request");
result.put(EventType.RESPONSE, "response");
result.put(EventType.REQUESTFINISHED, "requestFinished");
@@ -115,7 +113,22 @@ public class PageImpl extends ChannelOwner implements Page {
@Override
protected void handleEvent(String event, JsonObject params) {
if ("worker".equals(event)) {
if ("dialog".equals(event)) {
String guid = params.getAsJsonObject("dialog").get("guid").getAsString();
DialogImpl dialog = connection.getExistingObject(guid);
if (listeners.hasListeners(EventType.DIALOG)) {
listeners.notify(EventType.DIALOG, dialog);
} else {
if ("beforeunload".equals(dialog.type())) {
try {
dialog.accept();
} catch (PlaywrightException e) {
}
} else {
dialog.dismiss();
}
}
} else if ("worker".equals(event)) {
String guid = params.getAsJsonObject("worker").get("guid").getAsString();
WorkerImpl worker = connection.getExistingObject(guid);
worker.page = this;
@@ -125,6 +138,10 @@ public class PageImpl extends ChannelOwner implements Page {
String guid = params.getAsJsonObject("webSocket").get("guid").getAsString();
WebSocketImpl webSocket = connection.getExistingObject(guid);
listeners.notify(EventType.WEBSOCKET, webSocket);
} else if ("console".equals(event)) {
String guid = params.getAsJsonObject("message").get("guid").getAsString();
ConsoleMessageImpl message = connection.getExistingObject(guid);
listeners.notify(EventType.CONSOLE, message);
} else if ("download".equals(event)) {
String artifactGuid = params.getAsJsonObject("artifact").get("guid").getAsString();
ArtifactImpl artifact = connection.getExistingObject(artifactGuid);
@@ -936,16 +953,7 @@ public class PageImpl extends ChannelOwner implements Page {
@Override
public void pause() {
withLogging("Page.pause", () -> {
Double defaultNavigationTimeout = browserContext.timeoutSettings.defaultNavigationTimeout();
Double defaultTimeout = browserContext.timeoutSettings.defaultTimeout();
browserContext.setDefaultNavigationTimeoutImpl(0.0);
browserContext.setDefaultTimeoutImpl(0.0);
try {
runUntil(() -> {}, new WaitableRace<>(asList(context().pause(), (Waitable<JsonElement>) waitableClosedOrCrashed)));
} finally {
browserContext.setDefaultNavigationTimeoutImpl(defaultNavigationTimeout);
browserContext.setDefaultTimeoutImpl(defaultTimeout);
}
runUntil(() -> {}, new WaitableRace<>(asList(context().pause(), (Waitable<JsonElement>) waitableClosedOrCrashed)));
});
}
@@ -955,6 +963,9 @@ public class PageImpl extends ChannelOwner implements Page {
}
private byte[] pdfImpl(PdfOptions options) {
if (!browserContext.browser().isChromium()) {
throw new PlaywrightException("Page.pdf only supported in headless Chromium");
}
if (options == null) {
options = new PdfOptions();
}
@@ -32,7 +32,6 @@ class SerializedValue{
String v;
String d;
String u;
String bi;
public static class R {
String p;
String f;
@@ -47,7 +47,6 @@ public class RouteImpl extends ChannelOwner implements Route {
withLogging("Route.abort", () -> {
JsonObject params = new JsonObject();
params.addProperty("errorCode", errorCode);
params.addProperty("requestUrl", request.initializer.get("url").getAsString());
sendMessageAsync("abort", params);
});
}
@@ -58,13 +57,9 @@ public class RouteImpl extends ChannelOwner implements Route {
@Override
public void resume(ResumeOptions options) {
resume(options, false);
}
void resume(ResumeOptions options, boolean isFallback) {
startHandling();
applyOverrides(convertType(options, FallbackOptions.class));
withLogging("Route.resume", () -> resumeImpl(request().fallbackOverridesForResume(), isFallback));
withLogging("Route.resume", () -> resumeImpl(request().fallbackOverridesForResume()));
}
@Override
@@ -75,7 +70,7 @@ public class RouteImpl extends ChannelOwner implements Route {
}
applyOverrides(options);
if (shouldResumeIfFallbackIsCalled) {
resume(null, true);
resume();
}
}
@@ -96,14 +91,11 @@ public class RouteImpl extends ChannelOwner implements Route {
} else {
options.data = request.postDataBuffer();
}
if (fetchOptions != null && fetchOptions.timeout != null) {
options.timeout = fetchOptions.timeout;
}
APIRequestContextImpl apiRequest = request.frame().page().context().request();
String url = (fetchOptions == null || fetchOptions.url == null) ? request().url() : fetchOptions.url;
return apiRequest.fetch(url, options);
}
private void applyOverrides(FallbackOptions options) {
if (options == null) {
return;
@@ -118,7 +110,7 @@ public class RouteImpl extends ChannelOwner implements Route {
request().applyFallbackOverrides(overrides);
}
private void resumeImpl(RequestImpl.FallbackOverrides options, boolean isFallback) {
private void resumeImpl(RequestImpl.FallbackOverrides options) {
JsonObject params = new JsonObject();
if (options != null) {
if (options.url != null) {
@@ -135,8 +127,6 @@ public class RouteImpl extends ChannelOwner implements Route {
params.addProperty("postData", base64);
}
}
params.addProperty("requestUrl", request.initializer.get("url").getAsString());
params.addProperty("isFallback", isFallback);
sendMessageAsync("continue", params);
}
@@ -231,7 +221,6 @@ public class RouteImpl extends ChannelOwner implements Route {
if (fetchResponseUid != null) {
params.addProperty("fetchResponseUid", fetchResponseUid);
}
params.addProperty("requestUrl", request.initializer.get("url").getAsString());
sendMessageAsync("fulfill", params);
}
@@ -28,7 +28,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.Type;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
@@ -163,8 +162,6 @@ class Serialization {
result.d = ((LocalDateTime)value).atZone(ZoneId.systemDefault()).toInstant().toString();
} else if (value instanceof URL) {
result.u = ((URL)value).toString();
} else if (value instanceof BigInteger) {
result.bi = ((BigInteger)value).toString();
} else if (value instanceof Pattern) {
result.r = new SerializedValue.R();
result.r.p = ((Pattern)value).pattern();
@@ -239,9 +236,6 @@ class Serialization {
throw new PlaywrightException("Unexpected value: " + value.u, e);
}
}
if (value.bi != null) {
return (T) new BigInteger(value.bi);
}
if (value.d != null)
return (T)(Date.from(Instant.parse(value.d)));
if (value.r != null)
@@ -336,11 +330,6 @@ class Serialization {
}
static JsonArray toProtocol(Map<String, String> map) {
for (String value : map.values()) {
if (value == null) {
throw new PlaywrightException("Value cannot be null");
}
}
return toNameValueArray(map);
}
@@ -359,11 +348,7 @@ class Serialization {
for (Map.Entry<String, ?> e : map.entrySet()) {
JsonObject item = new JsonObject();
item.addProperty("name", e.getKey());
if (e.getValue() instanceof FilePayload) {
item.add("value", gson().toJsonTree(e.getValue()));
} else {
item.addProperty("value", "" + e.getValue());
}
item.add("value", gson().toJsonTree(e.getValue()));
array.add(item);
}
return array;
@@ -30,18 +30,11 @@ class TimeoutSettings {
this.parent = parent;
}
Double defaultTimeout() {
return defaultTimeout;
}
Double defaultNavigationTimeout() {
return defaultNavigationTimeout;
}
void setDefaultTimeout(Double timeout) {
void setDefaultTimeout(double timeout) {
defaultTimeout = timeout;
}
void setDefaultNavigationTimeout(Double timeout) {
void setDefaultNavigationTimeout(double timeout) {
defaultNavigationTimeout = timeout;
}
@@ -80,4 +73,5 @@ class TimeoutSettings {
}
return new WaitableTimeout<>(timeout(timeout));
}
}
@@ -90,11 +90,6 @@ class UrlMatcher {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UrlMatcher that = (UrlMatcher) o;
if (rawSource instanceof Pattern && that.rawSource instanceof Pattern) {
Pattern a = (Pattern) rawSource;
Pattern b = (Pattern) that.rawSource;
return a.pattern().equals(b.pattern()) && a.flags() == b.flags();
}
return Objects.equals(rawSource, that.rawSource);
}
@@ -89,8 +89,7 @@ class Utils {
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#escaping
static Set<Character> escapeGlobChars = new HashSet<>(Arrays.asList('$', '^', '+', '.', '*', '(', ')', '|', '\\', '?', '{', '}', '[', ']'));
static Set<Character> escapeGlobChars = new HashSet<>(Arrays.asList('/', '$', '^', '+', '.', '(', ')', '=', '!', '|'));
static String globToRegex(String glob) {
StringBuilder tokens = new StringBuilder();
@@ -98,12 +97,8 @@ class Utils {
boolean inGroup = false;
for (int i = 0; i < glob.length(); ++i) {
char c = glob.charAt(i);
if (c == '\\' && i + 1 < glob.length()) {
char nextChar = glob.charAt(++i);
if (escapeGlobChars.contains(nextChar)) {
tokens.append('\\');
}
tokens.append(nextChar);
if (escapeGlobChars.contains(c)) {
tokens.append("\\").append(c);
continue;
}
if (c == '*') {
@@ -144,11 +139,7 @@ class Utils {
tokens.append("\\").append(c);
break;
default:
if (escapeGlobChars.contains(c)) {
tokens.append('\\');
}
tokens.append(c);
break;
}
}
tokens.append('$');
@@ -171,15 +162,16 @@ class Utils {
static final int maxUplodBufferSize = 50 * 1024 * 1024;
static boolean hasLargeFile(Path[] files) {
int totalSize = 0;
for (Path file: files) {
try {
totalSize += Files.size(file);
if (Files.size(file)> maxUplodBufferSize) {
return true;
}
} catch (IOException e) {
throw new PlaywrightException("Cannot get file size.", e);
}
}
return totalSize > maxUplodBufferSize;
return false;
}
static void addLargeFileUploadParams(Path[] files, JsonObject params, BrowserContextImpl context) {
@@ -210,12 +202,10 @@ class Utils {
}
static void checkFilePayloadSize(FilePayload[] files) {
int totalSize = 0;
for (FilePayload file: files) {
totalSize += file.buffer.length;
}
if (totalSize > maxUplodBufferSize) {
throw new PlaywrightException("Cannot set buffer larger than 50Mb, please write it to a file and pass its path instead.");
if (file.buffer.length > maxUplodBufferSize) {
throw new PlaywrightException("Cannot set buffer larger than 50Mb, please write it to a file and pass its path instead.");
}
}
}
@@ -262,7 +252,7 @@ class Utils {
static void writeToFile(InputStream inputStream, Path path) {
mkParentDirs(path);
try (FileOutputStream out = new FileOutputStream(path.toFile())) {
byte[] buf = new byte[1024 * 1024];
byte[] buf = new byte[8192];
int length;
while ((length = inputStream.read(buf)) > 0) {
out.write(buf, 0, length);
@@ -19,20 +19,9 @@ package com.microsoft.playwright.options;
public class HttpCredentials {
public String username;
public String password;
/**
* Restrain sending http credentials on specific origin (scheme://host:port).
*/
public String origin;
public HttpCredentials(String username, String password) {
this.username = username;
this.password = password;
}
/**
* Restrain sending http credentials on specific origin (scheme://host:port).
*/
public HttpCredentials setOrigin(String origin) {
this.origin = origin;
return this;
}
}
@@ -52,8 +52,8 @@ public class Timing {
*/
public double requestStart;
/**
* Time immediately after the browser receives the first byte of the response from the server, cache, or local resource.
* The value is given in milliseconds relative to {@code startTime}, -1 if not available.
* Time immediately after the browser starts requesting the resource from the server, cache, or local resource. The value
* is given in milliseconds relative to {@code startTime}, -1 if not available.
*/
public double responseStart;
/**
@@ -16,7 +16,6 @@
package com.microsoft.playwright;
import com.microsoft.playwright.options.HttpCredentials;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
@@ -75,66 +74,4 @@ public class TestBrowserContextCredentials extends TestBase {
assertTrue(new String(response.body()).contains("Playground"));
}
}
@Test
void shouldWorkWithCorrectCredentialsAndMatchingOrigin() {
server.setAuth("/empty.html", "user", "pass");
final HttpCredentials httpCredentials = new HttpCredentials("user", "pass");
httpCredentials.setOrigin(server.PREFIX);
try (BrowserContext context = browser.newContext(new Browser.NewContextOptions()
.setHttpCredentials(httpCredentials))) {
Page page = context.newPage();
Response response = page.navigate(server.EMPTY_PAGE);
assertEquals(200, response.status());
}
}
@Test
void shouldWorkWithCorrectCredentialsAndMatchingOriginCaseInsensitive() {
server.setAuth("/empty.html", "user", "pass");
final HttpCredentials httpCredentials = new HttpCredentials("user", "pass");
httpCredentials.setOrigin(server.PREFIX.toUpperCase());
try (BrowserContext context = browser.newContext(new Browser.NewContextOptions()
.setHttpCredentials(httpCredentials))) {
Page page = context.newPage();
Response response = page.navigate(server.EMPTY_PAGE);
assertEquals(200, response.status());
}
}
@Test
void shouldFailWithCorrectCredentialsAndWrongOriginScheme() {
server.setAuth("/empty.html", "user", "pass");
final HttpCredentials httpCredentials = new HttpCredentials("user", "pass");
httpCredentials.setOrigin(Utils.generateDifferentOriginScheme(server));
try (BrowserContext context = browser.newContext(new Browser.NewContextOptions().setHttpCredentials(httpCredentials))) {
Page page = context.newPage();
Response response = page.navigate(server.EMPTY_PAGE);
assertEquals(401, response.status());
}
}
@Test
void shouldFailWithCorrectCredentialsAndWrongOriginHostname() {
server.setAuth("/empty.html", "user", "pass");
final HttpCredentials httpCredentials = new HttpCredentials("user", "pass");
httpCredentials.setOrigin(Utils.generateDifferentOriginHostname(server));
try (BrowserContext context = browser.newContext(new Browser.NewContextOptions().setHttpCredentials(httpCredentials))) {
Page page = context.newPage();
Response response = page.navigate(server.EMPTY_PAGE);
assertEquals(401, response.status());
}
}
@Test
void shouldFailWithCorrectCredentialsAndWrongOriginPort() {
server.setAuth("/empty.html", "user", "pass");
final HttpCredentials httpCredentials = new HttpCredentials("user", "pass");
httpCredentials.setOrigin(Utils.generateDifferentOriginPort(server));
try (BrowserContext context = browser.newContext(new Browser.NewContextOptions().setHttpCredentials(httpCredentials))) {
Page page = context.newPage();
Response response = page.navigate(server.EMPTY_PAGE);
assertEquals(401, response.status());
}
}
}
@@ -1,159 +0,0 @@
package com.microsoft.playwright;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import java.io.OutputStreamWriter;
import java.io.Writer;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TestBrowserContextEvents extends TestBase {
@Test
void consoleEventShouldWorkSmoke() {
ConsoleMessage message = context.waitForConsoleMessage(() -> {
page.evaluate("console.log('hello')");
});
assertEquals("hello", message.text());
assertEquals(page, message.page());
}
@Test
void consoleEventShouldWorkInPopup() {
Page[] popup = { null };
ConsoleMessage message = context.waitForConsoleMessage(() -> {
popup[0] = page.waitForPopup(() -> {
page.evaluate("const win = window.open('');\n" +
"win.console.log('hello');\n");
});
});
assertEquals("hello", message.text());
assertEquals(popup[0], message.page());
}
@Test
@DisabledIf(value="com.microsoft.playwright.TestBase#isFirefox", disabledReason="console message from javascript: url is not reported at all")
void consoleEventShouldWorkInPopup2() {
Page[] popup = { null };
ConsoleMessage message = context.waitForConsoleMessage(
new BrowserContext.WaitForConsoleMessageOptions().setPredicate(msg -> "log".equals(msg.type())),
() -> {
popup[0] = context.waitForPage(() -> {
page.evaluate("async () => {\n" +
" const win = window.open('javascript:console.log(\"hello\")');\n" +
" await new Promise(f => setTimeout(f, 0));\n" +
" win.close();\n" +
"}");
});
});
assertEquals("hello", message.text());
assertEquals(popup[0], message.page());
}
@Test
@DisabledIf(value="com.microsoft.playwright.TestBase#isFirefox", disabledReason="console message is not reported at all")
void consoleEventShouldWorkInImmediatelyClosedPopup() {
Page[] popup = { null };
ConsoleMessage message = context.waitForConsoleMessage(() -> {
popup[0] = page.waitForPopup(() -> {
page.evaluate("async () => {\n" +
" const win = window.open();\n" +
" win.console.log('hello');\n" +
" win.close();\n" +
" }\n");
});
});
assertEquals("hello", message.text());
assertEquals(popup[0], message.page());
}
@Test
void dialogEventShouldWorkSmoke() {
Dialog[] dialog = { null };
context.onDialog(d -> {
dialog[0] = d;
dialog[0].accept("hello");
});
Object result = page.evaluate("prompt('hey?')");
assertEquals("hello", result);
context.waitForCondition(() -> dialog[0] != null);
assertEquals("hey?", dialog[0].message());
assertEquals(page, dialog[0].page());
}
@Test
void dialogEventShouldWorkInPopup() {
Dialog[] dialog = { null };
context.onDialog(d -> {
dialog[0] = d;
d.accept("hello");
});
Page popup = page.waitForPopup(() -> {
Object result = page.evaluate("() => {\n" +
" const win = window.open('');\n" +
" return win.prompt('hey?');\n" +
" }");
assertEquals("hello", result);
});
assertEquals("hey?", dialog[0].message());
assertEquals(popup, dialog[0].page());
}
@Test
@DisabledIf(value="com.microsoft.playwright.TestBase#isFirefox", disabledReason="dialog from javascript: url is not reported at all")
void dialogEventShouldWorkInPopup2() {
Dialog[] dialog = { null };
context.onDialog(d -> {
dialog[0] = d;
d.accept("hello");
});
page.evaluate("window.open('javascript:prompt(\"hey?\")');");
context.waitForCondition(() -> dialog[0] != null);
assertEquals("hey?", dialog[0].message());
assertEquals(null, dialog[0].page());
}
@Test
void dialogEventShouldWorkInImmdiatelyClosedPopup() {
Dialog[] dialog = { null };
context.onDialog(d -> {
dialog[0] = d;
d.accept("hello");
});
Page popup = page.waitForPopup(() -> {
Object result = page.evaluate("async () => {\n" +
" const win = window.open();\n" +
" const result = win.prompt('hey?');\n" +
" win.close();\n" +
" return result;\n" +
" }");
assertEquals("hello", result);
});
assertEquals("hey?", dialog[0].message());
assertEquals(popup, dialog[0].page());
}
@Test
void dialogEventShouldWorkWithInlineScriptTag() {
server.setRoute("/popup.html", exchange -> {
exchange.getResponseHeaders().add("content-type", "text/html");
exchange.sendResponseHeaders(200, 0);
try (Writer writer = new OutputStreamWriter(exchange.getResponseBody())) {
writer.write("<script>window.result = prompt('hey?')</script>");
}
});
page.navigate(server.EMPTY_PAGE);
page.setContent("<a href='popup.html' target=_blank>Click me</a>");
Dialog[] dialog = { null };
context.onDialog(d -> {
dialog[0] = d;
d.accept("hello");
});
Page popup = context.waitForPage(() -> page.click("a"));
page.waitForCondition(() -> dialog[0] != null);
assertEquals("hey?", dialog[0].message());
assertEquals(popup, dialog[0].page());
page.waitForCondition(() -> "hello".equals(popup.evaluate("window.result")),
new Page.WaitForConditionOptions().setTimeout(5_000));
}
}
@@ -511,18 +511,14 @@ public class TestBrowserContextFetch extends TestBase {
FormData.create()
.set("firstName", "John")
.set("lastName", "Doe")
.set("age", 30)
.set("isMale", true)
.set("file", "f.js")));
assertEquals("POST", req.get().method);
assertEquals(asList("application/x-www-form-urlencoded"), req.get().headers.get("content-type"));
String body = new String(req.get().postBody);
assertTrue(body.contains("firstName=John"), body);
assertTrue(body.contains("lastName=Doe"), body);
assertTrue(body.contains("age=30"), body);
assertTrue(body.contains("isMale=true"), body);
assertTrue(body.contains("file=f.js"), body);
assertTrue(body.contains("firstName=John"));
assertTrue(body.contains("lastName=Doe"));
assertTrue(body.contains("file=f.js"));
}
@Test
@@ -530,8 +526,6 @@ public class TestBrowserContextFetch extends TestBase {
Map<String, Object> data = mapOf(
"firstName", "John",
"lastName", "Doe",
"age", 30,
"isMale", true,
"file", mapOf("name", "f.js")
);
Future<Server.Request> req = server.futureRequest("/empty.html");
@@ -677,67 +671,4 @@ public class TestBrowserContextFetch extends TestBase {
e = assertThrows(PlaywrightException.class, () -> context.request().post(server.EMPTY_PAGE));
assertTrue(e.getMessage().contains("Target page, context or browser has been closed"), e.getMessage());
}
@Test
void shouldWorkWithSetHTTPCredentialsAndMatchingOrigin() throws ExecutionException, InterruptedException {
server.setAuth("/empty.html", "user", "pass");
APIResponse response1 = context.request().get(server.EMPTY_PAGE);
assertEquals(401, response1.status());
final HttpCredentials httpCredentials = new HttpCredentials("user", "pass");
httpCredentials.setOrigin(server.PREFIX);
try (BrowserContext context2 = browser.newContext(
new Browser.NewContextOptions().setHttpCredentials(httpCredentials))) {
APIResponse response2 = context2.request().get(server.EMPTY_PAGE);
assertEquals(200, response2.status());
}
}
@Test
void shouldWorkWithSetHTTPCredentialsAndMatchingOriginCaseInsensitive() throws ExecutionException, InterruptedException {
server.setAuth("/empty.html", "user", "pass");
APIResponse response1 = context.request().get(server.EMPTY_PAGE);
assertEquals(401, response1.status());
final HttpCredentials httpCredentials = new HttpCredentials("user", "pass");
httpCredentials.setOrigin(server.PREFIX.toUpperCase());
try (BrowserContext context2 = browser.newContext(
new Browser.NewContextOptions().setHttpCredentials(httpCredentials))) {
APIResponse response2 = context2.request().get(server.EMPTY_PAGE);
assertEquals(200, response2.status());
}
}
@Test
void shouldReturnErrorWithCorrectCredentialsAndWrongOriginScheme() {
server.setAuth("/empty.html", "user", "pass");
final HttpCredentials httpCredentials = new HttpCredentials("user", "pass");
httpCredentials.setOrigin(Utils.generateDifferentOriginScheme(server));
try (BrowserContext context = browser.newContext(new Browser.NewContextOptions().setHttpCredentials(httpCredentials))) {
APIResponse response = context.request().get(server.EMPTY_PAGE);
assertEquals(401, response.status());
}
}
@Test
void shouldReturnErrorWithCorrectCredentialsAndWrongOriginHostname() {
server.setAuth("/empty.html", "user", "pass");
final HttpCredentials httpCredentials = new HttpCredentials("user", "pass");
httpCredentials.setOrigin(Utils.generateDifferentOriginHostname(server));
try (BrowserContext context = browser.newContext(new Browser.NewContextOptions().setHttpCredentials(httpCredentials))) {
APIResponse response = context.request().get(server.EMPTY_PAGE);
assertEquals(401, response.status());
}
}
@Test
void shouldReturnErrorWithCorrectCredentialsAndWrongOriginPort() {
server.setAuth("/empty.html", "user", "pass");
final HttpCredentials httpCredentials = new HttpCredentials("user", "pass");
httpCredentials.setOrigin(Utils.generateDifferentOriginPort(server));
try (BrowserContext context = browser.newContext(new Browser.NewContextOptions().setHttpCredentials(httpCredentials))) {
APIResponse response = context.request().get(server.EMPTY_PAGE);
assertEquals(401, response.status());
}
}
}
@@ -16,12 +16,15 @@
package com.microsoft.playwright;
import com.microsoft.playwright.options.AriaRole;
import com.microsoft.playwright.options.WaitUntilState;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import org.junit.jupiter.api.condition.EnabledIf;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import static com.microsoft.playwright.options.KeyboardModifier.SHIFT;
import static com.microsoft.playwright.options.MouseButton.RIGHT;
@@ -405,12 +408,6 @@ public class TestClick extends TestBase {
assertEquals(isWebKit() ? 1910 + 8 : 1910, page.evaluate("offsetY"));
}
private static void expectCloseTo(double expected, double actual) {
if (Math.abs(expected - actual) > 2)
fail("Expected: " + expected + ", received: " + actual);
}
@Test
@DisabledIf(value="com.microsoft.playwright.TestBase#isFirefox", disabledReason="skip")
void shouldClickTheButtonWithOffsetWithPageScale() {
@@ -425,10 +422,20 @@ public class TestClick extends TestBase {
"}");
page.click("button", new Page.ClickOptions().setPosition(20, 10));
assertEquals("Clicked", page.evaluate("result"));
// Expect 20;10 + 8px of border in each direction. Allow some delta as different
// browsers round up or down differently during css -> dip -> css conversion.
expectCloseTo(28, (Integer) page.evaluate("pageX"));
expectCloseTo(18, (Integer) page.evaluate("pageY"));
// 20;10 + 8px of border in each direction
int expectedX = 28;
int expectedY = 18;
if (isWebKit()) {
// WebKit rounds up during css -> dip -> css conversion.
expectedX = 26;
expectedY = 17;
} else if (isChromium() && !headful) {
// Headless Chromium rounds down during css -> dip -> css conversion.
expectedX = 27;
expectedY = 18;
}
assertEquals(expectedX, Math.round((Integer) page.evaluate("pageX") + 0.01));
assertEquals(expectedY, Math.round((Integer) page.evaluate("pageY") + 0.01));
context.close();
}
@@ -1,7 +1,6 @@
package com.microsoft.playwright;
import com.google.gson.Gson;
import com.microsoft.playwright.options.HttpCredentials;
import com.microsoft.playwright.options.HttpHeader;
import com.microsoft.playwright.options.RequestOptions;
import org.junit.jupiter.api.Disabled;
@@ -412,66 +411,4 @@ public class TestGlobalFetch extends TestBase {
request.dispose();
}
@Test
void shouldSupportGlobalHttpCredentialsOptionAndMatchingOrigin() {
server.setAuth("/empty.html", "user", "pass");
APIRequestContext request1 = playwright.request().newContext();
APIResponse response1 = request1.get(server.EMPTY_PAGE);
assertEquals(401, response1.status());
request1.dispose();
final HttpCredentials httpCredentials = new HttpCredentials("user", "pass");
httpCredentials.setOrigin(server.PREFIX);
APIRequestContext request2 = playwright.request().newContext(new APIRequest.NewContextOptions().setHttpCredentials(httpCredentials));
APIResponse response2 = request2.get(server.EMPTY_PAGE);
assertEquals(200, response2.status());
request2.dispose();
}
@Test
void shouldSupportGlobalHttpCredentialsOptionAndMatchingOriginCaseInsensitive() {
server.setAuth("/empty.html", "user", "pass");
APIRequestContext request1 = playwright.request().newContext();
APIResponse response1 = request1.get(server.EMPTY_PAGE);
assertEquals(401, response1.status());
request1.dispose();
final HttpCredentials httpCredentials = new HttpCredentials("user", "pass");
httpCredentials.setOrigin(server.PREFIX.toUpperCase());
APIRequestContext request2 = playwright.request().newContext(new APIRequest.NewContextOptions().setHttpCredentials(httpCredentials));
APIResponse response2 = request2.get(server.EMPTY_PAGE);
assertEquals(200, response2.status());
request2.dispose();
}
@Test
void shouldReturnErrorWithCorrectCredentialsAndWrongOriginScheme() {
server.setAuth("/empty.html", "user", "pass");
final HttpCredentials httpCredentials = new HttpCredentials("user", "pass");
httpCredentials.setOrigin(Utils.generateDifferentOriginScheme(server));
APIRequestContext request = playwright.request().newContext(new APIRequest.NewContextOptions().setHttpCredentials(httpCredentials));
APIResponse response = request.get(server.EMPTY_PAGE);
assertEquals(401, response.status());
}
@Test
void shouldReturnErrorWithCorrectCredentialsAndWrongOriginHostname() {
server.setAuth("/empty.html", "user", "pass");
final HttpCredentials httpCredentials = new HttpCredentials("user", "pass");
httpCredentials.setOrigin(Utils.generateDifferentOriginHostname(server));
APIRequestContext request = playwright.request().newContext(new APIRequest.NewContextOptions().setHttpCredentials(httpCredentials));
APIResponse response = request.get(server.EMPTY_PAGE);
assertEquals(401, response.status());
}
@Test
void shouldReturnErrorWithCorrectCredentialsAndWrongOriginPort() {
server.setAuth("/empty.html", "user", "pass");
final HttpCredentials httpCredentials = new HttpCredentials("user", "pass");
httpCredentials.setOrigin(Utils.generateDifferentOriginPort(server));
APIRequestContext request = playwright.request().newContext(new APIRequest.NewContextOptions().setHttpCredentials(httpCredentials));
APIResponse response = request.get(server.EMPTY_PAGE);
assertEquals(401, response.status());
}
}
@@ -1,102 +0,0 @@
package com.microsoft.playwright;
import com.microsoft.playwright.assertions.LocatorAssertions;
import org.junit.jupiter.api.Test;
import org.opentest4j.AssertionFailedError;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
public class TestLocatorAssertions2 extends TestBase {
@Test
void isAttachedDefault() {
page.setContent("<input></input>");
Locator locator = page.locator("input");
assertThat(locator).isAttached();
}
@Test
void isAttachedWithHiddenElement() {
page.setContent("<button style='display:none'>hello</button>");
Locator locator = page.locator("button");
assertThat(locator).isAttached();
}
@Test
void isAttachedWithNot() {
page.setContent("<button>hello</button>");
Locator locator = page.locator("input");
assertThat(locator).not().isAttached();
}
@Test
void isAttachedWithAttachedTrue() {
page.setContent("<button>hello</button>");
Locator locator = page.locator("button");
assertThat(locator).isAttached(new LocatorAssertions.IsAttachedOptions().setAttached(true));
}
@Test
void isAttachedWithAttachedFalse() {
page.setContent("<button>hello</button>");
Locator locator = page.locator("input");
assertThat(locator).isAttached(new LocatorAssertions.IsAttachedOptions().setAttached(false));
}
@Test
void isAttachedWithNotAndAttachedFalse() {
page.setContent("<button>hello</button>");
Locator locator = page.locator("button");
assertThat(locator).not().isAttached(new LocatorAssertions.IsAttachedOptions().setAttached(false));
}
@Test
void isAttachedEventually() {
page.setContent("<div></div>");
Locator locator = page.locator("span");
page.evalOnSelector("div", "div => setTimeout(() => {\n" +
" div.innerHTML = '<span>Hello</span>'\n" +
" }, 100)");
assertThat(locator).isAttached();
}
@Test
void isAttachedEventuallyWithNot() {
page.setContent("<div><span>Hello</span></div>");
Locator locator = page.locator("span");
page.evalOnSelector("div", "div => setTimeout(() => {\n" +
" div.textContent = '';\n" +
" }, 0)");
assertThat(locator).not().isAttached();
}
@Test
void isAttachedFail() {
page.setContent("<button>Hello</button>");
Locator locator = page.locator("input");
AssertionFailedError error = assertThrows(AssertionFailedError.class,
() -> assertThat(locator).isAttached(new LocatorAssertions.IsAttachedOptions().setTimeout(1000)));
assertFalse(error.getMessage().contains("locator resolved to"), error.getMessage());
}
@Test
void isAttachedFailWithNot() {
page.setContent("<input></input>");
Locator locator = page.locator("input");
AssertionFailedError error = assertThrows(AssertionFailedError.class,
() -> assertThat(locator).not().isAttached(new LocatorAssertions.IsAttachedOptions().setTimeout(1000)));
assertTrue(error.getMessage().contains("locator resolved to <input/>"), error.getMessage());
}
@Test
void isAttachedWithImpossibleTimeout() {
page.setContent("<div id=node>Text content</div>");
assertThat(page.locator("#node")).isAttached(new LocatorAssertions.IsAttachedOptions().setTimeout(1));
}
@Test
void isAttachedWithImpossibleTimeoutNot() {
page.setContent("<div id=node>Text content</div>");
assertThat(page.locator("no-such-thing")).not().isAttached(new LocatorAssertions.IsAttachedOptions().setTimeout(1));
}
}
@@ -19,7 +19,6 @@ package com.microsoft.playwright;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import java.math.BigInteger;
import java.time.*;
import java.util.Map;
import java.util.regex.Pattern;
@@ -116,12 +115,6 @@ public class TestPageEvaluate extends TestBase {
assertEquals(true, result);
}
@Test
void shouldTransferBigint() {
assertEquals(new BigInteger("42", 10), page.evaluate("() => 42n"));
assertEquals(new BigInteger("17", 10), page.evaluate("a => a", new BigInteger("17", 10)));
}
// @Test
void shouldTransferMapsAsEmptyObjects() {
// Not applicable.
@@ -2,8 +2,6 @@ package com.microsoft.playwright;
import org.junit.jupiter.api.Test;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
@@ -73,23 +71,6 @@ public class TestPageInterception extends TestBase {
assertTrue(response.headers().get("content-type").contains("text/html"));
}
@Test
void shouldSupportTimeoutOptionInRouteFetch() {
server.setRoute("/slow", exchange -> {
exchange.getResponseHeaders().set("Content-type", "text/plain");
exchange.sendResponseHeaders(200, 4096);
});
page.route("**/*", route -> {
PlaywrightException error = assertThrows(PlaywrightException.class,
() -> route.fetch(new Route.FetchOptions().setTimeout(1000)));
assertTrue(error.getMessage().contains("Request timed out after 1000ms"), error.getMessage());
});
PlaywrightException error = assertThrows(PlaywrightException.class,
() -> page.navigate(server.PREFIX + "/slow", new Page.NavigateOptions().setTimeout(2000)));
assertTrue(error.getMessage().contains("Timeout 2000ms exceeded"), error.getMessage());
}
@Test
void shouldInterceptWithUrlOverride() {
page.route("**/*.html", route -> {
@@ -172,39 +172,5 @@ public class TestPageLocatorQuery extends TestBase {
assertThat(page.locator("div").filter(new Locator.FilterOptions()
.setHas(page.locator("span"))
.setHasText("world"))).hasCount(1);
assertThat(page.locator("div").filter(new Locator.FilterOptions()
.setHasNot(page.locator("span", new Page.LocatorOptions().setHasText("world"))))).hasCount(1);
assertThat(page.locator("div").filter(new Locator.FilterOptions()
.setHasNot(page.locator("section")))).hasCount(2);
assertThat(page.locator("div").filter(new Locator.FilterOptions()
.setHasNot(page.locator("span")))).hasCount(0);
assertThat(page.locator("div").filter(new Locator.FilterOptions().setHasNotText("hello"))).hasCount(1);
assertThat(page.locator("div").filter(new Locator.FilterOptions().setHasNotText("foo"))).hasCount(2);
}
@Test
void shouldSupportLocatorAnd() {
page.setContent("<div data-testid=foo>hello</div><div data-testid=bar>world</div>\n" +
" <span data-testid=foo>hello2</span><span data-testid=bar>world2</span>");
assertThat(page.locator("div").and(page.locator("div"))).hasCount(2);
assertThat(page.locator("div").and(page.getByTestId("foo"))).hasText(new String[] { "hello" });
assertThat(page.locator("div").and(page.getByTestId("bar"))).hasText(new String[] { "world" });
assertThat(page.getByTestId("foo").and(page.locator("div"))).hasText(new String[] { "hello" });
assertThat(page.getByTestId("bar").and(page.locator("span"))).hasText(new String[] { "world2" });
assertThat(page.locator("span").and(page.getByTestId(Pattern.compile("bar|foo")))).hasCount(2);
}
@Test
void shouldSupportLocatorOr() {
page.setContent("<div>hello</div><span>world</span>");
assertThat(page.locator("div").or(page.locator("span"))).hasCount(2);
assertThat(page.locator("div").or(page.locator("span"))).hasText(new String[]{"hello", "world"});
assertThat(page.locator("span").or(page.locator("article")).or(page.locator("div"))).hasText(new String[]{"hello", "world"});
assertThat(page.locator("article").or(page.locator("someting"))).hasCount(0);
assertThat(page.locator("article").or(page.locator("div"))).hasText("hello");
assertThat(page.locator("article").or(page.locator("span"))).hasText("world");
assertThat(page.locator("div").or(page.locator("article"))).hasText("hello");
assertThat(page.locator("span").or(page.locator("article"))).hasText("world");
}
}
@@ -82,12 +82,12 @@ public class TestPageRoute extends TestBase {
intercepted.add(4);
route.fallback();
};
page.route(Pattern.compile("empty.html"), handler4);
page.route("**/empty.html", handler4);
page.navigate(server.EMPTY_PAGE);
assertEquals(asList(4, 3, 2, 1), intercepted);
intercepted.clear();
page.unroute(Pattern.compile("empty.html"), handler4);
page.unroute("**/empty.html", handler4);
page.navigate(server.EMPTY_PAGE);
assertEquals(asList(3, 2, 1), intercepted);
@@ -97,42 +97,6 @@ public class TestPageRoute extends TestBase {
assertEquals(asList(1), intercepted);
}
@Test
void shouldSupportQuestionMarkInGlobPattern() {
server.setRoute("/index", exchange -> {
exchange.sendResponseHeaders(200, 0);
try (OutputStreamWriter writer = new OutputStreamWriter(exchange.getResponseBody())) {
writer.write("index-no-hello");
}
});
server.setRoute("/index123hello", exchange -> {
exchange.sendResponseHeaders(200, 0);
try (OutputStreamWriter writer = new OutputStreamWriter(exchange.getResponseBody())) {
writer.write("index123hello");
}
});
page.route("**/index?hello", route -> {
route.fulfill(new Route.FulfillOptions().setBody("intercepted any character"));
});
page.route("**/index\\?hello", route -> {
route.fulfill(new Route.FulfillOptions().setBody("intercepted question mark"));
});
page.navigate(server.PREFIX + "/index?hello");
assertTrue(page.content().contains("intercepted question mark"), page.content());
page.navigate(server.PREFIX + "/index");
assertTrue(page.content().contains("index-no-hello"), page.content());
page.navigate(server.PREFIX + "/index1hello");
assertTrue(page.content().contains("intercepted any character"), page.content());
page.navigate(server.PREFIX + "/index123hello");
assertTrue(page.content().contains("index123hello"), page.content());
}
@Test
void shouldUnroutePredicate() {
List<Integer> intercepted = new ArrayList<>();
@@ -35,7 +35,6 @@ import java.util.Arrays;
import static com.microsoft.playwright.options.ScreenshotAnimations.DISABLED;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
// TODO: suite.skip(browserName === "firefox" && headful");
public class TestPageScreenshot extends TestBase {
@@ -234,19 +233,4 @@ public class TestPageScreenshot extends TestBase {
}
assertTrue(hasDifferentScreenshots);
}
@Test
void shouldWorkWhenMaskColorIsNotPinkF0F() {
page.setViewportSize(500, 500);
page.navigate(server.PREFIX + "/grid.html");
byte[] screenshot1 = page.screenshot(
new Page.ScreenshotOptions()
.setMask(asList(page.locator("div").nth(5)))
.setMaskColor("#00FF00"));
byte[] screenshot2 = page.screenshot(
new Page.ScreenshotOptions()
.setMask(asList(page.locator("div").nth(5))));
assertThrows(AssertionError.class, () -> assertArrayEquals(screenshot1, screenshot2));
}
}
@@ -73,6 +73,6 @@ public class TestPageSetExtraHttpHeaders extends TestBase {
PlaywrightException e = assertThrows(PlaywrightException.class, () -> {
browser.newContext(new Browser.NewContextOptions().setExtraHTTPHeaders(mapOf("foo", null)));
});
assertTrue(e.getMessage().contains("Value cannot be null"));
assertTrue(e.getMessage().contains("expected string, got undefined"));
}
}
@@ -16,7 +16,6 @@
package com.microsoft.playwright;
import com.microsoft.playwright.options.AriaRole;
import com.microsoft.playwright.options.FilePayload;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
@@ -97,34 +96,6 @@ public class TestPageSetInputFiles extends TestBase {
assertEquals(200 * 1024 * 1024, fields.get(0).content.length());
}
@Test
void shouldUploadMultipleLargeFiles(@TempDir Path tmpDir) throws IOException, ExecutionException, InterruptedException {
Assumptions.assumeTrue(3 <= (Runtime.getRuntime().maxMemory() >> 30), "Fails if max heap size is < 3Gb");
int filesCount = 10;
page.navigate(server.PREFIX + "/input/fileupload-multi.html");
Path uploadFile = tmpDir.resolve("50MB_1.zip");
String str = String.join("", Collections.nCopies(1024, "A"));
try (Writer stream = new OutputStreamWriter(Files.newOutputStream(uploadFile))) {
for (int i = 0; i < 49 * 1024; i++) {
stream.write(str);
}
}
Locator input = page.locator("input[type='file']");
List<Path> uploadFiles = new ArrayList<>();
uploadFiles.add(uploadFile);
for (int i = 1; i < filesCount; i++) {
Path dstFile = tmpDir.resolve("50MB_" + i + ".zip");
Files.copy(uploadFile, dstFile);
uploadFiles.add(dstFile);
}
FileChooser fileChooser = page.waitForFileChooser(() -> input.click());
fileChooser.setFiles(uploadFiles.toArray(new Path[0]));
Object filesLen = page.getByRole(AriaRole.TEXTBOX).evaluate("e => e.files.length");
assertTrue(fileChooser.isMultiple());
assertEquals(filesCount, filesLen);
}
@Test
void shouldUploadLargeFileWithRelativePath(@TempDir Path tmpDir) throws IOException, ExecutionException, InterruptedException {
Assumptions.assumeTrue(3 <= (Runtime.getRuntime().maxMemory() >> 30), "Fails if max heap size is < 3Gb");
@@ -52,18 +52,6 @@ public class TestPdf extends TestBase {
@DisabledIf(value="com.microsoft.playwright.TestBase#isChromium", disabledReason="skip")
void shouldThrowInNonChromium() {
PlaywrightException e = assertThrows(PlaywrightException.class, () -> page.pdf());
assertTrue(e.getMessage().contains("PDF generation is only supported for Headless Chromium"), e.getMessage());
}
@Test
@DisabledIf(value="com.microsoft.playwright.TestBase#isChromium", disabledReason="skip")
void correctExceptionWithPersistentContext(@TempDir Path tempDir) {
Path profile = tempDir.resolve("profile");
try (BrowserContext context = browserType.launchPersistentContext(profile)) {
Page page = context.newPage();
PlaywrightException e = assertThrows(PlaywrightException.class, () -> page.pdf());
assertTrue(e.getMessage().contains("PDF generation is only supported for Headless Chromium"), e.getMessage());
}
assertTrue(e.getMessage().contains("Page.pdf only supported in headless Chromium"));
}
}
@@ -2,7 +2,6 @@ package com.microsoft.playwright;
import org.junit.jupiter.api.Test;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.*;
public class TestSelectorsMisc extends TestBase {
@@ -195,39 +194,4 @@ public class TestSelectorsMisc extends TestBase {
e = assertThrows(PlaywrightException.class, () -> page.querySelector("div >> left-of='span',3,4"));
assertTrue(e.getMessage().contains("Malformed selector: left-of='span',3,4"));
}
@Test
void shouldWorkWithInternalHasNot() {
page.setContent("<section><span></span><div></div></section><section><br></section>");
assertEquals(1, page.evalOnSelectorAll("section >> internal:has-not=\"span\"", "els => els.length"));
assertEquals(0, page.evalOnSelectorAll("section >> internal:has-not=\"span, div, br\"", "els => els.length"));
assertEquals(1, page.evalOnSelectorAll("section >> internal:has-not=\"br\"", "els => els.length"));
assertEquals(1, page.evalOnSelectorAll("section >> internal:has-not=\"span, div\"", "els => els.length"));
assertEquals(2, page.evalOnSelectorAll("section >> internal:has-not=\"article\"", "els => els.length"));
}
@Test
void shouldWorkWithInternalAnd() {
page.setContent("<div class=foo>hello</div><div class=bar>world</div>\n" +
" <span class=foo>hello2</span><span class=bar>world2</span>");
assertEquals(asList(), page.evalOnSelectorAll("div >> internal:and=\"span\"", "els => els.map(e => e.textContent)"));
assertEquals(asList("hello"), page.evalOnSelectorAll("div >> internal:and=\".foo\"", "els => els.map(e => e.textContent)"));
assertEquals(asList("world"), page.evalOnSelectorAll("div >> internal:and=\".bar\"", "els => els.map(e => e.textContent)"));
assertEquals(asList("hello2", "world2"), page.evalOnSelectorAll("span >> internal:and=\"span\"", "els => els.map(e => e.textContent)"));
assertEquals(asList("hello"), page.evalOnSelectorAll(".foo >> internal:and=\"div\"", "els => els.map(e => e.textContent)"));
assertEquals(asList("world2"), page.evalOnSelectorAll(".bar >> internal:and=\"span\"", "els => els.map(e => e.textContent)"));
}
@Test
void shouldWorkWithInternalOr() {
page.setContent("<div>hello</div>\n" +
" <span>world</span>");
assertEquals(asList("hello", "world"), page.evalOnSelectorAll("div >> internal:or=\"span\"", "els => els.map(e => e.textContent)"));
assertEquals(asList("hello", "world"), page.evalOnSelectorAll("span >> internal:or=\"div\"", "els => els.map(e => e.textContent)"));
assertEquals(0, page.evalOnSelectorAll("article >> internal:or=\"something\"", "els => els.length"));
assertEquals("hello", page.locator("article >> internal:or=\"div\"").textContent());
assertEquals("world", page.locator("article >> internal:or=\"span\"").textContent());
assertEquals("hello", page.locator("div >> internal:or=\"article\"").textContent());
assertEquals("world", page.locator("span >> internal:or=\"article\"").textContent());
}
}
@@ -185,7 +185,7 @@ public class TestWebSocket extends TestBase {
PlaywrightException e = assertThrows(PlaywrightException.class, () -> {
ws.waitForFrameSent(() -> page.evaluate("window.ws.close()"));
});
assertTrue(e.getMessage().matches("Socket closed|Socket error"), e.getMessage());
assertTrue(e.getMessage().contains("Socket closed"), e.getMessage());
}
@Test
@@ -16,7 +16,6 @@
package com.microsoft.playwright;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import org.junit.jupiter.api.condition.EnabledIf;
@@ -29,11 +28,6 @@ import static org.junit.jupiter.api.Assertions.*;
public class TestWorkers extends TestBase {
private int browserMajorVersion() {
String version = browser.version();
return Integer.parseInt(version.split("\\.")[0]);
}
@Test
void pageWorkers() {
Worker worker = page.waitForWorker(() -> page.navigate(server.PREFIX + "/worker/worker.html"));
@@ -151,7 +145,6 @@ public class TestWorkers extends TestBase {
@Test
void shouldReportNetworkActivity() {
Assumptions.assumeFalse(isFirefox() && browserMajorVersion() < 114);
Worker worker = page.waitForWorker(() -> page.navigate(server.PREFIX + "/worker/worker.html"));
String url = server.PREFIX + "/one-style.css";
Request[] request = {null};
@@ -167,7 +160,6 @@ public class TestWorkers extends TestBase {
@Test
void shouldReportNetworkActivityOnWorkerCreation() {
Assumptions.assumeFalse(isFirefox() && browserMajorVersion() < 114);
// Chromium needs waitForDebugger enabled for this one.
page.navigate(server.EMPTY_PAGE);
String url = server.PREFIX + "/one-style.css";
@@ -144,10 +144,6 @@ class Utils {
return OS.UNKNOWN;
}
static int osVersion() {
return Integer.parseInt(System.getProperty("os.version").split("\\.")[0]);
}
static List<String> expectedSSLError(String browserName) {
switch (browserName) {
case "chromium":
@@ -200,18 +196,4 @@ class Utils {
assertEquals(width, page.evaluate("window.innerWidth"));
assertEquals(height, page.evaluate("window.innerHeight"));
}
static String generateDifferentOriginScheme(final Server server){
return server.PREFIX.startsWith("http://") ?
server.PREFIX.replace("http://", "https://") :
server.PREFIX.replace("https://", "http://");
}
static String generateDifferentOriginHostname(final Server server){
return server.PREFIX.replace("localhost", "mismatching-hostname");
}
static String generateDifferentOriginPort(final Server server){
return server.PREFIX.replace(String.valueOf(server.PORT), String.valueOf(server.PORT+1));
}
}
@@ -1,12 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>File upload test</title>
</head>
<body>
<form action="/upload" method="post" enctype="multipart/form-data">
<input type="file" multiple name="file1">
<input type="submit">
</form>
</body>
</html>
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.36.0</version>
<version>1.32.0</version>
<packaging>pom</packaging>
<name>Playwright Parent Project</name>
<description>Java library to automate Chromium, Firefox and WebKit with a single API.
+1 -1
View File
@@ -1 +1 @@
1.36.1
1.32.1
+1 -1
View File
@@ -33,7 +33,7 @@ fi
mkdir -p driver
cd driver
for PLATFORM in mac mac-arm64 linux linux-arm64 win32_x64
for PLATFORM in mac linux linux-arm64 win32_x64
do
FILE_NAME=$FILE_PREFIX-$PLATFORM.zip
if [[ -d $PLATFORM ]]; then
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>com.microsoft.playwright</groupId>
<artifactId>api-generator</artifactId>
<version>1.36.0</version>
<version>1.32.0</version>
<name>Playwright - API Generator</name>
<description>
This is an internal module used to generate Java API from the upstream Playwright
+1 -1
View File
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.playwright</groupId>
<artifactId>test-cli-fatjar</artifactId>
<version>1.36.0</version>
<version>1.32.0</version>
<name>Test Playwright Command Line FatJar</name>
<properties>
<compiler.version>1.8</compiler.version>
+1 -1
View File
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.playwright</groupId>
<artifactId>test-cli-version</artifactId>
<version>1.36.0</version>
<version>1.32.0</version>
<name>Test Playwright Command Line Version</name>
<properties>
<compiler.version>1.8</compiler.version>
+1 -1
View File
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.playwright</groupId>
<artifactId>test-local-installation</artifactId>
<version>1.36.0</version>
<version>1.32.0</version>
<name>Test local installation</name>
<description>Runs Playwright test suite (copied from playwright module) against locally cached Playwright</description>
<properties>
+1 -1
View File
@@ -9,7 +9,7 @@
</parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>test-spring-boot-starter</artifactId>
<version>1.36.0</version>
<version>1.32.0</version>
<name>Test Playwright With Spring Boot</name>
<properties>
<spring.version>2.4.3</spring.version>
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>com.microsoft.playwright</groupId>
<artifactId>update-version</artifactId>
<version>1.36.0</version>
<version>1.32.0</version>
<name>Playwright - Update Version in Documentation</name>
<description>
This is an internal module used to update versions in the documentation based on
-57
View File
@@ -1,57 +0,0 @@
FROM ubuntu:jammy
ARG DEBIAN_FRONTEND=noninteractive
ARG TZ=America/Los_Angeles
ARG DOCKER_IMAGE_NAME_TEMPLATE="mcr.microsoft.com/playwright/java:v%version%-jammy"
# === INSTALL JDK and Maven ===
RUN apt-get update && \
# Install install jdk 17 in a separate apt-get command so that
# installing maven doesn't bring in jdk 11
apt-get install -y --no-install-recommends openjdk-17-jdk && \
apt-get install -y --no-install-recommends \
# Ubuntu 22.04 and earlier come with Maven 3.6.3 which fails with
# Java 17, so we install latest Maven from Apache instead.
# maven \
# Install utilities required for downloading browsers
curl \
# Install utilities required for downloading driver
unzip \
# For the MSEdge install script
gpg && \
rm -rf /var/lib/apt/lists/* && \
# Create the pwuser
adduser pwuser
RUN VERSION=3.8.8 && \
curl -o - https://archive.apache.org/dist/maven/maven-3/$VERSION/binaries/apache-maven-$VERSION-bin.tar.gz | tar zxfv - -C /opt/ && \
ln -s /opt/apache-maven-$VERSION/bin/mvn /usr/local/bin/
ARG PW_TARGET_ARCH
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-${PW_TARGET_ARCH}
# === BAKE BROWSERS INTO IMAGE ===
# Browsers will remain downloaded in `/ms-playwright`.
# Note: make sure to set 777 to the registry so that any user can access
# registry.
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN mkdir /ms-playwright && \
mkdir /tmp/pw-java
COPY . /tmp/pw-java
RUN cd /tmp/pw-java && \
./scripts/download_driver_for_all_platforms.sh && \
mvn install -D skipTests --no-transfer-progress && \
DEBIAN_FRONTEND=noninteractive mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \
-D exec.args="install-deps" -f playwright/pom.xml --no-transfer-progress && \
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \
-D exec.args="install" -f playwright/pom.xml --no-transfer-progress && \
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI \
-D exec.args="mark-docker-image '${DOCKER_IMAGE_NAME_TEMPLATE}'" -f playwright/pom.xml --no-transfer-progress && \
rm -rf /tmp/pw-java && \
chmod -R 777 $PLAYWRIGHT_BROWSERS_PATH
+1 -1
View File
@@ -3,7 +3,7 @@ set -e
set +x
if [[ ($1 == '--help') || ($1 == '-h') || ($1 == '') || ($2 == '') ]]; then
echo "usage: $(basename $0) {--arm64,--amd64} {focal,jammy} playwright:localbuild-focal"
echo "usage: $(basename $0) {--arm64,--amd64} {focal} playwright:localbuild-focal"
echo
echo "Build Playwright docker image and tag it as 'playwright:localbuild-focal'."
echo "Once image is built, you can run it with"
+20 -25
View File
@@ -34,26 +34,25 @@ if [[ -z "${GITHUB_SHA}" ]]; then
exit 1
fi
BIONIC_TAGS=(
"next-bionic"
"v${PW_VERSION}-bionic"
)
if [[ "$RELEASE_CHANNEL" == "stable" ]]; then
BIONIC_TAGS+=("bionic")
fi
FOCAL_TAGS=(
"next"
"sha-${GITHUB_SHA}"
"next-focal"
)
if [[ "$RELEASE_CHANNEL" == "stable" ]]; then
FOCAL_TAGS+=("latest")
FOCAL_TAGS+=("focal")
FOCAL_TAGS+=("v${PW_VERSION}-focal")
fi
JAMMY_TAGS=(
"next"
"next-jammy"
"sha-${GITHUB_SHA}"
)
if [[ "$RELEASE_CHANNEL" == "stable" ]]; then
JAMMY_TAGS+=("jammy")
JAMMY_TAGS+=("latest")
JAMMY_TAGS+=("v${PW_VERSION}")
JAMMY_TAGS+=("v${PW_VERSION}-jammy")
FOCAL_TAGS+=("v${PW_VERSION}")
fi
tag_and_push() {
@@ -67,12 +66,12 @@ tag_and_push() {
publish_docker_images_with_arch_suffix() {
local FLAVOR="$1"
local TAGS=()
if [[ "$FLAVOR" == "focal" ]]; then
if [[ "$FLAVOR" == "bionic" ]]; then
TAGS=("${BIONIC_TAGS[@]}")
elif [[ "$FLAVOR" == "focal" ]]; then
TAGS=("${FOCAL_TAGS[@]}")
elif [[ "$FLAVOR" == "jammy" ]]; then
TAGS=("${JAMMY_TAGS[@]}")
else
echo "ERROR: unknown flavor - $FLAVOR. Must be either 'focal' or 'jammy'"
echo "ERROR: unknown flavor - $FLAVOR. Must be either 'bionic' or 'focal'"
exit 1
fi
local ARCH="$2"
@@ -93,12 +92,12 @@ publish_docker_images_with_arch_suffix() {
publish_docker_manifest () {
local FLAVOR="$1"
local TAGS=()
if [[ "$FLAVOR" == "focal" ]]; then
if [[ "$FLAVOR" == "bionic" ]]; then
TAGS=("${BIONIC_TAGS[@]}")
elif [[ "$FLAVOR" == "focal" ]]; then
TAGS=("${FOCAL_TAGS[@]}")
elif [[ "$FLAVOR" == "jammy" ]]; then
TAGS=("${JAMMY_TAGS[@]}")
else
echo "ERROR: unknown flavor - $FLAVOR. Must be either 'focal' or 'jammy'"
echo "ERROR: unknown flavor - $FLAVOR. Must be either 'bionic' or 'focal'"
exit 1
fi
@@ -120,7 +119,3 @@ publish_docker_manifest () {
publish_docker_images_with_arch_suffix focal amd64
publish_docker_images_with_arch_suffix focal arm64
publish_docker_manifest focal amd64 arm64
publish_docker_images_with_arch_suffix jammy amd64
publish_docker_images_with_arch_suffix jammy arm64
publish_docker_manifest jammy amd64 arm64