1
0
mirror of synced 2026-05-23 19:23:20 +00:00

Compare commits

...

32 Commits

Author SHA1 Message Date
Yury Semikhatsky fc07c91276 chore: roll driver, mark 1.20.1 (#862) 2022-03-23 16:49:11 -07:00
Yury Semikhatsky 6ae0df89fa fix: docker publishing (#851) 2022-03-14 20:22:53 -07:00
Yury Semikhatsky 5faf1b028a chore: update driver to 1.20.0 (#846) 2022-03-14 19:51:14 -07:00
Yury Semikhatsky 0212ebe3df devops: do not cache mvn packages (#848) (#850) 2022-03-14 19:04:43 -07:00
Yury Semikhatsky eee7732f1f chore: set version to 1.20.0 (#845) 2022-03-14 17:14:56 -07:00
Yury Semikhatsky 43ba37817b fix: send x-playwright-browser (#844) 2022-03-14 15:31:19 -07:00
Yury Semikhatsky 4916ba22af chore: roll driver (#838) 2022-03-14 12:04:20 -07:00
uchagani 94f72694f1 chore: move chmod command to after browsers are installed and consolidate co… (#835)
Co-authored-by: Max Schmitt <max@schmitt.mx>
2022-03-09 18:22:00 +01:00
Max Schmitt be167a161b devops: trigger Docker tests on Dockerfile changes (#839) 2022-03-09 09:08:36 -08:00
Yury Semikhatsky 187d2ad6c6 devops: restore test docker trigger (#840) 2022-03-09 09:07:07 -08:00
Max Schmitt 68a7dbc1e3 devops: publish no arm Docker for now (#837) 2022-03-08 22:01:54 +01:00
Yury Semikhatsky 1153d473fb feat: roll driver to 3/3/22 (#832) 2022-03-04 08:31:13 -08:00
Max Schmitt 00d53bd1ea devops: fix Docker publishing 2 2022-03-04 00:05:14 +01:00
Max Schmitt d423733d9d devops: fix Docker publishing 2022-03-04 00:00:16 +01:00
Max Schmitt e127abb68e chore: align Docker with upstream Docker infra (#831) 2022-03-03 22:55:21 +01:00
Yury Semikhatsky 5ee8f23380 fix(docs): drop trailing slash from link path (#818) 2022-02-17 15:26:10 -08:00
Yury Semikhatsky b448a1789a chore: roll 1.19.0 driver (#813) 2022-02-15 14:06:06 -08:00
Yury Semikhatsky 79b2c70513 fix: catch up with recent upstream changes (#812) 2022-02-15 08:39:27 -08:00
Max Schmitt d476d0a98c devops: trigger Java publish workflow on release (#811) 2022-02-14 22:44:03 +01:00
Yury Semikhatsky 2122c5690a fix: support multiple source dirs (#809) 2022-02-14 09:52:29 -08:00
Yury Semikhatsky 3119102b10 fix(assertions): include expected/actual values into error message (#808) 2022-02-11 13:02:27 -08:00
Yury Semikhatsky 838e7a40b3 feat: roll driver, support "has" option (#805) 2022-02-10 14:11:39 -08:00
Yury Semikhatsky ea6ede4670 fix: skip syntetic fields when converting options (#804) 2022-02-09 11:44:46 -08:00
Yury Semikhatsky 3cdefc2931 fix: normalize whitespaces in hasTitle (#803) 2022-02-09 09:54:46 -08:00
Yury Semikhatsky 119700a678 feat: add response param to route.fulfill (#797) 2022-01-28 08:38:24 -08:00
Yury Semikhatsky 17a4143a83 fix: throw if route is handled twice (#796) 2022-01-27 14:02:11 -08:00
Max Schmitt c03f4a9384 fix: CLI don't download browers automatically and set env accordingly (#790) 2022-01-24 12:54:49 -08:00
Andrey Lushnikov 85b671328e chore: roll to latest 1.18 (#785) 2022-01-19 16:42:07 -08:00
Yury Semikhatsky 11f898ca7f test: route.resume does not throw if page is closed (#781) 2022-01-19 13:19:33 -08:00
Yury Semikhatsky 2aef5c6742 fix: hide internal call from inspector log (#783) 2022-01-19 13:18:47 -08:00
Yury Semikhatsky 897d441c02 fix: include var name into tracing error message (#779) 2022-01-19 10:42:47 -08:00
Andrey Lushnikov f4c69faad3 chore: cut v1.18.0 (#777) 2022-01-19 08:42:53 -08:00
88 changed files with 1839 additions and 813 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
name: Publish
on:
workflow_dispatch:
release:
types: [published]
push:
branches:
- main
+6 -7
View File
@@ -17,10 +17,9 @@ jobs:
username: playwright
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: actions/checkout@v2
- name: Build Docker image
run: docker build -t playwright-java:localbuild-focal -f Dockerfile.focal .
- name: tag & publish
run: |
./scripts/tag_image_and_push.sh playwright-java:localbuild-focal playwright.azurecr.io/public/playwright/java:next
./scripts/tag_image_and_push.sh playwright-java:localbuild-focal playwright.azurecr.io/public/playwright/java:next-focal
./scripts/tag_image_and_push.sh playwright-java:localbuild-focal playwright.azurecr.io/public/playwright/java:sha-${{ github.sha }}
- name: Set up Docker QEMU for arm64 docker builds
uses: docker/setup-qemu-action@v1
with:
platforms: arm64
- name: publish docker canary
run: ./utils/docker/publish_docker.sh canary
+8 -16
View File
@@ -17,20 +17,12 @@ jobs:
login-server: playwright.azurecr.io
username: playwright
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker QEMU for arm64 docker builds
uses: docker/setup-qemu-action@v1
with:
platforms: arm64
- uses: actions/checkout@v2
- name: Build Docker image
run: docker build -t playwright-java:localbuild-focal -f Dockerfile.focal .
- name: tag & publish
run: |
# GITHUB_REF has a form of `refs/tags/v1.3.0`.
# TAG_NAME would be `v1.3.0`
TAG_NAME=${GITHUB_REF#refs/tags/}
if [[ ! "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]];
then
echo "Wrong TAG_NAME format: $TAG_NAME"
exit 1
fi
./scripts/tag_image_and_push.sh playwright-java:localbuild-focal playwright.azurecr.io/public/playwright/java:latest
./scripts/tag_image_and_push.sh playwright-java:localbuild-focal playwright.azurecr.io/public/playwright/java:focal
./scripts/tag_image_and_push.sh playwright-java:localbuild-focal playwright.azurecr.io/public/playwright/java:${TAG_NAME}
./scripts/tag_image_and_push.sh playwright-java:localbuild-focal playwright.azurecr.io/public/playwright/java:${TAG_NAME}-focal
- run: ./utils/docker/publish_docker.sh stable
if: (github.event_name != 'workflow_dispatch' && !github.event.release.prerelease) || (github.event_name == 'workflow_dispatch' && github.event.inputs.is_release == 'true')
- run: ./utils/docker/publish_docker.sh canary
if: (github.event_name != 'workflow_dispatch' && github.event.release.prerelease) || (github.event_name == 'workflow_dispatch' && github.event.inputs.is_release != 'true')
+9 -29
View File
@@ -19,23 +19,17 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1.5.0
- uses: microsoft/playwright-github-action@v1
- name: Set up JDK 1.8
uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 8
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Download drivers
shell: bash
run: scripts/download_driver_for_all_platforms.sh
- name: Build with Maven
run: mvn -B package -D skipTests --no-transfer-progress
- name: Build & Install
run: mvn -B install -D skipTests --no-transfer-progress
- name: Run tests
run: mvn test --no-transfer-progress --fail-at-end
env:
@@ -50,7 +44,6 @@ jobs:
env:
BROWSER: ${{ matrix.browser }}
run: |
mvn -B install -D skipTests --no-transfer-progress
cd tools/test-spring-boot-starter
mvn package -D skipTests --no-transfer-progress
java -jar target/test-spring-boot*.jar
@@ -70,7 +63,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1.5.0
- uses: microsoft/playwright-github-action@v1
- name: Install Media Pack
if: matrix.os == 'windows-latest'
shell: powershell
@@ -80,17 +73,11 @@ jobs:
with:
distribution: zulu
java-version: 8
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Download drivers
shell: bash
run: scripts/download_driver_for_all_platforms.sh
- name: Build with Maven
run: mvn -B package -D skipTests --no-transfer-progress
- name: Build & Install
run: mvn -B install -D skipTests --no-transfer-progress
- name: Run tests
run: mvn test --no-transfer-progress --fail-at-end
env:
@@ -106,23 +93,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1.5.0
- uses: microsoft/playwright-github-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 17
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: m2-${{ hashFiles('**/pom.xml') }}
restore-keys: m2
- name: Download drivers
shell: bash
run: scripts/download_driver_for_all_platforms.sh
- name: Build with Maven
run: mvn -B package -D skipTests --no-transfer-progress
- name: Build & Install
run: mvn -B install -D skipTests --no-transfer-progress
- name: Run tests
run: mvn test --no-transfer-progress --fail-at-end
env:
@@ -132,7 +113,6 @@ jobs:
env:
BROWSER: ${{ matrix.browser }}
run: |
mvn -B install -D skipTests --no-transfer-progress
cd tools/test-spring-boot-starter
mvn package -D skipTests --no-transfer-progress
java -jar target/test-spring-boot*.jar
+3 -3
View File
@@ -3,14 +3,14 @@ on:
push:
paths:
- '.github/workflows/test_docker.yml'
- 'Dockerfile*'
- '**/Dockerfile*'
branches:
- main
- release-*
pull_request:
paths:
- .github/workflows/test_docker.yml
- Dockerfile.*
- '**/Dockerfile*'
- scripts/CLI_VERSION
- '**/pom.xml'
branches:
@@ -23,7 +23,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build Docker image
run: docker build -t playwright-java:localbuild-focal -f Dockerfile.focal .
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-focal /bin/bash)"
+2 -2
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 -->99.0.4812.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Chromium <!-- GEN:chromium-version -->101.0.4929.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit <!-- GEN:webkit-version -->15.4<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->95.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Firefox <!-- GEN:firefox-version -->97.0.1<!-- 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.
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.20.1</version>
</parent>
<artifactId>driver-bundle</artifactId>
@@ -40,9 +40,10 @@ public class DriverJar extends Driver {
}
@Override
protected void initialize(Map<String, String> env) throws Exception {
protected void initialize(Map<String, String> env, Boolean installBrowsers) throws Exception {
extractDriverToTempDir();
installBrowsers(env);
if (installBrowsers)
installBrowsers(env);
}
private void installBrowsers(Map<String, String> env) throws IOException, InterruptedException {
@@ -60,6 +61,7 @@ public class DriverJar extends Driver {
}
ProcessBuilder pb = new ProcessBuilder(driver.toString(), "install");
pb.environment().putAll(env);
setRequiredEnvironmentVariables(pb);
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
Process p = pb.start();
@@ -40,7 +40,7 @@ public class TestInstall {
@Test
void playwrightCliInstalled() throws Exception {
Path cli = Driver.ensureDriverInstalled(Collections.emptyMap());
Path cli = Driver.ensureDriverInstalled(Collections.emptyMap(), false);
assertTrue(Files.exists(cli));
ProcessBuilder pb = new ProcessBuilder(cli.toString(), "install");
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.20.1</version>
</parent>
<artifactId>driver</artifactId>
@@ -35,7 +35,7 @@ public abstract class Driver {
}
@Override
protected void initialize(Map<String, String> env) {
protected void initialize(Map<String, String> env, Boolean installBrowsers) {
// no-op
}
@@ -45,11 +45,11 @@ public abstract class Driver {
}
}
public static synchronized Path ensureDriverInstalled(Map<String, String> env) {
public static synchronized Path ensureDriverInstalled(Map<String, String> env, Boolean installBrowsers) {
if (instance == null) {
try {
instance = createDriver();
instance.initialize(env);
instance.initialize(env, installBrowsers);
} catch (Exception exception) {
throw new RuntimeException("Failed to create driver", exception);
}
@@ -57,7 +57,7 @@ public abstract class Driver {
return instance.driverPath();
}
protected abstract void initialize(Map<String, String> env) throws Exception;
protected abstract void initialize(Map<String, String> env, Boolean installBrowsers) throws Exception;
public Path driverPath() {
String cliFileName = System.getProperty("os.name").toLowerCase().contains("windows") ?
@@ -66,9 +66,11 @@ public abstract class Driver {
}
public static void setRequiredEnvironmentVariables(ProcessBuilder pb) {
if (!pb.environment().containsKey("PW_CLI_TARGET_LANG")) {
pb.environment().put("PW_CLI_TARGET_LANG", "java");
pb.environment().put("PW_CLI_TARGET_LANG_VERSION", getMajorJavaVersion());
pb.environment().put("PW_LANG_NAME", "java");
pb.environment().put("PW_LANG_NAME_VERSION", getMajorJavaVersion());
String version = Driver.class.getPackage().getImplementationVersion();
if (version != null) {
pb.environment().put("PW_CLI_DISPLAY_VERSION", version);
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>org.example</groupId>
<artifactId>examples</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.20.1</version>
<name>Playwright Client Examples</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.20.1</version>
</parent>
<artifactId>playwright</artifactId>
@@ -21,9 +21,9 @@ import java.nio.file.Path;
import java.util.*;
/**
* Exposes API that can be used for the Web API testing. Each Playwright browser context has a APIRequestContext instance
* attached which shares cookies with the page context. Its also possible to create a new APIRequestContext instance
* manually. For more information see <a href="https://playwright.dev/java/docs/class-apirequestcontext">here</a>.
* Exposes API that can be used for the Web API testing. This class is used for creating {@code APIRequestContext} instance which
* in turn can be used for sending web requests. An instance of this class can be obtained via {@link Playwright#request
* Playwright.request()}. For more information see {@code APIRequestContext}.
*/
public interface APIRequest {
class NewContextOptions {
@@ -21,9 +21,24 @@ import java.nio.file.Path;
/**
* This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
* environment or the service to your e2e test. When used on {@code Page} or a {@code BrowserContext}, this API will automatically use
* the cookies from the corresponding {@code BrowserContext}. This means that if you log in using this API, your e2e test will be
* logged in and vice versa.
* environment or the service to your e2e test.
*
* <p> Each Playwright browser context has associated with it {@code APIRequestContext} instance which shares cookie storage with the
* browser context and can be accessed via {@link BrowserContext#request BrowserContext.request()} or {@link Page#request
* Page.request()}. It is also possible to create a new APIRequestContext instance manually by calling {@link
* APIRequest#newContext APIRequest.newContext()}.
*
* <p> **Cookie management**
*
* <p> {@code APIRequestContext} retuned by {@link BrowserContext#request BrowserContext.request()} and {@link Page#request
* Page.request()} shares cookie storage with the corresponding {@code BrowserContext}. Each API request will have {@code Cookie}
* header populated with the values from the browser context. If the API response contains {@code Set-Cookie} header it will
* automatically update {@code BrowserContext} cookies and requests made from the page will pick them up. This means that if you
* log in using this API, your e2e test will be logged in and vice versa.
*
* <p> If you want API requests to not interfere with the browser cookies you shoud create a new {@code APIRequestContext} by calling
* {@link APIRequest#newContext APIRequest.newContext()}. Such {@code APIRequestContext} object will have its own isolated cookie
* storage.
*/
public interface APIRequestContext {
class StorageStateOptions {
@@ -497,7 +497,6 @@ public interface BrowserContext extends AutoCloseable {
* <li> {@code "midi"}</li>
* <li> {@code "midi-sysex"} (system-exclusive midi)</li>
* <li> {@code "notifications"}</li>
* <li> {@code "push"}</li>
* <li> {@code "camera"}</li>
* <li> {@code "microphone"}</li>
* <li> {@code "background-sync"}</li>
@@ -524,7 +523,6 @@ public interface BrowserContext extends AutoCloseable {
* <li> {@code "midi"}</li>
* <li> {@code "midi-sysex"} (system-exclusive midi)</li>
* <li> {@code "notifications"}</li>
* <li> {@code "push"}</li>
* <li> {@code "camera"}</li>
* <li> {@code "microphone"}</li>
* <li> {@code "background-sync"}</li>
@@ -130,7 +130,7 @@ public interface BrowserType {
/**
* Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
* "msedge-beta", "msedge-dev", "msedge-canary". Read more about using <a
* href="https://playwright.dev/java/docs/browsers/#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
* href="https://playwright.dev/java/docs/browsers#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
*/
public Object channel;
/**
@@ -222,7 +222,7 @@ public interface BrowserType {
/**
* Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
* "msedge-beta", "msedge-dev", "msedge-canary". Read more about using <a
* href="https://playwright.dev/java/docs/browsers/#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
* href="https://playwright.dev/java/docs/browsers#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
*/
public LaunchOptions setChannel(BrowserChannel channel) {
this.channel = channel;
@@ -231,7 +231,7 @@ public interface BrowserType {
/**
* Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
* "msedge-beta", "msedge-dev", "msedge-canary". Read more about using <a
* href="https://playwright.dev/java/docs/browsers/#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
* href="https://playwright.dev/java/docs/browsers#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
*/
public LaunchOptions setChannel(String channel) {
this.channel = channel;
@@ -399,7 +399,7 @@ public interface BrowserType {
/**
* Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
* "msedge-beta", "msedge-dev", "msedge-canary". Read more about using <a
* href="https://playwright.dev/java/docs/browsers/#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
* href="https://playwright.dev/java/docs/browsers#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
*/
public Object channel;
/**
@@ -625,7 +625,7 @@ public interface BrowserType {
/**
* Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
* "msedge-beta", "msedge-dev", "msedge-canary". Read more about using <a
* href="https://playwright.dev/java/docs/browsers/#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
* href="https://playwright.dev/java/docs/browsers#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
*/
public LaunchPersistentContextOptions setChannel(BrowserChannel channel) {
this.channel = channel;
@@ -634,7 +634,7 @@ public interface BrowserType {
/**
* Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
* "msedge-beta", "msedge-dev", "msedge-canary". Read more about using <a
* href="https://playwright.dev/java/docs/browsers/#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
* href="https://playwright.dev/java/docs/browsers#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
*/
public LaunchPersistentContextOptions setChannel(String channel) {
this.channel = channel;
@@ -29,7 +29,7 @@ import static java.util.Arrays.asList;
*/
public class CLI {
public static void main(String[] args) throws IOException, InterruptedException {
Path driver = Driver.ensureDriverInstalled(Collections.emptyMap());
Path driver = Driver.ensureDriverInstalled(Collections.emptyMap(), false);
ProcessBuilder pb = new ProcessBuilder(driver.toString());
pb.command().addAll(asList(args));
Driver.setRequiredEnvironmentVariables(pb);
@@ -59,7 +59,7 @@ import java.util.*;
public interface ElementHandle extends JSHandle {
class CheckOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -81,14 +81,14 @@ public interface ElementHandle extends JSHandle {
*/
public Double timeout;
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
public Boolean trial;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public CheckOptions setForce(boolean force) {
@@ -129,7 +129,7 @@ public interface ElementHandle extends JSHandle {
return this;
}
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -152,7 +152,7 @@ public interface ElementHandle extends JSHandle {
*/
public Double delay;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -179,7 +179,7 @@ public interface ElementHandle extends JSHandle {
*/
public Double timeout;
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -207,7 +207,7 @@ public interface ElementHandle extends JSHandle {
return this;
}
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public ClickOptions setForce(boolean force) {
@@ -256,7 +256,7 @@ public interface ElementHandle extends JSHandle {
return this;
}
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -275,7 +275,7 @@ public interface ElementHandle extends JSHandle {
*/
public Double delay;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -302,7 +302,7 @@ public interface ElementHandle extends JSHandle {
*/
public Double timeout;
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -323,7 +323,7 @@ public interface ElementHandle extends JSHandle {
return this;
}
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public DblclickOptions setForce(boolean force) {
@@ -372,7 +372,7 @@ public interface ElementHandle extends JSHandle {
return this;
}
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -383,7 +383,7 @@ public interface ElementHandle extends JSHandle {
}
class FillOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -401,7 +401,7 @@ public interface ElementHandle extends JSHandle {
public Double timeout;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public FillOptions setForce(boolean force) {
@@ -429,7 +429,7 @@ public interface ElementHandle extends JSHandle {
}
class HoverOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -450,14 +450,14 @@ public interface ElementHandle extends JSHandle {
*/
public Double timeout;
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
public Boolean trial;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public HoverOptions setForce(boolean force) {
@@ -497,7 +497,7 @@ public interface ElementHandle extends JSHandle {
return this;
}
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -569,6 +569,20 @@ public interface ElementHandle extends JSHandle {
}
}
class ScreenshotOptions {
/**
* When set to {@code "disabled"}, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
* depending on their duration:
* <ul>
* <li> finite animations are fast-forwarded to completion, so they'll fire {@code transitionend} event.</li>
* <li> infinite animations are canceled to initial state, and then played over after the screenshot.</li>
* </ul>
*/
public ScreenshotAnimations animations;
/**
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
* {@code #FF00FF} that completely covers its bounding box.
*/
public List<Locator> mask;
/**
* Hides default white background and allows capturing screenshots with transparency. Not applicable to {@code jpeg} images.
* Defaults to {@code false}.
@@ -595,6 +609,26 @@ public interface ElementHandle extends JSHandle {
*/
public ScreenshotType type;
/**
* When set to {@code "disabled"}, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
* depending on their duration:
* <ul>
* <li> finite animations are fast-forwarded to completion, so they'll fire {@code transitionend} event.</li>
* <li> infinite animations are canceled to initial state, and then played over after the screenshot.</li>
* </ul>
*/
public ScreenshotOptions setAnimations(ScreenshotAnimations animations) {
this.animations = animations;
return this;
}
/**
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
* {@code #FF00FF} that completely covers its bounding box.
*/
public ScreenshotOptions setMask(List<Locator> mask) {
this.mask = mask;
return this;
}
/**
* Hides default white background and allows capturing screenshots with transparency. Not applicable to {@code jpeg} images.
* Defaults to {@code false}.
@@ -656,7 +690,7 @@ public interface ElementHandle extends JSHandle {
}
class SelectOptionOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -674,7 +708,7 @@ public interface ElementHandle extends JSHandle {
public Double timeout;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public SelectOptionOptions setForce(boolean force) {
@@ -702,7 +736,7 @@ public interface ElementHandle extends JSHandle {
}
class SelectTextOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -714,7 +748,7 @@ public interface ElementHandle extends JSHandle {
public Double timeout;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public SelectTextOptions setForce(boolean force) {
@@ -733,7 +767,7 @@ public interface ElementHandle extends JSHandle {
}
class SetCheckedOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -755,14 +789,14 @@ public interface ElementHandle extends JSHandle {
*/
public Double timeout;
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
public Boolean trial;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public SetCheckedOptions setForce(boolean force) {
@@ -803,7 +837,7 @@ public interface ElementHandle extends JSHandle {
return this;
}
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -847,7 +881,7 @@ public interface ElementHandle extends JSHandle {
}
class TapOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -874,14 +908,14 @@ public interface ElementHandle extends JSHandle {
*/
public Double timeout;
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
public Boolean trial;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public TapOptions setForce(boolean force) {
@@ -930,7 +964,7 @@ public interface ElementHandle extends JSHandle {
return this;
}
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -985,7 +1019,7 @@ public interface ElementHandle extends JSHandle {
}
class UncheckOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -1007,14 +1041,14 @@ public interface ElementHandle extends JSHandle {
*/
public Double timeout;
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
public Boolean trial;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public UncheckOptions setForce(boolean force) {
@@ -1055,7 +1089,7 @@ public interface ElementHandle extends JSHandle {
return this;
}
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -1164,7 +1198,7 @@ public interface ElementHandle extends JSHandle {
* <ol>
* <li> Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked, this
* method returns immediately.</li>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
@@ -1185,7 +1219,7 @@ public interface ElementHandle extends JSHandle {
* <ol>
* <li> Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked, this
* method returns immediately.</li>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
@@ -1202,7 +1236,7 @@ public interface ElementHandle extends JSHandle {
/**
* This method clicks the element by performing the following steps:
* <ol>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element, or the specified {@code position}.</li>
@@ -1220,7 +1254,7 @@ public interface ElementHandle extends JSHandle {
/**
* This method clicks the element by performing the following steps:
* <ol>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element, or the specified {@code position}.</li>
@@ -1240,7 +1274,7 @@ public interface ElementHandle extends JSHandle {
/**
* This method double clicks the element by performing the following steps:
* <ol>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to double click in the center of the element, or the specified {@code position}.</li>
@@ -1261,7 +1295,7 @@ public interface ElementHandle extends JSHandle {
/**
* This method double clicks the element by performing the following steps:
* <ol>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to double click in the center of the element, or the specified {@code position}.</li>
@@ -1352,7 +1386,7 @@ public interface ElementHandle extends JSHandle {
* Returns the return value of {@code expression}.
*
* <p> The method finds an element matching the specified selector in the {@code ElementHandle}s subtree and passes it as a first
* argument to {@code expression}. See <a href="https://playwright.dev/java/docs/selectors/">Working with selectors</a> for more
* argument to {@code expression}. See <a href="https://playwright.dev/java/docs/selectors">Working with selectors</a> for more
* details. If no elements match the selector, the method throws an error.
*
* <p> If {@code expression} returns a <a
@@ -1366,7 +1400,7 @@ public interface ElementHandle extends JSHandle {
* assertEquals("10", tweetHandle.evalOnSelector(".retweets", "node => node.innerText"));
* }</pre>
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors/">working with selectors</a> for more
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted
* as a function. Otherwise, evaluated as an expression.
@@ -1378,7 +1412,7 @@ public interface ElementHandle extends JSHandle {
* Returns the return value of {@code expression}.
*
* <p> The method finds an element matching the specified selector in the {@code ElementHandle}s subtree and passes it as a first
* argument to {@code expression}. See <a href="https://playwright.dev/java/docs/selectors/">Working with selectors</a> for more
* argument to {@code expression}. See <a href="https://playwright.dev/java/docs/selectors">Working with selectors</a> for more
* details. If no elements match the selector, the method throws an error.
*
* <p> If {@code expression} returns a <a
@@ -1392,7 +1426,7 @@ public interface ElementHandle extends JSHandle {
* assertEquals("10", tweetHandle.evalOnSelector(".retweets", "node => node.innerText"));
* }</pre>
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors/">working with selectors</a> for more
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted
* as a function. Otherwise, evaluated as an expression.
@@ -1403,7 +1437,7 @@ public interface ElementHandle extends JSHandle {
* Returns the return value of {@code expression}.
*
* <p> The method finds all elements matching the specified selector in the {@code ElementHandle}'s subtree and passes an array of
* matched elements as a first argument to {@code expression}. See <a href="https://playwright.dev/java/docs/selectors/">Working
* matched elements as a first argument to {@code expression}. See <a href="https://playwright.dev/java/docs/selectors">Working
* with selectors</a> for more details.
*
* <p> If {@code expression} returns a <a
@@ -1417,7 +1451,7 @@ public interface ElementHandle extends JSHandle {
* assertEquals(Arrays.asList("Hello!", "Hi!"), feedHandle.evalOnSelectorAll(".tweet", "nodes => nodes.map(n => n.innerText)"));
* }</pre>
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors/">working with selectors</a> for more
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted
* as a function. Otherwise, evaluated as an expression.
@@ -1429,7 +1463,7 @@ public interface ElementHandle extends JSHandle {
* Returns the return value of {@code expression}.
*
* <p> The method finds all elements matching the specified selector in the {@code ElementHandle}'s subtree and passes an array of
* matched elements as a first argument to {@code expression}. See <a href="https://playwright.dev/java/docs/selectors/">Working
* matched elements as a first argument to {@code expression}. See <a href="https://playwright.dev/java/docs/selectors">Working
* with selectors</a> for more details.
*
* <p> If {@code expression} returns a <a
@@ -1443,7 +1477,7 @@ public interface ElementHandle extends JSHandle {
* assertEquals(Arrays.asList("Hello!", "Hi!"), feedHandle.evalOnSelectorAll(".tweet", "nodes => nodes.map(n => n.innerText)"));
* }</pre>
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors/">working with selectors</a> for more
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted
* as a function. Otherwise, evaluated as an expression.
@@ -1451,7 +1485,7 @@ public interface ElementHandle extends JSHandle {
*/
Object evalOnSelectorAll(String selector, String expression, Object arg);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, focuses the
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, focuses the
* element, fills it and triggers an {@code input} event after filling. Note that you can pass an empty string to clear the input
* field.
*
@@ -1468,7 +1502,7 @@ public interface ElementHandle extends JSHandle {
fill(value, null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, focuses the
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, focuses the
* element, fills it and triggers an {@code input} event after filling. Note that you can pass an empty string to clear the input
* field.
*
@@ -1495,7 +1529,7 @@ public interface ElementHandle extends JSHandle {
/**
* This method hovers over the element by performing the following steps:
* <ol>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to hover over the center of the element, or the specified {@code position}.</li>
@@ -1513,7 +1547,7 @@ public interface ElementHandle extends JSHandle {
/**
* This method hovers over the element by performing the following steps:
* <ol>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to hover over the center of the element, or the specified {@code position}.</li>
@@ -1550,24 +1584,24 @@ public interface ElementHandle extends JSHandle {
boolean isChecked();
/**
* Returns whether the element is disabled, the opposite of <a
* href="https://playwright.dev/java/docs/actionability/#enabled">enabled</a>.
* href="https://playwright.dev/java/docs/actionability#enabled">enabled</a>.
*/
boolean isDisabled();
/**
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability/#editable">editable</a>.
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability#editable">editable</a>.
*/
boolean isEditable();
/**
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability/#enabled">enabled</a>.
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability#enabled">enabled</a>.
*/
boolean isEnabled();
/**
* Returns whether the element is hidden, the opposite of <a
* href="https://playwright.dev/java/docs/actionability/#visible">visible</a>.
* href="https://playwright.dev/java/docs/actionability#visible">visible</a>.
*/
boolean isHidden();
/**
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability/#visible">visible</a>.
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability#visible">visible</a>.
*/
boolean isVisible();
/**
@@ -1626,26 +1660,26 @@ public interface ElementHandle extends JSHandle {
void press(String key, PressOptions options);
/**
* The method finds an element matching the specified selector in the {@code ElementHandle}'s subtree. See <a
* href="https://playwright.dev/java/docs/selectors/">Working with selectors</a> for more details. If no elements match the
* href="https://playwright.dev/java/docs/selectors">Working with selectors</a> for more details. If no elements match the
* selector, returns {@code null}.
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors/">working with selectors</a> for more
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
*/
ElementHandle querySelector(String selector);
/**
* The method finds all elements matching the specified selector in the {@code ElementHandle}s subtree. See <a
* href="https://playwright.dev/java/docs/selectors/">Working with selectors</a> for more details. If no elements match the
* href="https://playwright.dev/java/docs/selectors">Working with selectors</a> for more details. If no elements match the
* selector, returns empty array.
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors/">working with selectors</a> for more
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
*/
List<ElementHandle> querySelectorAll(String selector);
/**
* Returns the buffer with the captured screenshot.
*
* <p> This method waits for the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, then
* <p> This method waits for the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, then
* scrolls element into view before taking a screenshot. If the element is detached from DOM, the method throws an error.
*/
default byte[] screenshot() {
@@ -1654,12 +1688,12 @@ public interface ElementHandle extends JSHandle {
/**
* Returns the buffer with the captured screenshot.
*
* <p> This method waits for the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, then
* <p> This method waits for the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, then
* scrolls element into view before taking a screenshot. If the element is detached from DOM, the method throws an error.
*/
byte[] screenshot(ScreenshotOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, then tries to
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, then tries to
* scroll element into view, unless it is completely visible as defined by <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API">IntersectionObserver</a>'s {@code ratio}.
*
@@ -1670,7 +1704,7 @@ public interface ElementHandle extends JSHandle {
scrollIntoViewIfNeeded(null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, then tries to
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, then tries to
* scroll element into view, unless it is completely visible as defined by <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API">IntersectionObserver</a>'s {@code ratio}.
*
@@ -1679,8 +1713,8 @@ public interface ElementHandle extends JSHandle {
*/
void scrollIntoViewIfNeeded(ScrollIntoViewIfNeededOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -1707,8 +1741,8 @@ public interface ElementHandle extends JSHandle {
return selectOption(values, null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -1733,8 +1767,8 @@ public interface ElementHandle extends JSHandle {
*/
List<String> selectOption(String values, SelectOptionOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -1761,8 +1795,8 @@ public interface ElementHandle extends JSHandle {
return selectOption(values, null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -1787,8 +1821,8 @@ public interface ElementHandle extends JSHandle {
*/
List<String> selectOption(ElementHandle values, SelectOptionOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -1815,8 +1849,8 @@ public interface ElementHandle extends JSHandle {
return selectOption(values, null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -1841,8 +1875,8 @@ public interface ElementHandle extends JSHandle {
*/
List<String> selectOption(String[] values, SelectOptionOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -1869,8 +1903,8 @@ public interface ElementHandle extends JSHandle {
return selectOption(values, null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -1895,8 +1929,8 @@ public interface ElementHandle extends JSHandle {
*/
List<String> selectOption(SelectOption values, SelectOptionOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -1923,8 +1957,8 @@ public interface ElementHandle extends JSHandle {
return selectOption(values, null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -1949,8 +1983,8 @@ public interface ElementHandle extends JSHandle {
*/
List<String> selectOption(ElementHandle[] values, SelectOptionOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -1977,8 +2011,8 @@ public interface ElementHandle extends JSHandle {
return selectOption(values, null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -2003,14 +2037,14 @@ public interface ElementHandle extends JSHandle {
*/
List<String> selectOption(SelectOption[] values, SelectOptionOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, then focuses
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, then focuses
* the element and selects all its text content.
*/
default void selectText() {
selectText(null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, then focuses
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, then focuses
* the element and selects all its text content.
*/
void selectText(SelectTextOptions options);
@@ -2019,7 +2053,7 @@ public interface ElementHandle extends JSHandle {
* <ol>
* <li> Ensure that element is a checkbox or a radio input. If not, this method throws.</li>
* <li> If the element already has the right checked state, this method returns immediately.</li>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the matched element,
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the matched element,
* unless {@code force} option is set. If the element is detached during the checks, the whole action is retried.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
@@ -2040,7 +2074,7 @@ public interface ElementHandle extends JSHandle {
* <ol>
* <li> Ensure that element is a checkbox or a radio input. If not, this method throws.</li>
* <li> If the element already has the right checked state, this method returns immediately.</li>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the matched element,
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the matched element,
* unless {@code force} option is set. If the element is detached during the checks, the whole action is retried.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
@@ -2129,7 +2163,7 @@ public interface ElementHandle extends JSHandle {
/**
* This method taps the element by performing the following steps:
* <ol>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#touchscreen Page.touchscreen()} to tap the center of the element, or the specified {@code position}.</li>
@@ -2149,7 +2183,7 @@ public interface ElementHandle extends JSHandle {
/**
* This method taps the element by performing the following steps:
* <ol>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#touchscreen Page.touchscreen()} to tap the center of the element, or the specified {@code position}.</li>
@@ -2213,7 +2247,7 @@ public interface ElementHandle extends JSHandle {
* <ol>
* <li> Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already unchecked,
* this method returns immediately.</li>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
@@ -2234,7 +2268,7 @@ public interface ElementHandle extends JSHandle {
* <ol>
* <li> Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already unchecked,
* this method returns immediately.</li>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
@@ -2252,19 +2286,18 @@ public interface ElementHandle extends JSHandle {
* Returns when the element satisfies the {@code state}.
*
* <p> Depending on the {@code state} parameter, this method waits for one of the <a
* href="https://playwright.dev/java/docs/actionability/">actionability</a> checks to pass. This method throws when the
* href="https://playwright.dev/java/docs/actionability">actionability</a> checks to pass. This method throws when the
* element is detached while waiting, unless waiting for the {@code "hidden"} state.
* <ul>
* <li> {@code "visible"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability/#visible">visible</a>.</li>
* <li> {@code "hidden"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability/#visible">not visible</a>
* or <a href="https://playwright.dev/java/docs/actionability/#attached">not attached</a>. Note that waiting for hidden
* does not throw when the element detaches.</li>
* <li> {@code "stable"} Wait until the element is both <a href="https://playwright.dev/java/docs/actionability/#visible">visible</a>
* and <a href="https://playwright.dev/java/docs/actionability/#stable">stable</a>.</li>
* <li> {@code "enabled"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability/#enabled">enabled</a>.</li>
* <li> {@code "disabled"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability/#enabled">not
* enabled</a>.</li>
* <li> {@code "editable"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability/#editable">editable</a>.</li>
* <li> {@code "visible"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability#visible">visible</a>.</li>
* <li> {@code "hidden"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability#visible">not visible</a> or
* <a href="https://playwright.dev/java/docs/actionability#attached">not attached</a>. Note that waiting for hidden does
* not throw when the element detaches.</li>
* <li> {@code "stable"} Wait until the element is both <a href="https://playwright.dev/java/docs/actionability#visible">visible</a>
* and <a href="https://playwright.dev/java/docs/actionability#stable">stable</a>.</li>
* <li> {@code "enabled"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability#enabled">enabled</a>.</li>
* <li> {@code "disabled"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability#enabled">not enabled</a>.</li>
* <li> {@code "editable"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability#editable">editable</a>.</li>
* </ul>
*
* <p> If the element does not satisfy the condition for the {@code timeout} milliseconds, this method will throw.
@@ -2278,19 +2311,18 @@ public interface ElementHandle extends JSHandle {
* Returns when the element satisfies the {@code state}.
*
* <p> Depending on the {@code state} parameter, this method waits for one of the <a
* href="https://playwright.dev/java/docs/actionability/">actionability</a> checks to pass. This method throws when the
* href="https://playwright.dev/java/docs/actionability">actionability</a> checks to pass. This method throws when the
* element is detached while waiting, unless waiting for the {@code "hidden"} state.
* <ul>
* <li> {@code "visible"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability/#visible">visible</a>.</li>
* <li> {@code "hidden"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability/#visible">not visible</a>
* or <a href="https://playwright.dev/java/docs/actionability/#attached">not attached</a>. Note that waiting for hidden
* does not throw when the element detaches.</li>
* <li> {@code "stable"} Wait until the element is both <a href="https://playwright.dev/java/docs/actionability/#visible">visible</a>
* and <a href="https://playwright.dev/java/docs/actionability/#stable">stable</a>.</li>
* <li> {@code "enabled"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability/#enabled">enabled</a>.</li>
* <li> {@code "disabled"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability/#enabled">not
* enabled</a>.</li>
* <li> {@code "editable"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability/#editable">editable</a>.</li>
* <li> {@code "visible"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability#visible">visible</a>.</li>
* <li> {@code "hidden"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability#visible">not visible</a> or
* <a href="https://playwright.dev/java/docs/actionability#attached">not attached</a>. Note that waiting for hidden does
* not throw when the element detaches.</li>
* <li> {@code "stable"} Wait until the element is both <a href="https://playwright.dev/java/docs/actionability#visible">visible</a>
* and <a href="https://playwright.dev/java/docs/actionability#stable">stable</a>.</li>
* <li> {@code "enabled"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability#enabled">enabled</a>.</li>
* <li> {@code "disabled"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability#enabled">not enabled</a>.</li>
* <li> {@code "editable"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability#editable">editable</a>.</li>
* </ul>
*
* <p> If the element does not satisfy the condition for the {@code timeout} milliseconds, this method will throw.
@@ -2316,7 +2348,7 @@ public interface ElementHandle extends JSHandle {
*
* <p> <strong>NOTE:</strong> This method does not work across navigations, use {@link Page#waitForSelector Page.waitForSelector()} instead.
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors/">working with selectors</a> for more
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
*/
default ElementHandle waitForSelector(String selector) {
@@ -2340,7 +2372,7 @@ public interface ElementHandle extends JSHandle {
*
* <p> <strong>NOTE:</strong> This method does not work across navigations, use {@link Page#waitForSelector Page.waitForSelector()} instead.
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors/">working with selectors</a> for more
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
*/
ElementHandle waitForSelector(String selector, WaitForSelectorOptions options);
File diff suppressed because it is too large Load Diff
@@ -49,12 +49,29 @@ import java.util.regex.Pattern;
*/
public interface FrameLocator {
class LocatorOptions {
/**
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
* For example, {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
*
* <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 containing specified text somewhere inside, possibly in a child or a descendant element. For example,
* {@code "Playwright"} matches {@code <article><div>Playwright</div></article>}.
*/
public Object hasText;
/**
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
* For example, {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public LocatorOptions setHas(Locator has) {
this.has = has;
return this;
}
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. For example,
* {@code "Playwright"} matches {@code <article><div>Playwright</div></article>}.
@@ -80,7 +97,7 @@ public interface FrameLocator {
* When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements in
* that iframe.
*
* @param selector A selector to use when resolving DOM element. See <a href="https://playwright.dev/java/docs/selectors/">working with
* @param selector A selector to use when resolving DOM element. See <a href="https://playwright.dev/java/docs/selectors">working with
* selectors</a> for more details.
*/
FrameLocator frameLocator(String selector);
@@ -91,7 +108,7 @@ public interface FrameLocator {
/**
* The method finds an element matching the specified selector in the FrameLocator's subtree.
*
* @param selector A selector to use when resolving DOM element. See <a href="https://playwright.dev/java/docs/selectors/">working with
* @param selector A selector to use when resolving DOM element. See <a href="https://playwright.dev/java/docs/selectors">working with
* selectors</a> for more details.
*/
default Locator locator(String selector) {
@@ -100,7 +117,7 @@ public interface FrameLocator {
/**
* The method finds an element matching the specified selector in the FrameLocator's subtree.
*
* @param selector A selector to use when resolving DOM element. See <a href="https://playwright.dev/java/docs/selectors/">working with
* @param selector A selector to use when resolving DOM element. See <a href="https://playwright.dev/java/docs/selectors">working with
* selectors</a> for more details.
*/
Locator locator(String selector, LocatorOptions options);
@@ -26,7 +26,7 @@ import java.util.regex.Pattern;
* to find element(s) on the page at any moment. Locator can be created with the {@link Page#locator Page.locator()}
* method.
*
* <p> <a href="https://playwright.dev/java/docs/locators/">Learn more about locators</a>.
* <p> <a href="https://playwright.dev/java/docs/locators">Learn more about locators</a>.
*/
public interface Locator {
class BoundingBoxOptions {
@@ -49,7 +49,7 @@ public interface Locator {
}
class CheckOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -71,14 +71,14 @@ public interface Locator {
*/
public Double timeout;
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
public Boolean trial;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public CheckOptions setForce(boolean force) {
@@ -119,7 +119,7 @@ public interface Locator {
return this;
}
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -142,7 +142,7 @@ public interface Locator {
*/
public Double delay;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -169,7 +169,7 @@ public interface Locator {
*/
public Double timeout;
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -197,7 +197,7 @@ public interface Locator {
return this;
}
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public ClickOptions setForce(boolean force) {
@@ -246,7 +246,7 @@ public interface Locator {
return this;
}
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -265,7 +265,7 @@ public interface Locator {
*/
public Double delay;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -292,7 +292,7 @@ public interface Locator {
*/
public Double timeout;
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -313,7 +313,7 @@ public interface Locator {
return this;
}
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public DblclickOptions setForce(boolean force) {
@@ -362,7 +362,7 @@ public interface Locator {
return this;
}
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -391,7 +391,7 @@ public interface Locator {
}
class DragToOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -418,14 +418,14 @@ public interface Locator {
*/
public Double timeout;
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
public Boolean trial;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public DragToOptions setForce(boolean force) {
@@ -481,7 +481,7 @@ public interface Locator {
return this;
}
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -546,7 +546,7 @@ public interface Locator {
}
class FillOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -564,7 +564,7 @@ public interface Locator {
public Double timeout;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public FillOptions setForce(boolean force) {
@@ -628,7 +628,7 @@ public interface Locator {
}
class HoverOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -649,14 +649,14 @@ public interface Locator {
*/
public Double timeout;
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
public Boolean trial;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public HoverOptions setForce(boolean force) {
@@ -696,7 +696,7 @@ public interface Locator {
return this;
}
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -864,12 +864,29 @@ public interface Locator {
}
}
class LocatorOptions {
/**
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
* For example, {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
*
* <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 containing specified text somewhere inside, possibly in a child or a descendant element. For example,
* {@code "Playwright"} matches {@code <article><div>Playwright</div></article>}.
*/
public Object hasText;
/**
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
* For example, {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
public LocatorOptions setHas(Locator has) {
this.has = has;
return this;
}
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. For example,
* {@code "Playwright"} matches {@code <article><div>Playwright</div></article>}.
@@ -932,6 +949,20 @@ public interface Locator {
}
}
class ScreenshotOptions {
/**
* When set to {@code "disabled"}, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
* depending on their duration:
* <ul>
* <li> finite animations are fast-forwarded to completion, so they'll fire {@code transitionend} event.</li>
* <li> infinite animations are canceled to initial state, and then played over after the screenshot.</li>
* </ul>
*/
public ScreenshotAnimations animations;
/**
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
* {@code #FF00FF} that completely covers its bounding box.
*/
public List<Locator> mask;
/**
* Hides default white background and allows capturing screenshots with transparency. Not applicable to {@code jpeg} images.
* Defaults to {@code false}.
@@ -958,6 +989,26 @@ public interface Locator {
*/
public ScreenshotType type;
/**
* When set to {@code "disabled"}, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
* depending on their duration:
* <ul>
* <li> finite animations are fast-forwarded to completion, so they'll fire {@code transitionend} event.</li>
* <li> infinite animations are canceled to initial state, and then played over after the screenshot.</li>
* </ul>
*/
public ScreenshotOptions setAnimations(ScreenshotAnimations animations) {
this.animations = animations;
return this;
}
/**
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
* {@code #FF00FF} that completely covers its bounding box.
*/
public ScreenshotOptions setMask(List<Locator> mask) {
this.mask = mask;
return this;
}
/**
* Hides default white background and allows capturing screenshots with transparency. Not applicable to {@code jpeg} images.
* Defaults to {@code false}.
@@ -1019,7 +1070,7 @@ public interface Locator {
}
class SelectOptionOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -1037,7 +1088,7 @@ public interface Locator {
public Double timeout;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public SelectOptionOptions setForce(boolean force) {
@@ -1065,7 +1116,7 @@ public interface Locator {
}
class SelectTextOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -1077,7 +1128,7 @@ public interface Locator {
public Double timeout;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public SelectTextOptions setForce(boolean force) {
@@ -1096,7 +1147,7 @@ public interface Locator {
}
class SetCheckedOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -1118,14 +1169,14 @@ public interface Locator {
*/
public Double timeout;
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
public Boolean trial;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public SetCheckedOptions setForce(boolean force) {
@@ -1166,7 +1217,7 @@ public interface Locator {
return this;
}
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -1210,7 +1261,7 @@ public interface Locator {
}
class TapOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -1237,14 +1288,14 @@ public interface Locator {
*/
public Double timeout;
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
public Boolean trial;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public TapOptions setForce(boolean force) {
@@ -1293,7 +1344,7 @@ public interface Locator {
return this;
}
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -1366,7 +1417,7 @@ public interface Locator {
}
class UncheckOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
@@ -1388,14 +1439,14 @@ public interface Locator {
*/
public Double timeout;
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
public Boolean trial;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public UncheckOptions setForce(boolean force) {
@@ -1436,7 +1487,7 @@ public interface Locator {
return this;
}
/**
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability">actionability</a>
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
* performing it.
*/
@@ -1543,7 +1594,7 @@ public interface Locator {
* <ol>
* <li> Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked, this
* method returns immediately.</li>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
@@ -1564,7 +1615,7 @@ public interface Locator {
* <ol>
* <li> Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked, this
* method returns immediately.</li>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
@@ -1581,7 +1632,7 @@ public interface Locator {
/**
* This method clicks the element by performing the following steps:
* <ol>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element, or the specified {@code position}.</li>
@@ -1599,7 +1650,7 @@ public interface Locator {
/**
* This method clicks the element by performing the following steps:
* <ol>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element, or the specified {@code position}.</li>
@@ -1619,7 +1670,7 @@ public interface Locator {
/**
* This method double clicks the element by performing the following steps:
* <ol>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to double click in the center of the element, or the specified {@code position}.</li>
@@ -1640,7 +1691,7 @@ public interface Locator {
/**
* This method double clicks the element by performing the following steps:
* <ol>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to double click in the center of the element, or the specified {@code position}.</li>
@@ -1957,7 +2008,7 @@ public interface Locator {
*/
JSHandle evaluateHandle(String expression, Object arg, EvaluateHandleOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, focuses the
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, focuses the
* element, fills it and triggers an {@code input} event after filling. Note that you can pass an empty string to clear the input
* field.
*
@@ -1974,7 +2025,7 @@ public interface Locator {
fill(value, null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, focuses the
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, focuses the
* element, fills it and triggers an {@code input} event after filling. Note that you can pass an empty string to clear the input
* field.
*
@@ -2010,7 +2061,7 @@ public interface Locator {
* locator.click();
* }</pre>
*
* @param selector A selector to use when resolving DOM element. See <a href="https://playwright.dev/java/docs/selectors/">working with
* @param selector A selector to use when resolving DOM element. See <a href="https://playwright.dev/java/docs/selectors">working with
* selectors</a> for more details.
*/
FrameLocator frameLocator(String selector);
@@ -2028,10 +2079,15 @@ public interface Locator {
* @param name Attribute name to get the value for.
*/
String getAttribute(String name, GetAttributeOptions options);
/**
* Highlight the corresponding element(s) on the screen. Useful for debugging, don't commit the code that uses {@link
* Locator#highlight Locator.highlight()}.
*/
void highlight();
/**
* This method hovers over the element by performing the following steps:
* <ol>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to hover over the center of the element, or the specified {@code position}.</li>
@@ -2049,7 +2105,7 @@ public interface Locator {
/**
* This method hovers over the element by performing the following steps:
* <ol>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to hover over the center of the element, or the specified {@code position}.</li>
@@ -2104,56 +2160,56 @@ public interface Locator {
boolean isChecked(IsCheckedOptions options);
/**
* Returns whether the element is disabled, the opposite of <a
* href="https://playwright.dev/java/docs/actionability/#enabled">enabled</a>.
* href="https://playwright.dev/java/docs/actionability#enabled">enabled</a>.
*/
default boolean isDisabled() {
return isDisabled(null);
}
/**
* Returns whether the element is disabled, the opposite of <a
* href="https://playwright.dev/java/docs/actionability/#enabled">enabled</a>.
* href="https://playwright.dev/java/docs/actionability#enabled">enabled</a>.
*/
boolean isDisabled(IsDisabledOptions options);
/**
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability/#editable">editable</a>.
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability#editable">editable</a>.
*/
default boolean isEditable() {
return isEditable(null);
}
/**
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability/#editable">editable</a>.
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability#editable">editable</a>.
*/
boolean isEditable(IsEditableOptions options);
/**
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability/#enabled">enabled</a>.
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability#enabled">enabled</a>.
*/
default boolean isEnabled() {
return isEnabled(null);
}
/**
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability/#enabled">enabled</a>.
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability#enabled">enabled</a>.
*/
boolean isEnabled(IsEnabledOptions options);
/**
* Returns whether the element is hidden, the opposite of <a
* href="https://playwright.dev/java/docs/actionability/#visible">visible</a>.
* href="https://playwright.dev/java/docs/actionability#visible">visible</a>.
*/
default boolean isHidden() {
return isHidden(null);
}
/**
* Returns whether the element is hidden, the opposite of <a
* href="https://playwright.dev/java/docs/actionability/#visible">visible</a>.
* href="https://playwright.dev/java/docs/actionability#visible">visible</a>.
*/
boolean isHidden(IsHiddenOptions options);
/**
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability/#visible">visible</a>.
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability#visible">visible</a>.
*/
default boolean isVisible() {
return isVisible(null);
}
/**
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability/#visible">visible</a>.
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability#visible">visible</a>.
*/
boolean isVisible(IsVisibleOptions options);
/**
@@ -2163,7 +2219,7 @@ public interface Locator {
/**
* The method finds an element matching the specified selector in the {@code Locator}'s subtree.
*
* @param selector A selector to use when resolving DOM element. See <a href="https://playwright.dev/java/docs/selectors/">working with
* @param selector A selector to use when resolving DOM element. See <a href="https://playwright.dev/java/docs/selectors">working with
* selectors</a> for more details.
*/
default Locator locator(String selector) {
@@ -2172,7 +2228,7 @@ public interface Locator {
/**
* The method finds an element matching the specified selector in the {@code Locator}'s subtree.
*
* @param selector A selector to use when resolving DOM element. See <a href="https://playwright.dev/java/docs/selectors/">working with
* @param selector A selector to use when resolving DOM element. See <a href="https://playwright.dev/java/docs/selectors">working with
* selectors</a> for more details.
*/
Locator locator(String selector, LocatorOptions options);
@@ -2180,6 +2236,10 @@ public interface Locator {
* Returns locator to the n-th matching element.
*/
Locator nth(int index);
/**
* A page this locator belongs to.
*/
Page page();
/**
* Focuses the element, and then uses {@link Keyboard#down Keyboard.down()} and {@link Keyboard#up Keyboard.up()}.
*
@@ -2233,7 +2293,7 @@ public interface Locator {
/**
* Returns the buffer with the captured screenshot.
*
* <p> This method waits for the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, then
* <p> This method waits for the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, then
* scrolls element into view before taking a screenshot. If the element is detached from DOM, the method throws an error.
*/
default byte[] screenshot() {
@@ -2242,12 +2302,12 @@ public interface Locator {
/**
* Returns the buffer with the captured screenshot.
*
* <p> This method waits for the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, then
* <p> This method waits for the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, then
* scrolls element into view before taking a screenshot. If the element is detached from DOM, the method throws an error.
*/
byte[] screenshot(ScreenshotOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, then tries to
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, then tries to
* scroll element into view, unless it is completely visible as defined by <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API">IntersectionObserver</a>'s {@code ratio}.
*/
@@ -2255,14 +2315,14 @@ public interface Locator {
scrollIntoViewIfNeeded(null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, then tries to
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, then tries to
* scroll element into view, unless it is completely visible as defined by <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API">IntersectionObserver</a>'s {@code ratio}.
*/
void scrollIntoViewIfNeeded(ScrollIntoViewIfNeededOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -2289,8 +2349,8 @@ public interface Locator {
return selectOption(values, null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -2315,8 +2375,8 @@ public interface Locator {
*/
List<String> selectOption(String values, SelectOptionOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -2343,8 +2403,8 @@ public interface Locator {
return selectOption(values, null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -2369,8 +2429,8 @@ public interface Locator {
*/
List<String> selectOption(ElementHandle values, SelectOptionOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -2397,8 +2457,8 @@ public interface Locator {
return selectOption(values, null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -2423,8 +2483,8 @@ public interface Locator {
*/
List<String> selectOption(String[] values, SelectOptionOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -2451,8 +2511,8 @@ public interface Locator {
return selectOption(values, null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -2477,8 +2537,8 @@ public interface Locator {
*/
List<String> selectOption(SelectOption values, SelectOptionOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -2505,8 +2565,8 @@ public interface Locator {
return selectOption(values, null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -2531,8 +2591,8 @@ public interface Locator {
*/
List<String> selectOption(ElementHandle[] values, SelectOptionOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -2559,8 +2619,8 @@ public interface Locator {
return selectOption(values, null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, waits until
* all specified options are present in the {@code <select>} element and selects these options.
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, waits until all
* specified options are present in the {@code <select>} element and selects these options.
*
* <p> If the target element is not a {@code <select>} element, this method throws an error. However, if the element is inside the
* {@code <label>} element that has an associated <a
@@ -2585,14 +2645,14 @@ public interface Locator {
*/
List<String> selectOption(SelectOption[] values, SelectOptionOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, then focuses
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, then focuses
* the element and selects all its text content.
*/
default void selectText() {
selectText(null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks, then focuses
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, then focuses
* the element and selects all its text content.
*/
void selectText(SelectTextOptions options);
@@ -2601,7 +2661,7 @@ public interface Locator {
* <ol>
* <li> Ensure that matched element is a checkbox or a radio input. If not, this method throws.</li>
* <li> If the element already has the right checked state, this method returns immediately.</li>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the matched element,
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the matched element,
* unless {@code force} option is set. If the element is detached during the checks, the whole action is retried.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
@@ -2622,7 +2682,7 @@ public interface Locator {
* <ol>
* <li> Ensure that matched element is a checkbox or a radio input. If not, this method throws.</li>
* <li> If the element already has the right checked state, this method returns immediately.</li>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the matched element,
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the matched element,
* unless {@code force} option is set. If the element is detached during the checks, the whole action is retried.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
@@ -2711,7 +2771,7 @@ public interface Locator {
/**
* This method taps the element by performing the following steps:
* <ol>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#touchscreen Page.touchscreen()} to tap the center of the element, or the specified {@code position}.</li>
@@ -2731,7 +2791,7 @@ public interface Locator {
/**
* This method taps the element by performing the following steps:
* <ol>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#touchscreen Page.touchscreen()} to tap the center of the element, or the specified {@code position}.</li>
@@ -2801,7 +2861,7 @@ public interface Locator {
* <ol>
* <li> Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already unchecked,
* this method returns immediately.</li>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
@@ -2822,7 +2882,7 @@ public interface Locator {
* <ol>
* <li> Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already unchecked,
* this method returns immediately.</li>
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks on the element, unless
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless
* {@code force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link Page#mouse Page.mouse()} to click in the center of the element.</li>
File diff suppressed because it is too large Load Diff
@@ -70,7 +70,7 @@ public interface Playwright extends AutoCloseable {
APIRequest request();
/**
* Selectors can be used to install custom selector engines. See <a
* href="https://playwright.dev/java/docs/selectors/">Working with selectors</a> for more information.
* href="https://playwright.dev/java/docs/selectors">Working with selectors</a> for more information.
*/
Selectors selectors();
/**
@@ -100,6 +100,11 @@ public interface Route {
* is resolved relative to the current working directory.
*/
public Path path;
/**
* {@code APIResponse} to fulfill route's request with. Individual fields of the response (such as headers) can be overridden
* using fulfill options.
*/
public APIResponse response;
/**
* Response status code, defaults to {@code 200}.
*/
@@ -141,6 +146,14 @@ public interface Route {
this.path = path;
return this;
}
/**
* {@code APIResponse} to fulfill route's request with. Individual fields of the response (such as headers) can be overridden
* using fulfill options.
*/
public FulfillOptions setResponse(APIResponse response) {
this.response = response;
return this;
}
/**
* Response status code, defaults to {@code 200}.
*/
@@ -20,7 +20,7 @@ import java.nio.file.Path;
/**
* Selectors can be used to install custom selector engines. See <a
* href="https://playwright.dev/java/docs/selectors/">Working with selectors</a> for more information.
* href="https://playwright.dev/java/docs/selectors">Working with selectors</a> for more information.
*/
public interface Selectors {
class RegisterOptions {
@@ -20,7 +20,7 @@ import java.nio.file.Path;
/**
* API for collecting and saving Playwright traces. Playwright traces can be opened in <a
* href="https://playwright.dev/java/docs/trace-viewer/">Trace Viewer</a> after Playwright script runs.
* href="https://playwright.dev/java/docs/trace-viewer">Trace Viewer</a> after Playwright script runs.
*
* <p> Start recording a trace before performing actions. At the end, stop tracing and save it to a file.
* <pre>{@code
@@ -47,7 +47,11 @@ public interface Tracing {
*/
public Boolean screenshots;
/**
* Whether to capture DOM snapshot on every action.
* If this option is true tracing will
* <ul>
* <li> capture DOM snapshot on every action</li>
* <li> record network activity</li>
* </ul>
*/
public Boolean snapshots;
/**
@@ -76,7 +80,11 @@ public interface Tracing {
return this;
}
/**
* Whether to capture DOM snapshot on every action.
* If this option is true tracing will
* <ul>
* <li> capture DOM snapshot on every action</li>
* <li> record network activity</li>
* </ul>
*/
public StartOptions setSnapshots(boolean snapshots) {
this.snapshots = snapshots;
@@ -39,7 +39,7 @@ package com.microsoft.playwright.assertions;
public interface APIResponseAssertions {
/**
* Makes the assertion check for the opposite condition. For example, this code tests that the response status is not
* successfull:
* successful:
* <pre>{@code
* assertThat(response).not().isOK();
* }</pre>
@@ -409,7 +409,7 @@ public interface LocatorAssertions {
void isFocused(IsFocusedOptions options);
/**
* Ensures the {@code Locator} points to a hidden DOM node, which is the opposite of <a
* href="https://playwright.dev/java/docs/actionability/#visible">visible</a>.
* href="https://playwright.dev/java/docs/actionability#visible">visible</a>.
* <pre>{@code
* assertThat(page.locator(".my-element")).isHidden();
* }</pre>
@@ -419,15 +419,14 @@ public interface LocatorAssertions {
}
/**
* Ensures the {@code Locator} points to a hidden DOM node, which is the opposite of <a
* href="https://playwright.dev/java/docs/actionability/#visible">visible</a>.
* href="https://playwright.dev/java/docs/actionability#visible">visible</a>.
* <pre>{@code
* assertThat(page.locator(".my-element")).isHidden();
* }</pre>
*/
void isHidden(IsHiddenOptions options);
/**
* Ensures the {@code Locator} points to a <a href="https://playwright.dev/java/docs/actionability/#visible">visible</a> DOM
* node.
* Ensures the {@code Locator} points to a <a href="https://playwright.dev/java/docs/actionability#visible">visible</a> DOM node.
* <pre>{@code
* assertThat(page.locator(".my-element")).toBeVisible();
* }</pre>
@@ -436,8 +435,7 @@ public interface LocatorAssertions {
isVisible(null);
}
/**
* Ensures the {@code Locator} points to a <a href="https://playwright.dev/java/docs/actionability/#visible">visible</a> DOM
* node.
* Ensures the {@code Locator} points to a <a href="https://playwright.dev/java/docs/actionability#visible">visible</a> DOM node.
* <pre>{@code
* assertThat(page.locator(".my-element")).toBeVisible();
* }</pre>
@@ -24,8 +24,8 @@ import com.microsoft.playwright.impl.LocatorAssertionsImpl;
import com.microsoft.playwright.impl.PageAssertionsImpl;
/**
* The {@code PlaywrightAssertions} class provides convenience methods for creating assertions that will wait until the expected
* condition is met.
* Playwright gives you Web-First Assertions with convenience methods for creating assertions that will wait and retry
* until the expected condition is met.
*
* <p> Consider the following example:
* <pre>{@code
@@ -48,15 +48,6 @@ import com.microsoft.playwright.impl.PageAssertionsImpl;
* You can pass this timeout as an option.
*
* <p> By default, the timeout for assertions is set to 5 seconds.
*
* <p> To use Playwright assertions add the following dependency into the {@code pom.xml} of your Maven project:
* <pre>{@code
* <dependency>
* <groupId>com.microsoft.playwright</groupId>
* <artifactId>assertions</artifactId>
* <version>1.17.0</version>
* </dependency>
* }</pre>
*/
public interface PlaywrightAssertions {
/**
@@ -21,8 +21,11 @@ import static com.microsoft.playwright.impl.Serialization.*;
import static com.microsoft.playwright.impl.Utils.toFilePayload;
class APIRequestContextImpl extends ChannelOwner implements APIRequestContext {
private final TracingImpl tracing;
APIRequestContextImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
super(parent, type, guid, initializer);
this.tracing = connection.getExistingObject(initializer.getAsJsonObject("tracing").get("guid").getAsString());
}
@Override
@@ -34,7 +34,7 @@ import static com.microsoft.playwright.impl.Utils.isSafeCloseError;
import static java.util.Arrays.asList;
class APIResponseImpl implements APIResponse {
private final APIRequestContextImpl context;
final APIRequestContextImpl context;
private final JsonObject initializer;
private final RawHeaders headers;
@@ -109,7 +109,7 @@ class APIResponseImpl implements APIResponse {
return initializer.get("url").getAsString();
}
private String fetchUid() {
String fetchUid() {
return initializer.get("fetchUid").getAsString();
}
@@ -67,7 +67,10 @@ class AssertionsBase {
if (expected == null) {
throw new AssertionFailedError(message + log);
}
throw new AssertionFailedError(message + log, formatValue(expected), formatValue(actual));
ValueWrapper expectedValue = formatValue(expected);
ValueWrapper actualValue = formatValue(actual);
message += ": " + expectedValue.getStringRepresentation() + "\nReceived: " + actualValue.getStringRepresentation() + "\n";
throw new AssertionFailedError(message + log, expectedValue, actualValue);
}
}
@@ -55,7 +55,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
Path videosDir;
URL baseUrl;
Path recordHarPath;
LocalUtils localUtils;
enum EventType {
CLOSE,
@@ -73,7 +72,8 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
} else {
browser = null;
}
this.tracing = new TracingImpl(this);
this.tracing = connection.getExistingObject(initializer.getAsJsonObject("tracing").get("guid").getAsString());
tracing.isRemote = browser != null && browser.isRemote;
this.request = connection.getExistingObject(initializer.getAsJsonObject("APIRequestContext").get("guid").getAsString());
}
@@ -429,7 +429,7 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
}
@Override
public Tracing tracing() {
public TracingImpl tracing() {
return tracing;
}
@@ -172,7 +172,7 @@ class BrowserImpl extends ChannelOwner implements Browser {
context.setBaseUrl(options.baseURL);
}
context.recordHarPath = options.recordHarPath;
context.localUtils = localUtils;
context.tracing().localUtils = localUtils;
contexts.add(context);
return context;
}
@@ -64,6 +64,22 @@ class BrowserTypeImpl extends ChannelOwner implements BrowserType {
// We don't use gson() here as the headers map should be serialized to a json object.
JsonObject params = new Gson().toJsonTree(options).getAsJsonObject();
params.addProperty("wsEndpoint", wsEndpoint);
if (!params.has("headers")) {
params.add("headers", new JsonObject());
}
JsonObject headers = params.get("headers").getAsJsonObject();
boolean foundBrowserHeader = false;
for (String name : headers.keySet()) {
if ("x-playwright-browser".equalsIgnoreCase(name)) {
foundBrowserHeader = true;
break;
}
}
if (!foundBrowserHeader) {
headers.addProperty("x-playwright-browser", name());
}
JsonObject json = sendMessage("connect", params).getAsJsonObject();
JsonPipe pipe = connection.getExistingObject(json.getAsJsonObject("pipe").get("guid").getAsString());
Connection connection = new Connection(pipe);
@@ -180,7 +196,7 @@ class BrowserTypeImpl extends ChannelOwner implements BrowserType {
context.setBaseUrl(options.baseURL);
}
context.recordHarPath = options.recordHarPath;
context.localUtils = localUtils;
context.tracing().localUtils = localUtils;
return context;
}
@@ -23,7 +23,6 @@ import com.microsoft.playwright.PlaywrightException;
import com.microsoft.playwright.TimeoutError;
import java.io.IOException;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
@@ -85,8 +84,7 @@ public class Connection {
}
this.transport = transport;
root = new Root(this);
String srcRoot = System.getenv("PLAYWRIGHT_JAVA_SRC");
stackTraceCollector = (srcRoot == null) ? null: new StackTraceCollector(Paths.get(srcRoot));
stackTraceCollector = StackTraceCollector.createFromEnv();
}
boolean isCollectingStacks() {
@@ -121,11 +119,15 @@ public class Connection {
message.addProperty("method", method);
message.add("params", params);
JsonObject metadata = new JsonObject();
if (stackTraceCollector != null) {
metadata.add("stack", stackTraceCollector.currentStackTrace());
}
if (apiName != null) {
if (apiName == null) {
metadata.addProperty("internal", true);
} else {
metadata.addProperty("apiName", apiName);
// All but first message in an API call are considered internal and will be hidden from the inspector.
apiName = null;
if (stackTraceCollector != null) {
metadata.add("stack", stackTraceCollector.currentStackTrace());
}
}
message.add("metadata", metadata);
transport.send(message);
@@ -291,6 +293,9 @@ public class Connection {
case "Selectors":
result = new SelectorsImpl(parent, type, guid, initializer);
break;
case "Tracing":
result = new TracingImpl(parent, type, guid, initializer);
break;
case "WebSocket":
result = new WebSocketImpl(parent, type, guid, initializer);
break;
@@ -586,7 +586,7 @@ public class FrameImpl extends ChannelOwner implements Frame {
}
@Override
public Page page() {
public PageImpl page() {
return page;
}
@@ -1024,6 +1024,12 @@ public class FrameImpl extends ChannelOwner implements Frame {
return result.get("value").getAsInt();
}
void highlightImpl(String selector) {
JsonObject params = new JsonObject();
params.addProperty("selector", selector);
sendMessage("highlight", params);
}
protected void handleEvent(String event, JsonObject params) {
if ("loadstate".equals(event)) {
JsonElement add = params.get("add");
@@ -24,14 +24,24 @@ class LocatorImpl implements Locator {
public LocatorImpl(FrameImpl frame, String selector, LocatorOptions options) {
this.frame = frame;
if (options != null && options.hasText != null) {
if (options.hasText instanceof Pattern) {
Pattern pattern = (Pattern) options.hasText;
selector += " >> :scope:text-matches(" + escapeWithQuotes(pattern.pattern()) + ", \"" + toJsRegexFlags(pattern) + "\")";
} else if (options.hasText instanceof String) {
String text = (String) options.hasText;
selector += " >> :scope:has-text(" + escapeWithQuotes(text)+ ")";
if (options != null) {
if (options.hasText != null) {
if (options.hasText instanceof Pattern) {
Pattern pattern = (Pattern) options.hasText;
selector += " >> :scope:text-matches(" + escapeWithQuotes(pattern.pattern()) + ", \"" + toJsRegexFlags(pattern) + "\")";
} else if (options.hasText instanceof String) {
String text = (String) options.hasText;
selector += " >> :scope:has-text(" + escapeWithQuotes(text) + ")";
}
}
if (options.has != null) {
LocatorImpl has = (LocatorImpl) options.has;
if (has.frame != frame) {
throw new PlaywrightException("Inner 'has' locator must belong to the same frame.");
}
selector += " >> has=" + gson().toJson(has.selector);
}
}
this.selector = selector;
}
@@ -186,6 +196,11 @@ class LocatorImpl implements Locator {
return frame.getAttribute(selector, name, convertType(options, Frame.GetAttributeOptions.class).setStrict(true));
}
@Override
public void highlight() {
frame.highlightImpl(selector);
}
@Override
public void hover(HoverOptions options) {
if (options == null) {
@@ -281,6 +296,11 @@ class LocatorImpl implements Locator {
return new LocatorImpl(frame, selector + " >> nth=" + index, null);
}
@Override
public Page page() {
return frame.page();
}
@Override
public void press(String key, PressOptions options) {
if (options == null) {
@@ -451,6 +471,15 @@ class LocatorImpl implements Locator {
return frame.withLogging("Locator.expect", () -> expectImpl(expression, options));
}
JsonObject toProtocol() {
JsonObject result = new JsonObject();
JsonObject frameJson = new JsonObject();
frameJson.addProperty("guid", frame.guid);
result.add("frame", frameJson);
result.addProperty("selector", selector);
return result;
}
private FrameExpectResult expectImpl(String expression, FrameExpectOptions options) {
if (options == null) {
options = new FrameExpectOptions();
@@ -40,6 +40,7 @@ public class PageAssertionsImpl extends AssertionsBase implements PageAssertions
public void hasTitle(String title, HasTitleOptions options) {
ExpectedTextValue expected = new ExpectedTextValue();
expected.string = title;
expected.normalizeWhiteSpace = true;
expectImpl("to.have.title", expected, title, "Page title expected to be", convertType(options, FrameExpectOptions.class));
}
@@ -28,11 +28,11 @@ import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import static com.microsoft.playwright.impl.Serialization.gson;
import static com.microsoft.playwright.impl.Utils.convertType;
import static com.microsoft.playwright.impl.Utils.isSafeCloseError;
import static com.microsoft.playwright.options.ScreenshotType.JPEG;
import static com.microsoft.playwright.options.ScreenshotType.PNG;
import static com.microsoft.playwright.impl.Serialization.gson;
import static com.microsoft.playwright.impl.Utils.isSafeCloseError;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.readAllBytes;
import static java.util.Arrays.asList;
@@ -1034,8 +1034,18 @@ public class PageImpl extends ChannelOwner implements Page {
}
}
}
List<Locator> mask = options.mask;
options.mask = null;
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
options.mask = mask;
params.remove("path");
if (mask != null) {
JsonArray maskArray = new JsonArray();
for (Locator locator: mask) {
maskArray.add(((LocatorImpl) locator).toProtocol());
}
params.add("mask", maskArray);
}
JsonObject json = sendMessage("screenshot", params).getAsJsonObject();
byte[] buffer = Base64.getDecoder().decode(json.get("binary").getAsString());
@@ -37,7 +37,7 @@ public class PlaywrightImpl extends ChannelOwner implements Playwright {
if (options != null && options.env != null) {
env = options.env;
}
Path driver = Driver.ensureDriverInstalled(env);
Path driver = Driver.ensureDriverInstalled(env, true);
ProcessBuilder pb = new ProcessBuilder(driver.toString(), "run-driver");
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
pb.environment().putAll(env);
@@ -18,7 +18,6 @@ package com.microsoft.playwright.impl;
import com.google.gson.JsonObject;
import com.microsoft.playwright.PlaywrightException;
import com.microsoft.playwright.Request;
import com.microsoft.playwright.Route;
import java.io.IOException;
@@ -29,12 +28,15 @@ import java.util.LinkedHashMap;
import java.util.Map;
public class RouteImpl extends ChannelOwner implements Route {
private boolean handled;
public RouteImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
super(parent, type, guid, initializer);
}
@Override
public void abort(String errorCode) {
startHandling();
withLogging("Route.abort", () -> {
JsonObject params = new JsonObject();
params.addProperty("errorCode", errorCode);
@@ -44,6 +46,7 @@ public class RouteImpl extends ChannelOwner implements Route {
@Override
public void resume(ResumeOptions options) {
startHandling();
withLogging("Route.resume", () -> resumeImpl(options));
}
@@ -78,6 +81,7 @@ public class RouteImpl extends ChannelOwner implements Route {
@Override
public void fulfill(FulfillOptions options) {
startHandling();
withLogging("Route.fulfill", () -> fulfillImpl(options));
}
@@ -86,16 +90,30 @@ public class RouteImpl extends ChannelOwner implements Route {
options = new FulfillOptions();
}
int status = options.status == null ? 200 : options.status;
String body = "";
Integer status = options.status;
Map<String, String> headersOption = options.headers;
String fetchResponseUid = null;
if (options.response != null) {
if (status == null) {
status = options.response.status();
}
if (headersOption == null) {
headersOption = options.response.headers();
}
}
if (status == null) {
status = 200;
}
String body = null;
boolean isBase64 = false;
int length = 0;
if (options.path != null) {
try {
byte[] buffer = Files.readAllBytes(options.path);
body = Base64.getEncoder().encodeToString(buffer);
isBase64 = true;
length = buffer.length;
byte[] buffer = Files.readAllBytes(options.path);
body = Base64.getEncoder().encodeToString(buffer);
isBase64 = true;
length = buffer.length;
} catch (IOException e) {
throw new PlaywrightException("Failed to read from file: " + options.path, e);
}
@@ -107,11 +125,22 @@ public class RouteImpl extends ChannelOwner implements Route {
body = Base64.getEncoder().encodeToString(options.bodyBytes);
isBase64 = true;
length = options.bodyBytes.length;
} else if (options.response != null) {
APIResponseImpl response = (APIResponseImpl) options.response;
if (response.context.connection == connection) {
fetchResponseUid = response.fetchUid();
} else {
byte[] bodyBytes = response.body();
body = Base64.getEncoder().encodeToString(bodyBytes);
isBase64 = true;
length = bodyBytes.length;
}
}
Map<String, String> headers = new LinkedHashMap<>();
if (options.headers != null) {
for (Map.Entry<String, String> h : options.headers.entrySet()) {
if (headersOption != null) {
for (Map.Entry<String, String> h : headersOption.entrySet()) {
headers.put(h.getKey().toLowerCase(), h.getValue());
}
}
@@ -128,11 +157,21 @@ public class RouteImpl extends ChannelOwner implements Route {
params.add("headers", Serialization.toProtocol(headers));
params.addProperty("isBase64", isBase64);
params.addProperty("body", body);
if (fetchResponseUid != null) {
params.addProperty("fetchResponseUid", fetchResponseUid);
}
sendMessageAsync("fulfill", params);
}
@Override
public Request request() {
public RequestImpl request() {
return connection.getExistingObject(initializer.getAsJsonObject("request").get("guid").getAsString());
}
private void startHandling() {
if (handled) {
throw new PlaywrightException("Route is already handled!");
}
handled = true;
}
}
@@ -40,6 +40,7 @@ class Serialization {
.registerTypeAdapter(Media.class, new ToLowerCaseSerializer<Media>())
.registerTypeAdapter(ForcedColors.class, new ToLowerCaseSerializer<ForcedColors>())
.registerTypeAdapter(ReducedMotion.class, new ToLowerCaseAndDashSerializer<ReducedMotion>())
.registerTypeAdapter(ScreenshotAnimations.class, new ToLowerCaseSerializer<ScreenshotAnimations>())
.registerTypeAdapter(ScreenshotType.class, new ToLowerCaseSerializer<ScreenshotType>())
.registerTypeAdapter(MouseButton.class, new ToLowerCaseSerializer<MouseButton>())
.registerTypeAdapter(LoadState.class, new ToLowerCaseSerializer<LoadState>())
@@ -23,15 +23,30 @@ import com.microsoft.playwright.PlaywrightException;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Collectors;
class StackTraceCollector {
private final Path srcDir;
private final List<Path> srcDirs;
private final Map<Path, String> classToSourceCache = new HashMap<>();
StackTraceCollector(Path srcDir) {
if (!Files.exists(srcDir.toAbsolutePath())) {
throw new PlaywrightException("Source location doesn't exist: '" + srcDir.toAbsolutePath() + "'");
static StackTraceCollector createFromEnv() {
String srcRoots = System.getenv("PLAYWRIGHT_JAVA_SRC");
if (srcRoots == null) {
return null;
}
this.srcDir = srcDir;
List<Path> srcDirs = Arrays.stream(srcRoots.split(File.pathSeparator)).map(p -> Paths.get(p)).collect(Collectors.toList());
for (Path srcDir: srcDirs) {
if (!Files.exists(srcDir.toAbsolutePath())) {
throw new PlaywrightException("Source location specified in PLAYWRIGHT_JAVA_SRC doesn't exist: '" + srcDir.toAbsolutePath() + "'");
}
}
return new StackTraceCollector(srcDirs);
}
private StackTraceCollector(List<Path> srcDirs) {
this.srcDirs = srcDirs;
}
private String sourceFile(StackTraceElement frame) {
@@ -47,7 +62,26 @@ class StackTraceCollector {
if (file == null) {
return "";
}
return srcDir.resolve(pkg).resolve(file).toString();
return resolveSourcePath(Paths.get(pkg).resolve(file));
}
private String resolveSourcePath(Path relativePath) {
String path = classToSourceCache.get(relativePath);
if (path == null) {
for (Path dir : srcDirs) {
Path absolutePath = dir.resolve(relativePath);
if (Files.exists(absolutePath)) {
path = absolutePath.toString();
classToSourceCache.put(relativePath, path);
break;
}
}
if (path == null) {
path = "";
classToSourceCache.put(relativePath, path);
}
}
return path;
}
JsonArray currentStackTrace() {
@@ -25,16 +25,16 @@ import java.nio.file.Path;
import static com.microsoft.playwright.impl.Serialization.gson;
class TracingImpl implements Tracing {
private final BrowserContextImpl context;
class TracingImpl extends ChannelOwner implements Tracing {
LocalUtils localUtils;
boolean isRemote;
private boolean includeSources;
TracingImpl(BrowserContextImpl context) {
this.context = context;
TracingImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
super(parent, type, guid, initializer);
}
private void stopChunkImpl(Path path) {
boolean isRemote = context.browser() != null && context.browser().isRemote;
JsonObject params = new JsonObject();
String mode = "doNotSave";
if (path != null) {
@@ -45,11 +45,11 @@ class TracingImpl implements Tracing {
}
}
params.addProperty("mode", mode);
JsonObject json = context.sendMessage("tracingStopChunk", params).getAsJsonObject();
JsonObject json = sendMessage("tracingStopChunk", params).getAsJsonObject();
if (!json.has("artifact")) {
return;
}
ArtifactImpl artifact = context.connection.getExistingObject(json.getAsJsonObject("artifact").get("guid").getAsString());
ArtifactImpl artifact = connection.getExistingObject(json.getAsJsonObject("artifact").get("guid").getAsString());
// In case of CDP connection browser is null but since the connection is established by
// the driver it is safe to consider the artifact local.
if (isRemote) {
@@ -61,18 +61,18 @@ class TracingImpl implements Tracing {
// Add local sources to the remote trace if necessary.
if (isRemote && json.has("sourceEntries")) {
JsonArray entries = json.getAsJsonArray("sourceEntries");
context.localUtils.zip(path, entries);
localUtils.zip(path, entries);
}
}
@Override
public void start(StartOptions options) {
context.withLogging("Tracing.start", () -> startImpl(options));
withLogging("Tracing.start", () -> startImpl(options));
}
@Override
public void startChunk(StartChunkOptions options) {
context.withLogging("Tracing.startChunk", () -> {
withLogging("Tracing.startChunk", () -> {
startChunkImpl(options);
});
}
@@ -82,7 +82,7 @@ class TracingImpl implements Tracing {
options = new StartChunkOptions();
}
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
context.sendMessage("tracingStartChunk", params);
sendMessage("tracingStartChunk", params);
}
private void startImpl(StartOptions options) {
@@ -92,26 +92,26 @@ class TracingImpl implements Tracing {
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
includeSources = options.sources != null;
if (includeSources) {
if (!context.connection.isCollectingStacks()) {
throw new PlaywrightException("Source root directories must be provided to enable source collection");
if (!connection.isCollectingStacks()) {
throw new PlaywrightException("Source root directory must be specified via PLAYWRIGHT_JAVA_SRC environment variable when source collection is enabled");
}
params.addProperty("sources", true);
}
context.sendMessage("tracingStart", params);
context.sendMessage("tracingStartChunk");
sendMessage("tracingStart", params);
sendMessage("tracingStartChunk");
}
@Override
public void stop(StopOptions options) {
context.withLogging("Tracing.stop", () -> {
withLogging("Tracing.stop", () -> {
stopChunkImpl(options == null ? null : options.path);
context.sendMessage("tracingStop");
sendMessage("tracingStop");
});
}
@Override
public void stopChunk(StopChunkOptions options) {
context.withLogging("Tracing.stopChunk", () -> {
withLogging("Tracing.stopChunk", () -> {
stopChunkImpl(options == null ? null : options.path);
});
}
@@ -51,6 +51,10 @@ class Utils {
try {
T result = t.getDeclaredConstructor().newInstance();
for (Field toField : t.getDeclaredFields()) {
// Skip fields added by test coverage tools, see https://github.com/microsoft/playwright-java/issues/802
if (toField.isSynthetic()) {
continue;
}
if (Modifier.isStatic(toField.getModifiers())) {
throw new RuntimeException("Unexpected field modifiers: " + t.getCanonicalName() + "." + toField.getName() + ", modifiers: " + toField.getModifiers());
}
@@ -22,7 +22,4 @@ interface Waitable<T> {
boolean isDone();
T get();
void dispose();
default <U> Waitable<U> apply(Function<T, U> transform) {
return new WaitableAdapter<T, U>(this, transform);
}
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.microsoft.playwright.options;
public enum ScreenshotAnimations {
DISABLED
}
@@ -57,6 +57,7 @@ public class TestBrowserContextAddCookies extends TestBase {
.setDomain(cookies.get(0).domain)
.setPath(cookies.get(0).path)
.setExpires(cookies.get(0).expires)
.setSameSite(cookies.get(0).sameSite)
));
assertJsonEquals(new Gson().toJson(cookies), context.cookies());
}
@@ -16,6 +16,7 @@
package com.microsoft.playwright;
import com.sun.net.httpserver.Filter;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
@@ -33,10 +34,19 @@ public class TestBrowserContextNetworkEvents extends TestBase {
page.setContent("<a target=_blank rel=noopener href='/one-style.html'>yo</a>");
Page page1 = context.waitForPage(() -> page.click("a"));
page1.waitForLoadState();
assertEquals(asList(
server.EMPTY_PAGE,
server.PREFIX + "/one-style.html",
server.PREFIX + "/one-style.css"), requests);
// In firefox one-style.css is requested multiple times.
if (isFirefox()) {
assertEquals(asList(
server.EMPTY_PAGE,
server.PREFIX + "/one-style.html",
server.PREFIX + "/one-style.css",
server.PREFIX + "/one-style.css"), requests);
} else {
assertEquals(asList(
server.EMPTY_PAGE,
server.PREFIX + "/one-style.html",
server.PREFIX + "/one-style.css"), requests);
}
}
@Test
@@ -47,10 +57,19 @@ public class TestBrowserContextNetworkEvents extends TestBase {
page.setContent("<a target=_blank rel=noopener href='/one-style.html'>yo</a>");
Page page1 = context.waitForPage(() -> page.click("a"));
page1.waitForLoadState();
assertEquals(asList(
server.EMPTY_PAGE,
server.PREFIX + "/one-style.html",
server.PREFIX + "/one-style.css"), responses);
// In firefox one-style.css is requested multiple times.
if (isFirefox()) {
assertEquals(asList(
server.EMPTY_PAGE,
server.PREFIX + "/one-style.html",
server.PREFIX + "/one-style.css",
server.PREFIX + "/one-style.css"), responses);
} else {
assertEquals(asList(
server.EMPTY_PAGE,
server.PREFIX + "/one-style.html",
server.PREFIX + "/one-style.css"), responses);
}
}
@Test
@@ -59,7 +78,12 @@ public class TestBrowserContextNetworkEvents extends TestBase {
List<Request> failedRequests = new ArrayList<>();
context.onRequestFailed(request -> failedRequests.add(request));
page.navigate(server.PREFIX + "/one-style.html");
assertEquals(1, failedRequests.size());
// In firefox one-style.css is requested multiple times.
if (isFirefox()) {
assertTrue(failedRequests.size() > 0);
} else {
assertEquals(1, failedRequests.size());
}
assertTrue(failedRequests.get(0).url().contains("one-style.css"));
assertNull(failedRequests.get(0).response());
assertEquals("stylesheet", failedRequests.get(0).resourceType());
@@ -16,10 +16,13 @@
package com.microsoft.playwright;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.function.Consumer;
import static java.util.Arrays.asList;
@@ -134,4 +137,74 @@ public class TestBrowserContextRoute extends TestBase {
page.navigate(server.EMPTY_PAGE);
assertEquals(2, intercepted[0]);
}
@Test
void shouldOverwritePostBodyWithEmptyString() throws ExecutionException, InterruptedException {
boolean[] routeHandled = {false};
context.route("**/empty.html", route -> {
route.resume(new Route.ResumeOptions().setPostData(""));
routeHandled[0] = true;
});
Future<Server.Request> req = server.futureRequest("/empty.html");
page.setContent("<script>\n" +
" (async () => {\n" +
" await fetch('" + server.EMPTY_PAGE + "', {\n" +
" method: 'POST',\n" +
" body: 'original',\n" +
" });\n" +
" })()\n" +
" </script>");
while (!routeHandled[0]) {
page.waitForTimeout(100);
}
byte[] body = req.get().postBody;
assertEquals(0, body.length);
}
@Test
void shouldNotSwallowExceptionsInRoute() throws ExecutionException, InterruptedException {
context.route("**/empty.html", route -> {
throw new RuntimeException("My Exception");
});
try {
page.navigate(server.EMPTY_PAGE);
fail("did not throw");
} catch (RuntimeException e) {
assertTrue(e.getMessage().contains("My Exception"), e.getMessage());
}
}
@Test
@Disabled("Conflicts with https://github.com/microsoft/playwright-java/pull/680")
void shouldNotSwallowExceptionsInFulfill() throws ExecutionException, InterruptedException {
APIRequestContext request = playwright.request().newContext();
APIResponse response = request.get(server.EMPTY_PAGE);
response.dispose();
page.route("**/*", route -> {
// Fulfilling with dsiposed response will lead to a server-side exception.
route.fulfill(new Route.FulfillOptions().setResponse(response));
});
try {
page.navigate(server.EMPTY_PAGE);
fail("did not throw");
} catch (RuntimeException e) {
assertTrue(e.getMessage().contains("Fetch response has been disposed"), e.getMessage());
}
}
@Test
@Disabled("Conflicts with https://github.com/microsoft/playwright-java/pull/680")
void shouldNotSwallowExceptionsInResume() throws ExecutionException, InterruptedException {
page.route("**/*", route -> {
route.resume(new Route.ResumeOptions().setUrl("file:///tmp"));
});
try {
page.navigate(server.EMPTY_PAGE);
fail("did not throw");
} catch (RuntimeException e) {
assertTrue(e.getMessage().contains("New URL must have same protocol as overridden URL"), e.getMessage());
}
}
}
@@ -32,8 +32,7 @@ import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Collectors;
import static com.microsoft.playwright.Utils.mapOf;
import static com.microsoft.playwright.Utils.parseTrace;
import static com.microsoft.playwright.Utils.*;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.*;
@@ -60,13 +59,13 @@ public class TestBrowserTypeConnect extends TestBase {
private static BrowserServer launchBrowserServer(BrowserType browserType) {
try {
Path driver = Driver.ensureDriverInstalled(Collections.emptyMap());
Path driver = Driver.ensureDriverInstalled(Collections.emptyMap(), false);
Path dir = driver.getParent();
String node = dir.resolve(isWindows ? "node.exe" : "node").toString();
String cliJs = dir.resolve("package/lib/cli/cli.js").toString();
// We launch node process directly instead of using playwright.sh script as killing the script
// process will leave node process running and killing it would be more hassle.
ProcessBuilder pb = new ProcessBuilder(node, cliJs, "launch-server", browserType.name());
ProcessBuilder pb = new ProcessBuilder(node, cliJs, "launch-server", "--browser", browserType.name());
pb.directory(dir.toFile());
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
BrowserServer result = new BrowserServer();
@@ -166,6 +165,7 @@ public class TestBrowserTypeConnect extends TestBase {
}
assertNotNull(webSocketServer.lastClientHandshake);
assertEquals("Playwright", webSocketServer.lastClientHandshake.getFieldValue("User-Agent"));
assertEquals(browserType.name(), webSocketServer.lastClientHandshake.getFieldValue("x-playwright-browser"));
assertEquals("bar", webSocketServer.lastClientHandshake.getFieldValue("foo"));
}
}
@@ -507,4 +507,15 @@ public class TestBrowserTypeConnect extends TestBase {
assertEquals(new String(thisFile, UTF_8), new String(sources.values().iterator().next(), UTF_8));
}
@Test
void shouldFulfillWithGlobalFetchResult() {
page.route("**/*", route -> {
APIRequestContext request = playwright.request().newContext();
APIResponse response = request.get(server.PREFIX + "/simple.json");
route.fulfill(new Route.FulfillOptions().setResponse(response));
});
Response response = page.navigate(server.EMPTY_PAGE);
assertEquals(200, response.status());
assertEquals("{\"foo\": \"bar\"}\n", response.text());
}
}
@@ -48,6 +48,6 @@ public class TestElementHandlePress extends TestBase {
void shouldWorkWithNumberInput() {
page.setContent("<input type='number' value=2 />");
page.press("input", "1");
assertEquals("12", page.evalOnSelector("input", "input => input.value"));
assertEquals(isWebKit() ? "1" : "12", page.evalOnSelector("input", "input => input.value"));
}
}
@@ -48,6 +48,6 @@ public class TestElementHandleType extends TestBase {
void shouldWorkWithNumberInput() {
page.setContent("<input type='number' value=2 />");
page.type("input", "13");
assertEquals("132", page.evalOnSelector("input", "input => input.value"));
assertEquals(isWebKit() ? "13" : "132", page.evalOnSelector("input", "input => input.value"));
}
}
@@ -190,7 +190,8 @@ public class TestLocatorAssertions extends TestBase {
} catch (AssertionFailedError e) {
assertEquals("[Text 1, Text 3, Extra]", e.getExpected().getStringRepresentation());
assertEquals("[Text 1, Text 3]", e.getActual().getStringRepresentation());
assertTrue(e.getMessage().contains("Locator expected to have text"), e.getMessage());
assertTrue(e.getMessage().contains("Locator expected to have text: [Text 1, Text 3, Extra]"), e.getMessage());
assertTrue(e.getMessage().contains("Received: [Text 1, Text 3]"), e.getMessage());
}
}
@@ -234,7 +235,7 @@ public class TestLocatorAssertions extends TestBase {
} catch (AssertionFailedError e) {
assertEquals("foo", e.getExpected().getStringRepresentation());
assertEquals("node", e.getActual().getStringRepresentation());
assertTrue(e.getMessage().contains("Locator expected to have attribute 'id'"), e.getMessage());
assertTrue(e.getMessage().contains("Locator expected to have attribute 'id': foo\nReceived: node"), e.getMessage());
}
}
@@ -255,7 +256,7 @@ public class TestLocatorAssertions extends TestBase {
} catch (AssertionFailedError e) {
assertEquals(".Nod..", e.getExpected().getStringRepresentation());
assertEquals("node", e.getActual().getStringRepresentation());
assertTrue(e.getMessage().contains("Locator expected to have attribute 'id' matching regex"), e.getMessage());
assertTrue(e.getMessage().contains("Locator expected to have attribute 'id' matching regex: .Nod..\nReceived: node"), e.getMessage());
}
}
@@ -0,0 +1,23 @@
package com.microsoft.playwright;
import com.google.gson.Gson;
import com.microsoft.playwright.options.BoundingBox;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TestLocatorHighlight extends TestBase {
@Disabled("Requires isUnderTest to be true https://github.com/microsoft/playwright/pull/12420")
@Test
void shouldHighlightLocator() {
page.setContent("<input type='text' />");
page.locator("input").highlight();
assertThat(page.locator("x-pw-tooltip")).hasText("input");
assertThat(page.locator("x-pw-highlight")).isVisible();
BoundingBox box1 = page.locator("input").boundingBox();
BoundingBox box2 = page.locator("x-pw-highlight").boundingBox();
assertEquals(new Gson().toJson(box2), new Gson().toJson(box1));
}
}
@@ -91,6 +91,12 @@ public class TestPageAssertions extends TestBase {
assertThat(page).hasTitle("Woof-Woof", new PageAssertions.HasTitleOptions().setTimeout(1_000));
}
@Test
void hasTitleTextNormalizeWhitespaces() {
page.setContent("<title> Foo Bar </title>");
assertThat(page).hasTitle(" Foo Bar", new PageAssertions.HasTitleOptions().setTimeout(1_000));
}
@Test
void hasTitleTextFail() {
page.navigate(server.PREFIX + "/title.html");
@@ -100,7 +106,7 @@ public class TestPageAssertions extends TestBase {
} catch (AssertionFailedError e) {
assertEquals("foo", e.getExpected().getValue());
assertEquals("Woof-Woof", e.getActual().getValue());
assertTrue(e.getMessage().contains("Page title expected to be"), e.getMessage());
assertTrue(e.getMessage().contains("Page title expected to be: foo\nReceived: Woof-Woof"), e.getMessage());
}
}
@@ -119,7 +125,7 @@ public class TestPageAssertions extends TestBase {
} catch (AssertionFailedError e) {
assertEquals("^foo[AB]", e.getExpected().getStringRepresentation());
assertEquals("Woof-Woof", e.getActual().getValue());
assertTrue(e.getMessage().contains("Page title expected to match regex"), e.getMessage());
assertTrue(e.getMessage().contains("Page title expected to match regex: ^foo[AB]\nReceived: Woof-Woof"), e.getMessage());
}
}
@@ -57,7 +57,12 @@ public class TestPageEventNetwork extends TestBase {
List<Request> failedRequests = new ArrayList<>();
page.onRequestFailed(request -> failedRequests.add(request));
page.navigate(server.PREFIX + "/one-style.html");
assertEquals(1, failedRequests.size());
// In firefox one-style.css is requested multiple times.
if (isFirefox()) {
assertTrue(failedRequests.size() > 0);
} else {
assertEquals(1, failedRequests.size());
}
assertTrue(failedRequests.get(0).url().contains("one-style.css"));
assertNull(failedRequests.get(0).response());
assertEquals("stylesheet", failedRequests.get(0).resourceType());
@@ -14,30 +14,21 @@
* limitations under the License.
*/
package com.microsoft.playwright.impl;
package com.microsoft.playwright;
import java.util.function.Function;
import org.junit.jupiter.api.Test;
class WaitableAdapter<F, T> implements Waitable<T> {
private final Waitable<F> waitable;
private final Function<F, T> transformation;
import static org.junit.jupiter.api.Assertions.assertEquals;
WaitableAdapter(Waitable<F> waitable, Function<F, T> transformation) {
this.waitable = waitable;
this.transformation = transformation;
}
@Override
public boolean isDone() {
return waitable.isDone();
}
@Override
public T get() {
return transformation.apply(waitable.get());
}
@Override
public void dispose() {
waitable.dispose();
public class TestPageLocatorConvenience extends TestBase {
@Test
void shouldReturnPage() {
page.navigate(server.PREFIX + "/frames/two-frames.html");
Locator outer = page.locator("#outer");
assertEquals(page, outer.page());
Locator inner = outer.locator("#inner");
assertEquals(page, inner.page());
Locator inFrame = page.frames().get(1).locator("div");
assertEquals(page, inFrame.page());
}
}
@@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test;
import java.util.regex.Pattern;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
public class TestPageLocatorQuery extends TestBase {
@@ -118,4 +119,19 @@ public class TestPageLocatorQuery extends TestBase {
assertEquals("Hello \"world\"", page.locator("div", new Page.LocatorOptions().setHasText(pattern)).textContent());
}
@Test
void shouldSupportHasLocator() {
page.setContent("<div><span>hello</span></div><div><span>world</span></div>");
assertThat(page.locator("div", new Page.LocatorOptions().setHas(page.locator("text=world")))).hasCount(1);
assertEquals("<div><span>world</span></div>", page.locator("div", new Page.LocatorOptions().setHas(page.locator("text=world"))).evaluate("e => e.outerHTML"));
assertThat(page.locator("div", new Page.LocatorOptions().setHas(page.locator("text='hello'")))).hasCount(1);
assertEquals("<div><span>hello</span></div>", page.locator("div", new Page.LocatorOptions().setHas(page.locator("text='hello'"))).evaluate("e => e.outerHTML"));
assertThat(page.locator("div", new Page.LocatorOptions().setHas(page.locator("xpath=./span")))).hasCount(2);
assertThat(page.locator("div", new Page.LocatorOptions().setHas(page.locator("span")))).hasCount(2);
assertThat(page.locator("div", new Page.LocatorOptions().setHas(page.locator("span", new Page.LocatorOptions().setHasText("wor"))))).hasCount(1);
assertEquals("<div><span>world</span></div>", page.locator("div", new Page.LocatorOptions().setHas(
page.locator("span", new Page.LocatorOptions().setHasText("wor")))).evaluate("e => e.outerHTML"));
assertThat(page.locator("div", new Page.LocatorOptions()
.setHas(page.locator("span")).setHasText("wor"))).hasCount(1);
}
}
@@ -24,7 +24,7 @@ import java.util.*;
import java.util.concurrent.Semaphore;
import java.util.stream.Collectors;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
public class TestPageNetworkRequest extends TestBase {
@Test
@@ -0,0 +1,42 @@
/*
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.microsoft.playwright;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
public class TestPageRequestContinue extends TestBase {
@Test
void shouldNotThrowWhenContinuingAfterPageIsClosed() {
boolean[] done = {false};
page.route("**/*", route -> {
page.close();
route.resume();
done[0] = true;
});
try {
page.navigate(server.EMPTY_PAGE);
fail("did not throw");
} catch (PlaywrightException e) {
assertTrue(e.getMessage().contains("Navigation failed because page was closed") ||
e.getMessage().contains("frame was detached"), e.getMessage());
}
assertTrue(done[0]);
}
}
@@ -0,0 +1,63 @@
/*
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.microsoft.playwright;
import org.junit.jupiter.api.Test;
import static com.microsoft.playwright.Utils.mapOf;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TestPageRequestFulfill extends TestBase {
@Test
void shouldFulfillWithGlobalFetchResult() {
page.route("**/*", route -> {
APIRequestContext request = playwright.request().newContext();
APIResponse response = request.get(server.PREFIX + "/simple.json");
route.fulfill(new Route.FulfillOptions().setResponse(response));
});
Response response = page.navigate(server.EMPTY_PAGE);
assertEquals("application/json", response.headers().get("content-type"));
assertEquals(200, response.status());
assertEquals("{\"foo\": \"bar\"}\n", response.text());
}
@Test
void shouldFulfillWithFetchResult() {
page.route("**/*", route -> {
APIResponse response = page.request().get(server.PREFIX + "/simple.json");
route.fulfill(new Route.FulfillOptions().setResponse(response));
});
Response response = page.navigate(server.EMPTY_PAGE);
assertEquals("application/json", response.headers().get("content-type"));
assertEquals(200, response.status());
assertEquals("{\"foo\": \"bar\"}\n", response.text());
}
@Test
void shouldFulfillWithFetchResultAndOverrides() {
page.route("**/*", route -> {
APIResponse response = page.request().get(server.PREFIX + "/simple.json");
route.fulfill(new Route.FulfillOptions().setResponse(response)
.setStatus(201).setHeaders(mapOf("Content-Type", "application/json", "foo", "bar")));
});
Response response = page.navigate(server.EMPTY_PAGE);
assertEquals("application/json", response.headers().get("content-type"));
assertEquals(201, response.status());
assertEquals("bar", response.allHeaders().get("foo"));
assertEquals("{\"foo\": \"bar\"}\n", response.text());
}
}
@@ -347,7 +347,12 @@ public class TestPageRoute extends TestBase {
assertEquals(200, response.status());
assertTrue(response.url().contains("one-style.html"));
assertEquals(2, intercepted.size());
// In firefox one-style.css is requested multiple times.
if (isFirefox()) {
assertTrue(intercepted.size() > 1);
} else {
assertEquals(2, intercepted.size());
}
assertEquals("document", intercepted.get(0).resourceType());
assertTrue(intercepted.get(0).url().contains("one-style.html"));
@@ -460,7 +465,12 @@ public class TestPageRoute extends TestBase {
});
Response response = page.navigate("data:text/html,<link rel='stylesheet' href='" + server.PREFIX + "/fonts?helvetica|arial'/>");
assertNull(response);
assertEquals(1, requests.size());
// In firefox linked resource is requested multiple times.
if (isFirefox()) {
assertTrue(requests.size() > 0);
} else {
assertEquals(1, requests.size());
}
assertEquals(400, (requests.get(0).response()).status());
}
@@ -17,14 +17,20 @@
package com.microsoft.playwright;
import com.microsoft.playwright.options.Clip;
import com.microsoft.playwright.options.ScreenshotAnimations;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.opentest4j.AssertionFailedError;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.file.Paths;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static com.microsoft.playwright.options.ScreenshotAnimations.DISABLED;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.*;
// TODO: suite.skip(browserName === "firefox" && headful");
public class TestPageScreenshot extends TestBase {
@@ -50,4 +56,101 @@ public class TestPageScreenshot extends TestBase {
assertEquals(100, image.getHeight());
// expect(screenshot).toMatchSnapshot("screenshot-clip-rect.png");
}
static private void rafraf(Page page) {
// Do a double raf since single raf does not
// actually guarantee a new animation frame.
page.evaluate("() => new Promise(x => {\n" +
" requestAnimationFrame(() => requestAnimationFrame(x));\n" +
" })");
}
@Test
void shouldNotCaptureInfiniteCssAnimation() {
page.navigate(server.PREFIX + "/rotate-z.html");
Locator div = page.locator("div");
byte[] screenshot = div.screenshot(new Locator.ScreenshotOptions().setAnimations(DISABLED));
for (int i = 0; i < 10; ++i) {
rafraf(page);
byte[] newScreenshot = div.screenshot(new Locator.ScreenshotOptions().setAnimations(DISABLED));
assertArrayEquals(screenshot, newScreenshot);
}
}
@Test
void shouldNotCapturePseudoElementCssAnimation() {
page.navigate(server.PREFIX + "/rotate-pseudo.html");
Locator div = page.locator("div");
byte[] screenshot = div.screenshot(new Locator.ScreenshotOptions().setAnimations(DISABLED));
for (int i = 0; i < 10; ++i) {
rafraf(page);
byte[] newScreenshot = div.screenshot(new Locator.ScreenshotOptions().setAnimations(DISABLED));
assertArrayEquals(screenshot, newScreenshot);
}
}
@Test
void shouldNotCaptureCssAnimationsInShadowDOM() {
page.navigate(server.PREFIX + "/rotate-z-shadow-dom.html");
byte[] screenshot = page.screenshot(new Page.ScreenshotOptions().setAnimations(DISABLED));
for (int i = 0; i < 10; ++i) {
rafraf(page);
byte[] newScreenshot = page.screenshot(new Page.ScreenshotOptions().setAnimations(DISABLED));
assertArrayEquals(screenshot, newScreenshot);
}
}
@Test
void shouldResumeInfiniteAnimations() {
page.navigate(server.PREFIX + "/rotate-z.html");
page.screenshot(new Page.ScreenshotOptions().setAnimations(DISABLED));
byte[] buffer1 = page.screenshot();
rafraf(page);
byte[] buffer2 = page.screenshot();
try {
assertArrayEquals(buffer1, buffer2);
} catch (AssertionFailedError e) {
return;
}
fail("Screenshots are equal");
}
@Test
void shouldNotCaptureInfiniteWebAnimations() {
page.navigate(server.PREFIX + "/web-animation.html");
Locator div = page.locator("div");
byte[] screenshot = div.screenshot(new Locator.ScreenshotOptions().setAnimations(DISABLED));
for (int i = 0; i < 10; ++i) {
rafraf(page);
byte[] newScreenshot = div.screenshot(new Locator.ScreenshotOptions().setAnimations(DISABLED));
assertArrayEquals(screenshot, newScreenshot);
}
// Should resume infinite web animation.
byte[] buffer1 = page.screenshot();
rafraf(page);
byte[] buffer2 = page.screenshot();
try {
assertArrayEquals(buffer1, buffer2);
} catch (AssertionFailedError e) {
return;
}
fail("Screenshots are equal");
}
@Test
void maskShouldWork() {
page.setViewportSize(500, 500);
page.navigate(server.PREFIX + "/grid.html");
byte[] screenshot = page.screenshot(new Page.ScreenshotOptions()
.setMask(asList(page.locator("div").nth(5))));
// TODO: toMatchSnapshot is not present in java, so we only checks that masked screenshot is different.
byte[] originalScreenshot = page.screenshot();
try {
assertArrayEquals(screenshot, originalScreenshot);
} catch (AssertionFailedError e) {
return;
}
fail("Screenshots are equal");
}
}
@@ -23,6 +23,8 @@ import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.regex.Pattern;
import static com.microsoft.playwright.Utils.expectedSSLError;
@@ -239,15 +241,18 @@ public class TestPageWaitForNavigation extends TestBase {
server.setRoute("/empty.html", exchange -> {});
try {
frame.waitForNavigation(() -> {
page.evaluate("() => {\n" +
" frames[0].location.href = '/empty.html';\n" +
" setTimeout(() => document.querySelector('iframe').remove());\n" +
"}\n");
Future<Server.Request> req = server.futureRequest("/empty.html");
page.evalOnSelector("iframe", "frame => { frame.contentWindow.location.href = '/empty.html'; }");
try {
req.get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
page.evaluate("setTimeout(() => document.querySelector('iframe').remove());");
});
fail("did not throw");
} catch (PlaywrightException e) {
// assertTrue(e.getMessage().contains("waiting for navigation until \"load\""));
assertTrue(e.getMessage().contains("frame was detached"));
assertTrue(e.getMessage().contains("frame was detached"), e.getMessage());
}
}
@@ -24,7 +24,7 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import static com.microsoft.playwright.Utils.mapOf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
public class TestRequestFulfill extends TestBase {
@Test
@@ -104,4 +104,45 @@ public class TestRequestFulfill extends TestBase {
}
@Test
void fulfillShouldThrowIfHandledTwice() {
try {
page.route("**/*", route -> {
route.fulfill();
route.fulfill();
});
page.navigate(server.EMPTY_PAGE);
fail("didn't throw");
} catch (PlaywrightException e) {
assertTrue(e.getMessage().contains("Route is already handled!"), e.getMessage());
}
}
@Test
void abortShouldThrowIfHandledTwice() {
try {
page.route("**/*", route -> {
route.abort();
route.abort();
});
page.navigate(server.EMPTY_PAGE);
fail("didn't throw");
} catch (PlaywrightException e) {
assertTrue(e.getMessage().contains("Route is already handled!"), e.getMessage());
}
}
@Test
void resumeShouldThrowIfHandledTwice() {
try {
page.route("**/*", route -> {
route.resume();
route.resume();
});
page.navigate(server.EMPTY_PAGE);
fail("didn't throw");
} catch (PlaywrightException e) {
assertTrue(e.getMessage().contains("Route is already handled!"), e.getMessage());
}
}
}
@@ -119,7 +119,9 @@ public class TestTracing extends TestBase {
assertEquals(1, sources.size());
String path = getClass().getName().replace('.', File.separatorChar);
Path sourceFile = Paths.get(System.getenv("PLAYWRIGHT_JAVA_SRC"), path + ".java");
String[] srcRoots = System.getenv("PLAYWRIGHT_JAVA_SRC").split(File.pathSeparator);
// Resolve in the last specified source dir.
Path sourceFile = Paths.get(srcRoots[srcRoots.length - 1], path + ".java");
byte[] thisFile = Files.readAllBytes(sourceFile);
assertEquals(new String(thisFile, UTF_8), new String(sources.values().iterator().next(), UTF_8));
}
@@ -0,0 +1,21 @@
<!DOCTYPE HTML>
<style>
div {
position: absolute;
top: 0;
left: 0;
width: 200px;
height: 100px;
background-color: red;
transition: all 10s;
}
.transition {
transform: rotate(360deg);
}
</style>
<div></div>
<script>
window.addEventListener('load', () => {
document.querySelector('div').classList.add('transition');
}, false);
</script>
@@ -0,0 +1,32 @@
<html>
<head>
<style type="text/css">
div::after {
position: absolute;
content: " ";
top: 0;
left: 0;
width: 200px;
height: 100px;
background-color: red;
animation-name: z-spin;
animation-duration: 5s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
div {
position: absolute;
width: 10px;
height: 10px;
}
@keyframes z-spin {
0% { transform: rotateZ(0deg); }
100% { transform: rotateZ(360deg); }
}
</style>
</head>
<body >
<div class="square"></div>
</body>
</html>
@@ -0,0 +1,31 @@
<html>
<head></head>
<body></body>
<script>
window.addEventListener('DOMContentLoaded', () => {
const shadow = document.body.attachShadow({mode: 'open'});
shadow.append(document.createElement('div'));
const style = document.createElement('style');
style.textContent = `
div {
position: absolute;
top: 0;
left: 0;
width: 200px;
height: 100px;
background-color: red;
animation-name: z-spin;
animation-duration: 5s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
@keyframes z-spin {
0% { transform: rotateZ(0deg); }
100% { transform: rotateZ(360deg); }
}
`;
shadow.append(style);
}, false);
</script>
</html>
+1 -1
View File
@@ -13,7 +13,7 @@
animation-iteration-count: infinite;
animation-timing-function: linear;
}
@keyframes z-spin {
0% { transform: rotateZ(0deg); }
100% { transform: rotateZ(360deg); }
@@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<style>
div {
position: absolute;
top: 0;
left: 0;
width: 200px;
height: 100px;
background-color: red;
}
</style>
<div></div>
<script>
document.querySelector('div').animate(
[
{ transform: 'rotate(0deg)' },
{ transform: 'rotate(360deg)' }
], {
duration: 3000,
iterations: Infinity
}
);
</script>
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.20.1</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.18.0-rc1
1.20.1
+1 -4
View File
@@ -16,10 +16,7 @@ cd "$(dirname $0)/.."
VERSION=$1
POM_FILES=(
pom.xml
tools/api-generator/pom.xml
tools/update-docs-version/pom.xml
tools/test-local-installation/pom.xml
tools/test-spring-boot-starter/pom.xml
tools/*/pom.xml
examples/pom.xml
)
-5
View File
@@ -1,5 +0,0 @@
#!/bin/bash
echo "-- tagging: $2"
docker tag $1 $2
docker push $2
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>com.microsoft.playwright</groupId>
<artifactId>api-generator</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.20.1</version>
<name>Playwright - API Generator</name>
<description>
This is an internal module used to generate Java API from the upstream Playwright
@@ -183,7 +183,7 @@ abstract class Element {
String url = matcher.group(2);
if (url.startsWith("./")) {
// ./actionability.md#editable => https://playwright.dev/java/docs/actionability/#editable
url = url.replace(".md", "/");
url = url.replace(".md", "");
url = url.replace("./", "https://playwright.dev/java/docs/");
}
String link = "<a href=\"" + url + "\">" + matcher.group(1) + "</a>";
+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.18.0-SNAPSHOT</version>
<version>1.20.1</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.18.0-SNAPSHOT</version>
<version>1.20.1</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.18.0-SNAPSHOT</version>
<version>1.20.1</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.18.0-SNAPSHOT</version>
<version>1.20.1</version>
<name>Playwright - Update Version in Documentation</name>
<description>
This is an internal module used to update versions in the documentation based on
@@ -2,26 +2,32 @@ FROM ubuntu:focal
# === INSTALL JDK and Maven ===
RUN apt-get update && apt-get install -y --no-install-recommends \
openjdk-11-jdk maven
RUN apt-get update && \
apt-get install -y --no-install-recommends \
openjdk-11-jdk maven \
# Install utilities required for downloading browsers
curl \
# Install utilities required for downloading driver
unzip && \
rm -rf /var/lib/apt/lists/* && \
# Create the pwuser
adduser pwuser
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
# Install utilities required for downloading driver
RUN apt-get update && apt-get install -y --no-install-recommends \
curl unzip
# === INSTALL playwright maven modules & browsers ===
# === 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 && chmod -R 777 $PLAYWRIGHT_BROWSERS_PATH
RUN mkdir /ms-playwright && \
mkdir /tmp/pw-java
RUN 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 && \
@@ -29,4 +35,5 @@ RUN cd /tmp/pw-java && \
-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 && \
rm -rf /tmp/pw-java
rm -rf /tmp/pw-java && \
chmod -R 777 $PLAYWRIGHT_BROWSERS_PATH
+4
View File
@@ -0,0 +1,4 @@
# Docker build infra
This folder contains the infra to build the Docker images for Java. It's based on
the upstream code located in [`microsoft/playwright/utils/docker`](https://github.com/microsoft/playwright/tree/main/utils/docker).
+35
View File
@@ -0,0 +1,35 @@
#!/bin/bash
set -e
set +x
if [[ ($1 == '--help') || ($1 == '-h') || ($1 == '') || ($2 == '') ]]; then
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"
echo ""
echo " docker run --rm -it playwright:localbuild-focal /bin/bash"
echo ""
echo "NOTE: this requires on Playwright PIP dependencies to be installed"
echo ""
exit 0
fi
function cleanup() {
:
}
trap "cleanup; cd $(pwd -P)" EXIT
cd "$(dirname "$0")"
PLATFORM=""
if [[ "$1" == "--arm64" ]]; then
PLATFORM="linux/arm64";
elif [[ "$1" == "--amd64" ]]; then
PLATFORM="linux/amd64"
else
echo "ERROR: unknown platform specifier - $1. Only --arm64 or --amd64 is supported"
exit 1
fi
docker build --platform "${PLATFORM}" -t "$3" -f "Dockerfile.$2" ../../
+117
View File
@@ -0,0 +1,117 @@
#!/bin/bash
set -e
set +x
trap "cd $(pwd -P)" EXIT
cd "$(dirname "$0")"
MCR_IMAGE_NAME="playwright/java"
# GITHUB_REF has a form of `refs/tags/v1.3.0`.
# TAG_NAME would be `v1.3.0`
TAG_NAME=${GITHUB_REF#refs/tags/}
PW_VERSION="${TAG_NAME#v}"
RELEASE_CHANNEL="$1"
if [[ "${RELEASE_CHANNEL}" == "stable" ]]; then
if [[ ! "${PW_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "ERROR: cannot publish stable docker with Playwright version '${PW_VERSION}'"
exit 1
fi
elif [[ "${RELEASE_CHANNEL}" == "canary" ]]; then
:
else
echo "ERROR: unknown release channel - ${RELEASE_CHANNEL}"
echo "Must be either 'stable' or 'canary'"
exit 1
fi
if [[ -z "${GITHUB_SHA}" ]]; then
echo "ERROR: GITHUB_SHA env variable must be specified"
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")
FOCAL_TAGS+=("v${PW_VERSION}")
fi
tag_and_push() {
local source="$1"
local target="$2"
echo "-- tagging: $target"
docker tag $source $target
docker push $target
}
publish_docker_images_with_arch_suffix() {
local FLAVOR="$1"
local TAGS=()
if [[ "$FLAVOR" == "bionic" ]]; then
TAGS=("${BIONIC_TAGS[@]}")
elif [[ "$FLAVOR" == "focal" ]]; then
TAGS=("${FOCAL_TAGS[@]}")
else
echo "ERROR: unknown flavor - $FLAVOR. Must be either 'bionic' or 'focal'"
exit 1
fi
local ARCH="$2"
if [[ "$ARCH" != "amd64" && "$ARCH" != "arm64" ]]; then
echo "ERROR: unknown arch - $ARCH. Must be either 'amd64' or 'arm64'"
exit 1
fi
# Prune docker images to avoid platform conflicts
docker system prune -fa
./build.sh "--${ARCH}" "${FLAVOR}" "${MCR_IMAGE_NAME}:localbuild"
for ((i = 0; i < ${#TAGS[@]}; i++)) do
local TAG="${TAGS[$i]}"
tag_and_push "${MCR_IMAGE_NAME}:localbuild" "playwright.azurecr.io/public/${MCR_IMAGE_NAME}:${TAG}-${ARCH}"
done
}
publish_docker_manifest () {
local FLAVOR="$1"
local TAGS=()
if [[ "$FLAVOR" == "bionic" ]]; then
TAGS=("${BIONIC_TAGS[@]}")
elif [[ "$FLAVOR" == "focal" ]]; then
TAGS=("${FOCAL_TAGS[@]}")
else
echo "ERROR: unknown flavor - $FLAVOR. Must be either 'bionic' or 'focal'"
exit 1
fi
for ((i = 0; i < ${#TAGS[@]}; i++)) do
local TAG="${TAGS[$i]}"
local BASE_IMAGE_TAG="playwright.azurecr.io/public/${MCR_IMAGE_NAME}:${TAG}"
local IMAGE_NAMES=""
if [[ "$2" == "arm64" || "$2" == "amd64" ]]; then
IMAGE_NAMES="${IMAGE_NAMES} ${BASE_IMAGE_TAG}-$2"
fi
if [[ "$3" == "arm64" || "$3" == "amd64" ]]; then
IMAGE_NAMES="${IMAGE_NAMES} ${BASE_IMAGE_TAG}-$3"
fi
docker manifest create "${BASE_IMAGE_TAG}" $IMAGE_NAMES
docker manifest push "${BASE_IMAGE_TAG}"
done
}
publish_docker_images_with_arch_suffix focal amd64
publish_docker_manifest focal amd64