1
0
mirror of synced 2026-05-24 03:33:15 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Yury Semikhatsky 23ad37122a chore: set version to 1.19.0 (#814) 2022-02-15 16:06:10 -08:00
82 changed files with 794 additions and 2128 deletions
+7 -6
View File
@@ -17,9 +17,10 @@ jobs:
username: playwright
password: ${{ secrets.DOCKER_PASSWORD }}
- uses: actions/checkout@v2
- 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
- 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 }}
+16 -13
View File
@@ -3,11 +3,6 @@ on:
release:
types: [published]
workflow_dispatch:
inputs:
is_release:
required: true
type: boolean
description: "Is this a release image?"
branches:
- release-*
jobs:
@@ -22,12 +17,20 @@ 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
- 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')
- 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
+32 -21
View File
@@ -19,35 +19,38 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1
- uses: microsoft/playwright-github-action@v1.5.0
- 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 & Install
run: mvn -B install -D skipTests --no-transfer-progress
- name: Build with Maven
run: mvn -B package -D skipTests --no-transfer-progress
- name: Run tests
run: mvn test -DexcludedGroups=isolated --no-transfer-progress --fail-at-end
run: mvn test --no-transfer-progress --fail-at-end
env:
BROWSER: ${{ matrix.browser }}
- name: Run tracing tests w/ sources
run: mvn test -DexcludedGroups=isolated --no-transfer-progress --fail-at-end -D test=*TestTracing*
run: mvn test --no-transfer-progress --fail-at-end -D test=*TestTracing*
env:
BROWSER: ${{ matrix.browser }}
PLAYWRIGHT_JAVA_SRC: src/test/java
- name: Run driver throw tests
run: mvn test -Dgroups=driverThrowTest --no-transfer-progress --fail-at-end
env:
BROWSER: ${{ matrix.browser }}
- name: Test Spring Boot Starter
shell: bash
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
@@ -67,7 +70,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1
- uses: microsoft/playwright-github-action@v1.5.0
- name: Install Media Pack
if: matrix.os == 'windows-latest'
shell: powershell
@@ -77,18 +80,19 @@ 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 & Install
run: mvn -B install -D skipTests --no-transfer-progress
- name: Build with Maven
run: mvn -B package -D skipTests --no-transfer-progress
- name: Run tests
run: mvn test -DexcludedGroups=isolated --no-transfer-progress --fail-at-end
env:
BROWSER: chromium
BROWSER_CHANNEL: ${{ matrix.browser-channel }}
- name: Run driver throw tests
run: mvn test -Dgroups=driverThrowTest --no-transfer-progress --fail-at-end
run: mvn test --no-transfer-progress --fail-at-end
env:
BROWSER: chromium
BROWSER_CHANNEL: ${{ matrix.browser-channel }}
@@ -102,17 +106,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1
- uses: microsoft/playwright-github-action@v1.5.0
- 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 & Install
run: mvn -B install -D skipTests --no-transfer-progress
- name: Build with Maven
run: mvn -B package -D skipTests --no-transfer-progress
- name: Run tests
run: mvn test --no-transfer-progress --fail-at-end
env:
@@ -122,6 +132,7 @@ 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: bash utils/docker/build.sh --amd64 focal playwright-java:localbuild-focal
run: docker build -t playwright-java:localbuild-focal -f Dockerfile.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)"
+7 -1
View File
@@ -20,7 +20,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1
- uses: microsoft/playwright-github-action@v1.5.0
- 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
run: scripts/download_driver_for_all_platforms.sh
- name: Regenerate APIs
-13
View File
@@ -49,19 +49,6 @@ Java interfaces for the current driver run the following commands:
./scripts/generate_api.sh
```
#### Updating driver version
Driver version is read from [scripts/CLI_VERSION](https://github.com/microsoft/playwright-java/blob/main/scripts/CLI_VERSION) and can be found in the upstream [GHA build](https://github.com/microsoft/playwright/actions/workflows/publish_canary.yml) logs. To update the driver to a particular version run the following commands:
```bash
cat > scripts/CLI_VERSION
<paste new version>
^D
./scripts/download_driver_for_all_platforms.sh -f
./scripts/generate_api.sh
./scripts/update_readme.sh
```
### Code Style
- We try to follow [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html)
@@ -2,32 +2,26 @@ FROM ubuntu:focal
# === INSTALL JDK and 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
RUN apt-get update && apt-get install -y --no-install-recommends \
openjdk-11-jdk maven
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
# === BAKE BROWSERS INTO IMAGE ===
# Install utilities required for downloading driver
RUN apt-get update && apt-get install -y --no-install-recommends \
curl unzip
# === INSTALL playwright maven modules & browsers ===
# Browsers will remain downloaded in `/ms-playwright`.
# Note: make sure to set 777 to the registry so that any user can access
# registry.
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN mkdir /ms-playwright && \
mkdir /tmp/pw-java
RUN mkdir /ms-playwright && chmod -R 777 $PLAYWRIGHT_BROWSERS_PATH
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 && \
@@ -35,5 +29,4 @@ 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 && \
chmod -R 777 $PLAYWRIGHT_BROWSERS_PATH
rm -rf /tmp/pw-java
+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 -->101.0.4951.15<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Chromium <!-- GEN:chromium-version -->100.0.4863.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit <!-- GEN:webkit-version -->15.4<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->98.0.2<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Firefox <!-- GEN:firefox-version -->96.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.21.0</version>
<version>1.19.0</version>
</parent>
<artifactId>driver-bundle</artifactId>
@@ -37,13 +37,11 @@ public class DriverJar extends Driver {
? Files.createTempDirectory(prefix)
: Files.createTempDirectory(Paths.get(alternativeTmpdir), prefix);
driverTempDir.toFile().deleteOnExit();
logMessage("created DriverJar: " + driverTempDir);
}
@Override
protected void initialize(Map<String, String> env, Boolean installBrowsers) throws Exception {
extractDriverToTempDir();
logMessage("extracted driver from jar to " + driverPath());
if (installBrowsers)
installBrowsers(env);
}
@@ -18,19 +18,16 @@ package com.microsoft.playwright;
import com.microsoft.playwright.impl.Driver;
import com.microsoft.playwright.impl.DriverJar;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestInstall {
@@ -39,18 +36,6 @@ public class TestInstall {
// Clear system property to ensure that the driver is loaded from jar.
System.clearProperty("playwright.cli.dir");
System.clearProperty("playwright.driver.tmpdir");
// Clear system property to ensure that the default driver is loaded.
System.clearProperty("playwright.driver.impl");
}
@Test
@Tags({@Tag("isolated"), @Tag("driverThrowTest")})
void shouldThrowWhenBrowserPathIsInvalid() {
Map<String,String> env = new HashMap<>();
env.put("PLAYWRIGHT_BROWSERS_PATH", "/some/bad/path/that/should/not/exist/i/hope");
assertThrows(RuntimeException.class, () -> Driver.ensureDriverInstalled(env, true));
assertThrows(RuntimeException.class, () -> Driver.ensureDriverInstalled(env, true));
}
@Test
@@ -72,19 +57,4 @@ public class TestInstall {
DriverJar driver = new DriverJar();
assertTrue(driver.driverPath().startsWith(tmpdir), "Driver path: " + driver.driverPath() + " tmp: " + tmpdir);
}
@Test
void playwrightDriverDefaultImpl() {
assertDoesNotThrow(() -> Driver.ensureDriverInstalled(Collections.emptyMap(), false));
}
@Test
void playwrightDriverAlternativeImpl() {
System.setProperty("playwright.driver.impl", "com.microsoft.playwright.impl.AlternativeDriver");
RuntimeException thrown =
assertThrows(
RuntimeException.class,
() -> Driver.ensureDriverInstalled(Collections.emptyMap(), false));
assertEquals("Failed to create driver", thrown.getMessage());
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.21.0</version>
<version>1.19.0</version>
</parent>
<artifactId>driver</artifactId>
@@ -18,11 +18,8 @@ package com.microsoft.playwright.impl;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.ZonedDateTime;
import java.util.Map;
import static com.microsoft.playwright.impl.DriverLogging.logWithTimestamp;
/**
* This class provides access to playwright-cli. It can be either preinstalled
* in the host system and its path is passed as a system property or it can be
@@ -34,7 +31,6 @@ public abstract class Driver {
private static class PreinstalledDriver extends Driver {
private final Path driverDir;
PreinstalledDriver(Path driverDir) {
logMessage("created PreinstalledDriver: " + driverDir);
this.driverDir = driverDir;
}
@@ -53,11 +49,8 @@ public abstract class Driver {
if (instance == null) {
try {
instance = createDriver();
logMessage("initializing driver");
instance.initialize(env, installBrowsers);
logMessage("driver initialized.");
} catch (Exception exception) {
instance = null;
throw new RuntimeException("Failed to create driver", exception);
}
}
@@ -99,16 +92,9 @@ public abstract class Driver {
return new PreinstalledDriver(Paths.get(pathFromProperty));
}
String driverImpl =
System.getProperty("playwright.driver.impl", "com.microsoft.playwright.impl.DriverJar");
Class<?> jarDriver = Class.forName(driverImpl);
Class<?> jarDriver = Class.forName("com.microsoft.playwright.impl.DriverJar");
return (Driver) jarDriver.getDeclaredConstructor().newInstance();
}
abstract Path driverDir();
protected static void logMessage(String message) {
// This matches log format produced by the server.
logWithTimestamp("pw:install " + message);
}
}
@@ -1,41 +0,0 @@
/*
* 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.impl;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
class DriverLogging {
private static final boolean isEnabled;
static {
String debug = System.getenv("DEBUG");
isEnabled = (debug != null) && debug.contains("pw:install");
}
private static final DateTimeFormatter timestampFormat = DateTimeFormatter.ofPattern(
"yyyy-MM-dd'T'HH:mm:ss.SSSXXX").withZone(ZoneId.of("UTC"));
static void logWithTimestamp(String message) {
if (!isEnabled) {
return;
}
// This matches log format produced by the server.
String timestamp = ZonedDateTime.now().format(timestampFormat);
System.err.println(timestamp + " " + message);
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>org.example</groupId>
<artifactId>examples</artifactId>
<version>1.21.0</version>
<version>1.19.0</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.21.0</version>
<version>1.19.0</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. 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}.
* 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>.
*/
public interface APIRequest {
class NewContextOptions {
@@ -21,24 +21,9 @@ 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.
*
* <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.
* 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.
*/
public interface APIRequestContext {
class StorageStateOptions {
@@ -1017,9 +1017,8 @@ public interface Browser extends AutoCloseable {
Page newPage(NewPageOptions options);
/**
* <strong>NOTE:</strong> This API controls <a href="https://www.chromium.org/developers/how-tos/trace-event-profiling-tool">Chromium Tracing</a>
* which is a low-level chromium-specific debugging tool. API to control <a
* href="https://playwright.dev/java/docs/trace-viewer">Playwright Tracing</a> could be found <a
* href="https://playwright.dev/java/docs/api/class-tracing">here</a>.
* which is a low-level chromium-specific debugging tool. API to control <a href="../trace-viewer">Playwright Tracing</a>
* could be found <a href="https://playwright.dev/java/docs/class-tracing">here</a>.
*
* <p> You can use {@link Browser#startTracing Browser.startTracing()} and {@link Browser#stopTracing Browser.stopTracing()} to
* create a trace file that can be opened in Chrome DevTools performance panel.
@@ -1037,9 +1036,8 @@ public interface Browser extends AutoCloseable {
}
/**
* <strong>NOTE:</strong> This API controls <a href="https://www.chromium.org/developers/how-tos/trace-event-profiling-tool">Chromium Tracing</a>
* which is a low-level chromium-specific debugging tool. API to control <a
* href="https://playwright.dev/java/docs/trace-viewer">Playwright Tracing</a> could be found <a
* href="https://playwright.dev/java/docs/api/class-tracing">here</a>.
* which is a low-level chromium-specific debugging tool. API to control <a href="../trace-viewer">Playwright Tracing</a>
* could be found <a href="https://playwright.dev/java/docs/class-tracing">here</a>.
*
* <p> You can use {@link Browser#startTracing Browser.startTracing()} and {@link Browser#stopTracing Browser.stopTracing()} to
* create a trace file that can be opened in Chrome DevTools performance panel.
@@ -1055,9 +1053,8 @@ public interface Browser extends AutoCloseable {
}
/**
* <strong>NOTE:</strong> This API controls <a href="https://www.chromium.org/developers/how-tos/trace-event-profiling-tool">Chromium Tracing</a>
* which is a low-level chromium-specific debugging tool. API to control <a
* href="https://playwright.dev/java/docs/trace-viewer">Playwright Tracing</a> could be found <a
* href="https://playwright.dev/java/docs/api/class-tracing">here</a>.
* which is a low-level chromium-specific debugging tool. API to control <a href="../trace-viewer">Playwright Tracing</a>
* could be found <a href="https://playwright.dev/java/docs/class-tracing">here</a>.
*
* <p> You can use {@link Browser#startTracing Browser.startTracing()} and {@link Browser#stopTracing Browser.stopTracing()} to
* create a trace file that can be opened in Chrome DevTools performance panel.
@@ -1073,9 +1070,8 @@ public interface Browser extends AutoCloseable {
void startTracing(Page page, StartTracingOptions options);
/**
* <strong>NOTE:</strong> This API controls <a href="https://www.chromium.org/developers/how-tos/trace-event-profiling-tool">Chromium Tracing</a>
* which is a low-level chromium-specific debugging tool. API to control <a
* href="https://playwright.dev/java/docs/trace-viewer">Playwright Tracing</a> could be found <a
* href="https://playwright.dev/java/docs/api/class-tracing">here</a>.
* which is a low-level chromium-specific debugging tool. API to control <a href="../trace-viewer">Playwright Tracing</a>
* could be found <a href="https://playwright.dev/java/docs/class-tracing">here</a>.
*
* <p> Returns the buffer with trace data.
*/
@@ -497,6 +497,7 @@ 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>
@@ -523,6 +524,7 @@ 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>
@@ -52,7 +52,8 @@ public interface BrowserType {
*/
public Double slowMo;
/**
* Maximum time in milliseconds to wait for the connection to be established. Defaults to {@code 0} (no timeout).
* Maximum time in milliseconds to wait for the connection to be established. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to
* disable timeout.
*/
public Double timeout;
@@ -72,7 +73,8 @@ public interface BrowserType {
return this;
}
/**
* Maximum time in milliseconds to wait for the connection to be established. Defaults to {@code 0} (no timeout).
* Maximum time in milliseconds to wait for the connection to be established. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to
* disable timeout.
*/
public ConnectOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -128,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;
/**
@@ -220,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;
@@ -229,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;
@@ -397,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;
/**
@@ -623,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;
@@ -632,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;
@@ -969,7 +971,7 @@ public interface BrowserType {
}
}
/**
* This method attaches Playwright to an existing browser instance.
* This methods attaches Playwright to an existing browser instance.
*
* @param wsEndpoint A browser websocket endpoint to connect to.
*/
@@ -977,13 +979,13 @@ public interface BrowserType {
return connect(wsEndpoint, null);
}
/**
* This method attaches Playwright to an existing browser instance.
* This methods attaches Playwright to an existing browser instance.
*
* @param wsEndpoint A browser websocket endpoint to connect to.
*/
Browser connect(String wsEndpoint, ConnectOptions options);
/**
* This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
* This methods attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
*
* <p> The default browser context is accessible via {@link Browser#contexts Browser.contexts()}.
*
@@ -996,7 +998,7 @@ public interface BrowserType {
return connectOverCDP(endpointURL, null);
}
/**
* This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
* This methods attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
*
* <p> The default browser context is accessible via {@link Browser#contexts Browser.contexts()}.
*
@@ -19,28 +19,7 @@ package com.microsoft.playwright;
import java.util.*;
/**
* {@code ConsoleMessage} objects are dispatched by page via the {@link Page#onConsoleMessage Page.onConsoleMessage()} event. For
* each console messages logged in the page there will be corresponding event in the Playwright context.
* <pre>{@code
* // Listen for all System.out.printlns
* page.onConsoleMessage(msg -> System.out.println(msg.text()));
*
* // Listen for all console events and handle errors
* page.onConsoleMessage(msg -> {
* if ("error".equals(msg.type()))
* System.out.println("Error text: " + msg.text());
* });
*
* // Get the next System.out.println
* ConsoleMessage msg = page.waitForConsoleMessage(() -> {
* // Issue console.log inside the page
* page.evaluate("console.log('hello', 42, { foo: 'bar' });");
* });
*
* // Deconstruct console.log arguments
* msg.args().get(0).jsonValue() // hello
* msg.args().get(1).jsonValue() // 42
* }</pre>
* {@code ConsoleMessage} objects are dispatched by page via the {@link Page#onConsoleMessage Page.onConsoleMessage()} event.
*/
public interface ConsoleMessage {
/**
@@ -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,27 +569,6 @@ 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>
*
* <p> Defaults to {@code "allow"} that leaves animations untouched.
*/
public ScreenshotAnimations animations;
/**
* When set to {@code "hide"}, screenshot will hide text caret. When set to {@code "initial"}, text caret behavior will not be changed.
* Defaults to {@code "hide"}.
*/
public ScreenshotCaret caret;
/**
* 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}.
@@ -605,12 +584,6 @@ public interface ElementHandle extends JSHandle {
* The quality of the image, between 0-100. Not applicable to {@code png} images.
*/
public Integer quality;
/**
* When set to {@code "css"}, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using {@code "device"} option will produce a single pixel per each device pixel, so screenhots of
* high-dpi devices will be twice as large or even larger. Defaults to {@code "device"}.
*/
public ScreenshotScale scale;
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
* using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link Page#setDefaultTimeout
@@ -622,36 +595,6 @@ 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>
*
* <p> Defaults to {@code "allow"} that leaves animations untouched.
*/
public ScreenshotOptions setAnimations(ScreenshotAnimations animations) {
this.animations = animations;
return this;
}
/**
* When set to {@code "hide"}, screenshot will hide text caret. When set to {@code "initial"}, text caret behavior will not be changed.
* Defaults to {@code "hide"}.
*/
public ScreenshotOptions setCaret(ScreenshotCaret caret) {
this.caret = caret;
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}.
@@ -676,15 +619,6 @@ public interface ElementHandle extends JSHandle {
this.quality = quality;
return this;
}
/**
* When set to {@code "css"}, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using {@code "device"} option will produce a single pixel per each device pixel, so screenhots of
* high-dpi devices will be twice as large or even larger. Defaults to {@code "device"}.
*/
public ScreenshotOptions setScale(ScreenshotScale scale) {
this.scale = scale;
return this;
}
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
* using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link Page#setDefaultTimeout
@@ -722,7 +656,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;
@@ -740,7 +674,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) {
@@ -768,7 +702,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;
@@ -780,7 +714,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) {
@@ -799,7 +733,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;
@@ -821,14 +755,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) {
@@ -869,7 +803,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.
*/
@@ -913,7 +847,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;
@@ -940,14 +874,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) {
@@ -996,7 +930,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.
*/
@@ -1051,7 +985,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;
@@ -1073,14 +1007,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) {
@@ -1121,7 +1055,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.
*/
@@ -1230,7 +1164,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>
@@ -1251,7 +1185,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>
@@ -1268,7 +1202,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>
@@ -1286,7 +1220,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>
@@ -1306,7 +1240,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>
@@ -1327,7 +1261,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>
@@ -1418,7 +1352,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
@@ -1432,7 +1366,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.
@@ -1444,7 +1378,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
@@ -1458,7 +1392,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.
@@ -1469,7 +1403,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
@@ -1483,7 +1417,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.
@@ -1495,7 +1429,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
@@ -1509,7 +1443,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.
@@ -1517,7 +1451,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.
*
@@ -1534,7 +1468,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.
*
@@ -1561,7 +1495,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>
@@ -1579,7 +1513,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>
@@ -1616,24 +1550,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();
/**
@@ -1692,26 +1626,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() {
@@ -1720,12 +1654,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}.
*
@@ -1736,7 +1670,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}.
*
@@ -1745,8 +1679,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
@@ -1773,8 +1707,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
@@ -1799,8 +1733,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
@@ -1827,8 +1761,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
@@ -1853,8 +1787,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
@@ -1881,8 +1815,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
@@ -1907,8 +1841,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
@@ -1935,8 +1869,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
@@ -1961,8 +1895,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
@@ -1989,8 +1923,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
@@ -2015,8 +1949,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
@@ -2043,8 +1977,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
@@ -2069,14 +2003,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);
@@ -2085,7 +2019,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>
@@ -2106,7 +2040,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>
@@ -2195,7 +2129,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>
@@ -2215,7 +2149,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>
@@ -2279,7 +2213,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>
@@ -2300,7 +2234,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>
@@ -2318,18 +2252,19 @@ 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.
@@ -2343,18 +2278,19 @@ 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.
@@ -2380,7 +2316,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) {
@@ -2404,7 +2340,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
@@ -57,9 +57,8 @@ public interface FrameLocator {
*/
public Locator has;
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
* [string], matching is case-insensitive and searches for a substring. For example, {@code "Playwright"} matches
* {@code <article><div>Playwright</div></article>}.
* 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;
@@ -74,18 +73,16 @@ public interface FrameLocator {
return this;
}
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
* [string], matching is case-insensitive and searches for a substring. For example, {@code "Playwright"} matches
* {@code <article><div>Playwright</div></article>}.
* 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 LocatorOptions setHasText(String hasText) {
this.hasText = hasText;
return this;
}
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
* [string], matching is case-insensitive and searches for a substring. For example, {@code "Playwright"} matches
* {@code <article><div>Playwright</div></article>}.
* 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 LocatorOptions setHasText(Pattern hasText) {
this.hasText = hasText;
@@ -100,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);
@@ -111,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) {
@@ -120,12 +117,12 @@ 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);
/**
* Returns locator to the n-th matching frame. It's zero based, {@code nth(0)} selects the first frame.
* Returns locator to the n-th matching frame.
*/
FrameLocator nth(int index);
}
@@ -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.
*/
@@ -872,9 +872,8 @@ public interface Locator {
*/
public Locator has;
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
* [string], matching is case-insensitive and searches for a substring. For example, {@code "Playwright"} matches
* {@code <article><div>Playwright</div></article>}.
* 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;
@@ -889,18 +888,16 @@ public interface Locator {
return this;
}
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
* [string], matching is case-insensitive and searches for a substring. For example, {@code "Playwright"} matches
* {@code <article><div>Playwright</div></article>}.
* 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 LocatorOptions setHasText(String hasText) {
this.hasText = hasText;
return this;
}
/**
* Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a
* [string], matching is case-insensitive and searches for a substring. For example, {@code "Playwright"} matches
* {@code <article><div>Playwright</div></article>}.
* 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 LocatorOptions setHasText(Pattern hasText) {
this.hasText = hasText;
@@ -952,27 +949,6 @@ 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>
*
* <p> Defaults to {@code "allow"} that leaves animations untouched.
*/
public ScreenshotAnimations animations;
/**
* When set to {@code "hide"}, screenshot will hide text caret. When set to {@code "initial"}, text caret behavior will not be changed.
* Defaults to {@code "hide"}.
*/
public ScreenshotCaret caret;
/**
* 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}.
@@ -988,12 +964,6 @@ public interface Locator {
* The quality of the image, between 0-100. Not applicable to {@code png} images.
*/
public Integer quality;
/**
* When set to {@code "css"}, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using {@code "device"} option will produce a single pixel per each device pixel, so screenhots of
* high-dpi devices will be twice as large or even larger. Defaults to {@code "device"}.
*/
public ScreenshotScale scale;
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
* using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link Page#setDefaultTimeout
@@ -1005,36 +975,6 @@ 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>
*
* <p> Defaults to {@code "allow"} that leaves animations untouched.
*/
public ScreenshotOptions setAnimations(ScreenshotAnimations animations) {
this.animations = animations;
return this;
}
/**
* When set to {@code "hide"}, screenshot will hide text caret. When set to {@code "initial"}, text caret behavior will not be changed.
* Defaults to {@code "hide"}.
*/
public ScreenshotOptions setCaret(ScreenshotCaret caret) {
this.caret = caret;
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}.
@@ -1059,15 +999,6 @@ public interface Locator {
this.quality = quality;
return this;
}
/**
* When set to {@code "css"}, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using {@code "device"} option will produce a single pixel per each device pixel, so screenhots of
* high-dpi devices will be twice as large or even larger. Defaults to {@code "device"}.
*/
public ScreenshotOptions setScale(ScreenshotScale scale) {
this.scale = scale;
return this;
}
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
* using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link Page#setDefaultTimeout
@@ -1105,7 +1036,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;
@@ -1123,7 +1054,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) {
@@ -1151,7 +1082,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;
@@ -1163,7 +1094,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) {
@@ -1182,7 +1113,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;
@@ -1204,14 +1135,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) {
@@ -1252,7 +1183,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.
*/
@@ -1296,7 +1227,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;
@@ -1323,14 +1254,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) {
@@ -1379,7 +1310,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.
*/
@@ -1452,7 +1383,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;
@@ -1474,14 +1405,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) {
@@ -1522,7 +1453,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.
*/
@@ -1629,7 +1560,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>
@@ -1650,7 +1581,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>
@@ -1667,7 +1598,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>
@@ -1685,7 +1616,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>
@@ -1705,7 +1636,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>
@@ -1726,7 +1657,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>
@@ -2043,7 +1974,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.
*
@@ -2060,7 +1991,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.
*
@@ -2096,7 +2027,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);
@@ -2114,15 +2045,10 @@ 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>
@@ -2140,7 +2066,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>
@@ -2195,56 +2121,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);
/**
@@ -2254,7 +2180,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) {
@@ -2263,12 +2189,12 @@ 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);
/**
* Returns locator to the n-th matching element. It's zero based, {@code nth(0)} selects the first element.
* Returns locator to the n-th matching element.
*/
Locator nth(int index);
/**
@@ -2328,7 +2254,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() {
@@ -2337,12 +2263,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}.
*/
@@ -2350,14 +2276,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
@@ -2384,8 +2310,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
@@ -2410,8 +2336,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
@@ -2438,8 +2364,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
@@ -2464,8 +2390,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
@@ -2492,8 +2418,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
@@ -2518,8 +2444,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
@@ -2546,8 +2472,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
@@ -2572,8 +2498,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
@@ -2600,8 +2526,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
@@ -2626,8 +2552,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
@@ -2654,8 +2580,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
@@ -2680,14 +2606,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);
@@ -2696,7 +2622,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>
@@ -2717,7 +2643,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>
@@ -2806,7 +2732,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>
@@ -2826,7 +2752,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>
@@ -2896,7 +2822,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>
@@ -2917,7 +2843,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>
@@ -122,12 +122,12 @@ public interface Mouse {
}
class MoveOptions {
/**
* Defaults to 1. Sends intermediate {@code mousemove} events.
* defaults to 1. Sends intermediate {@code mousemove} events.
*/
public Integer steps;
/**
* Defaults to 1. Sends intermediate {@code mousemove} events.
* defaults to 1. Sends intermediate {@code mousemove} events.
*/
public MoveOptions setSteps(int steps) {
this.steps = steps;
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();
/**
@@ -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
@@ -56,8 +56,7 @@ public interface Tracing {
public Boolean snapshots;
/**
* Whether to include source files for trace actions. List of the directories with source code for the application must be
* provided via {@code PLAYWRIGHT_JAVA_SRC} environment variable (the paths should be separated by ';' on Windows and by ':' on
* other platforms).
* provided via {@code PLAYWRIGHT_JAVA_SRC} environment variable.
*/
public Boolean sources;
/**
@@ -93,8 +92,7 @@ public interface Tracing {
}
/**
* Whether to include source files for trace actions. List of the directories with source code for the application must be
* provided via {@code PLAYWRIGHT_JAVA_SRC} environment variable (the paths should be separated by ';' on Windows and by ':' on
* other platforms).
* provided via {@code PLAYWRIGHT_JAVA_SRC} environment variable.
*/
public StartOptions setSources(boolean sources) {
this.sources = sources;
@@ -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/api/actionability#visible">visible</a>.
* href="https://playwright.dev/java/docs/actionability/#visible">visible</a>.
* <pre>{@code
* assertThat(page.locator(".my-element")).isHidden();
* }</pre>
@@ -419,14 +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/api/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/api/actionability#visible">visible</a> DOM
* 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();
@@ -436,7 +436,7 @@ public interface LocatorAssertions {
isVisible(null);
}
/**
* Ensures the {@code Locator} points to a <a href="https://playwright.dev/java/docs/api/actionability#visible">visible</a> DOM
* 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();
@@ -24,8 +24,8 @@ import com.microsoft.playwright.impl.LocatorAssertionsImpl;
import com.microsoft.playwright.impl.PageAssertionsImpl;
/**
* Playwright gives you Web-First Assertions with convenience methods for creating assertions that will wait and retry
* until the expected condition is met.
* The {@code PlaywrightAssertions} class provides convenience methods for creating assertions that will wait until the expected
* condition is met.
*
* <p> Consider the following example:
* <pre>{@code
@@ -560,11 +560,4 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
}
listeners.notify(EventType.CLOSE, this);
}
WritableStream createTempFile(String name) {
JsonObject params = new JsonObject();
params.addProperty("name", name);
JsonObject json = sendMessage("createTempFile", params).getAsJsonObject();
return connection.getExistingObject(json.getAsJsonObject("writableStream").get("guid").getAsString());
}
}
@@ -64,22 +64,6 @@ 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);
@@ -302,9 +302,6 @@ public class Connection {
case "Worker":
result = new WorkerImpl(parent, type, guid, initializer);
break;
case "WritableStream":
result = new WritableStream(parent, type, guid, initializer);
break;
default:
throw new PlaywrightException("Unknown type " + type);
}
@@ -33,8 +33,7 @@ import java.util.Base64;
import java.util.List;
import static com.microsoft.playwright.impl.Serialization.*;
import static com.microsoft.playwright.impl.Utils.*;
import static com.microsoft.playwright.impl.Utils.addLargeFileUploadParams;
import static com.microsoft.playwright.impl.Utils.convertType;
import static com.microsoft.playwright.options.ScreenshotType.JPEG;
import static com.microsoft.playwright.options.ScreenshotType.PNG;
@@ -300,7 +299,7 @@ public class ElementHandleImpl extends JSHandleImpl implements ElementHandle {
}
@Override
public FrameImpl ownerFrame() {
public Frame ownerFrame() {
return withLogging("ElementHandle.ownerFrame", () -> {
JsonObject json = sendMessage("ownerFrame").getAsJsonObject();
if (!json.has("frame")) {
@@ -456,24 +455,7 @@ public class ElementHandleImpl extends JSHandleImpl implements ElementHandle {
@Override
public void setInputFiles(Path[] files, SetInputFilesOptions options) {
withLogging("ElementHandle.setInputFiles", () -> setInputFilesImpl(files, options));
}
void setInputFilesImpl(Path[] files, SetInputFilesOptions options) {
FrameImpl frame = ownerFrame();
if (frame == null) {
throw new Error("Cannot set input files to detached element");
}
if (hasLargeFile(files)) {
if (options == null) {
options = new SetInputFilesOptions();
}
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
addLargeFileUploadParams(files, params, frame.page().context());
sendMessage("setInputFilePaths", params);
} else {
setInputFilesImpl(Utils.toFilePayloads(files), options);
}
setInputFiles(Utils.toFilePayloads(files), options);
}
@Override
@@ -487,7 +469,6 @@ public class ElementHandleImpl extends JSHandleImpl implements ElementHandle {
}
void setInputFilesImpl(FilePayload[] files, SetInputFilesOptions options) {
checkFilePayloadSize(files);
if (options == null) {
options = new SetInputFilesOptions();
}
@@ -58,8 +58,7 @@ class FileChooserImpl implements FileChooser {
@Override
public void setFiles(Path[] files, SetFilesOptions options) {
page.withLogging("FileChooser.setInputFiles",
() -> element.setInputFilesImpl(files, convertType(options, ElementHandle.SetInputFilesOptions.class)));
setFiles(Utils.toFilePayloads(files), options);
}
@Override
@@ -70,6 +69,6 @@ class FileChooserImpl implements FileChooser {
@Override
public void setFiles(FilePayload[] files, SetFilesOptions options) {
page.withLogging("FileChooser.setInputFiles",
() -> element.setInputFilesImpl(files, convertType(options, ElementHandle.SetInputFilesOptions.class)));
() -> element.setInputFilesImpl(files, convertType(options, ElementHandle.SetInputFilesOptions.class)));
}
}
@@ -23,7 +23,6 @@ import com.microsoft.playwright.*;
import com.microsoft.playwright.options.*;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -32,7 +31,7 @@ import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import static com.microsoft.playwright.impl.Utils.*;
import static com.microsoft.playwright.impl.Utils.convertType;
import static com.microsoft.playwright.options.WaitUntilState.*;
import static com.microsoft.playwright.impl.Serialization.*;
@@ -687,32 +686,21 @@ public class FrameImpl extends ChannelOwner implements Frame {
withLogging("Frame.setInputFiles", () -> setInputFilesImpl(selector, files, options));
}
void setInputFilesImpl(String selector, Path[] files, SetInputFilesOptions options) {
if (hasLargeFile(files)) {
if (options == null) {
options = new SetInputFilesOptions();
}
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
addLargeFileUploadParams(files, params, page.context());
params.addProperty("selector", selector);
sendMessage("setInputFilePaths", params);
} else {
setInputFilesImpl(selector, Utils.toFilePayloads(files), options);
}
}
@Override
public void setInputFiles(String selector, FilePayload files, SetInputFilesOptions options) {
setInputFiles(selector, new FilePayload[]{files}, options);
}
void setInputFilesImpl(String selector, Path[] files, SetInputFilesOptions options) {
setInputFiles(selector, Utils.toFilePayloads(files), options);
}
@Override
public void setInputFiles(String selector, FilePayload[] files, SetInputFilesOptions options) {
withLogging("Frame.setInputFiles", () -> setInputFilesImpl(selector, files, options));
}
void setInputFilesImpl(String selector, FilePayload[] files, SetInputFilesOptions options) {
checkFilePayloadSize(files);
if (options == null) {
options = new SetInputFilesOptions();
}
@@ -1036,12 +1024,6 @@ 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");
@@ -196,11 +196,6 @@ 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) {
@@ -471,15 +466,6 @@ 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();
@@ -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,18 +1034,8 @@ 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());
@@ -40,10 +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(ScreenshotScale.class, new ToLowerCaseSerializer<ScreenshotScale>())
.registerTypeAdapter(ScreenshotCaret.class, new ToLowerCaseSerializer<ScreenshotCaret>())
.registerTypeAdapter(MouseButton.class, new ToLowerCaseSerializer<MouseButton>())
.registerTypeAdapter(LoadState.class, new ToLowerCaseSerializer<LoadState>())
.registerTypeAdapter(WaitUntilState.class, new ToLowerCaseSerializer<WaitUntilState>())
@@ -212,14 +209,6 @@ class Serialization {
}
}
static JsonArray toJsonArray(Path[] files) {
JsonArray jsonFiles = new JsonArray();
for (Path p : files) {
jsonFiles.add(p.toString());
}
return jsonFiles;
}
static JsonArray toJsonArray(FilePayload[] files) {
JsonArray jsonFiles = new JsonArray();
for (FilePayload p : files) {
@@ -28,6 +28,7 @@ import static com.microsoft.playwright.impl.Serialization.gson;
class TracingImpl extends ChannelOwner implements Tracing {
LocalUtils localUtils;
boolean isRemote;
private boolean includeSources;
TracingImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
super(parent, type, guid, initializer);
@@ -89,7 +90,7 @@ class TracingImpl extends ChannelOwner implements Tracing {
options = new StartOptions();
}
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
boolean includeSources = options.sources != null && options.sources;
includeSources = options.sources != null;
if (includeSources) {
if (!connection.isCollectingStacks()) {
throw new PlaywrightException("Source root directory must be specified via PLAYWRIGHT_JAVA_SRC environment variable when source collection is enabled");
@@ -16,8 +16,6 @@
package com.microsoft.playwright.impl;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.microsoft.playwright.PlaywrightException;
import com.microsoft.playwright.options.FilePayload;
import com.microsoft.playwright.options.HttpHeader;
@@ -25,7 +23,6 @@ import com.microsoft.playwright.options.HttpHeader;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.file.Files;
@@ -33,8 +30,6 @@ import java.nio.file.Path;
import java.util.*;
import java.util.regex.Pattern;
import static com.microsoft.playwright.impl.Serialization.toJsonArray;
class Utils {
static <F, T> T convertType(F f, Class<T> t) {
if (f == null) {
@@ -149,49 +144,6 @@ class Utils {
return mimeType;
}
static final int maxUplodBufferSize = 50 * 1024 * 1024;
static boolean hasLargeFile(Path[] files) {
for (Path file: files) {
try {
if (Files.size(file)> maxUplodBufferSize) {
return true;
}
} catch (IOException e) {
throw new PlaywrightException("Cannot get file size.", e);
}
}
return false;
}
static void addLargeFileUploadParams(Path[] files, JsonObject params, BrowserContextImpl context) {
if (context.browser().isRemote) {
List<WritableStream> streams = new ArrayList<>();
JsonArray jsonStreams = new JsonArray();
for (Path path : files) {
WritableStream temp = context.createTempFile(path.getFileName().toString());
streams.add(temp);
try (OutputStream out = temp.stream()) {
Files.copy(path, out);
} catch (IOException e) {
throw new PlaywrightException("Failed to copy file to remote server.", e);
}
jsonStreams.add(temp.toProtocol());
}
params.add("streams", jsonStreams);
} else {
params.add("localPaths", toJsonArray(files));
}
}
static void checkFilePayloadSize(FilePayload[] files) {
for (FilePayload file: files) {
if (file.buffer.length > maxUplodBufferSize) {
throw new PlaywrightException("Cannot set buffer larger than 50Mb, please write it to a file and pass its path instead.");
}
}
}
static FilePayload[] toFilePayloads(Path[] files) {
List<FilePayload> payloads = new ArrayList<>();
for (Path file : files) {
@@ -1,39 +0,0 @@
package com.microsoft.playwright.impl;
import com.google.gson.JsonObject;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
class WritableStream extends ChannelOwner {
WritableStream(ChannelOwner parent, String type, String guid, JsonObject initializer) {
super(parent, type, guid, initializer);
}
OutputStream stream() {
return new OutputStream() {
@Override
public void write(int b) throws IOException {
write(new byte[] { (byte) b });
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
JsonObject params = new JsonObject();
ByteBuffer buffer = ByteBuffer.wrap(b, off, len);
ByteBuffer encoded = Base64.getEncoder().encode(buffer);
params.addProperty("binary", new String(encoded.array(), StandardCharsets.UTF_8));
sendMessage("write", params);
}
};
}
JsonObject toProtocol() {
JsonObject json = new JsonObject();
json.addProperty("guid", guid);
return json;
}
}
@@ -1,22 +0,0 @@
/*
* 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,
ALLOW
}
@@ -1,22 +0,0 @@
/*
* 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 ScreenshotCaret {
HIDE,
INITIAL
}
@@ -1,22 +0,0 @@
/*
* 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 ScreenshotScale {
CSS,
DEVICE
}
@@ -1,66 +0,0 @@
package com.microsoft.playwright;
import com.sun.net.httpserver.HttpExchange;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class MultipartFormData {
static MultipartFormData parseRequest(HttpExchange exchange) throws IOException {
ByteArrayOutputStream bodyBytes = new ByteArrayOutputStream();
try (OutputStream output = bodyBytes) {
Utils.copy(exchange.getRequestBody(), output);
}
String body = new String(bodyBytes.toByteArray(), StandardCharsets.UTF_8);
String contentType = exchange.getRequestHeaders().get("content-type").get(0);
Matcher matcher = Pattern.compile("boundary=(.*)$").matcher(contentType);
if (!matcher.find()) {
throw new RuntimeException("Boundary not found!");
}
String boundary = matcher.group(1);
return new MultipartFormData(body, boundary);
}
static class Field {
final String filename;
final String content;
Field(String filename, String content) {
this.filename = filename;
this.content = content;
}
}
final List<Field> fields = new ArrayList<>();
MultipartFormData(String body, String boundary) {
String[] parts = Pattern.compile("--" + boundary + "(--)?\r\n", Pattern.MULTILINE).split(body);
for (String part : parts) {
if (part.trim().length() == 0) {
continue;
}
String[] headersAndContent = Pattern.compile("\r\n\r\n", Pattern.MULTILINE).split(part);
if (headersAndContent.length != 2) {
throw new RuntimeException("Unexpected format: " + part);
}
String headers = headersAndContent[0];
String filename = null;
for (String header: Pattern.compile("\r\n", Pattern.MULTILINE).split(headers)) {
Matcher matcher = Pattern.compile("content-disposition: .*filename=\"([^\"]+)\"", Pattern.CASE_INSENSITIVE).matcher(header);
if (!matcher.find()) {
continue;
}
filename = matcher.group(1);
}
String content = headersAndContent[1];
content = content.substring(0, content.length() - "\r\n".length());
fields.add(new Field(filename, content));
}
}
}
@@ -346,21 +346,7 @@ public class TestBrowserContextAddCookies extends TestBase {
"}", server.CROSS_PROCESS_PREFIX + "/grid.html");
page.frames().get(1).evaluate("document.cookie = 'username=John Doe'");
page.waitForTimeout(2000);
boolean allowsThirdParty = isFirefox();
List<Cookie> cookies = context.cookies(server.CROSS_PROCESS_PREFIX + "/grid.html");
if (allowsThirdParty) {
assertJsonEquals("[{\n" +
" 'domain': '127.0.0.1',\n" +
" 'expires': -1,\n" +
" 'httpOnly': false,\n" +
" 'name': 'username',\n" +
" 'path': '/',\n" +
" 'sameSite': 'NONE',\n" +
" 'secure': false,\n" +
" 'value': 'John Doe'\n" +
"}]", cookies);
} else {
assertEquals(0, cookies.size());
}
assertEquals(0, cookies.size());
}
}
@@ -50,7 +50,7 @@ public class TestBrowserContextCookies extends TestBase {
" expires: -1,\n" +
" httpOnly: false,\n" +
" secure: false,\n" +
" sameSite: '" + (isChromium() ? "LAX" : "NONE") +"'\n" +
" sameSite: '" + (isChromium() || isFirefox() ? "LAX" : "NONE") +"'\n" +
" }]", cookies);
}
@@ -74,7 +74,7 @@ public class TestBrowserContextCookies extends TestBase {
assertEquals(timestamp, cookie.expires);
assertEquals(false, cookie.httpOnly);
assertEquals(false, cookie.secure);
if (isChromium()) {
if (isChromium() || isFirefox()) {
assertEquals(SameSiteAttribute.LAX, cookie.sameSite);
} else {
assertEquals(SameSiteAttribute.NONE, cookie.sameSite);
@@ -146,7 +146,7 @@ public class TestBrowserContextCookies extends TestBase {
" expires: -1,\n" +
" httpOnly: false,\n" +
" secure: false,\n" +
" sameSite: '" + (isChromium() ? "LAX" : "NONE") +"'\n" +
" sameSite: '" + (isChromium() || isFirefox() ? "LAX" : "NONE") +"'\n" +
" },\n" +
" {\n" +
" name: 'username',\n" +
@@ -156,7 +156,7 @@ public class TestBrowserContextCookies extends TestBase {
" expires: -1,\n" +
" httpOnly: false,\n" +
" secure: false,\n" +
" sameSite: '" + (isChromium() ? "LAX" : "NONE") +"'\n" +
" sameSite: '" + (isChromium() || isFirefox() ? "LAX" : "NONE") +"'\n" +
" }\n" +
"]", cookies);
}
@@ -16,7 +16,6 @@
package com.microsoft.playwright;
import com.sun.net.httpserver.Filter;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
@@ -34,19 +33,10 @@ 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();
// 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);
}
assertEquals(asList(
server.EMPTY_PAGE,
server.PREFIX + "/one-style.html",
server.PREFIX + "/one-style.css"), requests);
}
@Test
@@ -57,19 +47,10 @@ 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();
// 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);
}
assertEquals(asList(
server.EMPTY_PAGE,
server.PREFIX + "/one-style.html",
server.PREFIX + "/one-style.css"), responses);
}
@Test
@@ -78,12 +59,7 @@ public class TestBrowserContextNetworkEvents extends TestBase {
List<Request> failedRequests = new ArrayList<>();
context.onRequestFailed(request -> failedRequests.add(request));
page.navigate(server.PREFIX + "/one-style.html");
// In firefox one-style.css is requested multiple times.
if (isFirefox()) {
assertTrue(failedRequests.size() > 0);
} else {
assertEquals(1, failedRequests.size());
}
assertEquals(1, failedRequests.size());
assertTrue(failedRequests.get(0).url().contains("one-style.css"));
assertNull(failedRequests.get(0).response());
assertEquals("stylesheet", failedRequests.get(0).resourceType());
@@ -140,10 +140,8 @@ public class TestBrowserContextRoute extends TestBase {
@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");
@@ -155,9 +153,7 @@ public class TestBrowserContextRoute extends TestBase {
" });\n" +
" })()\n" +
" </script>");
while (!routeHandled[0]) {
page.waitForTimeout(100);
}
byte[] body = req.get().postBody;
assertEquals(0, body.length);
}
@@ -109,7 +109,7 @@ public class TestBrowserContextStorageState extends TestBase {
" 'expires':-1,\n" +
" 'httpOnly':false,\n" +
" 'secure':false,\n" +
" 'sameSite':'" + (isChromium() ? "Lax" : "None") + "'\n" +
" 'sameSite':'" + (isChromium() || isFirefox() ? "Lax" : "None") + "'\n" +
" }],\n" +
" 'origins':[\n" +
" {\n" +
@@ -30,11 +30,10 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import static com.microsoft.playwright.Utils.*;
import static com.microsoft.playwright.Utils.mapOf;
import static com.microsoft.playwright.Utils.parseTrace;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.*;
@@ -67,7 +66,7 @@ public class TestBrowserTypeConnect extends TestBase {
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", "--browser", browserType.name());
ProcessBuilder pb = new ProcessBuilder(node, cliJs, "launch-server", browserType.name());
pb.directory(dir.toFile());
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
BrowserServer result = new BrowserServer();
@@ -167,7 +166,6 @@ 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"));
}
}
@@ -520,44 +518,4 @@ public class TestBrowserTypeConnect extends TestBase {
assertEquals(200, response.status());
assertEquals("{\"foo\": \"bar\"}\n", response.text());
}
@Test
void shouldUploadLargeFile(@TempDir Path tmpDir) throws IOException, ExecutionException, InterruptedException {
Assumptions.assumeTrue(3 <= (Runtime.getRuntime().maxMemory() >> 30), "Fails if max heap size is < 3Gb");
page.navigate(server.PREFIX + "/input/fileupload.html");
Path uploadFile = tmpDir.resolve("200MB.zip");
String str = String.join("", Collections.nCopies(4 * 1024, "A"));
try (Writer stream = new OutputStreamWriter(Files.newOutputStream(uploadFile))) {
for (int i = 0; i < 50 * 1024; i++) {
stream.write(str);
}
}
Locator input = page.locator("input[type='file']");
JSHandle events = input.evaluateHandle("e => {\n" +
" const events = [];\n" +
" e.addEventListener('input', () => events.push('input'));\n" +
" e.addEventListener('change', () => events.push('change'));\n" +
" return events;\n" +
" }");
input.setInputFiles(uploadFile);
assertEquals("200MB.zip", input.evaluate("e => e.files[0].name"));
assertEquals(asList("input", "change"), events.evaluate("e => e"));
CompletableFuture<MultipartFormData> formData = new CompletableFuture<>();
server.setRoute("/upload", exchange -> {
try {
MultipartFormData multipartFormData = MultipartFormData.parseRequest(exchange);
formData.complete(multipartFormData);
} catch (Exception e) {
e.printStackTrace();
formData.completeExceptionally(e);
}
exchange.sendResponseHeaders(200, -1);
});
page.click("input[type=submit]", new Page.ClickOptions().setTimeout(90_000));
List<MultipartFormData.Field> fields = formData.get().fields;
assertEquals(1, fields.size());
assertEquals("200MB.zip", fields.get(0).filename);
assertEquals(200 * 1024 * 1024, fields.get(0).content.length());
}
}
@@ -48,6 +48,6 @@ public class TestElementHandlePress extends TestBase {
void shouldWorkWithNumberInput() {
page.setContent("<input type='number' value=2 />");
page.press("input", "1");
assertEquals(isWebKit() ? "1" : "12", page.evalOnSelector("input", "input => input.value"));
assertEquals("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(isWebKit() ? "13" : "132", page.evalOnSelector("input", "input => input.value"));
assertEquals("132", page.evalOnSelector("input", "input => input.value"));
}
}
@@ -137,7 +137,7 @@ public class TestGlobalFetch extends TestBase {
Optional<HttpHeader> contentType = response.headersArray().stream().filter(h -> "content-type".equals(h.name.toLowerCase())).findFirst();
assertTrue(contentType.isPresent());
assertEquals("application/json", contentType.get().value);
assertEquals("{\"foo\": \"bar\"}\n", response.text());
assertEquals("", response.text());
}
@Test
@@ -1,23 +0,0 @@
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));
}
}
@@ -57,12 +57,7 @@ public class TestPageEventNetwork extends TestBase {
List<Request> failedRequests = new ArrayList<>();
page.onRequestFailed(request -> failedRequests.add(request));
page.navigate(server.PREFIX + "/one-style.html");
// In firefox one-style.css is requested multiple times.
if (isFirefox()) {
assertTrue(failedRequests.size() > 0);
} else {
assertEquals(1, failedRequests.size());
}
assertEquals(1, failedRequests.size());
assertTrue(failedRequests.get(0).url().contains("one-style.css"));
assertNull(failedRequests.get(0).response());
assertEquals("stylesheet", failedRequests.get(0).resourceType());
@@ -347,12 +347,7 @@ public class TestPageRoute extends TestBase {
assertEquals(200, response.status());
assertTrue(response.url().contains("one-style.html"));
// In firefox one-style.css is requested multiple times.
if (isFirefox()) {
assertTrue(intercepted.size() > 1);
} else {
assertEquals(2, intercepted.size());
}
assertEquals(2, intercepted.size());
assertEquals("document", intercepted.get(0).resourceType());
assertTrue(intercepted.get(0).url().contains("one-style.html"));
@@ -465,12 +460,7 @@ public class TestPageRoute extends TestBase {
});
Response response = page.navigate("data:text/html,<link rel='stylesheet' href='" + server.PREFIX + "/fonts?helvetica|arial'/>");
assertNull(response);
// In firefox linked resource is requested multiple times.
if (isFirefox()) {
assertTrue(requests.size() > 0);
} else {
assertEquals(1, requests.size());
}
assertEquals(1, requests.size());
assertEquals(400, (requests.get(0).response()).status());
}
@@ -534,7 +524,9 @@ public class TestPageRoute extends TestBase {
page.navigate(server.EMPTY_PAGE);
page.route("**/cars*", route -> {
Map<String, String> headers = new HashMap<>();
headers.put("access-control-allow-origin", route.request().url().endsWith("allow") ? "*" : "none");
if (route.request().url().endsWith("allow")) {
headers.put("access-control-allow-origin", "*");
}
route.fulfill(new Route.FulfillOptions()
.setStatus(200)
.setContentType("application/json")
@@ -698,29 +690,4 @@ public class TestPageRoute extends TestBase {
page.navigate(server.EMPTY_PAGE);
assertEquals(1, intercepted[0]);
}
@Test
void shouldAddAccessControlAllowOriginByDefaultWhenFulfill() {
page.navigate(server.EMPTY_PAGE);
page.route("**/cars", route -> {
route.fulfill(new Route.FulfillOptions()
.setContentType("application/json")
.setStatus(200)
.setBody("[\"electric\",\"gas\"]"));
});
Response response = page.waitForResponse("https://example.com/cars", () -> {
Object result = page.evaluate("async () => {\n" +
" const response = await fetch('https://example.com/cars', {\n" +
" method: 'POST',\n" +
" headers: { 'Content-Type': 'application/json' },\n" +
" mode: 'cors',\n" +
" body: JSON.stringify({ 'number': 1 })\n" +
" });\n" +
" return response.text();\n" +
" }");
assertEquals("[\"electric\",\"gas\"]", result);
});
assertEquals(server.PREFIX, response.headerValue("Access-Control-Allow-Origin"));
}
}
@@ -17,23 +17,14 @@
package com.microsoft.playwright;
import com.microsoft.playwright.options.Clip;
import com.microsoft.playwright.options.ScreenshotAnimations;
import com.microsoft.playwright.options.ScreenshotCaret;
import com.microsoft.playwright.options.ScreenshotScale;
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 java.util.Arrays;
import static com.microsoft.playwright.options.ScreenshotAnimations.DISABLED;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
// TODO: suite.skip(browserName === "firefox" && headful");
public class TestPageScreenshot extends TestBase {
@@ -59,191 +50,4 @@ 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");
}
@Test
void shouldWorkWithDeviceScaleFactorAndClip() {
try (BrowserContext context = browser.newContext(new Browser.NewContextOptions()
.setViewportSize(500, 500).setDeviceScaleFactor(3))) {
Page page = context.newPage();
page.navigate(server.PREFIX + "/grid.html");
byte[] screenshot = page.screenshot(new Page.ScreenshotOptions().setClip(50, 100, 150, 100));
assertNotNull(screenshot);
// TODO:
// expect(screenshot).toMatchSnapshot("screenshot-device-scale-factor-clip.png");
}
}
@Test
void shouldWorkWithDeviceScaleFactorAndScaleCss() {
BrowserContext context = browser.newContext(new Browser.NewContextOptions()
.setViewportSize(320, 480).setDeviceScaleFactor(2));
Page page = context.newPage();
page.navigate(server.PREFIX + "/grid.html");
byte[] screenshot = page.screenshot(new Page.ScreenshotOptions().setScale(ScreenshotScale.CSS));
assertNotNull(screenshot);
// TODO:
// expect(screenshot).toMatchSnapshot("screenshot-device-scale-factor-css-size.png");
}
@Test
void shouldWorkWithDeviceScaleFactorAndScaleDevice() {
BrowserContext context = browser.newContext(new Browser.NewContextOptions()
.setViewportSize(320, 480).setDeviceScaleFactor(2));
Page page = context.newPage();
page.navigate(server.PREFIX + "/grid.html");
byte[] screenshot = page.screenshot(new Page.ScreenshotOptions().setScale(ScreenshotScale.DEVICE));
assertNotNull(screenshot);
// TODO:
// expect(screenshot).toMatchSnapshot("screenshot-device-scale-factor-device-size.png");
}
@Test
void shouldNotCaptureBlinkingCaretByDefault() {
page.setContent("<!-- Refer to stylesheet from other origin. Accessing this\n" +
" stylesheet rules will throw.\n" +
" -->\n" +
" <link rel=stylesheet href=\"" + server.CROSS_PROCESS_PREFIX + "/injectedstyle.css\">\n" +
" <!-- make life harder: define caret color in stylesheet -->\n" +
" <style>\n" +
" div {\n" +
" caret-color: #000 !important;\n" +
" }\n" +
" </style>\n" +
" <div contenteditable=\"true\"></div>\n");
Locator div = page.locator("div");
div.type("foo bar");
byte[] screenshot = div.screenshot();
for (int i = 0; i < 10; ++i) {
// Caret blinking time is set to 500ms.
// Try to capture variety of screenshots to make
// sure we don"t capture blinking caret.
page.waitForTimeout(150);
byte[] newScreenshot = div.screenshot();
assertArrayEquals(screenshot, newScreenshot);
}
}
@Test
void shouldCaptureBlinkingCaretIfExplicitlyAskedFor() {
page.setContent(" <!-- Refer to stylesheet from other origin. Accessing this\n" +
" stylesheet rules will throw.\n" +
" -->\n" +
" <link rel=stylesheet href=\"" + server.CROSS_PROCESS_PREFIX + "/injectedstyle.css'}\">\n" +
" <!-- make life harder: define caret color in stylesheet -->\n" +
" <style>\n" +
" div {\n" +
" caret-color: #000 !important;\n" +
" }\n" +
" </style>\n" +
" <div contenteditable=\"true\"></div>\n");
Locator div = page.locator("div");
div.type("foo bar");
byte[] screenshot = div.screenshot();
boolean hasDifferentScreenshots = false;
for (int i = 0; !hasDifferentScreenshots && i < 10; ++i) {
// Caret blinking time is set to 500ms.
// Try to capture variety of screenshots to make
// sure we capture blinking caret.
page.waitForTimeout(150);
byte[] newScreenshot = div.screenshot(new Locator.ScreenshotOptions().setCaret(ScreenshotCaret.INITIAL));
hasDifferentScreenshots = !Arrays.equals(newScreenshot, screenshot);
}
assertTrue(hasDifferentScreenshots);
}
}
@@ -17,22 +17,15 @@
package com.microsoft.playwright;
import com.microsoft.playwright.options.FilePayload;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.function.Consumer;
import static java.util.Arrays.asList;
@@ -56,46 +49,6 @@ public class TestPageSetInputFiles extends TestBase {
"}", input));
}
@Test
void shouldUploadLargeFile(@TempDir Path tmpDir) throws IOException, ExecutionException, InterruptedException {
Assumptions.assumeTrue(3 <= (Runtime.getRuntime().maxMemory() >> 30), "Fails if max heap size is < 3Gb");
page.navigate(server.PREFIX + "/input/fileupload.html");
Path uploadFile = tmpDir.resolve("200MB.zip");
String str = String.join("", Collections.nCopies(4 * 1024, "A"));
try (Writer stream = new OutputStreamWriter(Files.newOutputStream(uploadFile))) {
for (int i = 0; i < 50 * 1024; i++) {
stream.write(str);
}
}
Locator input = page.locator("input[type='file']");
JSHandle events = input.evaluateHandle("e => {\n" +
" const events = [];\n" +
" e.addEventListener('input', () => events.push('input'));\n" +
" e.addEventListener('change', () => events.push('change'));\n" +
" return events;\n" +
" }");
input.setInputFiles(uploadFile);
assertEquals("200MB.zip", input.evaluate("e => e.files[0].name"));
assertEquals(asList("input", "change"), events.evaluate("e => e"));
CompletableFuture<MultipartFormData> formData = new CompletableFuture<>();
server.setRoute("/upload", exchange -> {
try {
MultipartFormData multipartFormData = MultipartFormData.parseRequest(exchange);
formData.complete(multipartFormData);
} catch (Exception e) {
e.printStackTrace();
formData.completeExceptionally(e);
}
exchange.sendResponseHeaders(200, -1);
});
page.click("input[type=submit]", new Page.ClickOptions().setTimeout(90_000));
List<MultipartFormData.Field> fields = formData.get().fields;
assertEquals(1, fields.size());
assertEquals("200MB.zip", fields.get(0).filename);
assertEquals(200 * 1024 * 1024, fields.get(0).content.length());
}
@Test
void shouldWork() {
page.setContent("<input type=file>");
@@ -43,6 +43,7 @@ public class TestTracing extends TestBase {
@BeforeAll
void launchBrowser(@TempDir Path tempDir) {
System.out.println("new launchBrowser(");
BrowserType.LaunchOptions options = createLaunchOptions();
options.setTracesDir(tempDir.resolve("trace-dir"));
launchBrowser(options);
@@ -125,10 +126,4 @@ public class TestTracing extends TestBase {
assertEquals(new String(thisFile, UTF_8), new String(sources.values().iterator().next(), UTF_8));
}
@Test
void shouldNotFailWhenSourcesSetExplicitlyToFalse() throws IOException {
Assumptions.assumeTrue(System.getenv("PLAYWRIGHT_JAVA_SRC") == null, "PLAYWRIGHT_JAVA_SRC must not be set for this test");
context.tracing().start(new Tracing.StartOptions().setSources(false));
}
}
@@ -1,21 +0,0 @@
<!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>
@@ -4,8 +4,8 @@
<title>File upload test</title>
</head>
<body>
<form action="/upload" method="post" enctype="multipart/form-data">
<input type="file" name="file1">
<form action="/input/fileupload.html">
<input type="file">
<input type="submit">
</form>
</body>
@@ -1,32 +0,0 @@
<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>
@@ -1,31 +0,0 @@
<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); }
@@ -1,23 +0,0 @@
<!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.21.0</version>
<version>1.19.0</version>
<packaging>pom</packaging>
<name>Playwright Parent Project</name>
<description>Java library to automate Chromium, Firefox and WebKit with a single API.
+1 -1
View File
@@ -1 +1 @@
1.21.0
1.19.0
+5
View File
@@ -0,0 +1,5 @@
#!/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.21.0</version>
<version>1.19.0</version>
<name>Playwright - API Generator</name>
<description>
This is an internal module used to generate Java API from the upstream Playwright
@@ -181,15 +181,10 @@ abstract class Element {
int start = 0;
while (matcher.find()) {
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("../", "https://playwright.dev/java/docs/");
}
if (url.startsWith("./")) {
// ./class-tracing.md => https://playwright.dev/java/docs/api/class-tracing
url = url.replace(".md", "");
url = url.replace("./", "https://playwright.dev/java/docs/api/");
// ./actionability.md#editable => https://playwright.dev/java/docs/actionability/#editable
url = url.replace(".md", "/");
url = url.replace("./", "https://playwright.dev/java/docs/");
}
String link = "<a href=\"" + url + "\">" + matcher.group(1) + "</a>";
linkified += paragraph.substring(start, matcher.start());
+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.21.0</version>
<version>1.19.0</version>
<name>Test Playwright Command Line Version</name>
<properties>
<compiler.version>1.8</compiler.version>
+1 -1
View File
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.playwright</groupId>
<artifactId>test-local-installation</artifactId>
<version>1.21.0</version>
<version>1.19.0</version>
<name>Test local installation</name>
<description>Runs Playwright test suite (copied from playwright module) against locally cached Playwright</description>
<properties>
+1 -1
View File
@@ -9,7 +9,7 @@
</parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>test-spring-boot-starter</artifactId>
<version>1.21.0</version>
<version>1.19.0</version>
<name>Test Playwright With Spring Boot</name>
<properties>
<spring.version>2.4.3</spring.version>
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>com.microsoft.playwright</groupId>
<artifactId>update-version</artifactId>
<version>1.21.0</version>
<version>1.19.0</version>
<name>Playwright - Update Version in Documentation</name>
<description>
This is an internal module used to update versions in the documentation based on
-4
View File
@@ -1,4 +0,0 @@
# 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
@@ -1,35 +0,0 @@
#!/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" ../../
-120
View File
@@ -1,120 +0,0 @@
#!/bin/bash
set -e
set +x
trap "cd $(pwd -P)" EXIT
cd "$(dirname "$0")"
MCR_IMAGE_NAME="playwright/java"
POM_FILE=../../pom.xml
if [[ ! -f ${POM_FILE} ]]; then
echo "ERROR: pom.xml not found at ${POM_FILE}"
exit 1;
fi
PW_VERSION=$(mvn exec:exec -Dexec.executable='echo' -Dexec.args='${project.version}' -f ${POM_FILE} --non-recursive -q 2>/dev/null)
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