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

Compare commits

...

45 Commits

Author SHA1 Message Date
Yury Semikhatsky 40752df57e chore: set version to 1.46.0 (#1647) 2024-08-09 11:57:02 -07:00
Yury Semikhatsky 800c2e9c71 fix: support ControlOrMeta action modifier (#1644)
Fixes: https://github.com/microsoft/playwright-java/issues/1643
2024-08-07 17:08:33 -07:00
Meir Blachman edf8174581 docs: add discord link in readme (#1642) 2024-08-06 15:54:40 -07:00
Yury Semikhatsky 8ae67204eb test: disable failing certificate tests on webkit mac (#1641) 2024-08-06 13:08:26 -07:00
Yury Semikhatsky 5f2540e556 chore: roll driver to 1.46.0 (#1640) 2024-08-05 17:46:01 -07:00
Yury Semikhatsky 776e3f26ef chore: serizlize java Exception <==> javascript Error (#1639) 2024-08-02 10:32:18 -07:00
Yury Semikhatsky 46f4ac1f33 chore: roll driver to 1.46.0-beta (#1638) 2024-07-31 13:58:01 -07:00
dependabot[bot] 73d22552e6 chore(deps): bump org.apache.maven.plugins:maven-javadoc-plugin from 3.7.0 to 3.8.0 (#1631) 2024-07-23 15:03:57 -07:00
Thomas Fowler 650419c952 fix: Replaced println with logMessage in DriverJar (#1627) 2024-07-23 10:29:15 -07:00
dependabot[bot] 1e8adde480 chore(deps): bump org.apache.maven.plugins:maven-surefire-plugin from 3.3.0 to 3.3.1 (#1625) 2024-07-15 13:45:23 -07:00
dependabot[bot] a9e1242aef chore(deps-dev): bump org.java-websocket:Java-WebSocket from 1.5.6 to 1.5.7 (#1626) 2024-07-15 13:45:11 -07:00
dependabot[bot] a222edee5a chore(deps): bump junit.version from 5.10.2 to 5.10.3 (#1616) 2024-07-11 08:59:14 -07:00
Yury Semikhatsky 7a12897be4 feat: support java.time.OffsetDateTime in post data (#1624)
Fixes https://github.com/microsoft/playwright-java/issues/1623
2024-07-11 08:58:46 -07:00
Yury Semikhatsky 7fa8081032 devops: test on java 21 which is latest lts (#1613) 2024-06-27 14:37:55 -07:00
Yury Semikhatsky 212bf981f7 chore: bump dev version to 1.46.0-SNAPSHOT (#1612) 2024-06-27 13:28:56 -07:00
Yury Semikhatsky d9ac70c66b chore: roll driver to 1.45.0-beta (#1610) 2024-06-27 13:22:47 -07:00
dependabot[bot] 4279a4ef3e chore(deps): bump org.apache.maven.plugins:maven-jar-plugin from 3.4.1 to 3.4.2 (#1604) 2024-06-27 10:15:05 -07:00
dependabot[bot] 141afb1f09 chore(deps): bump org.apache.maven.plugins:maven-clean-plugin from 3.3.2 to 3.4.0 (#1603) 2024-06-27 10:09:04 -07:00
dependabot[bot] 2eaae58659 chore(deps): bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.5 to 3.3.0 (#1599) 2024-06-27 10:08:52 -07:00
Yury Semikhatsky e4828d00b6 chore: roll 1.45.0 (#1609) 2024-06-25 09:18:12 -07:00
Yury Semikhatsky a08ab2dcae devops: roll_driver script (#1605) 2024-06-25 08:34:20 -07:00
Jason Wu 626050d988 fix: Update README.md to fix wrong demo code (#1601)
Update README.md to fix wrong demo code

In Mobile and geolocation demo, code `page.click("a[data-original-title=\"Show My Location\"]");` will cause error while running.Because the website already change the attribute.
2024-06-19 09:24:45 -07:00
Yury Semikhatsky 4cc3fa3012 chore: roll driver to 1.45.0 beta, implement new features (#1600) 2024-06-18 17:08:45 -07:00
dependabot[bot] 226d075355 chore(deps): bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.3 to 3.7.0 (#1589) 2024-06-03 15:42:10 -07:00
Yury Semikhatsky 0a759e699e fix(fetch): support json objects with null values (#1587)
Fixes https://github.com/microsoft/playwright-java/issues/1585
2024-05-30 14:46:17 -07:00
Yury Semikhatsky f2a17b6255 devops: install msedge on macosx (#1581) 2024-05-20 16:21:27 -07:00
dependabot[bot] 202bc80d76 chore(deps): bump com.google.code.gson:gson from 2.10.1 to 2.11.0 (#1580) 2024-05-20 16:07:03 -07:00
Yury Semikhatsky 731d8e8dc2 chore: bump dev version to 1.45.0-SNAPSHOT (#1579) 2024-05-17 09:12:49 -07:00
Yury Semikhatsky 75062c4024 chore: roll 1.44.0 (#1575) 2024-05-08 12:10:05 -07:00
Yury Semikhatsky c9ea56a640 devops: stop producing .sha256 files, they are not required anymore (#1570) 2024-05-03 11:03:45 -07:00
Max Schmitt e4c427aa75 devops: fix ESRP publishing (#1569) 2024-05-03 10:55:40 -07:00
Max Schmitt 0471c5e86c devops: update to EsrpRelease@7 (#1566) 2024-05-03 09:03:41 -07:00
Yury Semikhatsky 5636edf69a test: ControlOrMeta modifier (#1564) 2024-05-02 16:30:27 -07:00
dependabot[bot] abfe50ce59 chore(deps): bump org.apache.maven.plugins:maven-jar-plugin from 3.3.0 to 3.4.1 (#1556) 2024-05-01 15:15:23 -07:00
Yury Semikhatsky d72364627b chore: roll driver to 1.44.0-beta-1714435420000 (#1563) 2024-04-30 08:57:03 -07:00
dependabot[bot] fe51fb4cf6 chore(deps): bump org.apache.maven.plugins:maven-install-plugin from 3.1.1 to 3.1.2 (#1562) 2024-04-29 17:02:12 -07:00
dependabot[bot] 764cc8cc8a chore(deps): bump org.apache.maven.plugins:maven-deploy-plugin from 3.1.1 to 3.1.2 (#1561) 2024-04-29 17:01:59 -07:00
Yury Semikhatsky 7b8efadc57 chore: roll driver, implement new features (#1559) 2024-04-27 08:46:04 -07:00
uchagani a654a4234e feat(junit): add ability to connect to remote browsers via fixtures (#1541) 2024-04-22 13:09:33 -07:00
dependabot[bot] 102d337b4a chore(deps): bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.3 to 3.2.4 (#1555) 2024-04-22 11:29:53 -07:00
Max Schmitt f5f9b8a12d devops: migrate to OIDC for Docker publishing (#1554) 2024-04-19 00:13:33 +02:00
Max Schmitt 2f264eab76 fix(cdpSession): events without payload (#1553) 2024-04-17 09:10:55 -07:00
dependabot[bot] 5c17cc49ed chore(deps): bump org.apache.maven.plugins:maven-gpg-plugin from 3.2.2 to 3.2.3 (#1550) 2024-04-16 10:57:00 -07:00
Max Schmitt 8652942482 fix(driver): consider PLAYWRIGHT_NODEJS_PATH from host env (#1552) 2024-04-16 19:54:15 +02:00
dependabot[bot] 2829a37d58 chore(deps): bump org.apache.maven.plugins:maven-source-plugin from 3.3.0 to 3.3.1 (#1543) 2024-04-10 09:19:51 -07:00
124 changed files with 4284 additions and 950 deletions
+19 -23
View File
@@ -47,7 +47,7 @@ extends:
GPG_PRIVATE_KEY_BASE64: $(GPG_PRIVATE_KEY_BASE64) # secret variable has to be mapped to an env variable
displayName: "Import gpg key"
- bash: ./scripts/download_driver_for_all_platforms.sh
- bash: ./scripts/download_driver.sh
displayName: 'Download driver'
- bash: mvn -B deploy -D skipTests --no-transfer-progress --activate-profiles release -D gpg.passphrase=$GPG_PASSPHRASE -DaltDeploymentRepository=snapshot-repo::default::file:$(pwd)/local-build
@@ -55,27 +55,23 @@ extends:
env:
GPG_PASSPHRASE: $(GPG_PASSPHRASE) # secret variable has to be mapped to an env variable
- bash: |
for file in $(find snapshots -type f); do
echo "processing: $file"
if [[ $file =~ \.(md5|sha1|sha256)$ ]]; then
continue
fi
sha256sum "$file" | cut -f1 -d \ > "$file.sha256"
done
displayName: 'Create .sha256 files'
- task: EsrpRelease@4
- task: EsrpRelease@7
inputs:
ConnectedServiceName: 'Playwright-ESRP'
Intent: 'PackageDistribution'
ContentType: 'Maven'
ContentSource: 'Folder'
FolderLocation: './local-build'
WaitForReleaseCompletion: true
Owners: 'yurys@microsoft.com'
Approvers: 'maxschmitt@microsoft.com'
ServiceEndpointUrl: 'https://api.esrp.microsoft.com'
MainPublisher: 'Playwright'
DomainTenantId: '72f988bf-86f1-41af-91ab-2d7cd011db47'
connectedservicename: 'Playwright-ESRP-Azure'
keyvaultname: 'pw-publishing-secrets'
authcertname: 'ESRP-Release-Auth'
signcertname: 'ESRP-Release-Sign'
clientid: '13434a40-7de4-4c23-81a3-d843dc81c2c5'
intent: 'PackageDistribution'
contenttype: 'Maven'
# Keeping it commented out as a workaround for:
# https://portal.microsofticm.com/imp/v3/incidents/incident/499972482/summary
# contentsource: 'folder'
folderlocation: './local-build'
waitforreleasecompletion: true
owners: 'yurys@microsoft.com'
approvers: 'maxschmitt@microsoft.com'
serviceendpointurl: 'https://api.esrp.microsoft.com'
mainpublisher: 'Playwright'
domaintenantid: '72f988bf-86f1-41af-91ab-2d7cd011db47'
displayName: 'ESRP Release to Maven'
+11 -4
View File
@@ -12,14 +12,21 @@ jobs:
publish-canary-docker:
name: publish to DockerHub
runs-on: ubuntu-22.04
permissions:
id-token: write # This is required for OIDC login (azure/login) to succeed
contents: read # This is required for actions/checkout to succeed
environment: Docker
if: github.repository == 'microsoft/playwright-java'
steps:
- uses: actions/checkout@v4
- uses: azure/docker-login@v1
- name: Azure login
uses: azure/login@v2
with:
login-server: playwright.azurecr.io
username: playwright
password: ${{ secrets.DOCKER_PASSWORD }}
client-id: ${{ secrets.AZURE_DOCKER_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_DOCKER_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_DOCKER_SUBSCRIPTION_ID }}
- name: Login to ACR via OIDC
run: az acr login --name playwright
- name: Set up Docker QEMU for arm64 docker builds
uses: docker/setup-qemu-action@v3
with:
+10 -6
View File
@@ -27,7 +27,7 @@ jobs:
java-version: 8
- name: Download drivers
shell: bash
run: scripts/download_driver_for_all_platforms.sh
run: scripts/download_driver.sh
- name: Build & Install
run: mvn -B install -D skipTests --no-transfer-progress
- name: Run tests
@@ -75,16 +75,20 @@ jobs:
java-version: 8
- name: Download drivers
shell: bash
run: scripts/download_driver_for_all_platforms.sh
run: scripts/download_driver.sh
- name: Build & Install
run: mvn -B install -D skipTests --no-transfer-progress
- name: Install MS Edge
if: matrix.browser-channel == 'msedge' && matrix.os == 'macos-latest'
shell: bash
run: mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install msedge" -f playwright/pom.xml
- name: Run tests
run: mvn test --no-transfer-progress --fail-at-end -D org.slf4j.simpleLogger.showDateTime=true -D org.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss
env:
BROWSER: chromium
BROWSER_CHANNEL: ${{ matrix.browser-channel }}
Java_17:
Java_21:
timeout-minutes: 30
strategy:
fail-fast: false
@@ -94,14 +98,14 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 17
java-version: 21
- name: Download drivers
shell: bash
run: scripts/download_driver_for_all_platforms.sh
run: scripts/download_driver.sh
- name: Build & Install
run: mvn -B install -D skipTests --no-transfer-progress
- name: Run tests
+1 -1
View File
@@ -21,7 +21,7 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Download drivers
run: scripts/download_driver_for_all_platforms.sh
run: scripts/download_driver.sh
- name: Intall Playwright
run: mvn install -D skipTests --no-transfer-progress
- name: Test CLI
+1 -1
View File
@@ -11,7 +11,7 @@ on:
paths:
- .github/workflows/test_docker.yml
- '**/Dockerfile*'
- scripts/CLI_VERSION
- scripts/DRIVER_VERSION
- '**/pom.xml'
branches:
- main
+1 -1
View File
@@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1
- name: Download drivers
run: scripts/download_driver_for_all_platforms.sh
run: scripts/download_driver.sh
- name: Regenerate APIs
run: scripts/generate_api.sh
- name: Update browser versions in README
+6 -14
View File
@@ -20,14 +20,12 @@ git clone https://github.com/microsoft/playwright-java
cd playwright-java
```
2. Run the following script to download playwright-cli binaries for all platforms into `driver-bundle/src/main/resources/driver/` directory (browser binaries for Chromium, Firefox and WebKit will be automatically downloaded later on first Playwright run).
2. Run the following script to download Playwright driver for all platforms into `driver-bundle/src/main/resources/driver/` directory (browser binaries for Chromium, Firefox and WebKit will be automatically downloaded later on first Playwright run).
```bash
scripts/download_driver_for_all_platforms.sh
scripts/download_driver.sh
```
Names of published driver archives can be found at https://github.com/microsoft/playwright-cli/actions
### Building and running the tests with Maven
```bash
@@ -41,25 +39,19 @@ BROWSER=chromium mvn test --projects=playwright -Dtest=TestPageNetworkSizes
### Generating API
Public Java API is generated from api.json which is produced by `playwright-cli print-api-json`. To regenerate
Java interfaces for the current driver run the following commands:
Public Java API is generated from api.json which is produced by `print-api-json` command of playwright CLI. To regenerate Java interfaces for the current driver run the following commands:
```bash
./scripts/download_driver_for_all_platforms.sh
./scripts/download_driver.sh
./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:
Versions of published driver archives can be found in [publish canary](https://github.com/microsoft/playwright/actions/workflows/publish_canary.yml) and [publish release](https://github.com/microsoft/playwright/actions/workflows/publish_release_driver.yml) actions logs. To update the driver to a particular version run the following command:
```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
scripts/roll_driver.sh [version]
```
### Code Style
+5 -5
View File
@@ -3,7 +3,7 @@
[![javadoc](https://javadoc.io/badge2/com.microsoft.playwright/playwright/javadoc.svg)](https://javadoc.io/doc/com.microsoft.playwright/playwright)
[![maven version](https://img.shields.io/maven-central/v/com.microsoft.playwright/playwright)](https://search.maven.org/search?q=com.microsoft.playwright)
[![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/com.microsoft.playwright/playwright.svg)](https://oss.sonatype.org/content/repositories/snapshots/com/microsoft/playwright/playwright/)
[![Join Slack](https://img.shields.io/badge/join-slack-infomational)](https://aka.ms/playwright-slack)
[![Join Discord](https://img.shields.io/badge/join-discord-infomational)](https://aka.ms/playwright/discord)
#### [Website](https://playwright.dev/java/) | [API reference](https://www.javadoc.io/doc/com.microsoft.playwright/playwright/latest/index.html)
@@ -11,9 +11,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom
| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->124.0.6367.18<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit <!-- GEN:webkit-version -->17.4<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->124.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Chromium <!-- GEN:chromium-version -->128.0.6613.18<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit <!-- GEN:webkit-version -->18.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->128.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
Headless execution is supported for all the browsers on all platforms. Check out [system requirements](https://playwright.dev/java/docs/intro#system-requirements) for details.
@@ -122,7 +122,7 @@ public class MobileAndGeolocation {
.setPermissions(asList("geolocation")));
Page page = context.newPage();
page.navigate("https://www.openstreetmap.org/");
page.click("a[data-original-title=\"Show My Location\"]");
page.click("a[data-bs-original-title=\"Show My Location\"]");
page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("colosseum-pixel2.png")));
}
}
+2 -2
View File
@@ -2,8 +2,8 @@
* make sure to have at least Java 8 and Maven 3.6.3
* clone playwright for java: http://github.com/microsoft/playwright-java
* set new driver version in `scripts/CLI_VERSION`
* regenerate API: `./scripts/download_driver_for_all_platforms.sh -f && ./scripts/generate_api.sh && ./scripts/update_readme.sh`
* set new driver version in `scripts/DRIVER_VERSION`
* regenerate API: `./scripts/download_driver.sh -f && ./scripts/generate_api.sh && ./scripts/update_readme.sh`
* commit & send PR with the roll
### Finding driver version
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.43.0-SNAPSHOT</version>
<version>1.46.0</version>
</parent>
<artifactId>driver-bundle</artifactId>
@@ -74,7 +74,7 @@ public class DriverJar extends Driver {
skip = System.getenv(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD);
}
if (skip != null && !"0".equals(skip) && !"false".equals(skip)) {
System.out.println("Skipping browsers download because `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` env variable is set");
logMessage("Skipping browsers download because `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` env variable is set");
return;
}
if (env.get(SELENIUM_REMOTE_URL) != null || System.getenv(SELENIUM_REMOTE_URL) != null) {
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.43.0-SNAPSHOT</version>
<version>1.46.0</version>
</parent>
<artifactId>driver</artifactId>
@@ -18,7 +18,6 @@ package com.microsoft.playwright.impl.driver;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -30,7 +29,7 @@ import static com.microsoft.playwright.impl.driver.DriverLogging.logWithTimestam
* loaded from the driver-bundle module if that module is in the classpath.
*/
public abstract class Driver {
protected final Map<String, String> env = new LinkedHashMap<>();
protected final Map<String, String> env = new LinkedHashMap<>(System.getenv());
public static final String PLAYWRIGHT_NODEJS_PATH = "PLAYWRIGHT_NODEJS_PATH";
private static Driver instance;
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>org.example</groupId>
<artifactId>examples</artifactId>
<version>1.43.0-SNAPSHOT</version>
<version>1.46.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.43.0-SNAPSHOT</version>
<version>1.46.0</version>
</parent>
<artifactId>playwright</artifactId>
@@ -41,6 +41,22 @@ public interface APIRequest {
* </ul>
*/
public String baseURL;
/**
* TLS Client Authentication allows the server to request a client certificate and verify it.
*
* <p> <strong>Details</strong>
*
* <p> An array of client certificates to be used. Each certificate object must have both {@code certPath} and {@code keyPath}
* or a single {@code pfxPath} to load the client certificate. Optionally, {@code passphrase} property should be provided
* if the certficiate is encrypted. The {@code origin} property should be provided with an exact match to the request
* origin that the certificate is valid for.
*
* <p> <strong>NOTE:</strong> Using Client Certificates in combination with Proxy Servers is not supported.
*
* <p> <strong>NOTE:</strong> When using WebKit on macOS, accessing {@code localhost} will not pick up client certificates. You can make it work by
* replacing {@code localhost} with {@code local.playwright}.
*/
public List<ClientCertificate> clientCertificates;
/**
* An object containing additional HTTP headers to be sent with every request. Defaults to none.
*/
@@ -100,6 +116,25 @@ public interface APIRequest {
this.baseURL = baseURL;
return this;
}
/**
* TLS Client Authentication allows the server to request a client certificate and verify it.
*
* <p> <strong>Details</strong>
*
* <p> An array of client certificates to be used. Each certificate object must have both {@code certPath} and {@code keyPath}
* or a single {@code pfxPath} to load the client certificate. Optionally, {@code passphrase} property should be provided
* if the certficiate is encrypted. The {@code origin} property should be provided with an exact match to the request
* origin that the certificate is valid for.
*
* <p> <strong>NOTE:</strong> Using Client Certificates in combination with Proxy Servers is not supported.
*
* <p> <strong>NOTE:</strong> When using WebKit on macOS, accessing {@code localhost} will not pick up client certificates. You can make it work by
* replacing {@code localhost} with {@code local.playwright}.
*/
public NewContextOptions setClientCertificates(List<ClientCertificate> clientCertificates) {
this.clientCertificates = clientCertificates;
return this;
}
/**
* An object containing additional HTTP headers to be sent with every request. Defaults to none.
*/
@@ -43,6 +43,20 @@ import java.nio.file.Path;
* object will have its own isolated cookie storage.
*/
public interface APIRequestContext {
class DisposeOptions {
/**
* The reason to be reported to the operations interrupted by the context disposal.
*/
public String reason;
/**
* The reason to be reported to the operations interrupted by the context disposal.
*/
public DisposeOptions setReason(String reason) {
this.reason = reason;
return this;
}
}
class StorageStateOptions {
/**
* The file path to save the storage state to. If {@code path} is a relative path, then it is resolved relative to current
@@ -88,13 +102,25 @@ public interface APIRequestContext {
*
* @since v1.16
*/
void dispose();
default void dispose() {
dispose(null);
}
/**
* All responses returned by {@link com.microsoft.playwright.APIRequestContext#get APIRequestContext.get()} and similar
* methods are stored in the memory, so that you can later call {@link com.microsoft.playwright.APIResponse#body
* APIResponse.body()}.This method discards all its resources, calling any method on disposed {@code APIRequestContext}
* will throw an exception.
*
* @since v1.16
*/
void dispose(DisposeOptions options);
/**
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
* context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly
* to the request.
* context cookies from the response. The method will automatically follow redirects.
*
* <p> <strong>Usage</strong>
*
* <p> JSON objects can be passed directly to the request:
* <pre>{@code
* Map<String, Object> data = new HashMap();
* data.put("title", "Book Title");
@@ -102,8 +128,9 @@ public interface APIRequestContext {
* request.fetch("https://example.com/api/createBook", RequestOptions.create().setMethod("post").setData(data));
* }</pre>
*
* <p> The common way to send file(s) in the body of a request is to encode it as form fields with {@code multipart/form-data}
* encoding. You can achieve that with Playwright API like this:
* <p> The common way to send file(s) in the body of a request is to upload them as form fields with {@code
* multipart/form-data} encoding. Use {@code FormData} to construct request body and pass it to the request as {@code
* multipart} parameter:
* <pre>{@code
* // Pass file path to the form data constructor:
* Path file = Paths.get("team.csv");
@@ -114,7 +141,7 @@ public interface APIRequestContext {
* // Or you can pass the file content directly as FilePayload object:
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
* APIResponse response = request.fetch("https://example.com/api/uploadScript",
* RequestOptions.create().setMethod("post").setMultipart(
* FormData.create().set("fileField", filePayload)));
* }</pre>
@@ -127,10 +154,11 @@ public interface APIRequestContext {
}
/**
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
* context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly
* to the request.
* context cookies from the response. The method will automatically follow redirects.
*
* <p> <strong>Usage</strong>
*
* <p> JSON objects can be passed directly to the request:
* <pre>{@code
* Map<String, Object> data = new HashMap();
* data.put("title", "Book Title");
@@ -138,8 +166,9 @@ public interface APIRequestContext {
* request.fetch("https://example.com/api/createBook", RequestOptions.create().setMethod("post").setData(data));
* }</pre>
*
* <p> The common way to send file(s) in the body of a request is to encode it as form fields with {@code multipart/form-data}
* encoding. You can achieve that with Playwright API like this:
* <p> The common way to send file(s) in the body of a request is to upload them as form fields with {@code
* multipart/form-data} encoding. Use {@code FormData} to construct request body and pass it to the request as {@code
* multipart} parameter:
* <pre>{@code
* // Pass file path to the form data constructor:
* Path file = Paths.get("team.csv");
@@ -150,7 +179,7 @@ public interface APIRequestContext {
* // Or you can pass the file content directly as FilePayload object:
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
* APIResponse response = request.fetch("https://example.com/api/uploadScript",
* RequestOptions.create().setMethod("post").setMultipart(
* FormData.create().set("fileField", filePayload)));
* }</pre>
@@ -162,10 +191,11 @@ public interface APIRequestContext {
APIResponse fetch(String urlOrRequest, RequestOptions params);
/**
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
* context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly
* to the request.
* context cookies from the response. The method will automatically follow redirects.
*
* <p> <strong>Usage</strong>
*
* <p> JSON objects can be passed directly to the request:
* <pre>{@code
* Map<String, Object> data = new HashMap();
* data.put("title", "Book Title");
@@ -173,8 +203,9 @@ public interface APIRequestContext {
* request.fetch("https://example.com/api/createBook", RequestOptions.create().setMethod("post").setData(data));
* }</pre>
*
* <p> The common way to send file(s) in the body of a request is to encode it as form fields with {@code multipart/form-data}
* encoding. You can achieve that with Playwright API like this:
* <p> The common way to send file(s) in the body of a request is to upload them as form fields with {@code
* multipart/form-data} encoding. Use {@code FormData} to construct request body and pass it to the request as {@code
* multipart} parameter:
* <pre>{@code
* // Pass file path to the form data constructor:
* Path file = Paths.get("team.csv");
@@ -185,7 +216,7 @@ public interface APIRequestContext {
* // Or you can pass the file content directly as FilePayload object:
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
* APIResponse response = request.fetch("https://example.com/api/uploadScript",
* RequestOptions.create().setMethod("post").setMultipart(
* FormData.create().set("fileField", filePayload)));
* }</pre>
@@ -198,10 +229,11 @@ public interface APIRequestContext {
}
/**
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
* context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly
* to the request.
* context cookies from the response. The method will automatically follow redirects.
*
* <p> <strong>Usage</strong>
*
* <p> JSON objects can be passed directly to the request:
* <pre>{@code
* Map<String, Object> data = new HashMap();
* data.put("title", "Book Title");
@@ -209,8 +241,9 @@ public interface APIRequestContext {
* request.fetch("https://example.com/api/createBook", RequestOptions.create().setMethod("post").setData(data));
* }</pre>
*
* <p> The common way to send file(s) in the body of a request is to encode it as form fields with {@code multipart/form-data}
* encoding. You can achieve that with Playwright API like this:
* <p> The common way to send file(s) in the body of a request is to upload them as form fields with {@code
* multipart/form-data} encoding. Use {@code FormData} to construct request body and pass it to the request as {@code
* multipart} parameter:
* <pre>{@code
* // Pass file path to the form data constructor:
* Path file = Paths.get("team.csv");
@@ -221,7 +254,7 @@ public interface APIRequestContext {
* // Or you can pass the file content directly as FilePayload object:
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
* APIResponse response = request.fetch("https://example.com/api/uploadScript",
* RequestOptions.create().setMethod("post").setMultipart(
* FormData.create().set("fileField", filePayload)));
* }</pre>
@@ -337,7 +370,8 @@ public interface APIRequestContext {
* }</pre>
*
* <p> The common way to send file(s) in the body of a request is to upload them as form fields with {@code
* multipart/form-data} encoding. You can achieve that with Playwright API like this:
* multipart/form-data} encoding. Use {@code FormData} to construct request body and pass it to the request as {@code
* multipart} parameter:
* <pre>{@code
* // Pass file path to the form data constructor:
* Path file = Paths.get("team.csv");
@@ -346,9 +380,9 @@ public interface APIRequestContext {
* FormData.create().set("fileField", file)));
*
* // Or you can pass the file content directly as FilePayload object:
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
* FilePayload filePayload1 = new FilePayload("f1.js", "text/javascript",
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
* APIResponse response = request.post("https://example.com/api/uploadTeamList",
* APIResponse response = request.post("https://example.com/api/uploadScript",
* RequestOptions.create().setMultipart(
* FormData.create().set("fileField", filePayload)));
* }</pre>
@@ -384,7 +418,8 @@ public interface APIRequestContext {
* }</pre>
*
* <p> The common way to send file(s) in the body of a request is to upload them as form fields with {@code
* multipart/form-data} encoding. You can achieve that with Playwright API like this:
* multipart/form-data} encoding. Use {@code FormData} to construct request body and pass it to the request as {@code
* multipart} parameter:
* <pre>{@code
* // Pass file path to the form data constructor:
* Path file = Paths.get("team.csv");
@@ -393,9 +428,9 @@ public interface APIRequestContext {
* FormData.create().set("fileField", file)));
*
* // Or you can pass the file content directly as FilePayload object:
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
* FilePayload filePayload1 = new FilePayload("f1.js", "text/javascript",
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
* APIResponse response = request.post("https://example.com/api/uploadTeamList",
* APIResponse response = request.post("https://example.com/api/uploadScript",
* RequestOptions.create().setMultipart(
* FormData.create().set("fileField", filePayload)));
* }</pre>
@@ -96,6 +96,22 @@ public interface Browser extends AutoCloseable {
* Toggles bypassing page's Content-Security-Policy. Defaults to {@code false}.
*/
public Boolean bypassCSP;
/**
* TLS Client Authentication allows the server to request a client certificate and verify it.
*
* <p> <strong>Details</strong>
*
* <p> An array of client certificates to be used. Each certificate object must have both {@code certPath} and {@code keyPath}
* or a single {@code pfxPath} to load the client certificate. Optionally, {@code passphrase} property should be provided
* if the certficiate is encrypted. The {@code origin} property should be provided with an exact match to the request
* origin that the certificate is valid for.
*
* <p> <strong>NOTE:</strong> Using Client Certificates in combination with Proxy Servers is not supported.
*
* <p> <strong>NOTE:</strong> When using WebKit on macOS, accessing {@code localhost} will not pick up client certificates. You can make it work by
* replacing {@code localhost} with {@code local.playwright}.
*/
public List<ClientCertificate> clientCertificates;
/**
* Emulates {@code "prefers-colors-scheme"} media feature, supported values are {@code "light"}, {@code "dark"}, {@code
* "no-preference"}. See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing
@@ -295,6 +311,25 @@ public interface Browser extends AutoCloseable {
this.bypassCSP = bypassCSP;
return this;
}
/**
* TLS Client Authentication allows the server to request a client certificate and verify it.
*
* <p> <strong>Details</strong>
*
* <p> An array of client certificates to be used. Each certificate object must have both {@code certPath} and {@code keyPath}
* or a single {@code pfxPath} to load the client certificate. Optionally, {@code passphrase} property should be provided
* if the certficiate is encrypted. The {@code origin} property should be provided with an exact match to the request
* origin that the certificate is valid for.
*
* <p> <strong>NOTE:</strong> Using Client Certificates in combination with Proxy Servers is not supported.
*
* <p> <strong>NOTE:</strong> When using WebKit on macOS, accessing {@code localhost} will not pick up client certificates. You can make it work by
* replacing {@code localhost} with {@code local.playwright}.
*/
public NewContextOptions setClientCertificates(List<ClientCertificate> clientCertificates) {
this.clientCertificates = clientCertificates;
return this;
}
/**
* Emulates {@code "prefers-colors-scheme"} media feature, supported values are {@code "light"}, {@code "dark"}, {@code
* "no-preference"}. See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing
@@ -626,6 +661,22 @@ public interface Browser extends AutoCloseable {
* Toggles bypassing page's Content-Security-Policy. Defaults to {@code false}.
*/
public Boolean bypassCSP;
/**
* TLS Client Authentication allows the server to request a client certificate and verify it.
*
* <p> <strong>Details</strong>
*
* <p> An array of client certificates to be used. Each certificate object must have both {@code certPath} and {@code keyPath}
* or a single {@code pfxPath} to load the client certificate. Optionally, {@code passphrase} property should be provided
* if the certficiate is encrypted. The {@code origin} property should be provided with an exact match to the request
* origin that the certificate is valid for.
*
* <p> <strong>NOTE:</strong> Using Client Certificates in combination with Proxy Servers is not supported.
*
* <p> <strong>NOTE:</strong> When using WebKit on macOS, accessing {@code localhost} will not pick up client certificates. You can make it work by
* replacing {@code localhost} with {@code local.playwright}.
*/
public List<ClientCertificate> clientCertificates;
/**
* Emulates {@code "prefers-colors-scheme"} media feature, supported values are {@code "light"}, {@code "dark"}, {@code
* "no-preference"}. See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing
@@ -825,6 +876,25 @@ public interface Browser extends AutoCloseable {
this.bypassCSP = bypassCSP;
return this;
}
/**
* TLS Client Authentication allows the server to request a client certificate and verify it.
*
* <p> <strong>Details</strong>
*
* <p> An array of client certificates to be used. Each certificate object must have both {@code certPath} and {@code keyPath}
* or a single {@code pfxPath} to load the client certificate. Optionally, {@code passphrase} property should be provided
* if the certficiate is encrypted. The {@code origin} property should be provided with an exact match to the request
* origin that the certificate is valid for.
*
* <p> <strong>NOTE:</strong> Using Client Certificates in combination with Proxy Servers is not supported.
*
* <p> <strong>NOTE:</strong> When using WebKit on macOS, accessing {@code localhost} will not pick up client certificates. You can make it work by
* replacing {@code localhost} with {@code local.playwright}.
*/
public NewPageOptions setClientCertificates(List<ClientCertificate> clientCertificates) {
this.clientCertificates = clientCertificates;
return this;
}
/**
* Emulates {@code "prefers-colors-scheme"} media feature, supported values are {@code "light"}, {@code "dark"}, {@code
* "no-preference"}. See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing
@@ -49,10 +49,9 @@ public interface BrowserContext extends AutoCloseable {
*
* <p> Emitted when new background page is created in the context.
* <pre>{@code
* Page backgroundPage = context.waitForBackgroundPage(() -> {
* page.getByText("activate extension").click();
* context.onBackgroundPage(backgroundPage -> {
* System.out.println(backgroundPage.url());
* });
* System.out.println(backgroundPage.evaluate("location.href"));
* }</pre>
*/
void onBackgroundPage(Consumer<Page> handler);
@@ -128,7 +127,10 @@ public interface BrowserContext extends AutoCloseable {
*
* <p> The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
* popup with {@code window.open('http://example.com')}, this event will fire when the network request to
* "http://example.com" is done and its response has started loading in the popup.
* "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen to
* this network request, use {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} and {@link
* com.microsoft.playwright.BrowserContext#onRequest BrowserContext.onRequest()} respectively instead of similar methods on
* the {@code Page}.
* <pre>{@code
* Page newPage = context.waitForPage(() -> {
* page.getByText("open new page").click();
@@ -277,14 +279,12 @@ public interface BrowserContext extends AutoCloseable {
}
class ExposeBindingOptions {
/**
* Whether to pass the argument as a handle, instead of passing by value. When passing a handle, only one argument is
* supported. When passing by value, multiple arguments are supported.
* @deprecated This option will be removed in the future.
*/
public Boolean handle;
/**
* Whether to pass the argument as a handle, instead of passing by value. When passing a handle, only one argument is
* supported. When passing by value, multiple arguments are supported.
* @deprecated This option will be removed in the future.
*/
public ExposeBindingOptions setHandle(boolean handle) {
this.handle = handle;
@@ -499,6 +499,12 @@ public interface BrowserContext extends AutoCloseable {
return this;
}
}
/**
* Playwright has ability to mock clock and passage of time.
*
* @since v1.45
*/
Clock clock();
/**
* Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be
* obtained via {@link com.microsoft.playwright.BrowserContext#cookies BrowserContext.cookies()}.
@@ -508,9 +514,6 @@ public interface BrowserContext extends AutoCloseable {
* browserContext.addCookies(Arrays.asList(cookieObject1, cookieObject2));
* }</pre>
*
* @param cookies Adds cookies to the browser context.
*
* <p> For the cookie to apply to all subdomains as well, prefix domain with a dot, like this: ".example.com".
* @since v1.8
*/
void addCookies(List<Cookie> cookies);
@@ -715,21 +718,6 @@ public interface BrowserContext extends AutoCloseable {
* }
* }</pre>
*
* <p> An example of passing an element handle:
* <pre>{@code
* context.exposeBinding("clicked", (source, args) -> {
* ElementHandle element = (ElementHandle) args[0];
* System.out.println(element.textContent());
* return null;
* }, new BrowserContext.ExposeBindingOptions().setHandle(true));
* page.setContent("" +
* "<script>\n" +
* " document.addEventListener('click', event => window.clicked(event.target));\n" +
* "</script>\n" +
* "<div>Click me</div>\n" +
* "<div>Or click me</div>\n");
* }</pre>
*
* @param name Name of the function on the window object.
* @param callback Callback function that will be called in the Playwright's context.
* @since v1.8
@@ -777,21 +765,6 @@ public interface BrowserContext extends AutoCloseable {
* }
* }</pre>
*
* <p> An example of passing an element handle:
* <pre>{@code
* context.exposeBinding("clicked", (source, args) -> {
* ElementHandle element = (ElementHandle) args[0];
* System.out.println(element.textContent());
* return null;
* }, new BrowserContext.ExposeBindingOptions().setHandle(true));
* page.setContent("" +
* "<script>\n" +
* " document.addEventListener('click', event => window.clicked(event.target));\n" +
* "</script>\n" +
* "<div>Click me</div>\n" +
* "<div>Or click me</div>\n");
* }</pre>
*
* @param name Name of the function on the window object.
* @param callback Callback function that will be called in the Playwright's context.
* @since v1.8
@@ -861,21 +834,22 @@ public interface BrowserContext extends AutoCloseable {
*
* @param permissions A permission or an array of permissions to grant. Permissions can be one of the following values:
* <ul>
* <li> {@code "geolocation"}</li>
* <li> {@code "midi"}</li>
* <li> {@code "midi-sysex"} (system-exclusive midi)</li>
* <li> {@code "notifications"}</li>
* <li> {@code "camera"}</li>
* <li> {@code "microphone"}</li>
* <li> {@code "background-sync"}</li>
* <li> {@code "ambient-light-sensor"}</li>
* <li> {@code "accelerometer"}</li>
* <li> {@code "gyroscope"}</li>
* <li> {@code "magnetometer"}</li>
* <li> {@code "accessibility-events"}</li>
* <li> {@code "ambient-light-sensor"}</li>
* <li> {@code "background-sync"}</li>
* <li> {@code "camera"}</li>
* <li> {@code "clipboard-read"}</li>
* <li> {@code "clipboard-write"}</li>
* <li> {@code "geolocation"}</li>
* <li> {@code "gyroscope"}</li>
* <li> {@code "magnetometer"}</li>
* <li> {@code "microphone"}</li>
* <li> {@code "midi-sysex"} (system-exclusive midi)</li>
* <li> {@code "midi"}</li>
* <li> {@code "notifications"}</li>
* <li> {@code "payment-handler"}</li>
* <li> {@code "storage-access"}</li>
* </ul>
* @since v1.8
*/
@@ -888,21 +862,22 @@ public interface BrowserContext extends AutoCloseable {
*
* @param permissions A permission or an array of permissions to grant. Permissions can be one of the following values:
* <ul>
* <li> {@code "geolocation"}</li>
* <li> {@code "midi"}</li>
* <li> {@code "midi-sysex"} (system-exclusive midi)</li>
* <li> {@code "notifications"}</li>
* <li> {@code "camera"}</li>
* <li> {@code "microphone"}</li>
* <li> {@code "background-sync"}</li>
* <li> {@code "ambient-light-sensor"}</li>
* <li> {@code "accelerometer"}</li>
* <li> {@code "gyroscope"}</li>
* <li> {@code "magnetometer"}</li>
* <li> {@code "accessibility-events"}</li>
* <li> {@code "ambient-light-sensor"}</li>
* <li> {@code "background-sync"}</li>
* <li> {@code "camera"}</li>
* <li> {@code "clipboard-read"}</li>
* <li> {@code "clipboard-write"}</li>
* <li> {@code "geolocation"}</li>
* <li> {@code "gyroscope"}</li>
* <li> {@code "magnetometer"}</li>
* <li> {@code "microphone"}</li>
* <li> {@code "midi-sysex"} (system-exclusive midi)</li>
* <li> {@code "midi"}</li>
* <li> {@code "notifications"}</li>
* <li> {@code "payment-handler"}</li>
* <li> {@code "storage-access"}</li>
* </ul>
* @since v1.8
*/
@@ -455,6 +455,22 @@ public interface BrowserType {
* Enable Chromium sandboxing. Defaults to {@code false}.
*/
public Boolean chromiumSandbox;
/**
* TLS Client Authentication allows the server to request a client certificate and verify it.
*
* <p> <strong>Details</strong>
*
* <p> An array of client certificates to be used. Each certificate object must have both {@code certPath} and {@code keyPath}
* or a single {@code pfxPath} to load the client certificate. Optionally, {@code passphrase} property should be provided
* if the certficiate is encrypted. The {@code origin} property should be provided with an exact match to the request
* origin that the certificate is valid for.
*
* <p> <strong>NOTE:</strong> Using Client Certificates in combination with Proxy Servers is not supported.
*
* <p> <strong>NOTE:</strong> When using WebKit on macOS, accessing {@code localhost} will not pick up client certificates. You can make it work by
* replacing {@code localhost} with {@code local.playwright}.
*/
public List<ClientCertificate> clientCertificates;
/**
* Emulates {@code "prefers-colors-scheme"} media feature, supported values are {@code "light"}, {@code "dark"}, {@code
* "no-preference"}. See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing
@@ -742,6 +758,25 @@ public interface BrowserType {
this.chromiumSandbox = chromiumSandbox;
return this;
}
/**
* TLS Client Authentication allows the server to request a client certificate and verify it.
*
* <p> <strong>Details</strong>
*
* <p> An array of client certificates to be used. Each certificate object must have both {@code certPath} and {@code keyPath}
* or a single {@code pfxPath} to load the client certificate. Optionally, {@code passphrase} property should be provided
* if the certficiate is encrypted. The {@code origin} property should be provided with an exact match to the request
* origin that the certificate is valid for.
*
* <p> <strong>NOTE:</strong> Using Client Certificates in combination with Proxy Servers is not supported.
*
* <p> <strong>NOTE:</strong> When using WebKit on macOS, accessing {@code localhost} will not pick up client certificates. You can make it work by
* replacing {@code localhost} with {@code local.playwright}.
*/
public LaunchPersistentContextOptions setClientCertificates(List<ClientCertificate> clientCertificates) {
this.clientCertificates = clientCertificates;
return this;
}
/**
* Emulates {@code "prefers-colors-scheme"} media feature, supported values are {@code "light"}, {@code "dark"}, {@code
* "no-preference"}. See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing
@@ -0,0 +1,312 @@
/*
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.microsoft.playwright;
import java.util.Date;
/**
* Accurately simulating time-dependent behavior is essential for verifying the correctness of applications. Learn more
* about <a href="https://playwright.dev/java/docs/clock">clock emulation</a>.
*
* <p> Note that clock is installed for the entire {@code BrowserContext}, so the time in all the pages and iframes is
* controlled by the same clock.
*/
public interface Clock {
class InstallOptions {
/**
* Time to initialize with, current system time by default.
*/
public Object time;
/**
* Time to initialize with, current system time by default.
*/
public InstallOptions setTime(long time) {
this.time = time;
return this;
}
/**
* Time to initialize with, current system time by default.
*/
public InstallOptions setTime(String time) {
this.time = time;
return this;
}
/**
* Time to initialize with, current system time by default.
*/
public InstallOptions setTime(Date time) {
this.time = time;
return this;
}
}
/**
* Advance the clock by jumping forward in time. Only fires due timers at most once. This is equivalent to user closing the
* laptop lid for a while and reopening it later, after given time.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* page.clock().fastForward(1000);
* page.clock().fastForward("30:00");
* }</pre>
*
* @param ticks Time may be the number of milliseconds to advance the clock by or a human-readable string. Valid string formats are "08"
* for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds.
* @since v1.45
*/
void fastForward(long ticks);
/**
* Advance the clock by jumping forward in time. Only fires due timers at most once. This is equivalent to user closing the
* laptop lid for a while and reopening it later, after given time.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* page.clock().fastForward(1000);
* page.clock().fastForward("30:00");
* }</pre>
*
* @param ticks Time may be the number of milliseconds to advance the clock by or a human-readable string. Valid string formats are "08"
* for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds.
* @since v1.45
*/
void fastForward(String ticks);
/**
* Install fake implementations for the following time-related functions:
* <ul>
* <li> {@code Date}</li>
* <li> {@code setTimeout}</li>
* <li> {@code clearTimeout}</li>
* <li> {@code setInterval}</li>
* <li> {@code clearInterval}</li>
* <li> {@code requestAnimationFrame}</li>
* <li> {@code cancelAnimationFrame}</li>
* <li> {@code requestIdleCallback}</li>
* <li> {@code cancelIdleCallback}</li>
* <li> {@code performance}</li>
* </ul>
*
* <p> Fake timers are used to manually control the flow of time in tests. They allow you to advance time, fire timers, and
* control the behavior of time-dependent functions. See {@link com.microsoft.playwright.Clock#runFor Clock.runFor()} and
* {@link com.microsoft.playwright.Clock#fastForward Clock.fastForward()} for more information.
*
* @since v1.45
*/
default void install() {
install(null);
}
/**
* Install fake implementations for the following time-related functions:
* <ul>
* <li> {@code Date}</li>
* <li> {@code setTimeout}</li>
* <li> {@code clearTimeout}</li>
* <li> {@code setInterval}</li>
* <li> {@code clearInterval}</li>
* <li> {@code requestAnimationFrame}</li>
* <li> {@code cancelAnimationFrame}</li>
* <li> {@code requestIdleCallback}</li>
* <li> {@code cancelIdleCallback}</li>
* <li> {@code performance}</li>
* </ul>
*
* <p> Fake timers are used to manually control the flow of time in tests. They allow you to advance time, fire timers, and
* control the behavior of time-dependent functions. See {@link com.microsoft.playwright.Clock#runFor Clock.runFor()} and
* {@link com.microsoft.playwright.Clock#fastForward Clock.fastForward()} for more information.
*
* @since v1.45
*/
void install(InstallOptions options);
/**
* Advance the clock, firing all the time-related callbacks.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* page.clock().runFor(1000);
* page.clock().runFor("30:00");
* }</pre>
*
* @param ticks Time may be the number of milliseconds to advance the clock by or a human-readable string. Valid string formats are "08"
* for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds.
* @since v1.45
*/
void runFor(long ticks);
/**
* Advance the clock, firing all the time-related callbacks.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* page.clock().runFor(1000);
* page.clock().runFor("30:00");
* }</pre>
*
* @param ticks Time may be the number of milliseconds to advance the clock by or a human-readable string. Valid string formats are "08"
* for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds.
* @since v1.45
*/
void runFor(String ticks);
/**
* Advance the clock by jumping forward in time and pause the time. Once this method is called, no timers are fired unless
* {@link com.microsoft.playwright.Clock#runFor Clock.runFor()}, {@link com.microsoft.playwright.Clock#fastForward
* Clock.fastForward()}, {@link com.microsoft.playwright.Clock#pauseAt Clock.pauseAt()} or {@link
* com.microsoft.playwright.Clock#resume Clock.resume()} is called.
*
* <p> Only fires due timers at most once. This is equivalent to user closing the laptop lid for a while and reopening it at
* the specified time and pausing.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* SimpleDateFormat format = new SimpleDateFormat("yyy-MM-dd");
* page.clock().pauseAt(format.parse("2020-02-02"));
* page.clock().pauseAt("2020-02-02");
* }</pre>
*
* @param time Time to pause at.
* @since v1.45
*/
void pauseAt(long time);
/**
* Advance the clock by jumping forward in time and pause the time. Once this method is called, no timers are fired unless
* {@link com.microsoft.playwright.Clock#runFor Clock.runFor()}, {@link com.microsoft.playwright.Clock#fastForward
* Clock.fastForward()}, {@link com.microsoft.playwright.Clock#pauseAt Clock.pauseAt()} or {@link
* com.microsoft.playwright.Clock#resume Clock.resume()} is called.
*
* <p> Only fires due timers at most once. This is equivalent to user closing the laptop lid for a while and reopening it at
* the specified time and pausing.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* SimpleDateFormat format = new SimpleDateFormat("yyy-MM-dd");
* page.clock().pauseAt(format.parse("2020-02-02"));
* page.clock().pauseAt("2020-02-02");
* }</pre>
*
* @param time Time to pause at.
* @since v1.45
*/
void pauseAt(String time);
/**
* Advance the clock by jumping forward in time and pause the time. Once this method is called, no timers are fired unless
* {@link com.microsoft.playwright.Clock#runFor Clock.runFor()}, {@link com.microsoft.playwright.Clock#fastForward
* Clock.fastForward()}, {@link com.microsoft.playwright.Clock#pauseAt Clock.pauseAt()} or {@link
* com.microsoft.playwright.Clock#resume Clock.resume()} is called.
*
* <p> Only fires due timers at most once. This is equivalent to user closing the laptop lid for a while and reopening it at
* the specified time and pausing.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* SimpleDateFormat format = new SimpleDateFormat("yyy-MM-dd");
* page.clock().pauseAt(format.parse("2020-02-02"));
* page.clock().pauseAt("2020-02-02");
* }</pre>
*
* @param time Time to pause at.
* @since v1.45
*/
void pauseAt(Date time);
/**
* Resumes timers. Once this method is called, time resumes flowing, timers are fired as usual.
*
* @since v1.45
*/
void resume();
/**
* Makes {@code Date.now} and {@code new Date()} return fixed fake time at all times, keeps all the timers running.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* page.clock().setFixedTime(new Date());
* page.clock().setFixedTime(new SimpleDateFormat("yyy-MM-dd").parse("2020-02-02"));
* page.clock().setFixedTime("2020-02-02");
* }</pre>
*
* @param time Time to be set in milliseconds.
* @since v1.45
*/
void setFixedTime(long time);
/**
* Makes {@code Date.now} and {@code new Date()} return fixed fake time at all times, keeps all the timers running.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* page.clock().setFixedTime(new Date());
* page.clock().setFixedTime(new SimpleDateFormat("yyy-MM-dd").parse("2020-02-02"));
* page.clock().setFixedTime("2020-02-02");
* }</pre>
*
* @param time Time to be set in milliseconds.
* @since v1.45
*/
void setFixedTime(String time);
/**
* Makes {@code Date.now} and {@code new Date()} return fixed fake time at all times, keeps all the timers running.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* page.clock().setFixedTime(new Date());
* page.clock().setFixedTime(new SimpleDateFormat("yyy-MM-dd").parse("2020-02-02"));
* page.clock().setFixedTime("2020-02-02");
* }</pre>
*
* @param time Time to be set in milliseconds.
* @since v1.45
*/
void setFixedTime(Date time);
/**
* Sets current system time but does not trigger any timers.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* page.clock().setSystemTime(new Date());
* page.clock().setSystemTime(new SimpleDateFormat("yyy-MM-dd").parse("2020-02-02"));
* page.clock().setSystemTime("2020-02-02");
* }</pre>
*
* @param time Time to be set in milliseconds.
* @since v1.45
*/
void setSystemTime(long time);
/**
* Sets current system time but does not trigger any timers.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* page.clock().setSystemTime(new Date());
* page.clock().setSystemTime(new SimpleDateFormat("yyy-MM-dd").parse("2020-02-02"));
* page.clock().setSystemTime("2020-02-02");
* }</pre>
*
* @param time Time to be set in milliseconds.
* @since v1.45
*/
void setSystemTime(String time);
/**
* Sets current system time but does not trigger any timers.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* page.clock().setSystemTime(new Date());
* page.clock().setSystemTime(new SimpleDateFormat("yyy-MM-dd").parse("2020-02-02"));
* page.clock().setSystemTime("2020-02-02");
* }</pre>
*
* @param time Time to be set in milliseconds.
* @since v1.45
*/
void setSystemTime(Date time);
}
@@ -20,7 +20,7 @@ import java.util.*;
/**
* {@code ConsoleMessage} objects are dispatched by page via the {@link com.microsoft.playwright.Page#onConsoleMessage
* Page.onConsoleMessage()} event. For each console messages logged in the page there will be corresponding event in the
* Page.onConsoleMessage()} event. For each console message logged in the page there will be corresponding event in the
* Playwright context.
* <pre>{@code
* // Listen for all console messages and print them to the standard output.
@@ -65,9 +65,7 @@ public interface ElementHandle extends JSHandle {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -98,9 +96,7 @@ public interface ElementHandle extends JSHandle {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public CheckOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -161,13 +157,12 @@ public interface ElementHandle extends JSHandle {
public Boolean force;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public Boolean noWaitAfter;
/**
@@ -220,16 +215,15 @@ public interface ElementHandle extends JSHandle {
}
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public ClickOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public ClickOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -286,13 +280,12 @@ public interface ElementHandle extends JSHandle {
public Boolean force;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -338,16 +331,15 @@ public interface ElementHandle extends JSHandle {
}
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public DblclickOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public DblclickOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -395,9 +387,7 @@ public interface ElementHandle extends JSHandle {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -417,9 +407,7 @@ public interface ElementHandle extends JSHandle {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public FillOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -444,13 +432,12 @@ public interface ElementHandle extends JSHandle {
public Boolean force;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -482,16 +469,15 @@ public interface ElementHandle extends JSHandle {
}
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public HoverOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public HoverOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -558,9 +544,7 @@ public interface ElementHandle extends JSHandle {
*/
public Double delay;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public Boolean noWaitAfter;
/**
@@ -579,9 +563,7 @@ public interface ElementHandle extends JSHandle {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public PressOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -795,9 +777,7 @@ public interface ElementHandle extends JSHandle {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public Boolean noWaitAfter;
/**
@@ -817,9 +797,7 @@ public interface ElementHandle extends JSHandle {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public SelectOptionOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -876,9 +854,7 @@ public interface ElementHandle extends JSHandle {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -909,9 +885,7 @@ public interface ElementHandle extends JSHandle {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public SetCheckedOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -954,9 +928,7 @@ public interface ElementHandle extends JSHandle {
}
class SetInputFilesOptions {
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -968,9 +940,7 @@ public interface ElementHandle extends JSHandle {
public Double timeout;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public SetInputFilesOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -995,13 +965,12 @@ public interface ElementHandle extends JSHandle {
public Boolean force;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -1033,16 +1002,15 @@ public interface ElementHandle extends JSHandle {
}
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public TapOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public TapOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1089,9 +1057,7 @@ public interface ElementHandle extends JSHandle {
*/
public Double delay;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -1110,9 +1076,7 @@ public interface ElementHandle extends JSHandle {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public TypeOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1136,9 +1100,7 @@ public interface ElementHandle extends JSHandle {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -1169,9 +1131,7 @@ public interface ElementHandle extends JSHandle {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public UncheckOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1324,7 +1284,6 @@ public interface ElementHandle extends JSHandle {
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now checked. If not, this method throws.</li>
* </ol>
*
@@ -1347,7 +1306,6 @@ public interface ElementHandle extends JSHandle {
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now checked. If not, this method throws.</li>
* </ol>
*
@@ -1413,8 +1371,6 @@ public interface ElementHandle extends JSHandle {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to double click in the center of the element, or the
* specified {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set. Note that if the
* first click of the {@code dblclick()} triggers a navigation event, this method will throw.</li>
* </ol>
*
* <p> If the element is detached from the DOM at any moment during the action, this method throws.
@@ -1437,8 +1393,6 @@ public interface ElementHandle extends JSHandle {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to double click in the center of the element, or the
* specified {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set. Note that if the
* first click of the {@code dblclick()} triggers a navigation event, this method will throw.</li>
* </ol>
*
* <p> If the element is detached from the DOM at any moment during the action, this method throws.
@@ -1695,7 +1649,6 @@ public interface ElementHandle extends JSHandle {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to hover over the center of the element, or the specified
* {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* </ol>
*
* <p> If the element is detached from the DOM at any moment during the action, this method throws.
@@ -1716,7 +1669,6 @@ public interface ElementHandle extends JSHandle {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to hover over the center of the element, or the specified
* {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* </ol>
*
* <p> If the element is detached from the DOM at any moment during the action, this method throws.
@@ -1820,7 +1772,7 @@ public interface ElementHandle extends JSHandle {
* ArrowUp}, etc.
*
* <p> Following modification shortcuts are also supported: {@code Shift}, {@code Control}, {@code Alt}, {@code Meta}, {@code
* ShiftLeft}.
* ShiftLeft}, {@code ControlOrMeta}.
*
* <p> Holding down {@code Shift} will type the text that corresponds to the {@code key} in the upper case.
*
@@ -1851,7 +1803,7 @@ public interface ElementHandle extends JSHandle {
* ArrowUp}, etc.
*
* <p> Following modification shortcuts are also supported: {@code Shift}, {@code Control}, {@code Alt}, {@code Meta}, {@code
* ShiftLeft}.
* ShiftLeft}, {@code ControlOrMeta}.
*
* <p> Holding down {@code Shift} will type the text that corresponds to the {@code key} in the upper case.
*
@@ -1918,6 +1870,8 @@ public interface ElementHandle extends JSHandle {
* <p> Throws when {@code elementHandle} does not point to an element <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected">connected</a> to a Document or a ShadowRoot.
*
* <p> See <a href="https://playwright.dev/java/docs/input#scrolling">scrolling</a> for alternative ways to scroll.
*
* @since v1.8
*/
default void scrollIntoViewIfNeeded() {
@@ -1932,6 +1886,8 @@ public interface ElementHandle extends JSHandle {
* <p> Throws when {@code elementHandle} does not point to an element <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected">connected</a> to a Document or a ShadowRoot.
*
* <p> See <a href="https://playwright.dev/java/docs/input#scrolling">scrolling</a> for alternative ways to scroll.
*
* @since v1.8
*/
void scrollIntoViewIfNeeded(ScrollIntoViewIfNeededOptions options);
@@ -2328,7 +2284,6 @@ public interface ElementHandle extends JSHandle {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now checked or unchecked. If not, this method throws.</li>
* </ol>
*
@@ -2350,7 +2305,6 @@ public interface ElementHandle extends JSHandle {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now checked or unchecked. If not, this method throws.</li>
* </ol>
*
@@ -2363,7 +2317,8 @@ public interface ElementHandle extends JSHandle {
void setChecked(boolean checked, SetCheckedOptions options);
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
* they are resolved relative to the current working directory. For empty array, clears the selected files.
* they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
* a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
* <p> This method expects {@code ElementHandle} to point to an <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a>. However, if the element is
@@ -2378,7 +2333,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
* they are resolved relative to the current working directory. For empty array, clears the selected files.
* they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
* a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
* <p> This method expects {@code ElementHandle} to point to an <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a>. However, if the element is
@@ -2391,7 +2347,8 @@ public interface ElementHandle extends JSHandle {
void setInputFiles(Path files, SetInputFilesOptions options);
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
* they are resolved relative to the current working directory. For empty array, clears the selected files.
* they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
* a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
* <p> This method expects {@code ElementHandle} to point to an <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a>. However, if the element is
@@ -2406,7 +2363,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
* they are resolved relative to the current working directory. For empty array, clears the selected files.
* they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
* a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
* <p> This method expects {@code ElementHandle} to point to an <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a>. However, if the element is
@@ -2419,7 +2377,8 @@ public interface ElementHandle extends JSHandle {
void setInputFiles(Path[] files, SetInputFilesOptions options);
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
* they are resolved relative to the current working directory. For empty array, clears the selected files.
* they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
* a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
* <p> This method expects {@code ElementHandle} to point to an <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a>. However, if the element is
@@ -2434,7 +2393,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
* they are resolved relative to the current working directory. For empty array, clears the selected files.
* they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
* a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
* <p> This method expects {@code ElementHandle} to point to an <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a>. However, if the element is
@@ -2447,7 +2407,8 @@ public interface ElementHandle extends JSHandle {
void setInputFiles(FilePayload files, SetInputFilesOptions options);
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
* they are resolved relative to the current working directory. For empty array, clears the selected files.
* they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
* a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
* <p> This method expects {@code ElementHandle} to point to an <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a>. However, if the element is
@@ -2462,7 +2423,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
* they are resolved relative to the current working directory. For empty array, clears the selected files.
* they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
* a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
* <p> This method expects {@code ElementHandle} to point to an <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a>. However, if the element is
@@ -2481,7 +2443,6 @@ public interface ElementHandle extends JSHandle {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#touchscreen Page.touchscreen()} to tap the center of the element, or the
* specified {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* </ol>
*
* <p> If the element is detached from the DOM at any moment during the action, this method throws.
@@ -2504,7 +2465,6 @@ public interface ElementHandle extends JSHandle {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#touchscreen Page.touchscreen()} to tap the center of the element, or the
* specified {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* </ol>
*
* <p> If the element is detached from the DOM at any moment during the action, this method throws.
@@ -2552,7 +2512,6 @@ public interface ElementHandle extends JSHandle {
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now unchecked. If not, this method throws.</li>
* </ol>
*
@@ -2575,7 +2534,6 @@ public interface ElementHandle extends JSHandle {
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now unchecked. If not, this method throws.</li>
* </ol>
*
@@ -30,9 +30,7 @@ import java.nio.file.Path;
public interface FileChooser {
class SetFilesOptions {
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -44,9 +42,7 @@ public interface FileChooser {
public Double timeout;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public SetFilesOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -72,7 +72,7 @@ public interface Frame {
*/
public Path path;
/**
* Script type. Use 'module' in order to load a Javascript ES6 module. See <a
* Script type. Use 'module' in order to load a JavaScript ES6 module. See <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script">script</a> for more details.
*/
public String type;
@@ -97,7 +97,7 @@ public interface Frame {
return this;
}
/**
* Script type. Use 'module' in order to load a Javascript ES6 module. See <a
* Script type. Use 'module' in order to load a JavaScript ES6 module. See <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script">script</a> for more details.
*/
public AddScriptTagOptions setType(String type) {
@@ -157,9 +157,7 @@ public interface Frame {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -195,9 +193,7 @@ public interface Frame {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public CheckOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -266,13 +262,12 @@ public interface Frame {
public Boolean force;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public Boolean noWaitAfter;
/**
@@ -330,16 +325,15 @@ public interface Frame {
}
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public ClickOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public ClickOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -404,13 +398,12 @@ public interface Frame {
public Boolean force;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -461,16 +454,15 @@ public interface Frame {
}
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public DblclickOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public DblclickOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -559,9 +551,7 @@ public interface Frame {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -602,9 +592,7 @@ public interface Frame {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public DragAndDropOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -691,9 +679,7 @@ public interface Frame {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -718,9 +704,7 @@ public interface Frame {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public FillOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1115,13 +1099,12 @@ public interface Frame {
public Boolean force;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -1158,16 +1141,15 @@ public interface Frame {
}
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public HoverOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public HoverOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1607,9 +1589,7 @@ public interface Frame {
*/
public Double delay;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public Boolean noWaitAfter;
/**
@@ -1633,9 +1613,7 @@ public interface Frame {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public PressOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1683,9 +1661,7 @@ public interface Frame {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public Boolean noWaitAfter;
/**
@@ -1710,9 +1686,7 @@ public interface Frame {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public SelectOptionOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1744,9 +1718,7 @@ public interface Frame {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -1782,9 +1754,7 @@ public interface Frame {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public SetCheckedOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1884,9 +1854,7 @@ public interface Frame {
}
class SetInputFilesOptions {
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -1903,9 +1871,7 @@ public interface Frame {
public Double timeout;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public SetInputFilesOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1938,13 +1904,12 @@ public interface Frame {
public Boolean force;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -1981,16 +1946,15 @@ public interface Frame {
}
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public TapOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public TapOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -2078,9 +2042,7 @@ public interface Frame {
*/
public Double delay;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -2104,9 +2066,7 @@ public interface Frame {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public TypeOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -2138,9 +2098,7 @@ public interface Frame {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -2176,9 +2134,7 @@ public interface Frame {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public UncheckOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -2523,7 +2479,6 @@ public interface Frame {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now checked. If not, this method throws.</li>
* </ol>
*
@@ -2546,7 +2501,6 @@ public interface Frame {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now checked. If not, this method throws.</li>
* </ol>
*
@@ -2617,9 +2571,8 @@ public interface Frame {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to double click in the center of the element, or the
* specified {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set. Note that if the
* first click of the {@code dblclick()} triggers a navigation event, this method will throw.</li>
* specified {@code position}. if the first click of the {@code dblclick()} triggers a navigation event, this method will
* throw.</li>
* </ol>
*
* <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
@@ -2641,9 +2594,8 @@ public interface Frame {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to double click in the center of the element, or the
* specified {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set. Note that if the
* first click of the {@code dblclick()} triggers a navigation event, this method will throw.</li>
* specified {@code position}. if the first click of the {@code dblclick()} triggers a navigation event, this method will
* throw.</li>
* </ol>
*
* <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
@@ -3823,7 +3775,6 @@ public interface Frame {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to hover over the center of the element, or the specified
* {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* </ol>
*
* <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
@@ -3844,7 +3795,6 @@ public interface Frame {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to hover over the center of the element, or the specified
* {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* </ol>
*
* <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
@@ -4082,7 +4032,8 @@ public interface Frame {
* ArrowUp}, etc.
*
* <p> Following modification shortcuts are also supported: {@code Shift}, {@code Control}, {@code Alt}, {@code Meta}, {@code
* ShiftLeft}.
* ShiftLeft}, {@code ControlOrMeta}. {@code ControlOrMeta} resolves to {@code Control} on Windows and Linux and to {@code
* Meta} on macOS.
*
* <p> Holding down {@code Shift} will type the text that corresponds to the {@code key} in the upper case.
*
@@ -4111,7 +4062,8 @@ public interface Frame {
* ArrowUp}, etc.
*
* <p> Following modification shortcuts are also supported: {@code Shift}, {@code Control}, {@code Alt}, {@code Meta}, {@code
* ShiftLeft}.
* ShiftLeft}, {@code ControlOrMeta}. {@code ControlOrMeta} resolves to {@code Control} on Windows and Linux and to {@code
* Meta} on macOS.
*
* <p> Holding down {@code Shift} will type the text that corresponds to the {@code key} in the upper case.
*
@@ -4558,7 +4510,6 @@ public interface Frame {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now checked or unchecked. If not, this method throws.</li>
* </ol>
*
@@ -4582,7 +4533,6 @@ public interface Frame {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now checked or unchecked. If not, this method throws.</li>
* </ol>
*
@@ -4743,7 +4693,6 @@ public interface Frame {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#touchscreen Page.touchscreen()} to tap the center of the element, or the
* specified {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* </ol>
*
* <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
@@ -4766,7 +4715,6 @@ public interface Frame {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#touchscreen Page.touchscreen()} to tap the center of the element, or the
* specified {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* </ol>
*
* <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
@@ -4832,7 +4780,6 @@ public interface Frame {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now unchecked. If not, this method throws.</li>
* </ol>
*
@@ -4855,7 +4802,6 @@ public interface Frame {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now unchecked. If not, this method throws.</li>
* </ol>
*
@@ -4989,6 +4935,9 @@ public interface Frame {
* <p> This returns when the frame reaches a required load state, {@code load} by default. The navigation must have been
* committed when this method is called. If current document has already reached the required state, resolves immediately.
*
* <p> <strong>NOTE:</strong> Most of the time, this method is not needed because Playwright <a
* href="https://playwright.dev/java/docs/actionability">auto-waits before every action</a>.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* frame.click("button"); // Click triggers navigation.
@@ -5014,6 +4963,9 @@ public interface Frame {
* <p> This returns when the frame reaches a required load state, {@code load} by default. The navigation must have been
* committed when this method is called. If current document has already reached the required state, resolves immediately.
*
* <p> <strong>NOTE:</strong> Most of the time, this method is not needed because Playwright <a
* href="https://playwright.dev/java/docs/actionability">auto-waits before every action</a>.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* frame.click("button"); // Click triggers navigation.
@@ -5031,6 +4983,9 @@ public interface Frame {
* <p> This returns when the frame reaches a required load state, {@code load} by default. The navigation must have been
* committed when this method is called. If current document has already reached the required state, resolves immediately.
*
* <p> <strong>NOTE:</strong> Most of the time, this method is not needed because Playwright <a
* href="https://playwright.dev/java/docs/actionability">auto-waits before every action</a>.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* frame.click("button"); // Click triggers navigation.
@@ -97,7 +97,8 @@ public interface Keyboard {
* ArrowUp}, etc.
*
* <p> Following modification shortcuts are also supported: {@code Shift}, {@code Control}, {@code Alt}, {@code Meta}, {@code
* ShiftLeft}.
* ShiftLeft}, {@code ControlOrMeta}. {@code ControlOrMeta} resolves to {@code Control} on Windows and Linux and to {@code
* Meta} on macOS.
*
* <p> Holding down {@code Shift} will type the text that corresponds to the {@code key} in the upper case.
*
@@ -147,7 +148,8 @@ public interface Keyboard {
* ArrowUp}, etc.
*
* <p> Following modification shortcuts are also supported: {@code Shift}, {@code Control}, {@code Alt}, {@code Meta}, {@code
* ShiftLeft}.
* ShiftLeft}, {@code ControlOrMeta}. {@code ControlOrMeta} resolves to {@code Control} on Windows and Linux and to {@code
* Meta} on macOS.
*
* <p> Holding down {@code Shift} will type the text that corresponds to the {@code key} in the upper case.
*
@@ -193,7 +195,8 @@ public interface Keyboard {
* ArrowUp}, etc.
*
* <p> Following modification shortcuts are also supported: {@code Shift}, {@code Control}, {@code Alt}, {@code Meta}, {@code
* ShiftLeft}.
* ShiftLeft}, {@code ControlOrMeta}. {@code ControlOrMeta} resolves to {@code Control} on Windows and Linux and to {@code
* Meta} on macOS.
*
* <p> Holding down {@code Shift} will type the text that corresponds to the {@code key} in the upper case.
*
@@ -76,9 +76,7 @@ public interface Locator {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -109,9 +107,7 @@ public interface Locator {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public CheckOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -159,9 +155,7 @@ public interface Locator {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -181,9 +175,7 @@ public interface Locator {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public ClearOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -220,13 +212,12 @@ public interface Locator {
public Boolean force;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public Boolean noWaitAfter;
/**
@@ -279,16 +270,15 @@ public interface Locator {
}
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public ClickOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public ClickOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -345,13 +335,12 @@ public interface Locator {
public Boolean force;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -397,16 +386,15 @@ public interface Locator {
}
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public DblclickOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public DblclickOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -474,9 +462,7 @@ public interface Locator {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -512,9 +498,7 @@ public interface Locator {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public DragToOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -637,9 +621,7 @@ public interface Locator {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -659,9 +641,7 @@ public interface Locator {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public FillOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1056,13 +1036,12 @@ public interface Locator {
public Boolean force;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -1094,16 +1073,15 @@ public interface Locator {
}
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public HoverOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public HoverOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1418,9 +1396,7 @@ public interface Locator {
*/
public Double delay;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public Boolean noWaitAfter;
/**
@@ -1439,9 +1415,7 @@ public interface Locator {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public PressOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1464,9 +1438,7 @@ public interface Locator {
*/
public Double delay;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -1485,9 +1457,7 @@ public interface Locator {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public PressSequentiallyOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1701,9 +1671,7 @@ public interface Locator {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public Boolean noWaitAfter;
/**
@@ -1723,9 +1691,7 @@ public interface Locator {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public SelectOptionOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1782,9 +1748,7 @@ public interface Locator {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -1815,9 +1779,7 @@ public interface Locator {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public SetCheckedOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1860,9 +1822,7 @@ public interface Locator {
}
class SetInputFilesOptions {
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -1874,9 +1834,7 @@ public interface Locator {
public Double timeout;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public SetInputFilesOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1901,13 +1859,12 @@ public interface Locator {
public Boolean force;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -1939,16 +1896,15 @@ public interface Locator {
}
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public TapOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public TapOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -2015,9 +1971,7 @@ public interface Locator {
*/
public Double delay;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -2036,9 +1990,7 @@ public interface Locator {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public TypeOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -2062,9 +2014,7 @@ public interface Locator {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -2095,9 +2045,7 @@ public interface Locator {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public UncheckOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -2326,7 +2274,6 @@ public interface Locator {
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now checked. If not, this method throws.</li>
* </ol>
*
@@ -2358,7 +2305,6 @@ public interface Locator {
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now checked. If not, this method throws.</li>
* </ol>
*
@@ -2524,8 +2470,6 @@ public interface Locator {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to double click in the center of the element, or the
* specified {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set. Note that if the
* first click of the {@code dblclick()} triggers a navigation event, this method will throw.</li>
* </ol>
*
* <p> If the element is detached from the DOM at any moment during the action, this method throws.
@@ -2552,8 +2496,6 @@ public interface Locator {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to double click in the center of the element, or the
* specified {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set. Note that if the
* first click of the {@code dblclick()} triggers a navigation event, this method will throw.</li>
* </ol>
*
* <p> If the element is detached from the DOM at any moment during the action, this method throws.
@@ -3749,7 +3691,6 @@ public interface Locator {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to hover over the center of the element, or the specified
* {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* </ol>
*
* <p> If the element is detached from the DOM at any moment during the action, this method throws.
@@ -3779,7 +3720,6 @@ public interface Locator {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to hover over the center of the element, or the specified
* {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* </ol>
*
* <p> If the element is detached from the DOM at any moment during the action, this method throws.
@@ -4186,7 +4126,8 @@ public interface Locator {
* ArrowUp}, etc.
*
* <p> Following modification shortcuts are also supported: {@code Shift}, {@code Control}, {@code Alt}, {@code Meta}, {@code
* ShiftLeft}.
* ShiftLeft}, {@code ControlOrMeta}. {@code ControlOrMeta} resolves to {@code Control} on Windows and Linux and to {@code
* Meta} on macOS.
*
* <p> Holding down {@code Shift} will type the text that corresponds to the {@code key} in the upper case.
*
@@ -4226,7 +4167,8 @@ public interface Locator {
* ArrowUp}, etc.
*
* <p> Following modification shortcuts are also supported: {@code Shift}, {@code Control}, {@code Alt}, {@code Meta}, {@code
* ShiftLeft}.
* ShiftLeft}, {@code ControlOrMeta}. {@code ControlOrMeta} resolves to {@code Control} on Windows and Linux and to {@code
* Meta} on macOS.
*
* <p> Holding down {@code Shift} will type the text that corresponds to the {@code key} in the upper case.
*
@@ -4362,6 +4304,8 @@ public interface Locator {
* href="https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API">IntersectionObserver</a>'s {@code
* ratio}.
*
* <p> See <a href="https://playwright.dev/java/docs/input#scrolling">scrolling</a> for alternative ways to scroll.
*
* @since v1.14
*/
default void scrollIntoViewIfNeeded() {
@@ -4373,6 +4317,8 @@ public interface Locator {
* href="https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API">IntersectionObserver</a>'s {@code
* ratio}.
*
* <p> See <a href="https://playwright.dev/java/docs/input#scrolling">scrolling</a> for alternative ways to scroll.
*
* @since v1.14
*/
void scrollIntoViewIfNeeded(ScrollIntoViewIfNeededOptions options);
@@ -4826,7 +4772,6 @@ public interface Locator {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now checked or unchecked. If not, this method throws.</li>
* </ol>
*
@@ -4857,7 +4802,6 @@ public interface Locator {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now checked or unchecked. If not, this method throws.</li>
* </ol>
*
@@ -4869,7 +4813,8 @@ public interface Locator {
*/
void setChecked(boolean checked, SetCheckedOptions options);
/**
* Upload file or multiple files into {@code <input type=file>}.
* Upload file or multiple files into {@code <input type=file>}. For inputs with a {@code [webkitdirectory]} attribute,
* only a single directory path is supported.
*
* <p> <strong>Usage</strong>
* <pre>{@code
@@ -4879,6 +4824,9 @@ public interface Locator {
* // Select multiple files
* page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
*
* // Select a directory
* page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
*
* // Remove all the selected files
* page.getByLabel("Upload file").setInputFiles(new Path[0]);
*
@@ -4904,7 +4852,8 @@ public interface Locator {
setInputFiles(files, null);
}
/**
* Upload file or multiple files into {@code <input type=file>}.
* Upload file or multiple files into {@code <input type=file>}. For inputs with a {@code [webkitdirectory]} attribute,
* only a single directory path is supported.
*
* <p> <strong>Usage</strong>
* <pre>{@code
@@ -4914,6 +4863,9 @@ public interface Locator {
* // Select multiple files
* page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
*
* // Select a directory
* page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
*
* // Remove all the selected files
* page.getByLabel("Upload file").setInputFiles(new Path[0]);
*
@@ -4937,7 +4889,8 @@ public interface Locator {
*/
void setInputFiles(Path files, SetInputFilesOptions options);
/**
* Upload file or multiple files into {@code <input type=file>}.
* Upload file or multiple files into {@code <input type=file>}. For inputs with a {@code [webkitdirectory]} attribute,
* only a single directory path is supported.
*
* <p> <strong>Usage</strong>
* <pre>{@code
@@ -4947,6 +4900,9 @@ public interface Locator {
* // Select multiple files
* page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
*
* // Select a directory
* page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
*
* // Remove all the selected files
* page.getByLabel("Upload file").setInputFiles(new Path[0]);
*
@@ -4972,7 +4928,8 @@ public interface Locator {
setInputFiles(files, null);
}
/**
* Upload file or multiple files into {@code <input type=file>}.
* Upload file or multiple files into {@code <input type=file>}. For inputs with a {@code [webkitdirectory]} attribute,
* only a single directory path is supported.
*
* <p> <strong>Usage</strong>
* <pre>{@code
@@ -4982,6 +4939,9 @@ public interface Locator {
* // Select multiple files
* page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
*
* // Select a directory
* page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
*
* // Remove all the selected files
* page.getByLabel("Upload file").setInputFiles(new Path[0]);
*
@@ -5005,7 +4965,8 @@ public interface Locator {
*/
void setInputFiles(Path[] files, SetInputFilesOptions options);
/**
* Upload file or multiple files into {@code <input type=file>}.
* Upload file or multiple files into {@code <input type=file>}. For inputs with a {@code [webkitdirectory]} attribute,
* only a single directory path is supported.
*
* <p> <strong>Usage</strong>
* <pre>{@code
@@ -5015,6 +4976,9 @@ public interface Locator {
* // Select multiple files
* page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
*
* // Select a directory
* page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
*
* // Remove all the selected files
* page.getByLabel("Upload file").setInputFiles(new Path[0]);
*
@@ -5040,7 +5004,8 @@ public interface Locator {
setInputFiles(files, null);
}
/**
* Upload file or multiple files into {@code <input type=file>}.
* Upload file or multiple files into {@code <input type=file>}. For inputs with a {@code [webkitdirectory]} attribute,
* only a single directory path is supported.
*
* <p> <strong>Usage</strong>
* <pre>{@code
@@ -5050,6 +5015,9 @@ public interface Locator {
* // Select multiple files
* page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
*
* // Select a directory
* page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
*
* // Remove all the selected files
* page.getByLabel("Upload file").setInputFiles(new Path[0]);
*
@@ -5073,7 +5041,8 @@ public interface Locator {
*/
void setInputFiles(FilePayload files, SetInputFilesOptions options);
/**
* Upload file or multiple files into {@code <input type=file>}.
* Upload file or multiple files into {@code <input type=file>}. For inputs with a {@code [webkitdirectory]} attribute,
* only a single directory path is supported.
*
* <p> <strong>Usage</strong>
* <pre>{@code
@@ -5083,6 +5052,9 @@ public interface Locator {
* // Select multiple files
* page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
*
* // Select a directory
* page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
*
* // Remove all the selected files
* page.getByLabel("Upload file").setInputFiles(new Path[0]);
*
@@ -5108,7 +5080,8 @@ public interface Locator {
setInputFiles(files, null);
}
/**
* Upload file or multiple files into {@code <input type=file>}.
* Upload file or multiple files into {@code <input type=file>}. For inputs with a {@code [webkitdirectory]} attribute,
* only a single directory path is supported.
*
* <p> <strong>Usage</strong>
* <pre>{@code
@@ -5118,6 +5091,9 @@ public interface Locator {
* // Select multiple files
* page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
*
* // Select a directory
* page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
*
* // Remove all the selected files
* page.getByLabel("Upload file").setInputFiles(new Path[0]);
*
@@ -5152,7 +5128,6 @@ public interface Locator {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#touchscreen Page.touchscreen()} to tap the center of the element, or the
* specified {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* </ol>
*
* <p> If the element is detached from the DOM at any moment during the action, this method throws.
@@ -5179,7 +5154,6 @@ public interface Locator {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#touchscreen Page.touchscreen()} to tap the center of the element, or the
* specified {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* </ol>
*
* <p> If the element is detached from the DOM at any moment during the action, this method throws.
@@ -5252,7 +5226,6 @@ public interface Locator {
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now unchecked. If not, this method throws.</li>
* </ol>
*
@@ -5284,7 +5257,6 @@ public interface Locator {
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now unchecked. If not, this method throws.</li>
* </ol>
*
@@ -163,6 +163,8 @@ public interface Mouse {
* Shortcut for {@link com.microsoft.playwright.Mouse#move Mouse.move()}, {@link com.microsoft.playwright.Mouse#down
* Mouse.down()}, {@link com.microsoft.playwright.Mouse#up Mouse.up()}.
*
* @param x X coordinate relative to the main frame's viewport in CSS pixels.
* @param y Y coordinate relative to the main frame's viewport in CSS pixels.
* @since v1.8
*/
default void click(double x, double y) {
@@ -172,6 +174,8 @@ public interface Mouse {
* Shortcut for {@link com.microsoft.playwright.Mouse#move Mouse.move()}, {@link com.microsoft.playwright.Mouse#down
* Mouse.down()}, {@link com.microsoft.playwright.Mouse#up Mouse.up()}.
*
* @param x X coordinate relative to the main frame's viewport in CSS pixels.
* @param y Y coordinate relative to the main frame's viewport in CSS pixels.
* @since v1.8
*/
void click(double x, double y, ClickOptions options);
@@ -180,6 +184,8 @@ public interface Mouse {
* Mouse.down()}, {@link com.microsoft.playwright.Mouse#up Mouse.up()}, {@link com.microsoft.playwright.Mouse#down
* Mouse.down()} and {@link com.microsoft.playwright.Mouse#up Mouse.up()}.
*
* @param x X coordinate relative to the main frame's viewport in CSS pixels.
* @param y Y coordinate relative to the main frame's viewport in CSS pixels.
* @since v1.8
*/
default void dblclick(double x, double y) {
@@ -190,6 +196,8 @@ public interface Mouse {
* Mouse.down()}, {@link com.microsoft.playwright.Mouse#up Mouse.up()}, {@link com.microsoft.playwright.Mouse#down
* Mouse.down()} and {@link com.microsoft.playwright.Mouse#up Mouse.up()}.
*
* @param x X coordinate relative to the main frame's viewport in CSS pixels.
* @param y Y coordinate relative to the main frame's viewport in CSS pixels.
* @since v1.8
*/
void dblclick(double x, double y, DblclickOptions options);
@@ -210,6 +218,8 @@ public interface Mouse {
/**
* Dispatches a {@code mousemove} event.
*
* @param x X coordinate relative to the main frame's viewport in CSS pixels.
* @param y Y coordinate relative to the main frame's viewport in CSS pixels.
* @since v1.8
*/
default void move(double x, double y) {
@@ -218,6 +228,8 @@ public interface Mouse {
/**
* Dispatches a {@code mousemove} event.
*
* @param x X coordinate relative to the main frame's viewport in CSS pixels.
* @param y Y coordinate relative to the main frame's viewport in CSS pixels.
* @since v1.8
*/
void move(double x, double y, MoveOptions options);
@@ -236,7 +248,8 @@ public interface Mouse {
*/
void up(UpOptions options);
/**
* Dispatches a {@code wheel} event.
* Dispatches a {@code wheel} event. This method is usually used to manually scroll the page. See <a
* href="https://playwright.dev/java/docs/input#scrolling">scrolling</a> for alternative ways to scroll.
*
* <p> <strong>NOTE:</strong> Wheel events may cause scrolling if they are not handled, and this method does not wait for the scrolling to finish
* before returning.
@@ -242,7 +242,10 @@ public interface Page extends AutoCloseable {
*
* <p> The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
* popup with {@code window.open('http://example.com')}, this event will fire when the network request to
* "http://example.com" is done and its response has started loading in the popup.
* "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen to
* this network request, use {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} and {@link
* com.microsoft.playwright.BrowserContext#onRequest BrowserContext.onRequest()} respectively instead of similar methods on
* the {@code Page}.
* <pre>{@code
* Page popup = page.waitForPopup(() -> {
* page.getByText("open the popup").click();
@@ -339,7 +342,7 @@ public interface Page extends AutoCloseable {
*/
public Path path;
/**
* Script type. Use 'module' in order to load a Javascript ES6 module. See <a
* Script type. Use 'module' in order to load a JavaScript ES6 module. See <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script">script</a> for more details.
*/
public String type;
@@ -364,7 +367,7 @@ public interface Page extends AutoCloseable {
return this;
}
/**
* Script type. Use 'module' in order to load a Javascript ES6 module. See <a
* Script type. Use 'module' in order to load a JavaScript ES6 module. See <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script">script</a> for more details.
*/
public AddScriptTagOptions setType(String type) {
@@ -424,9 +427,7 @@ public interface Page extends AutoCloseable {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -462,9 +463,7 @@ public interface Page extends AutoCloseable {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public CheckOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -533,13 +532,12 @@ public interface Page extends AutoCloseable {
public Boolean force;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public Boolean noWaitAfter;
/**
@@ -597,16 +595,15 @@ public interface Page extends AutoCloseable {
}
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public ClickOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public ClickOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -698,13 +695,12 @@ public interface Page extends AutoCloseable {
public Boolean force;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -755,16 +751,15 @@ public interface Page extends AutoCloseable {
}
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public DblclickOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public DblclickOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -853,9 +848,7 @@ public interface Page extends AutoCloseable {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -896,9 +889,7 @@ public interface Page extends AutoCloseable {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public DragAndDropOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1035,14 +1026,12 @@ public interface Page extends AutoCloseable {
}
class ExposeBindingOptions {
/**
* Whether to pass the argument as a handle, instead of passing by value. When passing a handle, only one argument is
* supported. When passing by value, multiple arguments are supported.
* @deprecated This option will be removed in the future.
*/
public Boolean handle;
/**
* Whether to pass the argument as a handle, instead of passing by value. When passing a handle, only one argument is
* supported. When passing by value, multiple arguments are supported.
* @deprecated This option will be removed in the future.
*/
public ExposeBindingOptions setHandle(boolean handle) {
this.handle = handle;
@@ -1056,9 +1045,7 @@ public interface Page extends AutoCloseable {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -1083,9 +1070,7 @@ public interface Page extends AutoCloseable {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public FillOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -1578,13 +1563,12 @@ public interface Page extends AutoCloseable {
public Boolean force;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -1621,16 +1605,15 @@ public interface Page extends AutoCloseable {
}
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public HoverOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public HoverOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -2258,9 +2241,7 @@ public interface Page extends AutoCloseable {
*/
public Double delay;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public Boolean noWaitAfter;
/**
@@ -2284,9 +2265,7 @@ public interface Page extends AutoCloseable {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public PressOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -2327,6 +2306,35 @@ public interface Page extends AutoCloseable {
return this;
}
}
class AddLocatorHandlerOptions {
/**
* By default, after calling the handler Playwright will wait until the overlay becomes hidden, and only then Playwright
* will continue with the action/assertion that triggered the handler. This option allows to opt-out of this behavior, so
* that overlay can stay visible after the handler has run.
*/
public Boolean noWaitAfter;
/**
* Specifies the maximum number of times this handler should be called. Unlimited by default.
*/
public Integer times;
/**
* By default, after calling the handler Playwright will wait until the overlay becomes hidden, and only then Playwright
* will continue with the action/assertion that triggered the handler. This option allows to opt-out of this behavior, so
* that overlay can stay visible after the handler has run.
*/
public AddLocatorHandlerOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
return this;
}
/**
* Specifies the maximum number of times this handler should be called. Unlimited by default.
*/
public AddLocatorHandlerOptions setTimes(int times) {
this.times = times;
return this;
}
}
class ReloadOptions {
/**
* Maximum operation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can
@@ -2683,9 +2691,7 @@ public interface Page extends AutoCloseable {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public Boolean noWaitAfter;
/**
@@ -2710,9 +2716,7 @@ public interface Page extends AutoCloseable {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option will default to {@code true} in the future.
*/
public SelectOptionOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -2744,9 +2748,7 @@ public interface Page extends AutoCloseable {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -2782,9 +2784,7 @@ public interface Page extends AutoCloseable {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public SetCheckedOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -2884,9 +2884,7 @@ public interface Page extends AutoCloseable {
}
class SetInputFilesOptions {
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -2903,9 +2901,7 @@ public interface Page extends AutoCloseable {
public Double timeout;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public SetInputFilesOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -2938,13 +2934,12 @@ public interface Page extends AutoCloseable {
public Boolean force;
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -2981,16 +2976,15 @@ public interface Page extends AutoCloseable {
}
/**
* Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
* modifiers back. If not specified, currently pressed modifiers are used.
* modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
*/
public TapOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public TapOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -3078,9 +3072,7 @@ public interface Page extends AutoCloseable {
*/
public Double delay;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -3104,9 +3096,7 @@ public interface Page extends AutoCloseable {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public TypeOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -3138,9 +3128,7 @@ public interface Page extends AutoCloseable {
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public Boolean noWaitAfter;
/**
@@ -3176,9 +3164,7 @@ public interface Page extends AutoCloseable {
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
* @deprecated This option has no effect.
*/
public UncheckOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
@@ -3752,6 +3738,12 @@ public interface Page extends AutoCloseable {
return this;
}
}
/**
* Playwright has ability to mock clock and passage of time.
*
* @since v1.45
*/
Clock clock();
/**
* Adds a script which would be evaluated in one of the following scenarios:
* <ul>
@@ -3856,7 +3848,6 @@ public interface Page extends AutoCloseable {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now checked. If not, this method throws.</li>
* </ol>
*
@@ -3879,7 +3870,6 @@ public interface Page extends AutoCloseable {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now checked. If not, this method throws.</li>
* </ol>
*
@@ -3979,8 +3969,6 @@ public interface Page extends AutoCloseable {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to double click in the center of the element, or the
* specified {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set. Note that if the
* first click of the {@code dblclick()} triggers a navigation event, this method will throw.</li>
* </ol>
*
* <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
@@ -4003,8 +3991,6 @@ public interface Page extends AutoCloseable {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to double click in the center of the element, or the
* specified {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set. Note that if the
* first click of the {@code dblclick()} triggers a navigation event, this method will throw.</li>
* </ol>
*
* <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
@@ -4583,21 +4569,6 @@ public interface Page extends AutoCloseable {
* }
* }</pre>
*
* <p> An example of passing an element handle:
* <pre>{@code
* page.exposeBinding("clicked", (source, args) -> {
* ElementHandle element = (ElementHandle) args[0];
* System.out.println(element.textContent());
* return null;
* }, new Page.ExposeBindingOptions().setHandle(true));
* page.setContent("" +
* "<script>\n" +
* " document.addEventListener('click', event => window.clicked(event.target));\n" +
* "</script>\n" +
* "<div>Click me</div>\n" +
* "<div>Or click me</div>\n");
* }</pre>
*
* @param name Name of the function on the window object.
* @param callback Callback function that will be called in the Playwright's context.
* @since v1.8
@@ -4648,21 +4619,6 @@ public interface Page extends AutoCloseable {
* }
* }</pre>
*
* <p> An example of passing an element handle:
* <pre>{@code
* page.exposeBinding("clicked", (source, args) -> {
* ElementHandle element = (ElementHandle) args[0];
* System.out.println(element.textContent());
* return null;
* }, new Page.ExposeBindingOptions().setHandle(true));
* page.setContent("" +
* "<script>\n" +
* " document.addEventListener('click', event => window.clicked(event.target));\n" +
* "</script>\n" +
* "<div>Click me</div>\n" +
* "<div>Or click me</div>\n");
* }</pre>
*
* @param name Name of the function on the window object.
* @param callback Callback function that will be called in the Playwright's context.
* @since v1.8
@@ -5420,7 +5376,7 @@ public interface Page extends AutoCloseable {
Locator getByTitle(Pattern text, GetByTitleOptions options);
/**
* Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
* last redirect. If can not go back, returns {@code null}.
* last redirect. If cannot go back, returns {@code null}.
*
* <p> Navigate to the previous page in history.
*
@@ -5431,7 +5387,7 @@ public interface Page extends AutoCloseable {
}
/**
* Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
* last redirect. If can not go back, returns {@code null}.
* last redirect. If cannot go back, returns {@code null}.
*
* <p> Navigate to the previous page in history.
*
@@ -5440,7 +5396,7 @@ public interface Page extends AutoCloseable {
Response goBack(GoBackOptions options);
/**
* Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
* last redirect. If can not go forward, returns {@code null}.
* last redirect. If cannot go forward, returns {@code null}.
*
* <p> Navigate to the next page in history.
*
@@ -5451,7 +5407,7 @@ public interface Page extends AutoCloseable {
}
/**
* Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
* last redirect. If can not go forward, returns {@code null}.
* last redirect. If cannot go forward, returns {@code null}.
*
* <p> Navigate to the next page in history.
*
@@ -5527,7 +5483,6 @@ public interface Page extends AutoCloseable {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to hover over the center of the element, or the specified
* {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* </ol>
*
* <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
@@ -5548,7 +5503,6 @@ public interface Page extends AutoCloseable {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to hover over the center of the element, or the specified
* {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* </ol>
*
* <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
@@ -5958,7 +5912,8 @@ public interface Page extends AutoCloseable {
* ArrowUp}, etc.
*
* <p> Following modification shortcuts are also supported: {@code Shift}, {@code Control}, {@code Alt}, {@code Meta}, {@code
* ShiftLeft}.
* ShiftLeft}, {@code ControlOrMeta}. {@code ControlOrMeta} resolves to {@code Control} on Windows and Linux and to {@code
* Meta} on macOS.
*
* <p> Holding down {@code Shift} will type the text that corresponds to the {@code key} in the upper case.
*
@@ -6002,7 +5957,8 @@ public interface Page extends AutoCloseable {
* ArrowUp}, etc.
*
* <p> Following modification shortcuts are also supported: {@code Shift}, {@code Control}, {@code Alt}, {@code Meta}, {@code
* ShiftLeft}.
* ShiftLeft}, {@code ControlOrMeta}. {@code ControlOrMeta} resolves to {@code Control} on Windows and Linux and to {@code
* Meta} on macOS.
*
* <p> Holding down {@code Shift} will type the text that corresponds to the {@code key} in the upper case.
*
@@ -6058,9 +6014,7 @@ public interface Page extends AutoCloseable {
*/
List<ElementHandle> querySelectorAll(String selector);
/**
* <strong>NOTE:</strong> This method is experimental and its behavior may change in the upcoming releases.
*
* <p> When testing a web page, sometimes unexpected overlays like a "Sign up" dialog appear and block actions you want to
* When testing a web page, sometimes unexpected overlays like a "Sign up" dialog appear and block actions you want to
* automate, e.g. clicking a button. These overlays don't always show up in the same way or at the same time, making them
* tricky to handle in automated tests.
*
@@ -6077,6 +6031,8 @@ public interface Page extends AutoCloseable {
* assertion check. When overlay is visible, Playwright calls the handler first, and then proceeds with the
* action/assertion. Note that the handler is only called when you perform an action/assertion - if the overlay becomes
* visible but you don't perform any actions, the handler will not be triggered.</li>
* <li> After executing the handler, Playwright will ensure that overlay that triggered the handler is not visible anymore. You
* can opt-out of this behavior with {@code noWaitAfter}.</li>
* <li> The execution time of the handler counts towards the timeout of the action/assertion that executed the handler. If your
* handler takes too long, it might cause timeouts.</li>
* <li> You can register multiple handlers. However, only a single handler will be running at a time. Make sure the actions
@@ -6122,24 +6078,135 @@ public interface Page extends AutoCloseable {
* }</pre>
*
* <p> An example with a custom callback on every actionability check. It uses a {@code <body>} locator that is always visible,
* so the handler is called before every actionability check:
* so the handler is called before every actionability check. It is important to specify {@code noWaitAfter}, because the
* handler does not hide the {@code <body>} element.
* <pre>{@code
* // Setup the handler.
* page.addLocatorHandler(page.locator("body")), () => {
* page.evaluate("window.removeObstructionsForTestIfNeeded()");
* });
* }, new Page.AddLocatorHandlerOptions.setNoWaitAfter(true));
*
* // Write the test as usual.
* page.goto("https://example.com");
* page.getByRole("button", Page.GetByRoleOptions().setName("Start here")).click();
* }</pre>
*
* <p> Handler takes the original locator as an argument. You can also automatically remove the handler after a number of
* invocations by setting {@code times}:
* <pre>{@code
* page.addLocatorHandler(page.getByLabel("Close"), locator => {
* locator.click();
* }, new Page.AddLocatorHandlerOptions().setTimes(1));
* }</pre>
*
* @param locator Locator that triggers the handler.
* @param handler Function that should be run once {@code locator} appears. This function should get rid of the element that blocks
* actions like click.
* @since v1.42
*/
void addLocatorHandler(Locator locator, Runnable handler);
default void addLocatorHandler(Locator locator, Consumer<Locator> handler) {
addLocatorHandler(locator, handler, null);
}
/**
* When testing a web page, sometimes unexpected overlays like a "Sign up" dialog appear and block actions you want to
* automate, e.g. clicking a button. These overlays don't always show up in the same way or at the same time, making them
* tricky to handle in automated tests.
*
* <p> This method lets you set up a special function, called a handler, that activates when it detects that overlay is
* visible. The handler's job is to remove the overlay, allowing your test to continue as if the overlay wasn't there.
*
* <p> Things to keep in mind:
* <ul>
* <li> When an overlay is shown predictably, we recommend explicitly waiting for it in your test and dismissing it as a part of
* your normal test flow, instead of using {@link com.microsoft.playwright.Page#addLocatorHandler
* Page.addLocatorHandler()}.</li>
* <li> Playwright checks for the overlay every time before executing or retrying an action that requires an <a
* href="https://playwright.dev/java/docs/actionability">actionability check</a>, or before performing an auto-waiting
* assertion check. When overlay is visible, Playwright calls the handler first, and then proceeds with the
* action/assertion. Note that the handler is only called when you perform an action/assertion - if the overlay becomes
* visible but you don't perform any actions, the handler will not be triggered.</li>
* <li> After executing the handler, Playwright will ensure that overlay that triggered the handler is not visible anymore. You
* can opt-out of this behavior with {@code noWaitAfter}.</li>
* <li> The execution time of the handler counts towards the timeout of the action/assertion that executed the handler. If your
* handler takes too long, it might cause timeouts.</li>
* <li> You can register multiple handlers. However, only a single handler will be running at a time. Make sure the actions
* within a handler don't depend on another handler.</li>
* </ul>
*
* <p> <strong>NOTE:</strong> Running the handler will alter your page state mid-test. For example it will change the currently focused element and
* move the mouse. Make sure that actions that run after the handler are self-contained and do not rely on the focus and
* mouse state being unchanged. <br /> <br /> For example, consider a test that calls {@link
* com.microsoft.playwright.Locator#focus Locator.focus()} followed by {@link com.microsoft.playwright.Keyboard#press
* Keyboard.press()}. If your handler clicks a button between these two actions, the focused element most likely will be
* wrong, and key press will happen on the unexpected element. Use {@link com.microsoft.playwright.Locator#press
* Locator.press()} instead to avoid this problem. <br /> <br /> Another example is a series of mouse actions, where {@link
* com.microsoft.playwright.Mouse#move Mouse.move()} is followed by {@link com.microsoft.playwright.Mouse#down
* Mouse.down()}. Again, when the handler runs between these two actions, the mouse position will be wrong during the mouse
* down. Prefer self-contained actions like {@link com.microsoft.playwright.Locator#click Locator.click()} that do not rely
* on the state being unchanged by a handler.
*
* <p> <strong>Usage</strong>
*
* <p> An example that closes a "Sign up to the newsletter" dialog when it appears:
* <pre>{@code
* // Setup the handler.
* page.addLocatorHandler(page.getByText("Sign up to the newsletter"), () => {
* page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("No thanks")).click();
* });
*
* // Write the test as usual.
* page.goto("https://example.com");
* page.getByRole("button", Page.GetByRoleOptions().setName("Start here")).click();
* }</pre>
*
* <p> An example that skips the "Confirm your security details" page when it is shown:
* <pre>{@code
* // Setup the handler.
* page.addLocatorHandler(page.getByText("Confirm your security details")), () => {
* page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Remind me later")).click();
* });
*
* // Write the test as usual.
* page.goto("https://example.com");
* page.getByRole("button", Page.GetByRoleOptions().setName("Start here")).click();
* }</pre>
*
* <p> An example with a custom callback on every actionability check. It uses a {@code <body>} locator that is always visible,
* so the handler is called before every actionability check. It is important to specify {@code noWaitAfter}, because the
* handler does not hide the {@code <body>} element.
* <pre>{@code
* // Setup the handler.
* page.addLocatorHandler(page.locator("body")), () => {
* page.evaluate("window.removeObstructionsForTestIfNeeded()");
* }, new Page.AddLocatorHandlerOptions.setNoWaitAfter(true));
*
* // Write the test as usual.
* page.goto("https://example.com");
* page.getByRole("button", Page.GetByRoleOptions().setName("Start here")).click();
* }</pre>
*
* <p> Handler takes the original locator as an argument. You can also automatically remove the handler after a number of
* invocations by setting {@code times}:
* <pre>{@code
* page.addLocatorHandler(page.getByLabel("Close"), locator => {
* locator.click();
* }, new Page.AddLocatorHandlerOptions().setTimes(1));
* }</pre>
*
* @param locator Locator that triggers the handler.
* @param handler Function that should be run once {@code locator} appears. This function should get rid of the element that blocks
* actions like click.
* @since v1.42
*/
void addLocatorHandler(Locator locator, Consumer<Locator> handler, AddLocatorHandlerOptions options);
/**
* Removes all locator handlers added by {@link com.microsoft.playwright.Page#addLocatorHandler Page.addLocatorHandler()}
* for a specific locator.
*
* @param locator Locator passed to {@link com.microsoft.playwright.Page#addLocatorHandler Page.addLocatorHandler()}.
* @since v1.44
*/
void removeLocatorHandler(Locator locator);
/**
* This method reloads the current page, in the same way as if the user had triggered a browser refresh. Returns the main
* resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect.
@@ -6175,6 +6242,9 @@ public interface Page extends AutoCloseable {
* <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers
* when using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
*
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#route Page.route()} will not intercept the first request of a popup page. Use
* {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} instead.
*
* <p> <strong>Usage</strong>
*
* <p> An example of a naive handler that aborts all image requests:
@@ -6231,6 +6301,9 @@ public interface Page extends AutoCloseable {
* <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers
* when using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
*
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#route Page.route()} will not intercept the first request of a popup page. Use
* {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} instead.
*
* <p> <strong>Usage</strong>
*
* <p> An example of a naive handler that aborts all image requests:
@@ -6285,6 +6358,9 @@ public interface Page extends AutoCloseable {
* <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers
* when using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
*
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#route Page.route()} will not intercept the first request of a popup page. Use
* {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} instead.
*
* <p> <strong>Usage</strong>
*
* <p> An example of a naive handler that aborts all image requests:
@@ -6341,6 +6417,9 @@ public interface Page extends AutoCloseable {
* <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers
* when using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
*
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#route Page.route()} will not intercept the first request of a popup page. Use
* {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} instead.
*
* <p> <strong>Usage</strong>
*
* <p> An example of a naive handler that aborts all image requests:
@@ -6395,6 +6474,9 @@ public interface Page extends AutoCloseable {
* <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers
* when using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
*
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#route Page.route()} will not intercept the first request of a popup page. Use
* {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} instead.
*
* <p> <strong>Usage</strong>
*
* <p> An example of a naive handler that aborts all image requests:
@@ -6451,6 +6533,9 @@ public interface Page extends AutoCloseable {
* <a href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers
* when using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
*
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#route Page.route()} will not intercept the first request of a popup page. Use
* {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} instead.
*
* <p> <strong>Usage</strong>
*
* <p> An example of a naive handler that aborts all image requests:
@@ -6930,7 +7015,6 @@ public interface Page extends AutoCloseable {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now checked or unchecked. If not, this method throws.</li>
* </ol>
*
@@ -6954,7 +7038,6 @@ public interface Page extends AutoCloseable {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now checked or unchecked. If not, this method throws.</li>
* </ol>
*
@@ -7029,7 +7112,8 @@ public interface Page extends AutoCloseable {
void setExtraHTTPHeaders(Map<String, String> headers);
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
* they are resolved relative to the current working directory. For empty array, clears the selected files.
* they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
* a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
* <p> This method expects {@code selector} to point to an <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a>. However, if the element is
@@ -7045,7 +7129,8 @@ public interface Page extends AutoCloseable {
}
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
* they are resolved relative to the current working directory. For empty array, clears the selected files.
* they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
* a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
* <p> This method expects {@code selector} to point to an <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a>. However, if the element is
@@ -7059,7 +7144,8 @@ public interface Page extends AutoCloseable {
void setInputFiles(String selector, Path files, SetInputFilesOptions options);
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
* they are resolved relative to the current working directory. For empty array, clears the selected files.
* they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
* a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
* <p> This method expects {@code selector} to point to an <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a>. However, if the element is
@@ -7075,7 +7161,8 @@ public interface Page extends AutoCloseable {
}
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
* they are resolved relative to the current working directory. For empty array, clears the selected files.
* they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
* a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
* <p> This method expects {@code selector} to point to an <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a>. However, if the element is
@@ -7089,7 +7176,8 @@ public interface Page extends AutoCloseable {
void setInputFiles(String selector, Path[] files, SetInputFilesOptions options);
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
* they are resolved relative to the current working directory. For empty array, clears the selected files.
* they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
* a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
* <p> This method expects {@code selector} to point to an <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a>. However, if the element is
@@ -7105,7 +7193,8 @@ public interface Page extends AutoCloseable {
}
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
* they are resolved relative to the current working directory. For empty array, clears the selected files.
* they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
* a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
* <p> This method expects {@code selector} to point to an <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a>. However, if the element is
@@ -7119,7 +7208,8 @@ public interface Page extends AutoCloseable {
void setInputFiles(String selector, FilePayload files, SetInputFilesOptions options);
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
* they are resolved relative to the current working directory. For empty array, clears the selected files.
* they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
* a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
* <p> This method expects {@code selector} to point to an <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a>. However, if the element is
@@ -7135,7 +7225,8 @@ public interface Page extends AutoCloseable {
}
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
* they are resolved relative to the current working directory. For empty array, clears the selected files.
* they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
* a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
* <p> This method expects {@code selector} to point to an <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input">input element</a>. However, if the element is
@@ -7177,7 +7268,6 @@ public interface Page extends AutoCloseable {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#touchscreen Page.touchscreen()} to tap the center of the element, or the
* specified {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* </ol>
*
* <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
@@ -7201,7 +7291,6 @@ public interface Page extends AutoCloseable {
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#touchscreen Page.touchscreen()} to tap the center of the element, or the
* specified {@code position}.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* </ol>
*
* <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
@@ -7274,7 +7363,6 @@ public interface Page extends AutoCloseable {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now unchecked. If not, this method throws.</li>
* </ol>
*
@@ -7297,7 +7385,6 @@ public interface Page extends AutoCloseable {
* 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 com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Wait for initiated navigations to either succeed or fail, unless {@code noWaitAfter} option is set.</li>
* <li> Ensure that the element is now unchecked. If not, this method throws.</li>
* </ol>
*
@@ -7588,6 +7675,9 @@ public interface Page extends AutoCloseable {
* <p> This resolves when the page reaches a required load state, {@code load} by default. The navigation must have been
* committed when this method is called. If current document has already reached the required state, resolves immediately.
*
* <p> <strong>NOTE:</strong> Most of the time, this method is not needed because Playwright <a
* href="https://playwright.dev/java/docs/actionability">auto-waits before every action</a>.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* page.getByRole(AriaRole.BUTTON).click(); // Click triggers navigation.
@@ -7621,6 +7711,9 @@ public interface Page extends AutoCloseable {
* <p> This resolves when the page reaches a required load state, {@code load} by default. The navigation must have been
* committed when this method is called. If current document has already reached the required state, resolves immediately.
*
* <p> <strong>NOTE:</strong> Most of the time, this method is not needed because Playwright <a
* href="https://playwright.dev/java/docs/actionability">auto-waits before every action</a>.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* page.getByRole(AriaRole.BUTTON).click(); // Click triggers navigation.
@@ -7646,6 +7739,9 @@ public interface Page extends AutoCloseable {
* <p> This resolves when the page reaches a required load state, {@code load} by default. The navigation must have been
* committed when this method is called. If current document has already reached the required state, resolves immediately.
*
* <p> <strong>NOTE:</strong> Most of the time, this method is not needed because Playwright <a
* href="https://playwright.dev/java/docs/actionability">auto-waits before every action</a>.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* page.getByRole(AriaRole.BUTTON).click(); // Click triggers navigation.
@@ -7904,7 +8000,7 @@ public interface Page extends AutoCloseable {
* });
*
* // Waits for the next response matching some conditions
* Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200, () -> {
* Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200 && "GET".equals(response.request().method()), () -> {
* // Triggers the response
* page.getByText("trigger response").click();
* });
@@ -7932,7 +8028,7 @@ public interface Page extends AutoCloseable {
* });
*
* // Waits for the next response matching some conditions
* Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200, () -> {
* Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200 && "GET".equals(response.request().method()), () -> {
* // Triggers the response
* page.getByText("trigger response").click();
* });
@@ -7958,7 +8054,7 @@ public interface Page extends AutoCloseable {
* });
*
* // Waits for the next response matching some conditions
* Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200, () -> {
* Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200 && "GET".equals(response.request().method()), () -> {
* // Triggers the response
* page.getByText("trigger response").click();
* });
@@ -7986,7 +8082,7 @@ public interface Page extends AutoCloseable {
* });
*
* // Waits for the next response matching some conditions
* Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200, () -> {
* Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200 && "GET".equals(response.request().method()), () -> {
* // Triggers the response
* page.getByText("trigger response").click();
* });
@@ -8012,7 +8108,7 @@ public interface Page extends AutoCloseable {
* });
*
* // Waits for the next response matching some conditions
* Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200, () -> {
* Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200 && "GET".equals(response.request().method()), () -> {
* // Triggers the response
* page.getByText("trigger response").click();
* });
@@ -8040,7 +8136,7 @@ public interface Page extends AutoCloseable {
* });
*
* // Waits for the next response matching some conditions
* Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200, () -> {
* Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200 && "GET".equals(response.request().method()), () -> {
* // Triggers the response
* page.getByText("trigger response").click();
* });
@@ -99,7 +99,7 @@ public interface Request {
*/
List<HttpHeader> headersArray();
/**
* Returns the value of the header matching the name. The name is case insensitive.
* Returns the value of the header matching the name. The name is case-insensitive.
*
* @param name Name of the header.
* @since v1.15
@@ -71,7 +71,7 @@ public interface Response {
*/
List<HttpHeader> headersArray();
/**
* Returns the value of the header matching the name. The name is case insensitive. If multiple headers have the same name
* Returns the value of the header matching the name. The name is case-insensitive. If multiple headers have the same name
* (except {@code set-cookie}), they are returned as a list separated by {@code , }. For {@code set-cookie}, the {@code \n}
* separator is used. If no headers are found, {@code null} is returned.
*
@@ -80,7 +80,7 @@ public interface Response {
*/
String headerValue(String name);
/**
* Returns all values of the headers matching the name, for example {@code set-cookie}. The name is case insensitive.
* Returns all values of the headers matching the name, for example {@code set-cookie}. The name is case-insensitive.
*
* @param name Name of the header.
* @since v1.15
@@ -147,6 +147,12 @@ public interface Route {
* exceeded. Defaults to {@code 20}. Pass {@code 0} to not follow redirects.
*/
public Integer maxRedirects;
/**
* Maximum number of times network errors should be retried. Currently only {@code ECONNRESET} error is retried. Does not
* retry based on HTTP response codes. An error will be thrown if the limit is exceeded. Defaults to {@code 0} - no
* retries.
*/
public Integer maxRetries;
/**
* If set changes the request method (e.g. GET or POST).
*/
@@ -179,6 +185,15 @@ public interface Route {
this.maxRedirects = maxRedirects;
return this;
}
/**
* Maximum number of times network errors should be retried. Currently only {@code ECONNRESET} error is retried. Does not
* retry based on HTTP response codes. An error will be thrown if the limit is exceeded. Defaults to {@code 0} - no
* retries.
*/
public FetchOptions setMaxRetries(int maxRetries) {
this.maxRetries = maxRetries;
return this;
}
/**
* If set changes the request method (e.g. GET or POST).
*/
@@ -28,6 +28,8 @@ public interface Touchscreen {
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#tap Page.tap()} the method will throw if {@code hasTouch} option of the browser
* context is false.
*
* @param x X coordinate relative to the main frame's viewport in CSS pixels.
* @param y Y coordinate relative to the main frame's viewport in CSS pixels.
* @since v1.8
*/
void tap(double x, double y);
@@ -17,6 +17,7 @@
package com.microsoft.playwright.assertions;
import java.util.regex.Pattern;
import com.microsoft.playwright.options.AriaRole;
/**
* The {@code LocatorAssertions} class provides assertion methods that can be used to make assertions about the {@code
@@ -253,6 +254,60 @@ public interface LocatorAssertions {
return this;
}
}
class HasAccessibleDescriptionOptions {
/**
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
* expression flag if specified.
*/
public Boolean ignoreCase;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
public Double timeout;
/**
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
* expression flag if specified.
*/
public HasAccessibleDescriptionOptions setIgnoreCase(boolean ignoreCase) {
this.ignoreCase = ignoreCase;
return this;
}
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
public HasAccessibleDescriptionOptions setTimeout(double timeout) {
this.timeout = timeout;
return this;
}
}
class HasAccessibleNameOptions {
/**
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
* expression flag if specified.
*/
public Boolean ignoreCase;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
public Double timeout;
/**
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
* expression flag if specified.
*/
public HasAccessibleNameOptions setIgnoreCase(boolean ignoreCase) {
this.ignoreCase = ignoreCase;
return this;
}
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
public HasAccessibleNameOptions setTimeout(double timeout) {
this.timeout = timeout;
return this;
}
}
class HasAttributeOptions {
/**
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
@@ -350,6 +405,20 @@ public interface LocatorAssertions {
return this;
}
}
class HasRoleOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
public HasRoleOptions setTimeout(double timeout) {
this.timeout = timeout;
return this;
}
}
class HasTextOptions {
/**
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
@@ -683,10 +752,10 @@ public interface LocatorAssertions {
* assertThat(page.getByText("Welcome")).isVisible();
*
* // At least one item in the list is visible.
* asserThat(page.getByTestId("todo-item").first()).isVisible();
* assertThat(page.getByTestId("todo-item").first()).isVisible();
*
* // At least one of the two elements is visible, possibly both.
* asserThat(
* assertThat(
* page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Sign in"))
* .or(page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Sign up")))
* .first()
@@ -711,10 +780,10 @@ public interface LocatorAssertions {
* assertThat(page.getByText("Welcome")).isVisible();
*
* // At least one item in the list is visible.
* asserThat(page.getByTestId("todo-item").first()).isVisible();
* assertThat(page.getByTestId("todo-item").first()).isVisible();
*
* // At least one of the two elements is visible, possibly both.
* asserThat(
* assertThat(
* page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Sign in"))
* .or(page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Sign up")))
* .first()
@@ -1076,6 +1145,126 @@ public interface LocatorAssertions {
* @since v1.20
*/
void containsText(Pattern[] expected, ContainsTextOptions options);
/**
* Ensures the {@code Locator} points to an element with a given <a
* href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* Locator locator = page.getByTestId("save-button");
* assertThat(locator).hasAccessibleDescription("Save results to disk");
* }</pre>
*
* @param description Expected accessible description.
* @since v1.44
*/
default void hasAccessibleDescription(String description) {
hasAccessibleDescription(description, null);
}
/**
* Ensures the {@code Locator} points to an element with a given <a
* href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* Locator locator = page.getByTestId("save-button");
* assertThat(locator).hasAccessibleDescription("Save results to disk");
* }</pre>
*
* @param description Expected accessible description.
* @since v1.44
*/
void hasAccessibleDescription(String description, HasAccessibleDescriptionOptions options);
/**
* Ensures the {@code Locator} points to an element with a given <a
* href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* Locator locator = page.getByTestId("save-button");
* assertThat(locator).hasAccessibleDescription("Save results to disk");
* }</pre>
*
* @param description Expected accessible description.
* @since v1.44
*/
default void hasAccessibleDescription(Pattern description) {
hasAccessibleDescription(description, null);
}
/**
* Ensures the {@code Locator} points to an element with a given <a
* href="https://w3c.github.io/accname/#dfn-accessible-description">accessible description</a>.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* Locator locator = page.getByTestId("save-button");
* assertThat(locator).hasAccessibleDescription("Save results to disk");
* }</pre>
*
* @param description Expected accessible description.
* @since v1.44
*/
void hasAccessibleDescription(Pattern description, HasAccessibleDescriptionOptions options);
/**
* Ensures the {@code Locator} points to an element with a given <a
* href="https://w3c.github.io/accname/#dfn-accessible-name">accessible name</a>.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* Locator locator = page.getByTestId("save-button");
* assertThat(locator).hasAccessibleName("Save to disk");
* }</pre>
*
* @param name Expected accessible name.
* @since v1.44
*/
default void hasAccessibleName(String name) {
hasAccessibleName(name, null);
}
/**
* Ensures the {@code Locator} points to an element with a given <a
* href="https://w3c.github.io/accname/#dfn-accessible-name">accessible name</a>.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* Locator locator = page.getByTestId("save-button");
* assertThat(locator).hasAccessibleName("Save to disk");
* }</pre>
*
* @param name Expected accessible name.
* @since v1.44
*/
void hasAccessibleName(String name, HasAccessibleNameOptions options);
/**
* Ensures the {@code Locator} points to an element with a given <a
* href="https://w3c.github.io/accname/#dfn-accessible-name">accessible name</a>.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* Locator locator = page.getByTestId("save-button");
* assertThat(locator).hasAccessibleName("Save to disk");
* }</pre>
*
* @param name Expected accessible name.
* @since v1.44
*/
default void hasAccessibleName(Pattern name) {
hasAccessibleName(name, null);
}
/**
* Ensures the {@code Locator} points to an element with a given <a
* href="https://w3c.github.io/accname/#dfn-accessible-name">accessible name</a>.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* Locator locator = page.getByTestId("save-button");
* assertThat(locator).hasAccessibleName("Save to disk");
* }</pre>
*
* @param name Expected accessible name.
* @since v1.44
*/
void hasAccessibleName(Pattern name, HasAccessibleNameOptions options);
/**
* Ensures the {@code Locator} points to an element with given attribute.
*
@@ -1456,6 +1645,42 @@ public interface LocatorAssertions {
* @since v1.20
*/
void hasJSProperty(String name, Object value, HasJSPropertyOptions options);
/**
* Ensures the {@code Locator} points to an element with a given <a href="https://www.w3.org/TR/wai-aria-1.2/#roles">ARIA
* role</a>.
*
* <p> Note that role is matched as a string, disregarding the ARIA role hierarchy. For example, asserting a superclass role
* {@code "checkbox"} on an element with a subclass role {@code "switch"} will fail.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* Locator locator = page.getByTestId("save-button");
* assertThat(locator).hasRole(AriaRole.BUTTON);
* }</pre>
*
* @param role Required aria role.
* @since v1.44
*/
default void hasRole(AriaRole role) {
hasRole(role, null);
}
/**
* Ensures the {@code Locator} points to an element with a given <a href="https://www.w3.org/TR/wai-aria-1.2/#roles">ARIA
* role</a>.
*
* <p> Note that role is matched as a string, disregarding the ARIA role hierarchy. For example, asserting a superclass role
* {@code "checkbox"} on an element with a subclass role {@code "switch"} will fail.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* Locator locator = page.getByTestId("save-button");
* assertThat(locator).hasRole(AriaRole.BUTTON);
* }</pre>
*
* @param role Required aria role.
* @since v1.44
*/
void hasRole(AriaRole role, HasRoleOptions options);
/**
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
* computing the text content of the element. You can use regular expressions for the value as well.
@@ -52,11 +52,24 @@ public interface PageAssertions {
}
}
class HasURLOptions {
/**
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
* expression flag if specified.
*/
public Boolean ignoreCase;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
public Double timeout;
/**
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
* expression flag if specified.
*/
public HasURLOptions setIgnoreCase(boolean ignoreCase) {
this.ignoreCase = ignoreCase;
return this;
}
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
@@ -29,6 +29,7 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.Base64;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import static com.microsoft.playwright.impl.Serialization.*;
@@ -36,6 +37,7 @@ import static com.microsoft.playwright.impl.Utils.toFilePayload;
class APIRequestContextImpl extends ChannelOwner implements APIRequestContext {
private final TracingImpl tracing;
private String disposeReason;
APIRequestContextImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
super(parent, type, guid, initializer);
@@ -48,8 +50,17 @@ class APIRequestContextImpl extends ChannelOwner implements APIRequestContext {
}
@Override
public void dispose() {
withLogging("APIRequestContext.dispose", () -> sendMessage("dispose"));
public void dispose(DisposeOptions options) {
withLogging("APIRequestContext.dispose", () -> disposeImpl(options));
}
private void disposeImpl(DisposeOptions options) {
if (options == null) {
options = new DisposeOptions();
}
disposeReason = options.reason;
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
sendMessage("dispose", params);
}
@Override
@@ -76,6 +87,9 @@ class APIRequestContextImpl extends ChannelOwner implements APIRequestContext {
}
private APIResponse fetchImpl(String url, RequestOptionsImpl options) {
if (disposeReason != null) {
throw new PlaywrightException(disposeReason);
}
if (options == null) {
options = new RequestOptionsImpl();
}
@@ -86,7 +100,7 @@ class APIRequestContextImpl extends ChannelOwner implements APIRequestContext {
for (Map.Entry<String, ?> e : options.params.entrySet()) {
queryParams.put(e.getKey(), "" + e.getValue());
}
params.add("params", toNameValueArray(queryParams));
params.add("params", toNameValueArray(queryParams.entrySet()));
}
if (options.method != null) {
params.addProperty("method", options.method);
@@ -106,7 +120,7 @@ class APIRequestContextImpl extends ChannelOwner implements APIRequestContext {
}
}
if (bytes == null) {
params.addProperty("jsonData", gson().toJson(options.data));
params.addProperty("jsonData", jsonDataSerializer.toJson(options.data));
} else {
String base64 = Base64.getEncoder().encodeToString(bytes);
params.addProperty("postData", base64);
@@ -133,6 +147,12 @@ class APIRequestContextImpl extends ChannelOwner implements APIRequestContext {
}
params.addProperty("maxRedirects", options.maxRedirects);
}
if (options.maxRetries != null) {
if (options.maxRetries < 0) {
throw new PlaywrightException("'maxRetries' must be greater than or equal to '0'");
}
params.addProperty("maxRetries", options.maxRetries);
}
JsonObject json = sendMessage("fetch", params).getAsJsonObject();
return new APIResponseImpl(this, json.getAsJsonObject("response"));
}
@@ -149,9 +169,9 @@ class APIRequestContextImpl extends ChannelOwner implements APIRequestContext {
return false;
}
private static JsonArray serializeMultipartData(Map<String, Object> data) {
private static JsonArray serializeMultipartData(List<? extends Map.Entry<String, Object>> data) {
JsonArray result = new JsonArray();
for (Map.Entry<String, Object> e : data.entrySet()) {
for (Map.Entry<String, ?> e : data) {
FilePayload filePayload = null;
if (e.getValue() instanceof FilePayload) {
filePayload = (FilePayload) e.getValue();
@@ -17,15 +17,21 @@
package com.microsoft.playwright.impl;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.microsoft.playwright.APIRequest;
import com.microsoft.playwright.PlaywrightException;
import com.microsoft.playwright.options.ClientCertificate;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Base64;
import java.util.List;
import static com.microsoft.playwright.impl.Serialization.gson;
import static com.microsoft.playwright.impl.Utils.addToProtocol;
import static java.nio.file.Files.readAllBytes;
class APIRequestImpl implements APIRequest {
private final PlaywrightImpl playwright;
@@ -42,6 +48,8 @@ class APIRequestImpl implements APIRequest {
private APIRequestContextImpl newContextImpl(NewContextOptions options) {
if (options == null) {
options = new NewContextOptions();
} else {
options = Utils.clone(options);
}
if (options.storageStatePath != null) {
try {
@@ -57,11 +65,13 @@ class APIRequestImpl implements APIRequest {
storageState = new Gson().fromJson(options.storageState, JsonObject.class);
options.storageState = null;
}
List<ClientCertificate> clientCertificateList = options.clientCertificates;
options.clientCertificates = null;
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
if (storageState != null) {
params.add("storageState", storageState);
}
addToProtocol(params, clientCertificateList);
JsonObject result = playwright.sendMessage("newRequest", params).getAsJsonObject();
APIRequestContextImpl context = playwright.connection.getExistingObject(result.getAsJsonObject("request").get("guid").getAsString());
return context;
@@ -20,6 +20,7 @@ import com.microsoft.playwright.PlaywrightException;
import org.opentest4j.AssertionFailedError;
import org.opentest4j.ValueWrapper;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.List;
import java.util.regex.Pattern;
@@ -91,4 +92,17 @@ class AssertionsBase {
}
return expected;
}
static Boolean shouldIgnoreCase(Object options) {
if (options == null) {
return null;
}
try {
Field fromField = options.getClass().getDeclaredField("ignoreCase");
Object value = fromField.get(options);
return (Boolean) value;
} catch (NoSuchFieldException | IllegalAccessException e) {
return null;
}
}
}
@@ -36,8 +36,7 @@ import java.util.regex.Pattern;
import static com.microsoft.playwright.impl.Serialization.addHarUrlFilter;
import static com.microsoft.playwright.impl.Serialization.gson;
import static com.microsoft.playwright.impl.Utils.isSafeCloseError;
import static com.microsoft.playwright.impl.Utils.toJsRegexFlags;
import static com.microsoft.playwright.impl.Utils.*;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.readAllBytes;
import static java.util.Arrays.asList;
@@ -46,6 +45,7 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
private final BrowserImpl browser;
private final TracingImpl tracing;
private final APIRequestContextImpl request;
private final ClockImpl clock;
final List<PageImpl> pages = new ArrayList<>();
final List<PageImpl> backgroundPages = new ArrayList<>();
@@ -104,6 +104,7 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
}
tracing = connection.getExistingObject(initializer.getAsJsonObject("tracing").get("guid").getAsString());
request = connection.getExistingObject(initializer.getAsJsonObject("requestContext").get("guid").getAsString());
clock = new ClockImpl(this);
closePromise = new WaitableEvent<>(listeners, EventType.CLOSE);
}
@@ -231,6 +232,11 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
listeners.remove(EventType.RESPONSE, handler);
}
@Override
public ClockImpl clock() {
return clock;
}
private <T> T waitForEventWithTimeout(EventType eventType, Runnable code, Predicate<T> predicate, Double timeout) {
List<Waitable<T>> waitables = new ArrayList<>();
waitables.add(new WaitableEvent<>(listeners, eventType, predicate));
@@ -284,6 +290,7 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
options = new CloseOptions();
}
closeReason = options.reason;
request.dispose(convertType(options, APIRequestContext.DisposeOptions.class));
for (Map.Entry<String, HarRecorder> entry : harRecorders.entrySet()) {
JsonObject params = new JsonObject();
params.addProperty("harId", entry.getKey());
@@ -208,6 +208,7 @@ class BrowserImpl extends ChannelOwner implements Browser {
params.addProperty("noDefaultViewport", true);
}
}
addToProtocol(params, options.clientCertificates);
params.remove("acceptDownloads");
if (options.acceptDownloads != null) {
params.addProperty("acceptDownloads", options.acceptDownloads ? "accept" : "deny");
@@ -30,6 +30,7 @@ import java.util.function.Consumer;
import static com.microsoft.playwright.impl.Serialization.addHarUrlFilter;
import static com.microsoft.playwright.impl.Serialization.gson;
import static com.microsoft.playwright.impl.Utils.addToProtocol;
import static com.microsoft.playwright.impl.Utils.convertType;
class BrowserTypeImpl extends ChannelOwner implements BrowserType {
@@ -221,6 +222,7 @@ class BrowserTypeImpl extends ChannelOwner implements BrowserType {
params.addProperty("noDefaultViewport", true);
}
}
addToProtocol(params, options.clientCertificates);
params.remove("acceptDownloads");
if (options.acceptDownloads != null) {
params.addProperty("acceptDownloads", options.acceptDownloads ? "accept" : "deny");
@@ -35,7 +35,10 @@ public class CDPSessionImpl extends ChannelOwner implements CDPSession {
super.handleEvent(event, parameters);
if ("event".equals(event)) {
String method = parameters.get("method").getAsString();
JsonObject params = parameters.get("params").getAsJsonObject();
JsonObject params = null;
if (parameters.has("params")) {
params = parameters.get("params").getAsJsonObject();
}
listeners.notify(method, params);
}
}
@@ -0,0 +1,129 @@
package com.microsoft.playwright.impl;
import com.google.gson.JsonObject;
import com.microsoft.playwright.Clock;
import java.util.Date;
class ClockImpl implements Clock {
private final ChannelOwner browserContext;
ClockImpl(BrowserContextImpl browserContext) {
this.browserContext = browserContext;
}
@Override
public void fastForward(long ticks) {
JsonObject params = new JsonObject();
params.addProperty("ticksNumber", ticks);
browserContext.sendMessage("clockFastForward", params);
}
@Override
public void fastForward(String ticks) {
JsonObject params = new JsonObject();
params.addProperty("ticksString", ticks);
browserContext.sendMessage("clockFastForward", params);
}
@Override
public void install(InstallOptions options) {
JsonObject params = new JsonObject();
if (options != null) {
parseTime(options.time, params);
}
browserContext.sendMessage("clockInstall", params);
}
@Override
public void runFor(long ticks) {
JsonObject params = new JsonObject();
params.addProperty("ticksNumber", ticks);
browserContext.sendMessage("clockRunFor", params);
}
@Override
public void runFor(String ticks) {
JsonObject params = new JsonObject();
params.addProperty("ticksString", ticks);
browserContext.sendMessage("clockRunFor", params);
}
@Override
public void pauseAt(long time) {
JsonObject params = new JsonObject();
params.addProperty("timeNumber", time);
browserContext.sendMessage("clockPauseAt", params);
}
@Override
public void pauseAt(String time) {
JsonObject params = new JsonObject();
params.addProperty("timeString", time);
browserContext.sendMessage("clockPauseAt", params);
}
@Override
public void pauseAt(Date time) {
JsonObject params = new JsonObject();
params.addProperty("timeNumber", time.getTime());
browserContext.sendMessage("clockPauseAt", params);
}
@Override
public void resume() {
browserContext.sendMessage("clockResume");
}
@Override
public void setFixedTime(long time) {
JsonObject params = new JsonObject();
params.addProperty("timeNumber", time);
browserContext.sendMessage("clockSetFixedTime", params);
}
@Override
public void setFixedTime(String time) {
JsonObject params = new JsonObject();
params.addProperty("timeString", time);
browserContext.sendMessage("clockSetFixedTime", params);
}
@Override
public void setFixedTime(Date time) {
JsonObject params = new JsonObject();
params.addProperty("timeNumber", time.getTime());
browserContext.sendMessage("clockSetFixedTime", params);
}
@Override
public void setSystemTime(long time) {
JsonObject params = new JsonObject();
params.addProperty("timeNumber", time);
browserContext.sendMessage("clockSetSystemTime", params);
}
@Override
public void setSystemTime(String time) {
JsonObject params = new JsonObject();
params.addProperty("timeString", time);
browserContext.sendMessage("clockSetSystemTime", params);
}
@Override
public void setSystemTime(Date time) {
JsonObject params = new JsonObject();
params.addProperty("timeNumber", time.getTime());
browserContext.sendMessage("clockSetSystemTime", params);
}
private static void parseTime(Object time, JsonObject params) {
if (time instanceof Long) {
params.addProperty("timeNumber", (Long) time);
} else if (time instanceof Date) {
params.addProperty("timeNumber", ((Date) time).getTime());
} else if (time instanceof String) {
params.addProperty("timeString", (String) time);
}
}
}
@@ -21,11 +21,13 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.microsoft.playwright.ElementHandle;
import com.microsoft.playwright.Frame;
import com.microsoft.playwright.PlaywrightException;
import com.microsoft.playwright.options.BoundingBox;
import com.microsoft.playwright.options.ElementState;
import com.microsoft.playwright.options.FilePayload;
import com.microsoft.playwright.options.SelectOption;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Base64;
@@ -20,39 +20,93 @@ import com.microsoft.playwright.options.FilePayload;
import com.microsoft.playwright.options.FormData;
import java.nio.file.Path;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
public class FormDataImpl implements FormData {
Map<String, Object> fields = new LinkedHashMap<>();
static class Field implements Map.Entry<String, Object> {
final String name;
final Object value;
private Field(String name, Object value) {
this.name = name;
this.value = value;
}
@Override
public String getKey() {
return name;
}
@Override
public Object getValue() {
return value;
}
@Override
public Object setValue(Object value) {
throw new UnsupportedOperationException();
}
}
List<Field> fields = new ArrayList();
@Override
public FormData append(String name, String value) {
return appendImpl(name, value);
}
@Override
public FormData append(String name, boolean value) {
return appendImpl(name, value);
}
@Override
public FormData append(String name, int value) {
return appendImpl(name, value);
}
@Override
public FormData append(String name, Path value) {
return appendImpl(name, value);
}
@Override
public FormData append(String name, FilePayload value) {
return appendImpl(name, value);
}
@Override
public FormData set(String name, String value) {
fields.put(name, value);
return this;
return setImpl(name, value);
}
@Override
public FormData set(String name, boolean value) {
fields.put(name, value);
return this;
return setImpl(name, value);
}
@Override
public FormData set(String name, int value) {
fields.put(name, value);
return this;
return setImpl(name, value);
}
@Override
public FormData set(String name, Path value) {
fields.put(name, value);
return this;
return setImpl(name, value);
}
@Override
public FormData set(String name, FilePayload value) {
fields.put(name, value);
return setImpl(name, value);
}
private FormData setImpl(String name, Object value) {
fields = fields.stream().filter(f -> !name.equals(f.name)).collect(Collectors.toList());
return appendImpl(name, value);
}
private FormData appendImpl(String name, Object value) {
fields.add(new Field(name, value));
return this;
}
}
@@ -33,6 +33,7 @@ class JsonPipe extends ChannelOwner implements Transport {
private ListenerCollection<EventType> listeners = new ListenerCollection<>();
private enum EventType { CLOSE }
private boolean isClosed;
private String closeReason = "Browser has been closed";
JsonPipe(ChannelOwner parent, String type, String guid, JsonObject initializer) {
super(parent, type, guid, initializer);
@@ -97,13 +98,19 @@ class JsonPipe extends ChannelOwner implements Transport {
incoming.add(params.get("message").getAsJsonObject());
} else if ("closed".equals(event)) {
isClosed = true;
if (params.has("reason")) {
String reason = params.get("reason").getAsString();
if (reason.trim().length() > 0) {
closeReason = reason;
}
}
listeners.notify(EventType.CLOSE, this);
}
}
private void checkIfClosed() {
if (isClosed) {
throw new PlaywrightException("Browser has been closed");
throw new PlaywrightException(closeReason);
}
}
}
@@ -18,6 +18,7 @@ package com.microsoft.playwright.impl;
import com.microsoft.playwright.Locator;
import com.microsoft.playwright.assertions.LocatorAssertions;
import com.microsoft.playwright.options.AriaRole;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -82,6 +83,36 @@ public class LocatorAssertionsImpl extends AssertionsBase implements LocatorAsse
expectImpl("to.contain.text.array", list, patterns, "Locator expected to contain text", convertType(options, FrameExpectOptions.class));
}
@Override
public void hasAccessibleDescription(String description, HasAccessibleDescriptionOptions options) {
ExpectedTextValue expected = new ExpectedTextValue();
expected.string = description;
expected.ignoreCase = shouldIgnoreCase(options);
expectImpl("to.have.accessible.description", expected, description, "Locator expected to have accessible description", convertType(options, FrameExpectOptions.class));
}
@Override
public void hasAccessibleDescription(Pattern pattern, HasAccessibleDescriptionOptions options) {
ExpectedTextValue expected = expectedRegex(pattern);
expected.ignoreCase = shouldIgnoreCase(options);
expectImpl("to.have.accessible.description", expected, pattern, "Locator expected to have accessible description", convertType(options, FrameExpectOptions.class));
}
@Override
public void hasAccessibleName(String name, HasAccessibleNameOptions options) {
ExpectedTextValue expected = new ExpectedTextValue();
expected.string = name;
expected.ignoreCase = shouldIgnoreCase(options);
expectImpl("to.have.accessible.name", expected, name, "Locator expected to have accessible name", convertType(options, FrameExpectOptions.class));
}
@Override
public void hasAccessibleName(Pattern pattern, HasAccessibleNameOptions options) {
ExpectedTextValue expected = expectedRegex(pattern);
expected.ignoreCase = shouldIgnoreCase(options);
expectImpl("to.have.accessible.name", expected, pattern, "Locator expected to have accessible name", convertType(options, FrameExpectOptions.class));
}
@Override
public void hasAttribute(String name, String text, HasAttributeOptions options) {
ExpectedTextValue expected = new ExpectedTextValue();
@@ -206,6 +237,13 @@ public class LocatorAssertionsImpl extends AssertionsBase implements LocatorAsse
expectImpl("to.have.property", list, value, "Locator expected to have JavaScript property '" + name + "'", commonOptions);
}
@Override
public void hasRole(AriaRole role, HasRoleOptions options) {
ExpectedTextValue expected = new ExpectedTextValue();
expected.string = role.toString().toLowerCase();
expectImpl("to.have.role", expected, expected.string, "Locator expected to have role", convertType(options, FrameExpectOptions.class));
}
@Override
public void hasText(String text, HasTextOptions options) {
ExpectedTextValue expected = new ExpectedTextValue();
@@ -366,17 +404,4 @@ public class LocatorAssertionsImpl extends AssertionsBase implements LocatorAsse
String message = "Locator expected to be " + (attached ? "attached" : "detached");
expectTrue(attached ? "to.be.attached" : "to.be.detached", message, frameOptions);
}
private static Boolean shouldIgnoreCase(Object options) {
if (options == null) {
return null;
}
try {
Field fromField = options.getClass().getDeclaredField("ignoreCase");
Object value = fromField.get(options);
return (Boolean) value;
} catch (NoSuchFieldException | IllegalAccessException e) {
return null;
}
}
}
@@ -624,6 +624,20 @@ class LocatorImpl implements Locator {
return "Locator@" + selector;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof LocatorImpl)) {
return false;
}
LocatorImpl locator = (LocatorImpl) obj;
return frame.equals(locator.frame) && selector.equals(locator.selector);
}
@Override
public int hashCode() {
return frame.hashCode() ^ selector.hashCode();
}
FrameExpectResult expect(String expression, FrameExpectOptions options) {
return frame.withLogging("Locator.expect", () -> expectImpl(expression, options));
}
@@ -21,6 +21,7 @@ import com.microsoft.playwright.assertions.PageAssertions;
import java.util.regex.Pattern;
import static com.microsoft.playwright.impl.LocatorAssertionsImpl.shouldIgnoreCase;
import static com.microsoft.playwright.impl.UrlMatcher.resolveUrl;
import static com.microsoft.playwright.impl.Utils.convertType;
@@ -57,6 +58,7 @@ public class PageAssertionsImpl extends AssertionsBase implements PageAssertions
url = resolveUrl(actualPage.context().baseUrl, url);
}
expected.string = url;
expected.ignoreCase = shouldIgnoreCase(options);
expectImpl("to.have.url", expected, url, "Page URL expected to be", convertType(options, FrameExpectOptions.class));
}
@@ -49,7 +49,34 @@ public class PageImpl extends ChannelOwner implements Page {
private ViewportSize viewport;
private final Router routes = new Router();
private final Set<FrameImpl> frames = new LinkedHashSet<>();
private final Map<Integer, Runnable> locatorHandlers = new HashMap<>();
private final Map<Integer, LocatorHandler> locatorHandlers = new HashMap<>();
private static class LocatorHandler {
private final Locator locator;
private final Consumer<Locator> handler;
private Integer times;
LocatorHandler(Locator locator, Consumer<Locator> handler, Integer times) {
this.locator = locator;
this.handler = handler;
this.times = times;
}
boolean call() {
if (shouldRemove()) {
return true;
}
if (times != null) {
--times;
}
handler.accept(locator);
return shouldRemove();
}
private boolean shouldRemove() {
return times != null && times == 0;
}
}
private static final Map<EventType, String> eventSubscriptions() {
Map<EventType, String> result = new HashMap<>();
@@ -404,6 +431,11 @@ public class PageImpl extends ChannelOwner implements Page {
listeners.remove(EventType.WORKER, handler);
}
@Override
public ClockImpl clock() {
return browserContext.clock();
}
@Override
public Page waitForClose(WaitForCloseOptions options, Runnable code) {
return withWaitLogging("Page.waitForClose", logger -> waitForCloseImpl(options, code));
@@ -530,29 +562,58 @@ public class PageImpl extends ChannelOwner implements Page {
}
@Override
public void addLocatorHandler(Locator locator, Runnable handler) {
public void addLocatorHandler(Locator locator, Consumer<Locator> handler, AddLocatorHandlerOptions options) {
LocatorImpl locatorImpl = (LocatorImpl) locator;
if (locatorImpl.frame != mainFrame) {
throw new PlaywrightException("Locator must belong to the main frame of this page");
}
if (options == null) {
options = new AddLocatorHandlerOptions();
}
if (options.times != null && options.times == 0) {
return;
}
AddLocatorHandlerOptions finalOptions = options;
withLogging("Page.addLocatorHandler", () -> {
JsonObject params = new JsonObject();
params.addProperty("selector", locatorImpl.selector);
if (finalOptions.noWaitAfter != null && finalOptions.noWaitAfter) {
params.addProperty("noWaitAfter", true);
}
params.addProperty("selector", locatorImpl.selector);
JsonObject json = (JsonObject) sendMessage("registerLocatorHandler", params);
int uid = json.get("uid").getAsInt();
locatorHandlers.put(uid, handler);
locatorHandlers.put(uid, new LocatorHandler(locator, handler, finalOptions.times));
});
}
private void onLocatorHandlerTriggered(int uid) {
try {
Runnable handler = locatorHandlers.get(uid);
if (handler != null) {
handler.run();
@Override
public void removeLocatorHandler(Locator locator) {
for (Map.Entry<Integer, LocatorHandler> entry: locatorHandlers.entrySet()) {
if (entry.getValue().locator.equals(locator)) {
locatorHandlers.remove(locator);
JsonObject params = new JsonObject();
params.addProperty("uid", entry.getKey());
try {
sendMessage("unregisterLocatorHandler", params);
} catch (PlaywrightException e) {
}
}
}
}
private void onLocatorHandlerTriggered(int uid) {
boolean remove = false;
try {
LocatorHandler handler = locatorHandlers.get(uid);
remove = handler != null && handler.call();
} finally {
if (remove) {
locatorHandlers.remove(uid);
}
JsonObject params = new JsonObject();
params.addProperty("uid", uid);
params.addProperty("remove", remove);
sendMessageAsync("resolveLocatorHandlerNoReply", params);
}
}
@@ -33,6 +33,12 @@ class SerializedValue{
String d;
String u;
String bi;
public static class E {
String m;
String n;
String s;
}
E e;
public static class R {
String p;
String f;
@@ -33,6 +33,7 @@ public class RequestOptionsImpl implements RequestOptions {
Boolean ignoreHTTPSErrors;
Double timeout;
Integer maxRedirects;
Integer maxRetries;
@Override
public RequestOptions setHeader(String name, String value) {
@@ -125,4 +126,10 @@ public class RequestOptionsImpl implements RequestOptions {
this.maxRedirects = maxRedirects;
return this;
}
@Override
public RequestOptions setMaxRetries(int maxRetries) {
this.maxRetries = maxRetries;
return this;
}
}
@@ -24,9 +24,7 @@ import com.microsoft.playwright.ElementHandle;
import com.microsoft.playwright.PlaywrightException;
import com.microsoft.playwright.options.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.*;
import java.lang.reflect.Type;
import java.math.BigInteger;
import java.net.MalformedURLException;
@@ -35,11 +33,7 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.*;
import java.util.*;
import java.util.regex.Pattern;
@@ -55,6 +49,7 @@ class Serialization {
.registerTypeAdapter(ColorScheme.class, new ToLowerCaseAndDashSerializer<ColorScheme>())
.registerTypeAdapter(Media.class, new ToLowerCaseSerializer<Media>())
.registerTypeAdapter(ForcedColors.class, new ToLowerCaseSerializer<ForcedColors>())
.registerTypeAdapter(HttpCredentialsSend.class, new ToLowerCaseSerializer<HttpCredentialsSend>())
.registerTypeAdapter(ReducedMotion.class, new ToLowerCaseAndDashSerializer<ReducedMotion>())
.registerTypeAdapter(ScreenshotAnimations.class, new ToLowerCaseSerializer<ScreenshotAnimations>())
.registerTypeAdapter(ScreenshotType.class, new ToLowerCaseSerializer<ScreenshotType>())
@@ -76,6 +71,12 @@ class Serialization {
return gson;
}
static final Gson jsonDataSerializer = new GsonBuilder().disableHtmlEscaping()
.registerTypeAdapter(Date.class, new DateSerializer())
.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer())
.registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeSerializer())
.serializeNulls().create();
static SerializedError serializeError(Throwable e) {
SerializedError result = new SerializedError();
result.error = new SerializedError.Error();
@@ -169,6 +170,14 @@ class Serialization {
result.r = new SerializedValue.R();
result.r.p = ((Pattern)value).pattern();
result.r.f = toJsRegexFlags(((Pattern)value));
} else if (value instanceof Exception) {
Exception exception = (Exception) value;
result.e = new SerializedValue.E();
result.e.m = exception.getMessage();
result.e.n = exception.getClass().getSimpleName();
StringWriter sw = new StringWriter();
exception.printStackTrace(new PrintWriter(sw));
result.e.s = sw.toString();
} else {
HashableValue mapKey = new HashableValue(value);
Integer id = valueToId.get(mapKey);
@@ -246,6 +255,9 @@ class Serialization {
return (T)(Date.from(Instant.parse(value.d)));
if (value.r != null)
return (T)(Pattern.compile(value.r.p, fromJsRegexFlags(value.r.f)));
if (value.e != null) {
return (T)new Exception(value.e.s);
}
if (value.v != null) {
switch (value.v) {
case "undefined":
@@ -303,6 +315,9 @@ class Serialization {
if (modifiers.contains(KeyboardModifier.CONTROL)) {
result.add("Control");
}
if (modifiers.contains(KeyboardModifier.CONTROLORMETA)) {
result.add("ControlOrMeta");
}
if (modifiers.contains(KeyboardModifier.META)) {
result.add("Meta");
}
@@ -351,7 +366,7 @@ class Serialization {
throw new PlaywrightException("Value cannot be null");
}
}
return toNameValueArray(map);
return toNameValueArray(map.entrySet());
}
static void addHarUrlFilter(JsonObject options, Object urlFilter) {
@@ -364,9 +379,9 @@ class Serialization {
}
}
static JsonArray toNameValueArray(Map<String, ?> map) {
static JsonArray toNameValueArray(Iterable<? extends Map.Entry<String, ?>> collection) {
JsonArray array = new JsonArray();
for (Map.Entry<String, ?> e : map.entrySet()) {
for (Map.Entry<String, ?> e : collection) {
JsonObject item = new JsonObject();
item.addProperty("name", e.getKey());
if (e.getValue() instanceof FilePayload) {
@@ -514,6 +529,13 @@ class Serialization {
}
}
private static class OffsetDateTimeSerializer implements JsonSerializer<OffsetDateTime> {
@Override
public JsonElement serialize(OffsetDateTime src, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive(dateFormat.format(Date.from(src.toInstant())));
}
}
private static class LocalDateTimeSerializer implements JsonSerializer<LocalDateTime> {
@Override
public JsonElement serialize(LocalDateTime src, Type typeOfSrc, JsonSerializationContext context) {
@@ -17,8 +17,10 @@
package com.microsoft.playwright.impl;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.microsoft.playwright.PlaywrightException;
import com.microsoft.playwright.options.ClientCertificate;
import com.microsoft.playwright.options.FilePayload;
import com.microsoft.playwright.options.HttpHeader;
@@ -33,8 +35,10 @@ import java.nio.file.Path;
import java.nio.file.attribute.FileTime;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static com.microsoft.playwright.impl.Serialization.toJsonArray;
import static java.nio.file.Files.readAllBytes;
public class Utils {
static <F, T> T convertType(F f, Class<T> t) {
@@ -173,42 +177,107 @@ public class Utils {
return mimeType;
}
static void addFilePathUploadParams(Path[] files, JsonObject params, BrowserContextImpl context) {
if (files.length == 0) {
static void addFilePathUploadParams(Path[] items, JsonObject params, BrowserContextImpl context) {
List<Path> localPaths = new ArrayList<>();
Path localDirectory = resolvePathsAndDirectoryForInputFiles(items, localPaths);
if (items.length == 0) {
// FIXME: shouldBeAbleToResetSelectedFilesWithEmptyFileList tesst hangs in Chromium if we pass empty paths list.
params.add("payloads", new JsonArray());
} else if (context.connection.isRemote) {
List<WritableStream> streams = new ArrayList<>();
JsonArray jsonStreams = new JsonArray();
for (Path path : files) {
long lastModifiedMs;
try {
lastModifiedMs = Files.getLastModifiedTime(path).toMillis();
} catch (IOException e) {
throw new PlaywrightException("Cannot read file timestamp: " + path, e);
}
WritableStream temp = context.createTempFile(path.getFileName().toString(), lastModifiedMs);
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.toProtocolRef());
if (localDirectory != null) {
localPaths = collectFiles(localDirectory);
}
JsonObject json = createTempFiles(context, localDirectory, localPaths);
JsonArray writableStreams = json.getAsJsonArray("writableStreams");
JsonArray jsonStreams = copyLocalToTempFiles(context, localPaths, writableStreams);
if (json.has("rootDir")) {
params.add("directoryStream", json.get("rootDir"));
} else {
params.add("streams", jsonStreams);
}
params.add("streams", jsonStreams);
} else {
Path[] absolute = Arrays.stream(files).map(f -> {
try {
return f.toRealPath();
} catch (IOException e) {
throw new PlaywrightException("Cannot get absolute file path", e);
}
}).toArray(Path[]::new);
params.add("localPaths", toJsonArray(absolute));
if (!localPaths.isEmpty()) {
params.add("localPaths", toJsonArray(localPaths.toArray(new Path[0])));
}
if (localDirectory != null) {
params.addProperty("localDirectory", localDirectory.toString());
}
}
}
private static Path resolvePathsAndDirectoryForInputFiles(Path[] items, List<Path> outLocalPaths) {
Path localDirectory = null;
try {
for (Path item : items) {
if (Files.isDirectory(item)) {
if (localDirectory != null) {
throw new PlaywrightException("Multiple directories are not supported");
}
localDirectory = item.toRealPath();
} else {
outLocalPaths.add(item.toRealPath());
}
}
} catch (IOException e) {
throw new PlaywrightException("Cannot get absolute file path", e);
}
if (!outLocalPaths.isEmpty() && localDirectory != null) {
throw new PlaywrightException("File paths must be all files or a single directory");
}
return localDirectory;
}
private static List<Path> collectFiles(Path localDirectory) {
try {
return Files.walk(localDirectory).filter(e -> Files.isRegularFile(e)).collect(Collectors.toList());
} catch (IOException e) {
throw new PlaywrightException("Failed to traverse directory", e);
}
}
private static JsonArray copyLocalToTempFiles(BrowserContextImpl context, List<Path> localPaths, JsonArray writableStreams) {
JsonArray jsonStreams = new JsonArray();
for (int i = 0; i < localPaths.size(); i++) {
JsonObject jsonStream = writableStreams.get(i).getAsJsonObject();
WritableStream temp = context.connection.getExistingObject(jsonStream.get("guid").getAsString());
try (OutputStream out = temp.stream()) {
Files.copy(localPaths.get(i), out);
} catch (IOException e) {
throw new PlaywrightException("Failed to copy file to remote server.", e);
}
jsonStreams.add(temp.toProtocolRef());
}
return jsonStreams;
}
private static JsonObject createTempFiles(BrowserContextImpl context, Path localDirectory, List<Path> localPaths) {
JsonObject tempFilesParams = new JsonObject();
if (localDirectory != null) {
tempFilesParams.addProperty("rootDirName", localDirectory.getFileName().toString());
}
JsonArray items = new JsonArray();
for (Path path : localPaths) {
long lastModifiedMs;
try {
lastModifiedMs = Files.getLastModifiedTime(path).toMillis();
} catch (IOException e) {
throw new PlaywrightException("Cannot read file timestamp: " + path, e);
}
Path name;
if (localDirectory == null) {
name = path.getFileName();
} else {
name = localDirectory.relativize(path);
}
JsonObject item = new JsonObject();
item.addProperty("name", name.toString());
item.addProperty("lastModifiedMs", lastModifiedMs);
items.add(item);
}
tempFilesParams.add("items", items);
return context.sendMessage("createTempFiles", tempFilesParams).getAsJsonObject();
}
static void checkFilePayloadSize(FilePayload[] files) {
long totalSize = 0;
for (FilePayload file: files) {
@@ -345,4 +414,40 @@ public class Utils {
static String addSourceUrlToScript(String source, Path path) {
return source + "\n//# sourceURL=" + path.toString().replace("\n", "");
}
static void addToProtocol(JsonObject params, List<ClientCertificate> clientCertificateList) {
if (clientCertificateList == null) {
return;
}
JsonArray clientCertificates = new JsonArray();
for (ClientCertificate cert: clientCertificateList) {
JsonObject jsonCert = new JsonObject();
jsonCert.addProperty("origin", cert.origin);
try {
if (cert.certPath != null) {
byte[] bytes = readAllBytes(cert.certPath);
String base64 = Base64.getEncoder().encodeToString(bytes);
jsonCert.addProperty("cert", base64);
}
if (cert.keyPath != null) {
byte[] bytes = readAllBytes(cert.keyPath);
String base64 = Base64.getEncoder().encodeToString(bytes);
jsonCert.addProperty("key", base64);
}
if (cert.pfxPath != null) {
byte[] bytes = readAllBytes(cert.pfxPath);
String base64 = Base64.getEncoder().encodeToString(bytes);
params.addProperty("pfx", base64);
}
} catch (IOException e) {
throw new PlaywrightException("Failed to read from file", e);
}
if (cert.passphrase != null) {
jsonCert.addProperty("passphrase", cert.passphrase);
}
clientCertificates.add(jsonCert);
}
params.remove("clientCertificates");
params.add("clientCertificates", clientCertificates);
}
}
@@ -62,7 +62,7 @@ public class BrowserExtension implements ParameterResolver, AfterAllCallback {
Options options = OptionsExtension.getOptions(extensionContext);
Playwright playwright = PlaywrightExtension.getOrCreatePlaywright(extensionContext);
BrowserType.LaunchOptions launchOptions = getLaunchOptions(options);
BrowserType browserType = playwright.chromium();
if (options.browserName != null) {
@@ -73,12 +73,27 @@ public class BrowserExtension implements ParameterResolver, AfterAllCallback {
browserType = getBrowserTypeForName(playwright, deviceDescriptor.defaultBrowserType);
}
}
browser = browserType.launch(launchOptions);
if(options.wsEndpoint != null && !options.wsEndpoint.isEmpty()) {
BrowserType.ConnectOptions connectOptions = getConnectOptions(options);
browser = browserType.connect(options.wsEndpoint, connectOptions);
} else {
BrowserType.LaunchOptions launchOptions = getLaunchOptions(options);
browser = browserType.launch(launchOptions);
}
threadLocalBrowser.set(browser);
return browser;
}
private static BrowserType.ConnectOptions getConnectOptions(Options options) {
BrowserType.ConnectOptions connectOptions = options.connectOptions;
if(connectOptions == null) {
connectOptions = new BrowserType.ConnectOptions();
}
return connectOptions;
}
private static BrowserType getBrowserTypeForName(Playwright playwright, String name) {
switch (name) {
case "webkit":
@@ -43,6 +43,20 @@ public class Options {
public Browser.NewContextOptions contextOptions;
public APIRequest.NewContextOptions apiRequestOptions;
public Playwright.CreateOptions playwrightCreateOptions;
// WebSocket endpoint to be used when connecting to a remote browser.
// If this is set, BrowserType.connect will be used. Otherwise, BrowserType.launch will be used.
public String wsEndpoint;
public BrowserType.ConnectOptions connectOptions;
public Options setWsEndpoint(String wsEndpoint) {
this.wsEndpoint = wsEndpoint;
return this;
}
public Options setConnectOptions(BrowserType.ConnectOptions connectOptions) {
this.connectOptions = connectOptions;
return this;
}
public Options setPlaywrightCreateOptions(Playwright.CreateOptions playwrightCreateOptions) {
this.playwrightCreateOptions = playwrightCreateOptions;
@@ -0,0 +1,75 @@
/*
* 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;
import java.nio.file.Path;
public class ClientCertificate {
/**
* Exact origin that the certificate is valid for. Origin includes {@code https} protocol, a hostname and optionally a
* port.
*/
public String origin;
/**
* Path to the file with the certificate in PEM format.
*/
public Path certPath;
/**
* Path to the file with the private key in PEM format.
*/
public Path keyPath;
/**
* Path to the PFX or PKCS12 encoded private key and certificate chain.
*/
public Path pfxPath;
/**
* Passphrase for the private key (PEM or PFX).
*/
public String passphrase;
public ClientCertificate(String origin) {
this.origin = origin;
}
/**
* Path to the file with the certificate in PEM format.
*/
public ClientCertificate setCertPath(Path certPath) {
this.certPath = certPath;
return this;
}
/**
* Path to the file with the private key in PEM format.
*/
public ClientCertificate setKeyPath(Path keyPath) {
this.keyPath = keyPath;
return this;
}
/**
* Path to the PFX or PKCS12 encoded private key and certificate chain.
*/
public ClientCertificate setPfxPath(Path pfxPath) {
this.pfxPath = pfxPath;
return this;
}
/**
* Passphrase for the private key (PEM or PFX).
*/
public ClientCertificate setPassphrase(String passphrase) {
this.passphrase = passphrase;
return this;
}
}
@@ -20,15 +20,16 @@ public class Cookie {
public String name;
public String value;
/**
* either url or domain / path are required. Optional.
* Either url or domain / path are required. Optional.
*/
public String url;
/**
* either url or domain / path are required Optional.
* For the cookie to apply to all subdomains as well, prefix domain with a dot, like this: ".example.com". Either url or
* domain / path are required. Optional.
*/
public String domain;
/**
* either url or domain / path are required Optional.
* Either url or domain / path are required Optional.
*/
public String path;
/**
@@ -53,21 +54,22 @@ public class Cookie {
this.value = value;
}
/**
* either url or domain / path are required. Optional.
* Either url or domain / path are required. Optional.
*/
public Cookie setUrl(String url) {
this.url = url;
return this;
}
/**
* either url or domain / path are required Optional.
* For the cookie to apply to all subdomains as well, prefix domain with a dot, like this: ".example.com". Either url or
* domain / path are required. Optional.
*/
public Cookie setDomain(String domain) {
this.domain = domain;
return this;
}
/**
* either url or domain / path are required Optional.
* Either url or domain / path are required Optional.
*/
public Cookie setPath(String path) {
this.path = path;
@@ -32,6 +32,141 @@ import java.nio.file.Path;
* }</pre>
*/
public interface FormData {
/**
* Appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist. File
* values can be passed either as {@code Path} or as {@code FilePayload}. Multiple fields with the same name can be added.
*
* <p> The difference between {@link com.microsoft.playwright.FormData#set FormData.set()} and {@link
* com.microsoft.playwright.FormData#append FormData.append()} is that if the specified key already exists, {@link
* com.microsoft.playwright.FormData#set FormData.set()} will overwrite all existing values with the new one, whereas
* {@link com.microsoft.playwright.FormData#append FormData.append()} will append the new value onto the end of the
* existing set of values.
* <pre>{@code
* import com.microsoft.playwright.options.FormData;
* ...
* FormData form = FormData.create()
* // Only name and value are set.
* .append("firstName", "John")
* // Name and value are set, filename and Content-Type are inferred from the file path.
* .append("attachment", Paths.get("pic.jpg"))
* // Name, value, filename and Content-Type are set.
* .append("attachment", new FilePayload("table.csv", "text/csv", Files.readAllBytes(Paths.get("my-tble.csv"))));
* page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
* }</pre>
*
* @param name Field name.
* @param value Field value.
* @since v1.44
*/
FormData append(String name, String value);
/**
* Appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist. File
* values can be passed either as {@code Path} or as {@code FilePayload}. Multiple fields with the same name can be added.
*
* <p> The difference between {@link com.microsoft.playwright.FormData#set FormData.set()} and {@link
* com.microsoft.playwright.FormData#append FormData.append()} is that if the specified key already exists, {@link
* com.microsoft.playwright.FormData#set FormData.set()} will overwrite all existing values with the new one, whereas
* {@link com.microsoft.playwright.FormData#append FormData.append()} will append the new value onto the end of the
* existing set of values.
* <pre>{@code
* import com.microsoft.playwright.options.FormData;
* ...
* FormData form = FormData.create()
* // Only name and value are set.
* .append("firstName", "John")
* // Name and value are set, filename and Content-Type are inferred from the file path.
* .append("attachment", Paths.get("pic.jpg"))
* // Name, value, filename and Content-Type are set.
* .append("attachment", new FilePayload("table.csv", "text/csv", Files.readAllBytes(Paths.get("my-tble.csv"))));
* page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
* }</pre>
*
* @param name Field name.
* @param value Field value.
* @since v1.44
*/
FormData append(String name, boolean value);
/**
* Appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist. File
* values can be passed either as {@code Path} or as {@code FilePayload}. Multiple fields with the same name can be added.
*
* <p> The difference between {@link com.microsoft.playwright.FormData#set FormData.set()} and {@link
* com.microsoft.playwright.FormData#append FormData.append()} is that if the specified key already exists, {@link
* com.microsoft.playwright.FormData#set FormData.set()} will overwrite all existing values with the new one, whereas
* {@link com.microsoft.playwright.FormData#append FormData.append()} will append the new value onto the end of the
* existing set of values.
* <pre>{@code
* import com.microsoft.playwright.options.FormData;
* ...
* FormData form = FormData.create()
* // Only name and value are set.
* .append("firstName", "John")
* // Name and value are set, filename and Content-Type are inferred from the file path.
* .append("attachment", Paths.get("pic.jpg"))
* // Name, value, filename and Content-Type are set.
* .append("attachment", new FilePayload("table.csv", "text/csv", Files.readAllBytes(Paths.get("my-tble.csv"))));
* page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
* }</pre>
*
* @param name Field name.
* @param value Field value.
* @since v1.44
*/
FormData append(String name, int value);
/**
* Appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist. File
* values can be passed either as {@code Path} or as {@code FilePayload}. Multiple fields with the same name can be added.
*
* <p> The difference between {@link com.microsoft.playwright.FormData#set FormData.set()} and {@link
* com.microsoft.playwright.FormData#append FormData.append()} is that if the specified key already exists, {@link
* com.microsoft.playwright.FormData#set FormData.set()} will overwrite all existing values with the new one, whereas
* {@link com.microsoft.playwright.FormData#append FormData.append()} will append the new value onto the end of the
* existing set of values.
* <pre>{@code
* import com.microsoft.playwright.options.FormData;
* ...
* FormData form = FormData.create()
* // Only name and value are set.
* .append("firstName", "John")
* // Name and value are set, filename and Content-Type are inferred from the file path.
* .append("attachment", Paths.get("pic.jpg"))
* // Name, value, filename and Content-Type are set.
* .append("attachment", new FilePayload("table.csv", "text/csv", Files.readAllBytes(Paths.get("my-tble.csv"))));
* page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
* }</pre>
*
* @param name Field name.
* @param value Field value.
* @since v1.44
*/
FormData append(String name, Path value);
/**
* Appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist. File
* values can be passed either as {@code Path} or as {@code FilePayload}. Multiple fields with the same name can be added.
*
* <p> The difference between {@link com.microsoft.playwright.FormData#set FormData.set()} and {@link
* com.microsoft.playwright.FormData#append FormData.append()} is that if the specified key already exists, {@link
* com.microsoft.playwright.FormData#set FormData.set()} will overwrite all existing values with the new one, whereas
* {@link com.microsoft.playwright.FormData#append FormData.append()} will append the new value onto the end of the
* existing set of values.
* <pre>{@code
* import com.microsoft.playwright.options.FormData;
* ...
* FormData form = FormData.create()
* // Only name and value are set.
* .append("firstName", "John")
* // Name and value are set, filename and Content-Type are inferred from the file path.
* .append("attachment", Paths.get("pic.jpg"))
* // Name, value, filename and Content-Type are set.
* .append("attachment", new FilePayload("table.csv", "text/csv", Files.readAllBytes(Paths.get("my-tble.csv"))));
* page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
* }</pre>
*
* @param name Field name.
* @param value Field value.
* @since v1.44
*/
FormData append(String name, FilePayload value);
/**
* Creates new instance of {@code FormData}.
*
@@ -51,7 +186,7 @@ public interface FormData {
* // Name and value are set, filename and Content-Type are inferred from the file path.
* .set("profilePicture1", Paths.get("john.jpg"))
* // Name, value, filename and Content-Type are set.
* .set("profilePicture2", new FilePayload("john.jpg", "image/jpeg", Files.readAllBytes(Paths.get("john.jpg"))));
* .set("profilePicture2", new FilePayload("john.jpg", "image/jpeg", Files.readAllBytes(Paths.get("john.jpg"))))
* .set("age", 30);
* page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
* }</pre>
@@ -72,7 +207,7 @@ public interface FormData {
* // Name and value are set, filename and Content-Type are inferred from the file path.
* .set("profilePicture1", Paths.get("john.jpg"))
* // Name, value, filename and Content-Type are set.
* .set("profilePicture2", new FilePayload("john.jpg", "image/jpeg", Files.readAllBytes(Paths.get("john.jpg"))));
* .set("profilePicture2", new FilePayload("john.jpg", "image/jpeg", Files.readAllBytes(Paths.get("john.jpg"))))
* .set("age", 30);
* page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
* }</pre>
@@ -93,7 +228,7 @@ public interface FormData {
* // Name and value are set, filename and Content-Type are inferred from the file path.
* .set("profilePicture1", Paths.get("john.jpg"))
* // Name, value, filename and Content-Type are set.
* .set("profilePicture2", new FilePayload("john.jpg", "image/jpeg", Files.readAllBytes(Paths.get("john.jpg"))));
* .set("profilePicture2", new FilePayload("john.jpg", "image/jpeg", Files.readAllBytes(Paths.get("john.jpg"))))
* .set("age", 30);
* page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
* }</pre>
@@ -114,7 +249,7 @@ public interface FormData {
* // Name and value are set, filename and Content-Type are inferred from the file path.
* .set("profilePicture1", Paths.get("john.jpg"))
* // Name, value, filename and Content-Type are set.
* .set("profilePicture2", new FilePayload("john.jpg", "image/jpeg", Files.readAllBytes(Paths.get("john.jpg"))));
* .set("profilePicture2", new FilePayload("john.jpg", "image/jpeg", Files.readAllBytes(Paths.get("john.jpg"))))
* .set("age", 30);
* page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
* }</pre>
@@ -135,7 +270,7 @@ public interface FormData {
* // Name and value are set, filename and Content-Type are inferred from the file path.
* .set("profilePicture1", Paths.get("john.jpg"))
* // Name, value, filename and Content-Type are set.
* .set("profilePicture2", new FilePayload("john.jpg", "image/jpeg", Files.readAllBytes(Paths.get("john.jpg"))));
* .set("profilePicture2", new FilePayload("john.jpg", "image/jpeg", Files.readAllBytes(Paths.get("john.jpg"))))
* .set("age", 30);
* page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
* }</pre>
@@ -23,6 +23,13 @@ public class HttpCredentials {
* Restrain sending http credentials on specific origin (scheme://host:port).
*/
public String origin;
/**
* This option only applies to the requests sent from corresponding {@code APIRequestContext} and does not affect requests
* sent from the browser. {@code "always"} - {@code Authorization} header with basic authentication credentials will be
* sent with the each API request. {@code 'unauthorized} - the credentials are only sent when 401 (Unauthorized) response
* with {@code WWW-Authenticate} header is received. Defaults to {@code "unauthorized"}.
*/
public HttpCredentialsSend send;
public HttpCredentials(String username, String password) {
this.username = username;
@@ -35,4 +42,14 @@ public class HttpCredentials {
this.origin = origin;
return this;
}
/**
* This option only applies to the requests sent from corresponding {@code APIRequestContext} and does not affect requests
* sent from the browser. {@code "always"} - {@code Authorization} header with basic authentication credentials will be
* sent with the each API request. {@code 'unauthorized} - the credentials are only sent when 401 (Unauthorized) response
* with {@code WWW-Authenticate} header is received. Defaults to {@code "unauthorized"}.
*/
public HttpCredentials setSend(HttpCredentialsSend send) {
this.send = send;
return this;
}
}
@@ -0,0 +1,22 @@
/*
* 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 HttpCredentialsSend {
UNAUTHORIZED,
ALWAYS
}
@@ -19,6 +19,7 @@ package com.microsoft.playwright.options;
public enum KeyboardModifier {
ALT,
CONTROL,
CONTROLORMETA,
META,
SHIFT
}
@@ -133,6 +133,15 @@ public interface RequestOptions {
* @since v1.26
*/
RequestOptions setMaxRedirects(int maxRedirects);
/**
*
*
* @param maxRetries Maximum number of times network errors should be retried. Currently only {@code ECONNRESET} error is retried. Does not
* retry based on HTTP response codes. An error will be thrown if the limit is exceeded. Defaults to {@code 0} - no
* retries.
* @since v1.46
*/
RequestOptions setMaxRetries(int maxRetries);
/**
* Changes the request method (e.g. <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT">PUT</a> or <a
* href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST">POST</a>).
@@ -19,11 +19,15 @@ package com.microsoft.playwright;
import com.sun.net.httpserver.HttpsConfigurator;
import com.sun.net.httpserver.HttpsParameters;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLParameters;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.*;
import java.io.FileInputStream;
import java.io.InputStream;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
class HttpsConfiguratorImpl extends HttpsConfigurator {
@@ -31,7 +35,7 @@ class HttpsConfiguratorImpl extends HttpsConfigurator {
return new HttpsConfiguratorImpl(createSSLContext());
}
private HttpsConfiguratorImpl(SSLContext context) {
HttpsConfiguratorImpl(SSLContext context) {
super(context);
}
@@ -20,7 +20,6 @@ import com.sun.net.httpserver.*;
import java.io.*;
import java.net.InetSocketAddress;
import java.nio.file.FileSystems;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
@@ -73,11 +72,8 @@ public class Server implements HttpHandler {
} else {
server = HttpServer.create(new InetSocketAddress("localhost", port), 0);
}
server.createContext("/", this);
server.setExecutor(null); // creates a default executor
File cwd = FileSystems.getDefault().getPath(".").toFile();
server.start();
}
@@ -0,0 +1,160 @@
/*
* Copyright (c) Microsoft Corporation.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.microsoft.playwright;
import com.sun.net.httpserver.*;
import javax.net.ssl.*;
import java.io.*;
import java.net.InetSocketAddress;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.cert.*;
import java.util.*;
public class ServerWithClientCertificate implements HttpHandler {
private final HttpServer server;
final String origin;
final String crossOrigin;
final String url;
KeyStore keyStore;
static ServerWithClientCertificate create(int port) throws IOException {
return new ServerWithClientCertificate(port);
}
private ServerWithClientCertificate(int port) throws IOException {
origin = "https://localhost:" + port;
crossOrigin = "https://127.0.0.1:" + port;;
url = origin + "/index.html";
HttpsServer httpsServer = HttpsServer.create(new InetSocketAddress("localhost", port), 0);
httpsServer.setHttpsConfigurator(new HttpsConfiguratorImpl(loadCertificates()));
server = httpsServer;
server.createContext("/", this);
server.setExecutor(null); // creates a default executor
server.start();
}
public void stop() {
server.stop(0);
}
private SSLContext loadCertificates() {
try {
// Create an SSL context
SSLContext sslContext = SSLContext.getInstance("TLS");
// Load the keystore from file
char[] password = "".toCharArray(); // the password you set during the PKCS12 export
keyStore = KeyStore.getInstance("PKCS12");
InputStream fis = HttpsConfiguratorImpl.class.getClassLoader().getResourceAsStream(
"resources/client-certificates/server/server_keystore.p12");
keyStore.load(fis, password);
// Set up the KeyManagerFactory to use the keystore
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(keyStore, password);
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
List<X509Certificate> certs = new ArrayList<>();
try {
for (String alias : Collections.list(keyStore.aliases())) {
certs.add((X509Certificate) keyStore.getCertificate(alias));
}
} catch (KeyStoreException e) {
throw new RuntimeException(e);
}
return certs.toArray(new X509Certificate[0]);
}
public void checkClientTrusted(X509Certificate[] clientCerts, String authType) throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
}
};
// Initialize the SSL context
sslContext.init(kmf.getKeyManagers(), trustAllCerts, null);
return sslContext;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private boolean validateCertChain(Certificate[] clientCerts) {
try {
// Create CertPath from the provided client certificates
CertificateFactory factory = CertificateFactory.getInstance("X.509");
CertPath certPath = factory.generateCertPath(Arrays.asList(clientCerts));
// Extract Trust Anchors from the trust store
Set<TrustAnchor> trustAnchors = new HashSet<>();
for (String alias : Collections.list(keyStore.aliases())) {
X509Certificate trustedCert = (X509Certificate) keyStore.getCertificate(alias);
if (trustedCert != null) {
trustAnchors.add(new TrustAnchor(trustedCert, null));
}
}
// Initialize PKIX parameters
PKIXParameters params = new PKIXParameters(trustAnchors);
params.setRevocationEnabled(false); // Set to true if you want to enable CRL checking
// Validate the certification path
CertPathValidator certPathValidator = CertPathValidator.getInstance(CertPathValidator.getDefaultType());
certPathValidator.validate(certPath, params);
return true;
} catch (Exception e) {
return false;
}
}
private static String div(String testId, String message) {
return "<div data-testid='" + testId + "'>" + message + "</div>";
}
@Override
public void handle(HttpExchange exchange) throws IOException {
SSLSession sslSession = ((HttpsExchange) exchange).getSSLSession();
String response = div("servername", sslSession.getPeerHost());
Certificate[] certs = sslSession.getPeerCertificates();
if (certs.length > 0 && certs[0] instanceof X509Certificate) {
X509Certificate cert = (X509Certificate) certs[0];
exchange.getResponseHeaders().add("Content-Type", "text/html");
if (validateCertChain(certs)) {
exchange.sendResponseHeaders(200, 0);
response += div("message", String.format("Hello %s, your certificate was issued by %s!",
cert.getSubjectX500Principal().getName(), cert.getIssuerX500Principal().getName()));
} else {
response += div("message", String.format("Sorry %s, certificates from %s are not welcome here.",
cert.getSubjectX500Principal().getName(), cert.getIssuerX500Principal().getName()));
exchange.sendResponseHeaders(403, 0);
}
} else {
response += div("message", "Sorry, but you need to provide a client certificate to continue.");
exchange.sendResponseHeaders(401, 0);
}
try (OutputStreamWriter writer = new OutputStreamWriter(exchange.getResponseBody())) {
writer.write(response);
}
}
}
@@ -22,6 +22,7 @@ import com.microsoft.playwright.options.SameSiteAttribute;
import javax.sql.rowset.Predicate;
import java.io.IOException;
import java.io.InputStream;
import java.security.Provider;
import java.time.Duration;
import java.time.Instant;
@@ -42,9 +43,11 @@ public class TestBase {
Browser browser;
static final boolean isMac = Utils.getOS() == Utils.OS.MAC;
static final boolean isLinux = Utils.getOS() == Utils.OS.LINUX;
static final boolean isWindows = Utils.getOS() == Utils.OS.WINDOWS;
static final boolean headful;
static final SameSiteAttribute defaultSameSiteCookieValue;
static {
String headfulEnv = System.getenv("HEADFUL");
headful = headfulEnv != null && !"0".equals(headfulEnv) && !"false".equals(headfulEnv);
@@ -160,14 +163,28 @@ public class TestBase {
void waitForCondition(BooleanSupplier predicate) {
waitForCondition(predicate, 5_000);
}
void waitForCondition(BooleanSupplier predicate, int timeoutMs) {
page.waitForCondition(predicate, new Page.WaitForConditionOptions().setTimeout(timeoutMs));
}
private static SameSiteAttribute initSameSiteAttribute() {
if (isChromium()) return SameSiteAttribute.LAX;
if (isWebKit()) return SameSiteAttribute.NONE;
if (isWebKit() && isLinux) return SameSiteAttribute.LAX;
if (isWebKit() && !isLinux) return SameSiteAttribute.NONE;
// for firefox version >= 103 'None' is used.
return SameSiteAttribute.NONE;
}
static boolean chromiumVersionLessThan(String a, String b) {
String[] aParts = a.split("\\.");
String[] bParts = b.split("\\.");
for (int i = 0; i < 4; i++) {
int aPart = Integer.parseInt(aParts[i]);
int bPart = Integer.parseInt(bParts[i]);
if (aPart > bPart) return false;
if (aPart < bPart) return true;
}
return false;
}
}
@@ -18,6 +18,7 @@ package com.microsoft.playwright;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.microsoft.playwright.junit.FixtureTest;
import com.microsoft.playwright.junit.UsePlaywright;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
@@ -25,9 +26,9 @@ import org.junit.jupiter.api.condition.EnabledIf;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Pattern;
import static com.microsoft.playwright.Utils.getBrowserTypeFromEnv;
import static org.junit.jupiter.api.Assertions.*;
@FixtureTest
@UsePlaywright(TestOptionsFactories.BasicOptionsFactory.class)
public class TestBrowser1 {
@@ -73,8 +74,8 @@ public class TestBrowser1 {
}
@Test
void shouldReturnBrowserType(Playwright playwright, Browser browser) {
assertEquals(getBrowserTypeFromEnv(playwright), browser.browserType());
void shouldReturnBrowserType(BrowserType browserType, Browser browser) {
assertEquals(browserType, browser.browserType());
}
@Test
@@ -16,6 +16,7 @@
package com.microsoft.playwright;
import com.microsoft.playwright.junit.FixtureTest;
import com.microsoft.playwright.junit.Options;
import com.microsoft.playwright.junit.OptionsFactory;
import com.microsoft.playwright.junit.UsePlaywright;
@@ -28,6 +29,7 @@ import static com.microsoft.playwright.TestOptionsFactories.createLaunchOptions;
import static com.microsoft.playwright.TestOptionsFactories.getBrowserChannelFromEnv;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@FixtureTest
@UsePlaywright(TestBrowser2.ChannelOptionsFactory.class)
public class TestBrowser2 {
@@ -70,12 +72,11 @@ public class TestBrowser2 {
}
@Test
void shouldSupportDeprecatedChannelEnum(Playwright playwright) {
void shouldSupportDeprecatedChannelEnum(BrowserType browserType) {
BrowserChannel channel = getBrowserChannelEnumFromEnv();
Assumptions.assumeTrue(channel != null);
BrowserType.LaunchOptions options = createLaunchOptions();
options.setChannel(channel);
BrowserType browserType = Utils.getBrowserTypeFromEnv(playwright);
Browser browser = browserType.launch(options);
assertNotNull(browser);
browser.close();
@@ -26,7 +26,7 @@ import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import static com.microsoft.playwright.TestOptionsFactories.isChromium;
import static com.microsoft.playwright.TestBase.defaultSameSiteCookieValue;
import static com.microsoft.playwright.TestOptionsFactories.isFirefox;
import static com.microsoft.playwright.Utils.assertJsonEquals;
import static java.util.Arrays.asList;
@@ -227,7 +227,7 @@ public class TestBrowserContextAddCookies {
" expires: -1,\n" +
" httpOnly: false,\n" +
" secure: false,\n" +
" sameSite: '" + (isChromium() ? "LAX" : "NONE") +"'\n" +
" sameSite: '" + defaultSameSiteCookieValue +"'\n" +
"}]", cookies);
}
@@ -246,7 +246,7 @@ public class TestBrowserContextAddCookies {
" expires: -1,\n" +
" httpOnly: false,\n" +
" secure: false,\n" +
" sameSite: '" + (isChromium() ? "LAX" : "NONE") +"'\n" +
" sameSite: '" + defaultSameSiteCookieValue +"'\n" +
"}]", cookies);
assertEquals("gridcookie=GRID", page.evaluate("document.cookie"));
page.navigate(server.EMPTY_PAGE);
@@ -311,7 +311,7 @@ public class TestBrowserContextAddCookies {
" expires: -1,\n" +
" httpOnly: false,\n" +
" secure: true,\n" +
" sameSite: '" + (isChromium() ? "LAX" : "NONE") +"'\n" +
" sameSite: '" + defaultSameSiteCookieValue +"'\n" +
"}]", context.cookies("https://www.example.com"));
}
@@ -48,7 +48,7 @@ public class TestBrowserContextCookies extends TestBase {
" expires: -1,\n" +
" httpOnly: false,\n" +
" secure: false,\n" +
" sameSite: '" + (isChromium() ? "LAX" : "NONE") +"'\n" +
" sameSite: '" + defaultSameSiteCookieValue +"'\n" +
" }]", cookies);
}
@@ -72,6 +72,7 @@ public class TestBrowserContextCookies extends TestBase {
assertFalse(cookies.get(0).httpOnly);
assertFalse(cookies.get(0).secure);
assertEquals(defaultSameSiteCookieValue, cookies.get(0).sameSite);
assertEquals(defaultSameSiteCookieValue, cookies.get(0).sameSite);
// Browsers start to cap cookies with 400 days max expires value.
// See https://github.com/httpwg/http-extensions/pull/1732
@@ -147,7 +148,7 @@ public class TestBrowserContextCookies extends TestBase {
" expires: -1,\n" +
" httpOnly: false,\n" +
" secure: false,\n" +
" sameSite: '" + (isChromium() ? "LAX" : "NONE") +"'\n" +
" sameSite: '" + defaultSameSiteCookieValue +"'\n" +
" },\n" +
" {\n" +
" name: 'username',\n" +
@@ -157,7 +158,7 @@ public class TestBrowserContextCookies extends TestBase {
" expires: -1,\n" +
" httpOnly: false,\n" +
" secure: false,\n" +
" sameSite: '" + (isChromium() ? "LAX" : "NONE") +"'\n" +
" sameSite: '" + defaultSameSiteCookieValue +"'\n" +
" }\n" +
"]", cookies);
}
@@ -178,7 +179,7 @@ public class TestBrowserContextCookies extends TestBase {
" expires: -1.0,\n" +
" httpOnly: false,\n" +
" secure: true,\n" +
" sameSite: '" + (isChromium() ? "LAX" : "NONE") +"'\n" +
" sameSite: '" + defaultSameSiteCookieValue +"'\n" +
"}, {\n" +
" name: 'doggo',\n" +
" value: 'woofs',\n" +
@@ -187,7 +188,7 @@ public class TestBrowserContextCookies extends TestBase {
" expires: -1.0,\n" +
" httpOnly: false,\n" +
" secure: true,\n" +
" sameSite: '" + (isChromium() ? "LAX" : "NONE") +"'\n" +
" sameSite: '" + defaultSameSiteCookieValue +"'\n" +
"}]", cookies);
}
@@ -205,14 +206,14 @@ public class TestBrowserContextCookies extends TestBase {
page.navigate(server.EMPTY_PAGE);
Object documentCookie = page.evaluate("document.cookie.split('; ').sort().join('; ')");
if (isChromium()) {
if (isChromium() || (isLinux && isWebKit())) {
assertEquals("one=uno; two=dos", documentCookie);
} else {
assertEquals("one=uno; three=tres; two=dos", documentCookie);
}
List<SameSiteAttribute> list = context.cookies().stream().map(c -> c.sameSite).sorted().collect(Collectors.toList());
if (isChromium()) {
if (isChromium() || (isLinux && isWebKit())) {
assertEquals(asList(SameSiteAttribute.STRICT, SameSiteAttribute.LAX), list);
} else {
assertEquals(asList(SameSiteAttribute.STRICT, SameSiteAttribute.LAX, SameSiteAttribute.NONE), list);
@@ -23,10 +23,12 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.text.ParseException;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.ExecutionException;
@@ -516,10 +518,20 @@ public class TestBrowserContextFetch extends TestBase {
testData.date = new Date(currentMillis);
testData.localDateTime = testData.date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
context.request().fetch(pageReq, RequestOptions.create().setMethod("POST").setData(testData));
assertEquals("{\"name\":\"foo\",\"localDateTime\":\"2022-12-23T06:14:58.818Z\",\"date\":\"2022-12-23T06:14:58.818Z\"}",
assertEquals("{\"name\":\"foo\",\"localDateTime\":\"2022-12-23T06:14:58.818Z\",\"date\":\"2022-12-23T06:14:58.818Z\",\"nullLocalDateTime\":null,\"nullDate\":null}",
new String(req.get().postBody));
}
@Test
void shouldSupportOffsetDateTimeInData() throws ExecutionException, InterruptedException {
APIRequestContext request = playwright.request().newContext();
OffsetDateTime offsetDateTime = OffsetDateTime.parse("2024-07-10T10:15:30-08:00");
Future<Server.Request> serverRequest = server.futureRequest("/empty.html");
request.get(server.EMPTY_PAGE, RequestOptions.create().setData(mapOf("date", offsetDateTime)));
byte[] body = serverRequest.get().postBody;
assertEquals("{\"date\":\"2024-07-10T18:15:30.000Z\"}", new String(body));
}
@Test
void shouldSupportApplicationXWwwFormUrlencoded() throws ExecutionException, InterruptedException {
Future<Server.Request> req = server.futureRequest("/empty.html");
@@ -591,6 +603,46 @@ public class TestBrowserContextFetch extends TestBase {
assertEquals(200, response.status());
}
@Test
public void shouldSupportRepeatingNamesInMultipartFormData() throws InterruptedException, ExecutionException {
Future<Server.Request> serverRequest = server.futureRequest("/empty.html");
FilePayload file1 = new FilePayload("f.js", "text/javascript",
"var x = 10;\r\n;console.log(x);".getBytes(StandardCharsets.UTF_8));
FilePayload file2 = new FilePayload("f2.txt", "text/plain",
"hello".getBytes(StandardCharsets.UTF_8));
APIResponse response = context.request().post(server.EMPTY_PAGE, RequestOptions.create().setMultipart(
FormData.create()
.set("name", "John")
.append("name", "Doe")
.append("file", file1)
.append("file", file2)));
assertEquals("POST", serverRequest.get().method);
List<String> contentType = serverRequest.get().headers.get("content-type");
assertNotNull(contentType);
assertEquals(1, contentType.size());
assertTrue(contentType.get(0).contains("multipart/form-data"), contentType.get(0));
String body = new String(serverRequest.get().postBody);
assertTrue(body.contains("content-disposition: form-data; name=\"name\"\r\n" +
"\r\n" +
"John"), body);
assertTrue(body.contains("content-disposition: form-data; name=\"name\"\r\n" +
"\r\n" +
"Doe"), body);
assertTrue(body.contains("content-disposition: form-data; name=\"file\"; filename=\"f.js\"\r\n" +
"content-type: text/javascript\r\n" +
"\r\n" +
"var x = 10;\r\n" +
";console.log(x);"), body);
assertTrue(body.contains("content-disposition: form-data; name=\"file\"; filename=\"f2.txt\"\r\n" +
"content-type: text/plain\r\n" +
"\r\n" +
"hello"), body);
assertEquals(200, response.status());
}
@Test
void shouldSupportMultipartFormDataWithPathValues(@TempDir Path tmp) throws ExecutionException, InterruptedException, IOException {
Future<Server.Request> serverRequest = server.futureRequest("/empty.html");
@@ -756,4 +808,85 @@ public class TestBrowserContextFetch extends TestBase {
assertEquals(401, response.status());
}
}
@Test
void shouldSerializeNullValuesInPostData() throws ExecutionException, InterruptedException {
Future<Server.Request> req = server.futureRequest("/empty.html");
APIResponse response = context.request().post(server.EMPTY_PAGE, RequestOptions.create().setData(mapOf("foo", null)));
assertEquals(200, response.status());
assertEquals("{\"foo\":null}", new String(req.get().postBody));
}
@Test
void shouldSupportHTTPCredentialsSendImmediatelyForNewContext() throws ExecutionException, InterruptedException {
Browser.NewContextOptions options = new Browser.NewContextOptions().setHttpCredentials(
new HttpCredentials("user", "pass")
.setOrigin(server.PREFIX.toUpperCase())
.setSend(HttpCredentialsSend.ALWAYS));
try (BrowserContext context = browser.newContext(options)) {
Future<Server.Request> serverRequest = server.futureRequest("/empty.html");
APIResponse response = context.request().get(server.EMPTY_PAGE);
assertEquals("Basic " + java.util.Base64.getEncoder().encodeToString("user:pass".getBytes()),
serverRequest.get().headers.getFirst("authorization"));
assertEquals(200, response.status());
serverRequest = server.futureRequest("/empty.html");
response = context.request().get(server.CROSS_PROCESS_PREFIX + "/empty.html");
// Not sent to another origin.
assertNull(serverRequest.get().headers.get("authorization"));
assertEquals(200, response.status());
}
}
@Test
void shouldSupportHTTPCredentialsSendImmediatelyForBrowserNewPage() throws ExecutionException, InterruptedException {
Browser.NewPageOptions options = new Browser.NewPageOptions().setHttpCredentials(
new HttpCredentials("user", "pass")
.setOrigin(server.PREFIX.toUpperCase())
.setSend(HttpCredentialsSend.ALWAYS));
try (Page newPage = browser.newPage(options)) {
Future<Server.Request> serverRequest = server.futureRequest("/empty.html");
APIResponse response = newPage.request().get(server.EMPTY_PAGE);
assertEquals("Basic " + java.util.Base64.getEncoder().encodeToString("user:pass".getBytes()),
serverRequest.get().headers.getFirst("authorization"));
assertEquals(200, response.status());
serverRequest = server.futureRequest("/empty.html");
response = newPage.request().get(server.CROSS_PROCESS_PREFIX + "/empty.html");
// Not sent to another origin.
assertNull(serverRequest.get().headers.get("authorization"));
assertEquals(200, response.status());
}
}
@Test
void shouldNotWorkAfterContextDispose() {
context.close(new BrowserContext.CloseOptions().setReason("Test ended."));
PlaywrightException e = assertThrows(PlaywrightException.class, () -> context.request().get(server.EMPTY_PAGE));
assertTrue(e.getMessage().contains("Test ended."), e.getMessage());
}
@Test
public void shouldRetryECONNRESET() {
int[] requestCount = {0};
server.setRoute("/test", exchange -> {
if (requestCount[0]++ < 3) {
exchange.close();
return;
}
exchange.getResponseHeaders().add("Content-Type", "text/plain");
exchange.sendResponseHeaders(200, 0);
try (OutputStreamWriter writer = new OutputStreamWriter(exchange.getResponseBody())) {
writer.write("Hello!");
}
});
APIRequestContext requestContext = context.request();
APIResponse response = requestContext.get(server.PREFIX + "/test",
RequestOptions.create().setMaxRetries(3));
assertEquals(200, response.status());
assertEquals("Hello!", response.text());
assertEquals(4, requestCount[0]);
}
}
@@ -98,6 +98,20 @@ public class TestBrowserContextStorageState extends TestBase {
"}");
Path path = tempDir.resolve("storage-state.json");
context.storageState(new BrowserContext.StorageStateOptions().setPath(path));
String sameSiteCamelCase = "Lax";
switch (defaultSameSiteCookieValue) {
case STRICT:
sameSiteCamelCase = "Strict";
break;
case LAX:
sameSiteCamelCase = "Lax";
break;
case NONE:
sameSiteCamelCase = "None";
break;
}
JsonObject expected = new Gson().fromJson(
"{\n" +
" 'cookies':[\n" +
@@ -109,7 +123,7 @@ public class TestBrowserContextStorageState extends TestBase {
" 'expires':-1,\n" +
" 'httpOnly':false,\n" +
" 'secure':false,\n" +
" 'sameSite':'" + (isChromium() ? "Lax" : "None") + "'\n" +
" 'sameSite':'" + sameSiteCamelCase + "'\n" +
" }],\n" +
" 'origins':[\n" +
" {\n" +
@@ -238,7 +238,7 @@ public class TestBrowserTypeConnect extends TestBase {
}
assertFalse(remote.isConnected());
PlaywrightException e = assertThrows(PlaywrightException.class, () -> page.evaluate("1 + 1"));
assertTrue(e.getMessage().contains("Browser has been closed"), e.getMessage());
assertTrue(e.getMessage().contains("Browser has been closed") || e.getMessage().contains("Browser closed"), e.getMessage());
assertFalse(remote.isConnected());
}
@@ -259,7 +259,7 @@ public class TestBrowserTypeConnect extends TestBase {
}
assertFalse(browser.isConnected());
PlaywrightException e = assertThrows(PlaywrightException.class, () -> page.waitForNavigation(() -> {}));
assertTrue(e.getMessage().contains("Page closed") || e.getMessage().contains("Browser has been closed"), e.getMessage());
assertTrue(e.getMessage().contains("Browser closed") || e.getMessage().contains("Page closed") || e.getMessage().contains("Browser has been closed"), e.getMessage());
}
@Test
@@ -506,7 +506,7 @@ public class TestBrowserTypeConnect extends TestBase {
}
@Test
void setInputFilesDhouldPreserveLastModifiedTimestamp() throws IOException {
void setInputFilesShouldPreserveLastModifiedTimestamp() throws IOException {
page.setContent("<input type=file multiple=true/>");
Locator input = page.locator("input");
input.setInputFiles(FILE_TO_UPLOAD);
@@ -0,0 +1,194 @@
package com.microsoft.playwright;
import com.microsoft.playwright.options.ClientCertificate;
import com.microsoft.playwright.options.Proxy;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import org.junit.jupiter.api.io.TempDir;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import static com.microsoft.playwright.Utils.nextFreePort;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.*;
public class TestClientCertificates extends TestBase {
private ServerWithClientCertificate customServer;
private static Path asset(String path) {
return Paths.get("src/test/resources/" + path).toAbsolutePath();
}
private static String origin(String urlString) {
try {
URL url = new URL(urlString);
String origin = url.getProtocol() + "://" + url.getHost();
if (url.getPort() != -1 && url.getPort() != url.getDefaultPort()) {
origin += ":" + url.getPort();
}
return origin;
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
@BeforeAll
@Override
void startServer() throws IOException {
super.startServer();
customServer = ServerWithClientCertificate.create(nextFreePort());
}
@AfterAll
@Override
void stopServer() {
if (customServer != null) {
customServer.stop();
customServer = null;
}
super.stopServer();
}
@BeforeAll
@Override
void launchBrowser() {
// TODO: remove once Chromium Stable tests pass without it on Windows.
launchBrowser(createLaunchOptions().setProxy(new Proxy("per-context")));
}
@Test
public void shouldFailWithNoClientCertificatesProvided() {
APIRequestContext request = playwright.request().newContext(
new APIRequest.NewContextOptions().setIgnoreHTTPSErrors(true));
PlaywrightException e = assertThrows(PlaywrightException.class, () -> request.get(customServer.url));
assertTrue(e.getMessage().contains("Error: socket hang up"), e.getMessage());
request.dispose();
}
@Test
public void shouldKeepSupportingHttp() {
APIRequest.NewContextOptions requestOptions = new APIRequest.NewContextOptions()
.setIgnoreHTTPSErrors(true) // TODO: remove once we can pass a custom CA.
.setClientCertificates(asList(
new ClientCertificate(origin(server.PREFIX))
.setCertPath(asset("client-certificates/client/trusted/cert.pem"))
.setKeyPath(asset("client-certificates/client/trusted/key.pem"))));
APIRequestContext request = playwright.request().newContext(requestOptions);
APIResponse response = request.get(server.PREFIX + "/one-style.html");
assertEquals(server.PREFIX + "/one-style.html", response.url());
assertEquals(200, response.status());
assertTrue(response.text().contains("<div>hello, world!</div>"));
request.dispose();
}
@Test
public void shouldThrowWithUntrustedClientCerts() {
APIRequest.NewContextOptions requestOptions = new APIRequest.NewContextOptions()
.setIgnoreHTTPSErrors(true) // TODO: remove once we can pass a custom CA.
.setClientCertificates(asList(
new ClientCertificate(customServer.origin)
.setCertPath(asset("client-certificates/client/self-signed/cert.pem"))
.setKeyPath(asset("client-certificates/client/self-signed/key.pem"))));
APIRequestContext request = playwright.request().newContext(requestOptions);
APIResponse response = request.get(customServer.url);
assertEquals(customServer.url, response.url());
assertEquals(403, response.status());
assertTrue(response.text().contains("Sorry CN=Bob, certificates from CN=Bob are not welcome here."), response.text());
request.dispose();
}
@Test
public void passWithTrustedClientCertificates() {
APIRequest.NewContextOptions requestOptions = new APIRequest.NewContextOptions()
.setIgnoreHTTPSErrors(true) // TODO: remove once we can pass a custom CA.
.setClientCertificates(asList(
new ClientCertificate(customServer.origin)
.setCertPath(asset("client-certificates/client/trusted/cert.pem"))
.setKeyPath(asset("client-certificates/client/trusted/key.pem"))));
APIRequestContext request = playwright.request().newContext(requestOptions);
APIResponse response = request.get(customServer.url);
assertEquals(customServer.url, response.url());
assertEquals(200, response.status());
assertTrue(response.text().contains("Hello CN=Alice, your certificate was issued by O=Client Certificate Demo,CN=localhost!"), response.text());
request.dispose();
}
static boolean isWebKitMacOS() {
return isWebKit() && isMac;
}
@Test
@DisabledIf(value="com.microsoft.playwright.TestClientCertificates#isWebKitMacOS", disabledReason="The network connection was lost.")
public void shouldWorkWithBrowserNewContext() {
Browser.NewContextOptions options = new Browser.NewContextOptions()
.setIgnoreHTTPSErrors(true) // TODO: remove once we can pass a custom CA.
.setClientCertificates(asList(
new ClientCertificate(customServer.origin)
.setCertPath(asset("client-certificates/client/trusted/cert.pem"))
.setKeyPath(asset("client-certificates/client/trusted/key.pem"))));
try (BrowserContext context = browser.newContext(options)) {
Page page = context.newPage();
assertThrows(PlaywrightException.class, () -> page.navigate(customServer.crossOrigin));
assertThrows(PlaywrightException.class, () -> page.request().get(customServer.crossOrigin));
page.navigate(customServer.url);
assertThat(page.getByText("Hello CN=Alice")).isVisible();
APIResponse response = page.request().get(customServer.url);
assertTrue(response.text().contains("Hello CN=Alice"), response.text());
}
}
@Test
@DisabledIf(value="com.microsoft.playwright.TestClientCertificates#isWebKitMacOS", disabledReason="The network connection was lost.")
public void shouldWorkWithBrowserNewPage() {
Browser.NewPageOptions options = new Browser.NewPageOptions()
.setIgnoreHTTPSErrors(true) // TODO: remove once we can pass a custom CA.
.setClientCertificates(asList(
new ClientCertificate(customServer.origin)
.setCertPath(asset("client-certificates/client/trusted/cert.pem"))
.setKeyPath(asset("client-certificates/client/trusted/key.pem"))));
try (Page page = browser.newPage(options)) {
assertThrows(PlaywrightException.class, () -> page.navigate(customServer.crossOrigin));
assertThrows(PlaywrightException.class, () -> page.request().get(customServer.crossOrigin));
page.navigate(customServer.url);
assertThat(page.getByText("Hello CN=Alice")).isVisible();
APIResponse response = page.request().get(customServer.url);
assertTrue(response.text().contains("Hello CN=Alice"), response.text());
}
}
@Test
@DisabledIf(value="com.microsoft.playwright.TestClientCertificates#isWebKitMacOS", disabledReason="The network connection was lost.")
public void shouldWorkWithBrowserLaunchPersistentContext(@TempDir Path tmpDir) {
BrowserType.LaunchPersistentContextOptions options = new BrowserType.LaunchPersistentContextOptions()
.setIgnoreHTTPSErrors(true) // TODO: remove once we can pass a custom CA.
.setClientCertificates(asList(
new ClientCertificate(customServer.origin)
.setCertPath(asset("client-certificates/client/trusted/cert.pem"))
.setKeyPath(asset("client-certificates/client/trusted/key.pem"))));
try (BrowserContext context = browser.browserType().launchPersistentContext(tmpDir.resolve("profile") , options)) {
Page page = context.pages().get(0);
assertThrows(PlaywrightException.class, () -> page.navigate(customServer.crossOrigin));
assertThrows(PlaywrightException.class, () -> page.request().get(customServer.crossOrigin));
page.navigate(customServer.url);
assertThat(page.getByText("Hello CN=Alice")).isVisible();
APIResponse response = page.request().get(customServer.url);
assertTrue(response.text().contains("Hello CN=Alice"), response.text());
}
}
}
@@ -43,9 +43,9 @@ public class TestElementHandleConvenience extends TestBase {
String text = String.join("", Collections.nCopies(100, "😛"));
page.setContent("<div title='" + text + "'>" + text + "</div>");
ElementHandle handle = page.querySelector("div");
context.waitForCondition(() -> "JSHandle@<div title=\"😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛>😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛…</div>"
context.waitForCondition(() -> "JSHandle@<div title=\"😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛\">😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛…</div>"
.equals(handle.toString()), new BrowserContext.WaitForConditionOptions().setTimeout(5_000));
assertEquals("JSHandle@<div title=\"😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛>😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛…</div>", handle.toString());
assertEquals("JSHandle@<div title=\"😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛\">😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛…</div>", handle.toString());
}
@Test
@@ -18,6 +18,7 @@ package com.microsoft.playwright;
import com.google.gson.Gson;
import com.microsoft.playwright.options.HttpCredentials;
import com.microsoft.playwright.options.HttpCredentialsSend;
import com.microsoft.playwright.options.HttpHeader;
import com.microsoft.playwright.options.RequestOptions;
import org.junit.jupiter.api.Disabled;
@@ -25,6 +26,7 @@ import org.junit.jupiter.api.Test;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Base64;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
@@ -490,4 +492,60 @@ public class TestGlobalFetch extends TestBase {
assertEquals(401, response.status());
}
@Test
void shouldSupportHTTPCredentialsSendImmediately() throws InterruptedException, ExecutionException {
APIRequestContext request = playwright.request().newContext(new APIRequest.NewContextOptions()
.setHttpCredentials(new HttpCredentials("user", "pass")
.setOrigin(server.PREFIX.toUpperCase())
.setSend(HttpCredentialsSend.ALWAYS)));
Future<Server.Request> serverRequestFuture = server.futureRequest("/empty.html");
APIResponse response = request.get(server.EMPTY_PAGE);
assertEquals("Basic " + Base64.getEncoder().encodeToString("user:pass".getBytes()),
serverRequestFuture.get().headers.getFirst("authorization"));
assertEquals(200, response.status());
// Second request and response to another origin
serverRequestFuture = server.futureRequest("/empty.html");
response = request.get(server.CROSS_PROCESS_PREFIX + "/empty.html");
// Not sent to another origin
assertNull(serverRequestFuture.get().headers.get("authorization"));
assertEquals(200, response.status());
request.dispose();
}
@Test
void shouldSupportDisposeReason() {
APIRequestContext request = playwright.request().newContext();
request.dispose(new APIRequestContext.DisposeOptions().setReason("My reason"));
PlaywrightException e = assertThrows(PlaywrightException.class, () -> request.get(server.EMPTY_PAGE));
assertTrue(e.getMessage().contains("My reason"), e.getMessage());
}
@Test
public void shouldRetryECONNRESET() {
int[] requestCount = {0};
server.setRoute("/test", exchange -> {
if (requestCount[0]++ < 3) {
exchange.close();
return;
}
exchange.getResponseHeaders().add("Content-Type", "text/plain");
exchange.sendResponseHeaders(200, 0);
try (OutputStreamWriter writer = new OutputStreamWriter(exchange.getResponseBody())) {
writer.write("Hello!");
}
});
APIRequestContext requestContext = playwright.request().newContext();
APIResponse response = requestContext.get(server.PREFIX + "/test",
RequestOptions.create().setMaxRetries(3));
assertEquals(200, response.status());
assertEquals("Hello!", response.text());
assertEquals(4, requestCount[0]);
requestContext.dispose();
}
}
@@ -17,9 +17,12 @@
package com.microsoft.playwright;
import com.microsoft.playwright.assertions.LocatorAssertions;
import com.microsoft.playwright.options.AriaRole;
import org.junit.jupiter.api.Test;
import org.opentest4j.AssertionFailedError;
import java.util.regex.Pattern;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
@@ -115,4 +118,36 @@ public class TestLocatorAssertions2 extends TestBase {
page.setContent("<div id=node>Text content</div>");
assertThat(page.locator("no-such-thing")).not().isAttached(new LocatorAssertions.IsAttachedOptions().setTimeout(1));
}
@Test
public void toHaveAccessibleName() {
page.setContent("<div role=\"button\" aria-label=\"Hello\"></div>");
assertThat(page.locator("div")).hasAccessibleName("Hello");
assertThat(page.locator("div")).not().hasAccessibleName("hello");
assertThat(page.locator("div")).hasAccessibleName("hello", new LocatorAssertions.HasAccessibleNameOptions().setIgnoreCase(true));
assertThat(page.locator("div")).hasAccessibleName(Pattern.compile("ell\\w"));
assertThat(page.locator("div")).not().hasAccessibleName(Pattern.compile("hello"));
assertThat(page.locator("div")).hasAccessibleName(Pattern.compile("hello"), new LocatorAssertions.HasAccessibleNameOptions().setIgnoreCase(true));
}
@Test
public void toHaveAccessibleDescription() {
page.setContent("<div role=\"button\" aria-description=\"Hello\"></div>");
assertThat(page.locator("div")).hasAccessibleDescription("Hello");
assertThat(page.locator("div")).not().hasAccessibleDescription("hello");
assertThat(page.locator("div")).hasAccessibleDescription("hello", new LocatorAssertions.HasAccessibleDescriptionOptions().setIgnoreCase(true));
assertThat(page.locator("div")).hasAccessibleDescription(Pattern.compile("ell\\w"));
assertThat(page.locator("div")).not().hasAccessibleDescription(Pattern.compile("hello"));
assertThat(page.locator("div")).hasAccessibleDescription(Pattern.compile("hello"), new LocatorAssertions.HasAccessibleDescriptionOptions().setIgnoreCase(true));
}
@Test
public void toHaveRole() {
page.setContent("<div role=\"button\">Button!</div>");
assertThat(page.locator("div")).hasRole(AriaRole.BUTTON);
assertThat(page.locator("div")).not().hasRole(AriaRole.CHECKBOX);
}
}
@@ -16,9 +16,12 @@
package com.microsoft.playwright;
import com.microsoft.playwright.options.KeyboardModifier;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TestLocatorClick extends TestBase {
@@ -54,4 +57,12 @@ public class TestLocatorClick extends TestBase {
assertEquals(true, page.evaluate("double"));
assertEquals("Clicked", page.evaluate("result"));
}
@Test
void shouldSupportCotrolOrMetaModifier() {
page.setContent("<a href='" + server.PREFIX + "/title.html'>Go</a>");
Page newPage = page.context().waitForPage(() ->
page.getByText("Go").click(new Locator.ClickOptions().setModifiers(asList(KeyboardModifier.CONTROLORMETA))));
assertThat(newPage).hasURL(server.PREFIX + "/title.html");
}
}
@@ -16,14 +16,12 @@
package com.microsoft.playwright;
import com.microsoft.playwright.options.HttpHeader;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
@@ -113,15 +111,50 @@ public class TestNetworkRequest extends TestBase {
assertTrue(response.request().headers().get("user-agent").contains("WebKit"));
}
static boolean isWebKitWindowsOrChromium() {
return (isWebKit() && getOS() == Utils.OS.WINDOWS) || isChromium();
}
static boolean isWebKitWindows() {
return isWebKit() && getOS() == Utils.OS.WINDOWS;
}
// HTTP server in java does not preserve headers order.
static List<HttpHeader> normalizeServerHeaders(Map<String,List<String>> headers) {
List<HttpHeader> serverHeaders = new ArrayList<>();
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
for (String value: entry.getValue()) {
HttpHeader header = new HttpHeader();
header.name = entry.getKey().toLowerCase();
header.value = value;
serverHeaders.add(header);
}
}
Comparator<HttpHeader> comparator = Comparator.comparing(h -> h.name);
serverHeaders.sort(comparator);
return serverHeaders;
}
static List<HttpHeader> normalizeAllHeaders(Map<String, String> headers) {
List<HttpHeader> serverHeaders = new ArrayList<>();
for (Map.Entry<String, String> entry : headers.entrySet()) {
HttpHeader header = new HttpHeader();
header.name = entry.getKey().toLowerCase();
header.value = entry.getValue();
serverHeaders.add(header);
}
Comparator<HttpHeader> comparator = Comparator.comparing(h -> h.name);
serverHeaders.sort(comparator);
return serverHeaders;
}
static List<HttpHeader> adjustServerHeaders(List<HttpHeader> headers) {
if (isFirefox()) {
for (Iterator<HttpHeader> it = headers.iterator(); it.hasNext(); ) {
if ("priority".equals(it.next().name)) {
it.remove();
}
}
}
return headers;
}
@Test
@DisabledIf(value="isWebKitWindows", disabledReason="Flaky, see https://github.com/microsoft/playwright/issues/6690")
void shouldGetTheSameHeadersAsTheServer() throws ExecutionException, InterruptedException {
@@ -133,9 +166,10 @@ public class TestNetworkRequest extends TestBase {
}
});
Response response = page.navigate(server.PREFIX + "/empty.html");
Map<String, String> expectedHeaders = serverRequest.get().headers.entrySet().stream().collect(
Collectors.toMap(e -> e.getKey().toLowerCase(), e -> e.getValue().get(0)));
assertEquals(expectedHeaders, response.request().allHeaders());
List<HttpHeader> expectedHeaders = adjustServerHeaders(normalizeServerHeaders(serverRequest.get().headers));
List<HttpHeader> allHeaders = normalizeAllHeaders(response.request().allHeaders());
assertJsonEquals(expectedHeaders, allHeaders);
}
@Test
@@ -157,9 +191,9 @@ public class TestNetworkRequest extends TestBase {
"}", server.CROSS_PROCESS_PREFIX + "/something");
assertEquals("done", text);
});
Map<String, String> expectedHeaders = serverRequest.get().headers.entrySet().stream().collect(
Collectors.toMap(e -> e.getKey().toLowerCase(), e -> e.getValue().get(0)));
assertEquals(expectedHeaders, response.request().allHeaders());
List<HttpHeader> expectedHeaders = adjustServerHeaders(normalizeServerHeaders(serverRequest.get().headers));
List<HttpHeader> allHeaders = normalizeAllHeaders(response.request().allHeaders());
assertJsonEquals(expectedHeaders, allHeaders);
}
@Test
@@ -63,4 +63,7 @@ public class TestOptionsFactories {
public static boolean isWebKit() {
return getBrowserName().equals("webkit");
}
static final boolean isMac = Utils.getOS() == Utils.OS.MAC;
static final boolean isWindows = Utils.getOS() == Utils.OS.WINDOWS;
}
@@ -16,6 +16,8 @@
package com.microsoft.playwright;
import com.microsoft.playwright.options.AriaRole;
import com.microsoft.playwright.options.WaitForSelectorState;
import org.junit.jupiter.api.Test;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
@@ -29,11 +31,13 @@ public class TestPageAddLocatorHandler extends TestBase {
int[] beforeCount = {0};
int[] afterCount = {0};
page.addLocatorHandler(page.getByText("This interstitial covers the button"), () -> {
Locator originalLocator = page.getByText("This interstitial covers the button");
page.addLocatorHandler(originalLocator, locator -> {
assertEquals(originalLocator, locator);
++beforeCount[0];
page.locator("#close").click();
++afterCount[0];
});
}, new Page.AddLocatorHandlerOptions().setNoWaitAfter(true));
String[][] argsList = {
{"mouseover", "1"},
@@ -73,10 +77,10 @@ public class TestPageAddLocatorHandler extends TestBase {
void shouldWorkWithCustomCheck() {
page.navigate(server.PREFIX + "/input/handle-locator.html");
page.addLocatorHandler(page.locator("body"), () -> {
page.addLocatorHandler(page.locator("body"), locator -> {
if (page.getByText("This interstitial covers the button").isVisible())
page.locator("#close").click();
});
}, new Page.AddLocatorHandlerOptions().setNoWaitAfter(true));
String[][] argsList = {
{"mouseover", "2"},
@@ -103,7 +107,7 @@ public class TestPageAddLocatorHandler extends TestBase {
void shouldWorkWithLocatorHover() {
page.navigate(server.PREFIX + "/input/handle-locator.html");
page.addLocatorHandler(page.getByText("This interstitial covers the button"), () -> {
page.addLocatorHandler(page.getByText("This interstitial covers the button"), locator -> {
page.locator("#close").click();
});
@@ -120,7 +124,7 @@ public class TestPageAddLocatorHandler extends TestBase {
void shouldNotWorkWithForceTrue() {
page.navigate(server.PREFIX + "/input/handle-locator.html");
page.addLocatorHandler(page.getByText("This interstitial covers the button"), () -> {
page.addLocatorHandler(page.getByText("This interstitial covers the button"), locator -> {
page.locator("#close").click();
});
@@ -138,7 +142,7 @@ public class TestPageAddLocatorHandler extends TestBase {
void shouldThrowWhenPageCloses() {
page.navigate(server.PREFIX + "/input/handle-locator.html");
page.addLocatorHandler(page.getByText("This interstitial covers the button"), () -> {
page.addLocatorHandler(page.getByText("This interstitial covers the button"), locator -> {
page.close();
});
@@ -156,7 +160,7 @@ public class TestPageAddLocatorHandler extends TestBase {
page.navigate(server.PREFIX + "/input/handle-locator.html");
int[] called = {0};
page.addLocatorHandler(page.getByText("This interstitial covers the button"), () -> {
page.addLocatorHandler(page.getByText("This interstitial covers the button"), locator -> {
++called[0];
page.locator("#close").click();
});
@@ -169,4 +173,168 @@ public class TestPageAddLocatorHandler extends TestBase {
assertThat(page.locator("#interstitial")).not().isVisible();
assertEquals(1, called[0]);
}
@Test
public void shouldWorkWhenOwnerFrameDetaches() {
Page page = browser.newPage();
page.navigate(server.EMPTY_PAGE);
page.evaluate("() => {\n" +
" const iframe = document.createElement('iframe');\n" +
" iframe.src = 'data:text/html,<body>hello from iframe</body>';\n" +
" document.body.append(iframe);\n" +
"\n" +
" const target = document.createElement('button');\n" +
" target.textContent = 'Click me';\n" +
" target.id = 'target';\n" +
" target.addEventListener('click', () => window._clicked = true);\n" +
" document.body.appendChild(target);\n" +
"\n" +
" const closeButton = document.createElement('button');\n" +
" closeButton.textContent = 'close';\n" +
" closeButton.id = 'close';\n" +
" closeButton.addEventListener('click', () => iframe.remove());\n" +
" document.body.appendChild(closeButton);\n" +
" }");
page.addLocatorHandler(page.frameLocator("iframe").locator("body"), locator -> {
page.locator("#close").click();
});
page.locator("#target").click();
assertNull(page.querySelector("iframe"));
assertTrue((Boolean) page.evaluate("window._clicked"));
}
@Test
public void shouldWorkWithTimesOption() {
Page page = browser.newPage();
page.navigate(server.PREFIX + "/input/handle-locator.html");
int[] called = {0};
page.addLocatorHandler(page.locator("body"), locator -> {
++called[0];
}, new Page.AddLocatorHandlerOptions().setNoWaitAfter(true).setTimes(2));
page.locator("#aside").hover();
page.evaluate("() => {\n" +
" window.clicked = 0;\n" +
" window.setupAnnoyingInterstitial('mouseover', 4);\n" +
" }");
PlaywrightException e = assertThrows(PlaywrightException.class, () -> page.locator("#target").click(new Locator.ClickOptions().setTimeout(3_000)));
assertEquals(2, called[0]);
assertEquals(0, (int) page.evaluate("window.clicked"));
assertTrue(page.locator("#interstitial").isVisible());
assertTrue(e.getMessage().contains("Timeout 3000ms exceeded"), e.getMessage());
assertTrue(e.getMessage().contains("<div>This interstitial covers the button</div> from <div class=\"visible\" id=\"interstitial\">…</div> subtree intercepts pointer events"), e.getMessage());
}
@Test
public void shouldWaitForHiddenByDefault() {
Page page = browser.newPage();
page.navigate(server.PREFIX + "/input/handle-locator.html");
int[] called = {0};
page.addLocatorHandler(page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("close")), button -> {
++called[0];
button.click();
});
page.locator("#aside").hover();
page.evaluate("() => {" +
"window.clicked = 0;" +
"window.setupAnnoyingInterstitial('timeout', 1);" +
"}");
page.locator("#target").click();
assertEquals(1, (int) page.evaluate("window.clicked"));
assertFalse(page.locator("#interstitial").isVisible());
assertEquals(1, called[0]);
}
@Test
public void shouldWaitForHiddenByDefault2() {
Page page = browser.newPage();
page.navigate(server.PREFIX + "/input/handle-locator.html");
int[] called = {0};
page.addLocatorHandler(page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("close")), button -> {
++called[0];
});
page.locator("#aside").hover();
page.evaluate("() => {" +
"window.clicked = 0;" +
"window.setupAnnoyingInterstitial('hide', 1);" +
"}");
PlaywrightException e = assertThrows(PlaywrightException.class, () -> page.locator("#target").click(new Locator.ClickOptions().setTimeout(3_000)));
assertEquals(0, (int) page.evaluate("window.clicked"));
assertThat(page.locator("#interstitial")).isVisible();
assertEquals(1, called[0]);
assertTrue(e.getMessage().contains("locator handler has finished, waiting for getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName(\"close\")) to be hidden"), e.getMessage());
}
@Test
public void shouldWorkWithNoWaitAfter() {
Page page = browser.newPage();
page.navigate(server.PREFIX + "/input/handle-locator.html");
int[] called = {0};
page.addLocatorHandler(page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("close")), button -> {
++called[0];
if (called[0] == 1) {
button.click();
} else {
page.locator("#interstitial").waitFor(new Locator.WaitForOptions().setState(WaitForSelectorState.HIDDEN));
}
}, new Page.AddLocatorHandlerOptions().setNoWaitAfter(true));
page.locator("#aside").hover();
page.evaluate("() => {" +
"window.clicked = 0;" +
"window.setupAnnoyingInterstitial('timeout', 1);" +
"}");
page.locator("#target").click();
assertEquals(1, (int) page.evaluate("window.clicked"));
assertThat(page.locator("#interstitial")).not().isVisible();
assertEquals(2, called[0]);
}
@Test
public void shouldRemoveLocatorHandler() {
Page page = browser.newPage();
page.navigate(server.PREFIX + "/input/handle-locator.html");
int[] called = {0};
page.addLocatorHandler(page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("close")), button -> {
++called[0];
button.click();
});
page.evaluate("() => {" +
"window.clicked = 0;" +
"window.setupAnnoyingInterstitial('hide', 1);" +
"}");
page.locator("#target").click();
assertEquals(1, called[0]);
assertEquals(1, (int) page.evaluate("window.clicked"));
assertThat(page.locator("#interstitial")).not().isVisible();
page.evaluate("() => {" +
"window.clicked = 0;" +
"window.setupAnnoyingInterstitial('hide', 1);" +
"}");
page.removeLocatorHandler(page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("close")));
PlaywrightException e = assertThrows(PlaywrightException.class, () -> page.locator("#target").click(new Locator.ClickOptions().setTimeout(3_000)));
assertEquals(1, called[0]);
assertEquals(0, (int) page.evaluate("window.clicked"));
assertThat(page.locator("#interstitial")).isVisible();
assertTrue(e.getMessage().contains("Timeout 3000ms exceeded"));
}
}
@@ -58,6 +58,12 @@ public class TestPageAssertions extends TestBase {
assertThat(page).not().hasURL("about:blank", new PageAssertions.HasURLOptions().setTimeout(1000));
}
@Test
public void hasUrlSupportIgnoreCase() {
page.navigate("data:text/html,<div>A</div>");
assertThat(page).hasURL("DATA:teXT/HTml,<div>a</div>", new PageAssertions.HasURLOptions().setIgnoreCase(true));
}
@Test
void hasURLRegexPass() {
page.navigate("data:text/html,<div>A</div>");
@@ -0,0 +1,464 @@
package com.microsoft.playwright;
import com.microsoft.playwright.junit.FixtureTest;
import com.microsoft.playwright.junit.UsePlaywright;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import static com.microsoft.playwright.Utils.assertJsonEquals;
import static org.junit.jupiter.api.Assertions.*;
@FixtureTest
@UsePlaywright
public class TestPageClock {
private ArrayList<Object> calls;
@BeforeEach
void exposeStubFunction(Page page) {
calls = new ArrayList();
page.exposeFunction("stub", (Object... params) -> {
calls.add(params);
return null;
});
}
private void setupRunForTest(Page page) {
page.clock().install(new Clock.InstallOptions().setTime(0));
page.clock().pauseAt(1000);
}
@Test
void runForTriggersImmediatelyWithoutSpecifiedDelay(Page page) {
setupRunForTest(page);
page.evaluate("() => setTimeout(window.stub)");
page.clock().runFor(0);
assertEquals(1, calls.size());
}
@Test
void runForDoesNotTriggerWithoutSufficientDelay(Page page) {
setupRunForTest(page);
// Trigger the stub with a delay
page.evaluate("() => setTimeout(window.stub, 100)");
page.clock().runFor(11);
assertEquals(0, calls.size());
}
@Test
void runForTriggersAfterSufficientDelay(Page page) {
setupRunForTest(page);
page.evaluate("() => setTimeout(window.stub, 100)");
page.clock().runFor(100);
assertEquals(1, calls.size());
}
@Test
void runForTriggersSimultaneousTimers(Page page) {
setupRunForTest(page);
page.evaluate("() => { setTimeout(window.stub, 100);" +
"setTimeout(window.stub, 100); }");
page.clock().runFor(100);
assertEquals(2, calls.size());
}
@Test
void runForTriggersMultipleSimultaneousTimers(Page page) {
setupRunForTest(page);
page.evaluate("() => { setTimeout(window.stub, 100);" +
"setTimeout(window.stub, 100);" +
"setTimeout(window.stub, 99);" +
"setTimeout(window.stub, 100); }");
page.clock().runFor(100);
assertEquals(4, calls.size());
}
@Test
void runForWaitsAfterSetTimeoutWasCalled(Page page) {
setupRunForTest(page);
page.evaluate("() => setTimeout(window.stub, 150)");
page.clock().runFor(50);
assertEquals(0, calls.size());
page.clock().runFor(100);
assertEquals(1, calls.size());
}
@Test
void runForTriggersEventWhenSomeThrow(Page page) {
setupRunForTest(page);
page.evaluate("() => {\n" +
" setTimeout(() => {throw new Error(); }, 100);\n" +
" setTimeout(window.stub, 120);\n" +
"}");
assertThrows(PlaywrightException.class, () -> page.clock().runFor(120));
assertEquals(1, calls.size());
}
@Test
void runForCreatesUpdatedDateWhileTicking(Page page) {
setupRunForTest(page);
page.clock().setSystemTime(0);
page.evaluate("() => setInterval(() => { window.stub(new Date().getTime()); }, 10)");
page.clock().runFor(100);
assertJsonEquals("[[10],[20],[30],[40],[50],[60],[70],[80],[90],[100]]", calls);
}
@Test
void runForPasses8Seconds(Page page) {
setupRunForTest(page);
page.evaluate("() => setInterval(window.stub, 4000)");
page.clock().runFor("08");
assertEquals(2, calls.size());
}
@Test
void runForPasses1Minute(Page page) {
setupRunForTest(page);
page.evaluate("() => setInterval(window.stub, 6000)");
page.clock().runFor("01:00");
assertEquals(10, calls.size());
}
@Test
void runForPasses2Hours34MinutesAnd10Seconds(Page page) {
setupRunForTest(page);
page.evaluate("() => setInterval(window.stub, 10000)");
page.clock().runFor("02:34:10");
assertEquals(925, calls.size());
}
@Test
void runForThrowsForInvalidFormat(Page page) {
setupRunForTest(page);
page.evaluate("() => setInterval(window.stub, 10000)");
assertThrows(PlaywrightException.class, () -> page.clock().runFor("12:02:34:10"));
assertEquals(0, calls.size());
}
@Test
void runForReturnsTheCurrentNowValue(Page page) {
setupRunForTest(page);
page.clock().setSystemTime(0);
final int value = 200;
page.clock().runFor(value);
assertEquals(value, page.evaluate("() => Date.now()"));
}
private void setupFastForwardTest(Page page) {
page.clock().install(new Clock.InstallOptions().setTime(0));
page.clock().pauseAt(1000);
}
@Test
void fastForwardIgnoresTimersWhichWouldntBeRun(Page page) {
setupFastForwardTest(page);
page.evaluate("() => setTimeout(() => { window.stub('should not be logged'); }, 1000)");
page.clock().fastForward(500);
assertEquals(0, calls.size());
}
@Test
void fastForwardPushesBackExecutionTimeForSkippedTimers(Page page) {
setupFastForwardTest(page);
page.evaluate("() => setTimeout(() => { window.stub(Date.now()); }, 1000)");
page.clock().fastForward(2000);
assertEquals(1, calls.size());
assertEquals(1000 + 2000, ((Object[])calls.get(0))[0]);
}
@Test
void fastForwardSupportsStringTimeArguments(Page page) {
setupFastForwardTest(page);
page.evaluate("() => setTimeout(() => { window.stub(Date.now()); }, 100000)");
page.clock().fastForward("01:50");
assertEquals(1, calls.size());
assertEquals(1000 + 110000, ((Object[])calls.get(0))[0]);
}
private void setupStubTimers(Page page) {
page.clock().install(new Clock.InstallOptions().setTime(0));
page.clock().pauseAt(1000);
}
@Test
void setsInitialTimestamp(Page page) {
setupStubTimers(page);
page.clock().setSystemTime(1400);
assertEquals(1400, page.evaluate("() => Date.now()"));
}
@Test
void replacesGlobalSetTimeout(Page page) {
setupStubTimers(page);
page.evaluate("() => setTimeout(window.stub, 1000)");
page.clock().runFor(1000);
assertEquals(1, calls.size());
}
@Test
void globalFakeSetTimeoutShouldReturnId(Page page) {
setupStubTimers(page);
Double to = (Double) page.evaluate("() => setTimeout(window.stub, 1000)");
assertTrue(to > 0);
}
@Test
void replacesGlobalClearTimeout(Page page) {
setupStubTimers(page);
page.evaluate("() => { const to = setTimeout(window.stub, 1000); clearTimeout(to); }");
page.clock().runFor(1000);
assertEquals(0, calls.size());
}
@Test
void replacesGlobalSetInterval(Page page) {
setupStubTimers(page);
page.evaluate("() => setInterval(window.stub, 500)");
page.clock().runFor(1000);
assertEquals(2, calls.size());
}
@Test
void replacesGlobalClearInterval(Page page) {
setupStubTimers(page);
page.evaluate("() => { const to = setInterval(window.stub, 500); clearInterval(to); }");
page.clock().runFor(1000);
assertEquals(0, calls.size());
}
@Test
void replacesGlobalPerformanceNow(Page page) {
}
@Test
void fakesDateConstructor(Page page) {
setupStubTimers(page);
Integer now = (Integer) page.evaluate("() => new Date().getTime()");
assertEquals(1000, now);
}
@Test
void replacesGlobalPerformanceTimeOrigin(Page page) {
}
@Test
void shouldTickAfterPopup(Page page) throws ParseException {
page.clock().install(new Clock.InstallOptions().setTime(0));
Date now = new SimpleDateFormat("yyyy-MM-dd").parse("2015-09-25");
page.clock().pauseAt(now.getTime());
Page popup = page.waitForPopup(() -> {
page.evaluate("() => window.open('about:blank')");
});
Double popupTime = (Double) popup.evaluate("() => Date.now()");
assertEquals(now.getTime(), popupTime);
page.clock().runFor(1000);
Double popupTimeAfter = (Double) popup.evaluate("() => Date.now()");
assertEquals(now.getTime() + 1000, popupTimeAfter);
}
@Test
void shouldTickBeforePopup(Page page) throws ParseException {
page.clock().install(new Clock.InstallOptions().setTime(0));
Date now = new SimpleDateFormat("yyyy-MM-dd").parse("2015-09-25");
page.clock().pauseAt(now.getTime());
page.clock().runFor(1000);
Page popup = page.waitForPopup(() -> {
page.evaluate("() => window.open('about:blank')");
});
Double popupTime = (Double) popup.evaluate("() => Date.now()");
assertEquals(now.getTime() + 1000, popupTime);
}
@Test
void shouldRunTimeBeforePopup(Page page, Server server) {
server.setRoute("/popup.html", exchange -> {
exchange.getResponseHeaders().set("Content-type", "text/html");
exchange.sendResponseHeaders(200, 0);
try (Writer writer = new OutputStreamWriter(exchange.getResponseBody())) {
writer.write("<script>window.time = Date.now()</script>");
}
});
page.navigate(server.EMPTY_PAGE);
page.waitForTimeout(2000);
Page popup = page.waitForPopup(() -> {
page.evaluate("url => window.open(url)", server.PREFIX + "/popup.html");
});
Double popupTime = (Double) popup.evaluate("time");
assertTrue(popupTime >= 2000);
}
@Test
void shouldNotRunTimeBeforePopupOnPause(Page page, Server server) {
server.setRoute("/popup.html", exchange -> {
exchange.getResponseHeaders().set("Content-type", "text/html");
exchange.sendResponseHeaders(200, 0);
try (Writer writer = new OutputStreamWriter(exchange.getResponseBody())) {
writer.write("<script>window.time = Date.now()</script>");
}
});
page.clock().install(new Clock.InstallOptions().setTime(0));
page.clock().pauseAt(1000);
page.navigate(server.EMPTY_PAGE);
page.waitForTimeout(2000);
Page popup = page.waitForPopup(() -> {
page.evaluate("url => window.open(url)", server.PREFIX + "/popup.html");
});
Object popupTime = popup.evaluate("time");
assertEquals(1000, popupTime);
}
@Test
void setFixedTimeDoesNotFakeMethods(Page page) {
page.clock().setFixedTime(0);
// Should not stall.
page.evaluate("() => new Promise(f => setTimeout(f, 1))");
}
@Test
void setFixedTimeAllowsSettingTimeMultipleTimes(Page page) {
page.clock().setFixedTime(100);
assertEquals(100, page.evaluate("() => Date.now()"));
page.clock().setFixedTime(200);
assertEquals(200, page.evaluate("() => Date.now()"));
}
@Test
void setFixedTimeFixedTimeIsNotAffectedByClockManipulation(Page page) {
page.clock().setFixedTime(100);
assertEquals(100, page.evaluate("() => Date.now()"));
page.clock().fastForward(20);
assertEquals(100, page.evaluate("() => Date.now()"));
}
@Test
void setFixedTimeAllowsInstallingFakeTimersAfterSettingTime(Page page) {
page.clock().setFixedTime(100);
assertEquals(100, page.evaluate("() => Date.now()"));
page.clock().setFixedTime(200);
page.evaluate("async () => { setTimeout(() => window.stub(Date.now()), 0); }");
page.clock().runFor(0);
assertEquals(1, calls.size());
assertEquals(200, ((Object[]) calls.get(0))[0]);
}
@Test
void whileRunningShouldProgressTime(Page page) {
page.clock().install(new Clock.InstallOptions().setTime(0));
page.navigate("data:text/html,");
page.waitForTimeout(1000);
int now = (int) page.evaluate("() => Date.now()");
assertTrue(now >= 1000 && now <= 2000);
}
@Test
void whileRunningShouldRunFor(Page page) {
page.clock().install(new Clock.InstallOptions().setTime(0));
page.navigate("data:text/html,");
page.clock().runFor(10000);
int now = (int) page.evaluate("() => Date.now()");
assertTrue(now >= 10000 && now <= 11000);
}
@Test
void whileRunningShouldFastForward(Page page) {
page.clock().install(new Clock.InstallOptions().setTime(0));
page.navigate("data:text/html,");
page.clock().fastForward(10000);
int now = (int) page.evaluate("() => Date.now()");
assertTrue(now >= 10000 && now <= 11000);
}
@Test
void whileRunningShouldFastForwardTo(Page page) {
page.clock().install(new Clock.InstallOptions().setTime(0));
page.navigate("data:text/html,");
page.clock().fastForward(10000);
int now = (int) page.evaluate("() => Date.now()");
assertTrue(now >= 10000 && now <= 11000);
}
@Test
void whileRunningShouldPause(Page page) {
page.clock().install(new Clock.InstallOptions().setTime(0));
page.navigate("data:text/html,");
page.clock().pauseAt(1000);
page.waitForTimeout(1000);
page.clock().resume();
int now = (int) page.evaluate("() => Date.now()");
assertTrue(now >= 0 && now <= 1000);
}
@Test
void whileRunningShouldPauseAndFastForward(Page page) {
page.clock().install(new Clock.InstallOptions().setTime(0));
page.navigate("data:text/html,");
page.clock().pauseAt(1000);
page.clock().fastForward(1000);
int now = (int) page.evaluate("() => Date.now()");
assertEquals(2000, now);
}
@Test
void whileRunningShouldSetSystemTimeOnPause(Page page) {
page.clock().install(new Clock.InstallOptions().setTime(0));
page.navigate("data:text/html,");
page.clock().pauseAt(1000);
int now = (int) page.evaluate("() => Date.now()");
assertEquals(1000, now);
}
@Test
void whileOnPauseFastForwardShouldNotRunNestedImmediate(Page page) {
page.clock().install(new Clock.InstallOptions().setTime(0));
page.navigate("data:text/html,");
page.clock().pauseAt(1000);
page.evaluate("() => { setTimeout(() => { window.stub('outer'); setTimeout(() => window.stub('inner'), 0); }, 1000); }");
page.clock().fastForward(1000);
assertEquals(1, calls.size());
assertEquals("outer", ((Object[]) calls.get(0))[0]);
page.clock().fastForward(1);
assertEquals(2, calls.size());
assertEquals("inner", ((Object[]) calls.get(1))[0]);
}
@Test
void whileOnPauseRunForShouldNotRunNestedImmediate(Page page) {
page.clock().install(new Clock.InstallOptions().setTime(0));
page.navigate("data:text/html,");
page.clock().pauseAt(1000);
page.evaluate("() => { setTimeout(() => { window.stub('outer'); setTimeout(() => window.stub('inner'), 0); }, 1000); }");
page.clock().runFor(1000);
assertEquals(1, calls.size());
assertEquals("outer", ((Object[]) calls.get(0))[0]);
page.clock().runFor(1);
assertEquals(2, calls.size());
assertEquals("inner", ((Object[]) calls.get(1))[0]);
}
@Test
void whileOnPauseRunForShouldNotRunNestedImmediateFromMicrotask(Page page) {
page.clock().install(new Clock.InstallOptions().setTime(0));
page.navigate("data:text/html,");
page.clock().pauseAt(1000);
page.evaluate("() => { setTimeout(() => { window.stub('outer'); void Promise.resolve().then(() => setTimeout(() => window.stub('inner'), 0)); }, 1000); }");
page.clock().runFor(1000);
assertEquals(1, calls.size());
assertEquals("outer", ((Object[]) calls.get(0))[0]);
page.clock().runFor(1);
assertEquals(2, calls.size());
assertEquals("inner", ((Object[]) calls.get(1))[0]);
}
@Test
void shouldThrowForInvalidDate(Page page) {
Exception exception1 = assertThrows(PlaywrightException.class, () -> page.clock().setSystemTime("invalid"));
assertTrue(exception1.getMessage().contains("Invalid date: invalid"), exception1.getMessage());
}
}
@@ -539,19 +539,30 @@ public class TestPageEvaluate extends TestBase {
@Test
void shouldEvaluateException() {
String result = (String) page.evaluate("() => {\n" +
Exception result = (Exception) page.evaluate("() => {\n" +
" return (function functionOnStack() {\n" +
" return new Error('error message');\n" +
" })();\n" +
"}");
assertTrue(result.contains("Error: error message"));
assertTrue(result.contains("functionOnStack"));
assertTrue(result.getMessage().contains("Error: error message"), result.getMessage());
assertTrue(result.getMessage().contains("functionOnStack"), result.getMessage());
}
@Test
void shouldEvaluateException2() {
Object error = page.evaluate("new Error('error message')");
assertTrue(((String) error).contains("Error: error message"));
Exception error = (Exception) page.evaluate("new Error('error message')");
assertTrue(error.getMessage().contains("Error: error message"), error.getMessage());
}
@Test
void shouldPassExceptionArgument() {
Exception e = new Exception("error message");
Map<String, Object> received = (Map<String, Object>) page.evaluate("e => { return { message: e.message, name: e.name, stack: e.stack }; }", e);
assertEquals("error message", received.get("message"));
assertEquals("Exception", received.get("name"));
assertNotNull(received.get("stack"));
assertTrue(received.get("stack").toString().contains("shouldPassExceptionArgument"), received.get("stack").toString());
}
@Test
@@ -343,10 +343,9 @@ public class TestPageKeyboard extends TestBase {
page.navigate(server.PREFIX + "/input/textarea.html");
ElementHandle textarea = page.querySelector("textarea");
textarea.type("some text");
String modifier = isMac ? "Meta" : "Control";
page.keyboard().down(modifier);
page.keyboard().down("ControlOrMeta");
page.keyboard().press("a");
page.keyboard().up(modifier);
page.keyboard().up("ControlOrMeta");
page.keyboard().press("Backspace");
assertTrue(((String)page.evalOnSelector("textarea", "textarea => textarea.value")).isEmpty());
}
@@ -362,10 +361,9 @@ public class TestPageKeyboard extends TestBase {
" event.preventDefault();\n" +
" }, false);\n" +
"}");
String modifier = isMac ? "Meta" : "Control";
page.keyboard().down(modifier);
page.keyboard().down("ControlOrMeta");
page.keyboard().press("a");
page.keyboard().up(modifier);
page.keyboard().up("ControlOrMeta");
page.keyboard().press("Backspace");
assertEquals("some tex", page.evalOnSelector("textarea", "textarea => textarea.value"));
}
@@ -62,12 +62,18 @@ public class TestPageNetworkRequest extends TestBase {
});
responseWritten.acquire();
List<HttpHeader> expectedHeaders = serverHeaders;
if (isWebKit() && isWindows) {
expectedHeaders = expectedHeaders.stream()
.filter(h -> !"accept-encoding".equals(h.name.toLowerCase()) && !"accept-language".equals(h.name.toLowerCase()))
.collect(Collectors.toList());
}
if (isFirefox()) {
expectedHeaders = expectedHeaders.stream()
.filter(h -> !"priority".equals(h.name.toLowerCase()))
.collect(Collectors.toList());
}
List<HttpHeader> headers = request.headersArray();
// Java HTTP server normalizes header names, work around that:
@@ -252,8 +252,20 @@ public class TestPageScreenshot extends TestBase {
assertThrows(AssertionError.class, () -> assertArrayEquals(screenshot1, screenshot2));
}
static boolean isScreenshotTestDisabled() {
if (isWebKit()) {
// Array lengths differ.
return true;
}
if (getBrowserChannelFromEnv() != null) {
// Stable builds may have different expectations.
return true;
}
return false;
}
@Test
@DisabledIf(value="com.microsoft.playwright.TestBase#isWebKit", disabledReason="array lengths differ")
@DisabledIf(value="com.microsoft.playwright.TestPageScreenshot#isScreenshotTestDisabled", disabledReason="array lengths differ")
void shouldHideElementsBasedOnAttr() throws IOException {
page.setViewportSize(500, 500);
page.navigate(server.PREFIX + "/grid.html");
@@ -269,7 +281,7 @@ public class TestPageScreenshot extends TestBase {
}
@Test
@DisabledIf(value="com.microsoft.playwright.TestBase#isWebKit", disabledReason="array lengths differ")
@DisabledIf(value="com.microsoft.playwright.TestPageScreenshot#isScreenshotTestDisabled", disabledReason="array lengths differ")
void shouldRemoveElementsBasedOnAttr() throws IOException {
page.setViewportSize(500, 500);
page.navigate(server.PREFIX + "/grid.html");
@@ -21,7 +21,6 @@ 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 org.junit.platform.commons.support.AnnotationSupport;
import java.io.*;
import java.nio.file.Files;
@@ -429,5 +428,85 @@ public class TestPageSetInputFiles extends TestBase {
// rounds it to seconds in WebKit: 1696272058110 -> 1696272058000.
assertTrue(Math.abs(timestamps.get(0) - expected.toMillis()) < 1000, "expected: " + expected.toMillis() + "; actual: " + timestamps.get(0));
}
static void writeFile(Path file, String content) throws IOException {
try (Writer stream = new OutputStreamWriter(Files.newOutputStream(file))) {
stream.write(content);
}
}
@Test
void shouldUploadAFolder(@TempDir Path tmpDir) throws IOException {
page.navigate(server.PREFIX + "/input/folderupload.html");
Locator input = page.locator("input[name=\"file1\"]");
Path dir = tmpDir.resolve("file-upload-test");
Files.createDirectories(dir);
writeFile(dir.resolve("file1.txt"), "file1 content");
writeFile(dir.resolve("file2"), "file2 content");
Files.createDirectories(dir.resolve("sub-dir"));
writeFile(dir.resolve("sub-dir").resolve("really.txt"), "sub-dir file content");
input.setInputFiles(dir);
List<String> webkitRelativePaths = (List<String>) input.evaluate("e => [...e.files].map(f => f.webkitRelativePath)");
List<String> relativePathsSorted = new ArrayList<>(webkitRelativePaths);
relativePathsSorted.sort(String::compareTo);
// https://issues.chromium.org/issues/345393164
if (isChromium() && !isHeadful() && chromiumVersionLessThan(browser.version(), "127.0.6533.0")) {
assertEquals(asList("file-upload-test/file1.txt", "file-upload-test/file2"), relativePathsSorted);
} else {
assertEquals(asList("file-upload-test/file1.txt", "file-upload-test/file2", "file-upload-test/sub-dir/really.txt"), relativePathsSorted);
}
for (int i = 0; i < webkitRelativePaths.size(); i++) {
String relativePath = webkitRelativePaths.get(i);
Object content = input.evaluate("(e, i) => {\n" +
" const reader = new FileReader();\n" +
" const promise = new Promise(fulfill => reader.onload = fulfill);\n" +
" reader.readAsText(e.files[i]);\n" +
" return promise.then(() => reader.result);\n" +
" }", i);
String expectedContent = new String(Files.readAllBytes(tmpDir.resolve(relativePath)));
assertEquals(expectedContent, content);
}
}
@Test
void shouldUploadAFolderAndThrowForMultipleDirectories() throws IOException {
page.navigate(server.PREFIX + "/input/folderupload.html");
Locator input = page.locator("input[name=\"file1\"]");
Path dir = Paths.get("file-upload-test"); // Adjust path as necessary
Files.createDirectories(dir.resolve("folder1"));
writeFile(dir.resolve("folder1").resolve("file1.txt"), "file1 content");
Files.createDirectories(dir.resolve("folder2"));
writeFile(dir.resolve("folder2").resolve("file2.txt"), "file2 content");
PlaywrightException e = assertThrows(PlaywrightException.class,
() -> input.setInputFiles(new Path[]{dir.resolve("folder1"), dir.resolve("folder2")}));
assertTrue(e.getMessage().contains("Multiple directories are not supported"), e.getMessage());
}
@Test
void shouldThrowIfADirectoryAndFilesArePassed() throws IOException {
// Skipping conditions based on environment not directly translatable to Java; needs custom implementation
page.navigate(server.PREFIX + "/input/folderupload.html");
Locator input = page.locator("input[name=\"file1\"]");
Path dir = Paths.get("file-upload-test"); // Adjust path as necessary
Files.createDirectories(dir.resolve("folder1"));
writeFile(dir.resolve("folder1").resolve("file1.txt"), "file1 content");
PlaywrightException e = assertThrows(PlaywrightException.class,
() -> input.setInputFiles(new Path[]{ dir.resolve("folder1"), dir.resolve("folder1").resolve("file1.txt") }));
assertTrue(e.getMessage().contains("File paths must be all files or a single directory"), e.getMessage());
}
@Test
void shouldThrowWhenUploadingAFolderInANormalFileUploadInput() throws IOException {
page.navigate(server.PREFIX + "/input/fileupload.html");
Locator input = page.locator("input[name=\"file1\"]");
Path dir = Paths.get("file-upload-test"); // Adjust path as necessary
Files.createDirectories(dir);
writeFile(dir.resolve("file1.txt"), "file1 content");
PlaywrightException e = assertThrows(PlaywrightException.class,
() -> input.setInputFiles(dir));
assertTrue(e.getMessage().contains("File input does not support directories, pass individual files instead"), e.getMessage());
}
}
@@ -18,16 +18,13 @@ package com.microsoft.playwright;
import org.junit.jupiter.api.Test;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Semaphore;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import static com.microsoft.playwright.options.KeyboardModifier.ALT;
import static com.microsoft.playwright.Utils.mapOf;
import static com.microsoft.playwright.options.KeyboardModifier.ALT;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TestTap extends TestBase {
@@ -97,26 +94,13 @@ public class TestTap extends TestBase {
}
@Test
void shouldWaitForANavigationCausedByATap() throws InterruptedException {
void shouldNotWaitForANavigationCausedByATap() throws InterruptedException, ExecutionException {
page.navigate(server.EMPTY_PAGE);
page.setContent("<a href='/intercept-this.html'>link</a>;");
Semaphore responseWritten = new Semaphore(0);
List<String> events = Collections.synchronizedList(new ArrayList<>());
server.setRoute("/intercept-this.html", exchange -> {
// make sure the tap doesnt resolve too early
assertDoesNotThrow(() -> Thread.sleep(100));
exchange.getResponseHeaders().add("Content-Type", "application/octet-stream");
exchange.sendResponseHeaders(200, 0);
try (OutputStreamWriter writer = new OutputStreamWriter(exchange.getResponseBody())) {
writer.write("foo");
}
events.add("sent response");
responseWritten.release();
});
Future<Server.Request> serverReq = server.futureRequest("/intercept-this.html");
server.setRoute("/intercept-this.html", exchange -> {});
page.tap("a");
events.add("tap finished");
responseWritten.acquire();
assertEquals(asList("sent response", "tap finished"), events);
serverReq.get();
}
@Test
@@ -182,7 +182,7 @@ public class Utils {
return browserName;
}
static BrowserType getBrowserTypeFromEnv(Playwright playwright) {
public static BrowserType getBrowserTypeFromEnv(Playwright playwright) {
String browserName = getBrowserNameFromEnv();
switch (browserName) {
case "webkit":
@@ -0,0 +1,9 @@
package com.microsoft.playwright.impl;
import com.microsoft.playwright.Browser;
public class ImplUtils {
public static boolean isRemoteBrowser(Browser browser) {
return ((BrowserImpl) browser).isConnectedOverWebSocket;
}
}
@@ -0,0 +1,24 @@
package com.microsoft.playwright.junit;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.Playwright;
import com.microsoft.playwright.impl.junit.PlaywrightExtension;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ParameterContext;
import org.junit.jupiter.api.extension.ParameterResolutionException;
import org.junit.jupiter.api.extension.ParameterResolver;
import static com.microsoft.playwright.Utils.getBrowserTypeFromEnv;
public class BrowserTypeParameterResolver implements ParameterResolver {
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
return BrowserType.class.equals(parameterContext.getParameter().getType());
}
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
Playwright playwright = PlaywrightExtension.getOrCreatePlaywright(extensionContext);
return getBrowserTypeFromEnv(playwright);
}
}
@@ -24,7 +24,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@ExtendWith(ServerLifecycle.class)
@ExtendWith({ServerLifecycle.class, BrowserTypeParameterResolver.class})
@Tag("fixtures")
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@@ -0,0 +1,66 @@
# Client Certificate test-certificates
## Server
```bash
openssl req \
-x509 \
-newkey rsa:4096 \
-keyout server/server_key.pem \
-out server/server_cert.pem \
-nodes \
-days 365 \
-subj "/CN=localhost/O=Client\ Certificate\ Demo" \
-addext "subjectAltName=DNS:localhost,DNS:local.playwright"
```
## Trusted client-certificate (server signed/valid)
```
mkdir -p client/trusted
# generate server-signed (valid) certifcate
openssl req \
-newkey rsa:4096 \
-keyout client/trusted/key.pem \
-out client/trusted/csr.pem \
-nodes \
-days 365 \
-subj "/CN=Alice"
# sign with server_cert.pem
openssl x509 \
-req \
-in client/trusted/csr.pem \
-CA server/server_cert.pem \
-CAkey server/server_key.pem \
-out client/trusted/cert.pem \
-set_serial 01 \
-days 365
```
## Self-signed certificate (invalid)
```
mkdir -p client/self-signed
openssl req \
-newkey rsa:4096 \
-keyout client/self-signed/key.pem \
-out client/self-signed/csr.pem \
-nodes \
-days 365 \
-subj "/CN=Bob"
# sign with self-signed/key.pem
openssl x509 \
-req \
-in client/self-signed/csr.pem \
-signkey client/self-signed/key.pem \
-out client/self-signed/cert.pem \
-days 365
```
## Java: Convert PEM Files to PKCS12
```
openssl pkcs12 -export -in server_cert.pem -inkey server_key.pem -out server_keystore.p12 -name myalias
```
@@ -0,0 +1,28 @@
-----BEGIN CERTIFICATE-----
MIIEyzCCArOgAwIBAgIUYps4gh4MqFYg8zqQhHYL7zYfbLkwDQYJKoZIhvcNAQEL
BQAwDjEMMAoGA1UEAwwDQm9iMB4XDTI0MDcxOTEyNDc0MFoXDTI1MDcxOTEyNDc0
MFowDjEMMAoGA1UEAwwDQm9iMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKC
AgEA179eTsqcc1c3AOQHzCZEyYLPta2CCAscUFqcEZ9vWvjW0uzOv9TDlB33Unov
jch4CElZOBhzTadVsbmnYKpxwyVU89WCuQKvedz4k1vu7S1YryfNbmS8PWbnQ4ds
9NB7SgJNHZILvx9DXuWeFEyzRIo1984z4HheBzrkf791LqpYKaKziANUo8h8t0dm
TX/boOz8cEnQNwtTC0ZX3aD0obG/UAhr/22ZGPo/E659fh4ptyYX2LrIUHGy+Eux
nJ9Y4cTqa88Ee6K6AkDiT/AoNQNxE4X++jqLuie8j/ZYpI1Oll38GwKVOyy1msRL
toGmISNwkMIQDGABrJlxgpP4QQAQ+08v9srzXOlkdxdr7OCP81r+ccBXiSQEe7BA
kdJ8l98l5dprJ++GJ+SZcV4+/iGR0dKU2IdAG5HiKZIFn6ch9Ux+UMqeGaYCpkHr
TiietHwcXgtVBlE0jFmB/HspmI/O0abK+grMmueaH7XtTI8YHnw0mUpL8+yp7mfA
7zFusgFgyiBPXeD/NQgg8vja67k++d1VGoXm2xr+5WPQCSbgQoMkkOBMLHWJTefd
6F4Z5M+oI0VwYbf6eQW246wJgpCHSPR0Vdijd6MAGRWKUuLfDsA9+12iGbKvwJ2e
nJlStft2V2LZcjBfdIMbigW1aSVNN5w6m6YVrQPry3WPkWcCAwEAAaMhMB8wHQYD
VR0OBBYEFPxKWTFQJSg4HD2qjxL0dnXX/z4qMA0GCSqGSIb3DQEBCwUAA4ICAQBz
4H1d5eGRU9bekUvi7LbZ5CP/I6w6PL/9AlXqO3BZKxplK7fYGHd3uqyDorJEsvjV
hxwvFlEnS0JIU3nRzhJU/h4Yaivf1WLRFwGZ4TPBjX9KFU27exFWD3rppazkWybJ
i4WuEdP3TJMdKLcNTtXWUDroDOgPlS66u6oZ+mUyUROil+B+fgQgVDhjRc5fvRgZ
Lng8wuejCo3ExQyxkwn2G5guyIimgHmOQghPtLO5xlc67Z4GPUZ1m4tC+BCiFO4D
YIXl3QiIpmU7Pss39LLKMGXXAgLRqyMzqE52lsznu18v5vDLfTaRH4u/wjzULhXz
SrV1IUJmhgEXta4EeDmPH0itgKtkbwjgCOD7drrFrJq/EnvIaJ5cpxiI1pFmYD8g
VVD7/KT/CyT1Uz1dI8QaP/JX8XEgtMJaSkPfjPErIViN9rh9ECCNLgFyv7Y0Plar
A6YlvdyV1Rta/BHndf5Hqz9QWNhbFCMQRGVQNEcoKwpFyjAE9SXoKJvFIK/w5WXu
qKzIYA26QXE3p734Xu1n8QiFJIyltVHbyUlD0k06194t5a2WK+/eDeReIsk0QOI8
FGqhyPZ7YjR5tSZTmgljtViqBO5AA23QOVFqtjOUrjXP5pTbPJel99Z/FTkqSwvB
Rt4OX7HfuokWQDTT0TMn5jVtJyi54cH7f9MmsNJ23g==
-----END CERTIFICATE-----
@@ -0,0 +1,26 @@
-----BEGIN CERTIFICATE REQUEST-----
MIIEUzCCAjsCAQAwDjEMMAoGA1UEAwwDQm9iMIICIjANBgkqhkiG9w0BAQEFAAOC
Ag8AMIICCgKCAgEA179eTsqcc1c3AOQHzCZEyYLPta2CCAscUFqcEZ9vWvjW0uzO
v9TDlB33Unovjch4CElZOBhzTadVsbmnYKpxwyVU89WCuQKvedz4k1vu7S1YryfN
bmS8PWbnQ4ds9NB7SgJNHZILvx9DXuWeFEyzRIo1984z4HheBzrkf791LqpYKaKz
iANUo8h8t0dmTX/boOz8cEnQNwtTC0ZX3aD0obG/UAhr/22ZGPo/E659fh4ptyYX
2LrIUHGy+EuxnJ9Y4cTqa88Ee6K6AkDiT/AoNQNxE4X++jqLuie8j/ZYpI1Oll38
GwKVOyy1msRLtoGmISNwkMIQDGABrJlxgpP4QQAQ+08v9srzXOlkdxdr7OCP81r+
ccBXiSQEe7BAkdJ8l98l5dprJ++GJ+SZcV4+/iGR0dKU2IdAG5HiKZIFn6ch9Ux+
UMqeGaYCpkHrTiietHwcXgtVBlE0jFmB/HspmI/O0abK+grMmueaH7XtTI8YHnw0
mUpL8+yp7mfA7zFusgFgyiBPXeD/NQgg8vja67k++d1VGoXm2xr+5WPQCSbgQoMk
kOBMLHWJTefd6F4Z5M+oI0VwYbf6eQW246wJgpCHSPR0Vdijd6MAGRWKUuLfDsA9
+12iGbKvwJ2enJlStft2V2LZcjBfdIMbigW1aSVNN5w6m6YVrQPry3WPkWcCAwEA
AaAAMA0GCSqGSIb3DQEBCwUAA4ICAQCb07d2IjUy1PeHCj/2k/z9FrZSo6K3c8y6
b/u/MZ0AXPKLPDSo7UYpOJ8Z2cBiJ8jQapjTSEL8POUYqcvCmP55R6u68KmvINHo
+Ly7pP+xPrbA4Q0WmPnz37hQn+I1he0GuEQyjZZqUln9zwp67TsWNKxKtCH+1j8M
Ltzx6kuHCdPtDUtv291yhVRqvbjiDs+gzdQYNJtAkUbHwHFxu8oZhg8QZGyXYMN8
TGoQ1LTezFZXJtX69K7WnrDGrjsgB6EMvwkqAFSYNH0LFvI0xo13OOgXr9mrwohA
76uZtjXL9B15EqrMce6mdUZi46QJuQ2avTi57Lz+fqvsBYdQO89VcFSmqu2nfspN
QZDrooyjHrlls8MpoBd8fde9oT4uA4/d9SJtuHUnjgGN7Qr7eTruWXL8wVMwFnvL
igWE4detO9y2gpRLq6uEqzWYMGtN9PXJCGU8C8m9E2EBUKMrT/bpNbboatLcgRrW
acj0BRVqoVzk1sRq7Sa6ejywqgARvIhTehg6DqdMdcENCPQ7rxDRu5PSDM8/mwIj
0KYl8d2PlECB4ofRyLcy17BZzjP6hSnkGzcFk0/bChZOSIRnwvKbvfXnB45hhPk8
XwT/6UNSwC2STP3gtOmLqrWj+OE0gy0AkDMvP3UnQVGMUvgfYg+N4ROCVtlqzxe9
W65c05Mm1g==
-----END CERTIFICATE REQUEST-----
@@ -0,0 +1,52 @@
-----BEGIN PRIVATE KEY-----
MIIJQQIBADANBgkqhkiG9w0BAQEFAASCCSswggknAgEAAoICAQDXv15OypxzVzcA
5AfMJkTJgs+1rYIICxxQWpwRn29a+NbS7M6/1MOUHfdSei+NyHgISVk4GHNNp1Wx
uadgqnHDJVTz1YK5Aq953PiTW+7tLVivJ81uZLw9ZudDh2z00HtKAk0dkgu/H0Ne
5Z4UTLNEijX3zjPgeF4HOuR/v3UuqlgporOIA1SjyHy3R2ZNf9ug7PxwSdA3C1ML
RlfdoPShsb9QCGv/bZkY+j8Trn1+Him3JhfYushQcbL4S7Gcn1jhxOprzwR7oroC
QOJP8Cg1A3EThf76Oou6J7yP9likjU6WXfwbApU7LLWaxEu2gaYhI3CQwhAMYAGs
mXGCk/hBABD7Ty/2yvNc6WR3F2vs4I/zWv5xwFeJJAR7sECR0nyX3yXl2msn74Yn
5JlxXj7+IZHR0pTYh0AbkeIpkgWfpyH1TH5Qyp4ZpgKmQetOKJ60fBxeC1UGUTSM
WYH8eymYj87Rpsr6Csya55ofte1MjxgefDSZSkvz7KnuZ8DvMW6yAWDKIE9d4P81
CCDy+NrruT753VUahebbGv7lY9AJJuBCgySQ4EwsdYlN593oXhnkz6gjRXBht/p5
BbbjrAmCkIdI9HRV2KN3owAZFYpS4t8OwD37XaIZsq/AnZ6cmVK1+3ZXYtlyMF90
gxuKBbVpJU03nDqbphWtA+vLdY+RZwIDAQABAoICAETxu6J0LuDQ+xvGwxMjG5JF
wjitlMMbQdYPzpX3HC+3G3dWA4/b3xAjL1jlAPNPH8SOI/vAHICxO7pKuMk0Tpxs
/qPZFCgpSogn7CuzEjwq5I88qfJgMKNyke7LhS8KvItfBuOvOx+9Ttsxh323MQZz
IGHrPDq8XFf1IvYL6deaygesHbEWV2Lre6daIsAbXsUjVlxPykD81nHg7c0+VU6i
rZ9WwaRjkqwftC6G8UVvQCdt/erdbYv/eZDNJ5oEdfPX6I3BHw6fZs+3ilq/RSoD
yovRozS1ptc7QY/DynnzSizVJe4/ug6p7/LgTc2pyrwGRj+MNHKv73kHo/V1cbxF
fBJCpxlfcGcEP27BkENiTKyRQEF1bjStw+UUKygrRXLm3MDtAVX8TrDERta4LAeW
XvPiJbSOwWk2yYCs62RyKl+T1no7alIvc6SUy8rvKKm+AihjaTsxTeACC1cBc41m
5HMz1dqdUWcB5jbnPsV+27dNK1/zIC+e0OXtoSXvS+IbQXo/awHJyXv5ClgldbB9
hESFTYz/uI6ftuTM6coHQfASLgmnq0fOd1gyqO6Jr9ZSvxcPNheGpyzN3I3o5i2j
LTYJdX3AoI5rQ5d7/GS2qIwWf0q8rxQnq1/34ABWD0umSa9tenCXkl7FIB4drwPB
4n7n+SL7rhmv0vFKIjepAoIBAQD19MuggpKRHicmNH2EzPOyahttuhnB7Le7j6FC
afuYUBFNcxww+L34GMRhmQZrGIYmuQ3QV4RjYh2bowEEX+F5R1V90iBtYQL1P73a
jYtTfaJn0t62EBSC//w2rtaRJPgGhbXbnyid64J0ujRFCelej8FRJdBV342ctRAL
0RazxQ/KcTRl9pncALxGhnSsBElZlDtZd/dWnWBDZ/fg/C97VV9ZQLcpyGvL516i
GpB8BQsHiIe9Jt5flZvcKB7z/KItGzPB4WK6dpV8t/FeQiUpZXkQlqO03XaZT4NP
AEGH3rKIRMpP7TORYFhbYrZwov3kzLaggax2wGPTkfMFNlTjAoIBAQDgjsYfShkz
6Dl1UTYBrDMy9pakJbC6qmd0KOKX+4XH/Dc1mOzR8NGgoY7xWXFUlozgntKKnJda
M6GfOt/dxc0Sq7moYzA7Jv4+9hNdU3jX5YrqAbcaSFj6k4yauO2BKCBahQo8qseY
a3N5f0gp+5ftTMvOTwGw3JRJFJq0/DvKWAYLIaJ0Oo77zGs0vxa1Aqob10MloXt5
DMwjazWujntTzTJY1vsfsBHa8OEObMwiftqnmn6L4Qprd3AzQkaNlZEsvERyLfFq
1pu4EsDJJGdVfpZYfo+6vTglLXFBLEUQmh4/018Mw4O4pGgCVMj/wict/gTViQGC
qSj+IOThsTytAoIBAHu3L3nEU/8EwMJ54q0a/nW+458U3gHqlRyWCZJDhxc9Jwbj
IMoNRFj39Ef3VgAmrMvrh2RFsUTgRG5V1pwhsmNzmzAXstHx2zALaO73BZ7wcfFx
Yy8G9ZpTMsU6upj1lICLX0diTmbo4IzgYIxdiPJUsvOjZqDbOvsZJEIdYSL5u5Cj
0qx7FzdPc2SyGxuvaEnTwuqk6le5/4LIWCnmD+gksDpP0BIHSxmcfsBhRk3rp3mZ
llVxqKdBtM1PrQojCFxR833RZfzOyzCZwaIc+V5SOUw7yYqfXxmMokrpoQy72ueq
Wm1LrgWxBaCqDYSop7cftbkUoPB2o3/3SNtVUesCggEAReqOKy3R/QRf53QaoZiw
9DwsmP0XMndd8J/ONU3d0G9p7SkpCxC05BOJQwH7NEAPqtwoZ3nr8ezDdKVLEGzG
tfp7ur7vRGuWm5nYW6Viqa3Re5x/GxLNiW8pRv8vC5inwidMEamGraE++eQ0XsXz
/rF7f0fAGgYDsWFV7eXe49hWQV7+iru0yxdRhcG9WyxyNGrogC3wGLdwU9LMiwXX
xjbMZzbAR5R1arq3B9u+Dzt57tc+cWTm7qDocT1AZFLeOZSApyBA22foYf6MwdOw
zMC2JOV68MR7V6/3ZDhZZJrnsi2omXvCZlnh/F/TmTYlJr/BV47pxnnOxpkNSmv5
nQKCAQBRqrsUVO7NOgR1sVX7YDaekQiJKS6Vq/7y2gR4FoLm/MMzNZQgGo9afmKg
F2hSv6tuoqc33Wm0FnoSEMaI8ky0qgA5kwXvhfQ6pDf/2zASFBwjwhTyJziDlhum
iwWe1F7lNaVNpxAXzJBaBTWvHznuM42cGv5bbPBSRuIRniGsyn/zYMrISWgL+h/Q
fsQ2rfPSqollPw+IUPN0mX+1zg6PFxaR4HM9UrRX7cnRKG20GIDPodsUl8IMg+SO
M5YG/UqDD10hfeEutvQIvl0oJraBWT34cqUZLVpUwJzf1be7zl9MzHGcym/ni7lX
dg6m3MAyZ1IXjHlogOdmGvnq07/w
-----END PRIVATE KEY-----
@@ -0,0 +1,29 @@
-----BEGIN CERTIFICATE-----
MIIFAzCCAuugAwIBAgIBATANBgkqhkiG9w0BAQsFADA2MRIwEAYDVQQDDAlsb2Nh
bGhvc3QxIDAeBgNVBAoMF0NsaWVudCBDZXJ0aWZpY2F0ZSBEZW1vMB4XDTI0MDcx
OTEyNDczN1oXDTI1MDcxOTEyNDczN1owEDEOMAwGA1UEAwwFQWxpY2UwggIiMA0G
CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCac3+4rNmH4/N1s4HqR2X168tgS/aA
6sHW5at8mWRnq54Nm11RvnK55jHQYVAdBgJy5M07w0wakp8inxzlY95wqxBimYG6
3Un/1p7mX9FkB4LNISCc6j/s/Ufv85MXPbn0S5rm9UcQO9cINJb1RP1YgDDLN5cx
Mz6X4nyofN8H6Lhvh4JDdBw4DfDEFERkVfF+bkZ7YW4XHEChgzm3RxCF0eeGzIXG
rkkK9AsSdJAhOvTlHPFCQKXTYZhsL5+3Ma4RnWnDWvLTHx6KzoU+twTM2mYhhQuQ
gQpnmDHxGge8kGeHGtfdgAjtVJTE57xF/shP0JU+tuIV8NNhQ/vEmhL0Wa093/Ev
pTVp0EUEuDh9ORRH5K5M4bKJyU4XX5noiht6yOn00uaoJcWduUAWsU+cDSvDTMw8
1opWWm0QIAV3G2yuRSkumHAKqvQLeyeyiKz+OEhyEiZ7EZNExPD0TSpApSTU6aCT
UAvPYGQ59VjsMHTuJ9r4wKIYaDvfL+t72vg2vTQma5cTOBJfIdxH9blFTjEnToH3
LX8t0XndQ2RkiRnIze2p2jUShxo/lWCjCw+2Iaw0A0fNUK1BbOrFRPq1u7AnEuMJ
t7HF50MloItM97R9vofDwgDIzlX/PzlVRcn1WCo8Fr/0EXxPPreX0YDIp1ANQ8fS
v7bKb2vQIxWuCQIDAQABo0IwQDAdBgNVHQ4EFgQUVJVRJJ2k/Z4r0M1AXe6agyD4
uCwwHwYDVR0jBBgwFoAUEHtrxWCk96Ehr60E0HBuwLk2i+IwDQYJKoZIhvcNAQEL
BQADggIBAGEvSkxhxRKmlvKG8wCXop2OaUUAOG16+T96vd+aFYaJNlfGoPvqv4Lw
qaHztVktnRrJ//fpNWOsdxkE1uPU4uyGjl2KbyH81JvkE6A3OX0P4B01n8lcimY2
j3oje6KjORUouYVsypD1VcwfWJgsE3U2Txv5srD8BoemVWgWbWjfyim4kk8C5zlf
tWEazVAaI4MWecqtU4P5gIEomCI7MG9ebxYp5oQhRxeOndOYdUbSzAkZj50gXFA1
+TNkvuhTFlJF0F7qIFVJSJTmJ+6E5B4ddbkyUYwbOdO+P8mz5N5mSljE+EiIQTxo
AwbG8cSivMy/jI3h048tCUONAJzcSWCF4k1r9Qr6xbyW2ud2GmKiFCEYJkYTsMWV
fM/RujTHlGvJ2+bQK5HiNyW0tO9znW9kaoxolu1YBvTh2492v3agK7nALyGGgdo1
/nN/ikgkQiyaCpZwFeooJv1YFU5aDhR9RjIIJ9UbJ8FdAv8Xd00E3viunLTvqqXK
RVMokw+tFQTEzjKofKWYArPDjB9LUbN+vQbumKalis3+NlJ3WolYPrCg55tqt1o3
zXi+xv7120cJFouilRFwrafNFV6F+pRMkMmiWopMnoVJPVXcoqyJRcsmO62uslhg
BLFgAH4H/14drYrgWIMz0no78RInEz0z507zwLkWk5d9W9pJ/4Rf
-----END CERTIFICATE-----
@@ -0,0 +1,26 @@
-----BEGIN CERTIFICATE REQUEST-----
MIIEVTCCAj0CAQAwEDEOMAwGA1UEAwwFQWxpY2UwggIiMA0GCSqGSIb3DQEBAQUA
A4ICDwAwggIKAoICAQCac3+4rNmH4/N1s4HqR2X168tgS/aA6sHW5at8mWRnq54N
m11RvnK55jHQYVAdBgJy5M07w0wakp8inxzlY95wqxBimYG63Un/1p7mX9FkB4LN
ISCc6j/s/Ufv85MXPbn0S5rm9UcQO9cINJb1RP1YgDDLN5cxMz6X4nyofN8H6Lhv
h4JDdBw4DfDEFERkVfF+bkZ7YW4XHEChgzm3RxCF0eeGzIXGrkkK9AsSdJAhOvTl
HPFCQKXTYZhsL5+3Ma4RnWnDWvLTHx6KzoU+twTM2mYhhQuQgQpnmDHxGge8kGeH
GtfdgAjtVJTE57xF/shP0JU+tuIV8NNhQ/vEmhL0Wa093/EvpTVp0EUEuDh9ORRH
5K5M4bKJyU4XX5noiht6yOn00uaoJcWduUAWsU+cDSvDTMw81opWWm0QIAV3G2yu
RSkumHAKqvQLeyeyiKz+OEhyEiZ7EZNExPD0TSpApSTU6aCTUAvPYGQ59VjsMHTu
J9r4wKIYaDvfL+t72vg2vTQma5cTOBJfIdxH9blFTjEnToH3LX8t0XndQ2RkiRnI
ze2p2jUShxo/lWCjCw+2Iaw0A0fNUK1BbOrFRPq1u7AnEuMJt7HF50MloItM97R9
vofDwgDIzlX/PzlVRcn1WCo8Fr/0EXxPPreX0YDIp1ANQ8fSv7bKb2vQIxWuCQID
AQABoAAwDQYJKoZIhvcNAQELBQADggIBAGgf3EC8WL3RGmuGA+d/4wd1jNfrfU6n
xjnDwdEEX0TQZGGPjh5xvoCK76yZPkO6+z0IYSepEmWBS27HJKl7nuoOvS7MjQyJ
C+3Bdk3ToCeQjmNBlRBKsUw5ftTU902oMl5BptHGj1KGjYBLAkPdXb44wXSVKJ8q
ihFhWlovsva6GDoUorksU3vOwijdlGzTANQHJGFncgrRud9ATavpGS3KVxR73R3A
aBbu3Qw+QIfu8Qx5eBJp8CbMrpAmjfuq17STvqr5bC10Fnn4NegrnHOQG9JcK02+
5Bn3+9X/n1mue7aohIdErLEiDMSqMOwFfrJeaH6YM1G4QkWyqGugtmHsWOUf0nlU
nkH1krvfw9rb6b+03c4A6GSeHnbX5ufFDSf5gaR6Wy7c0jBnoxVbtBLH2zXlrd0k
iRQG7C6XZzGMS7hb7GL7+bkRy9kWjmDL7z7Fp+EgzKhNmzuWII3E9X9va33HoQ/Q
UdK3JVToxRQg6XRKOxL9+U/+8i6U8lxObLWkWh2cypZqbz5qJxa+2u5JYO/KEoHZ
G963UX7XWezR98vZuTc1XHGZtBDMrjjDd7Kmb4/i/xBPeWwseeGtzFy9z2pnEnkL
uKE4C8wUNpzUUlsn4LneZXObIoErE7FqAAlVFujVe7iaJBmXoUXZR36drbfiaODK
vwAGyrYHaOlR
-----END CERTIFICATE REQUEST-----

Some files were not shown because too many files have changed in this diff Show More