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

Compare commits

..

1 Commits

Author SHA1 Message Date
Yury Semikhatsky ccffa01154 chore: set release version to 1.42.0 (#1512) 2024-03-11 17:00:17 -07:00
115 changed files with 2389 additions and 4574 deletions
+22 -18
View File
@@ -55,23 +55,27 @@ extends:
env:
GPG_PASSPHRASE: $(GPG_PASSPHRASE) # secret variable has to be mapped to an env variable
- task: EsrpRelease@7
- 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
inputs:
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'
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'
displayName: 'ESRP Release to Maven'
+4 -11
View File
@@ -12,21 +12,14 @@ 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
- name: Azure login
uses: azure/login@v2
- uses: azure/docker-login@v1
with:
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
login-server: playwright.azurecr.io
username: playwright
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker QEMU for arm64 docker builds
uses: docker/setup-qemu-action@v3
with:
+2 -2
View File
@@ -11,9 +11,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom
| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->125.0.6422.26<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Chromium <!-- GEN:chromium-version -->123.0.6312.4<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit <!-- GEN:webkit-version -->17.4<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->125.0.1<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Firefox <!-- GEN:firefox-version -->123.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.
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.44.0</version>
<version>1.42.0</version>
</parent>
<artifactId>driver-bundle</artifactId>
@@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit;
public class DriverJar extends Driver {
private static final String PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD";
private static final String SELENIUM_REMOTE_URL = "SELENIUM_REMOTE_URL";
static final String PLAYWRIGHT_NODEJS_PATH = "PLAYWRIGHT_NODEJS_PATH";
private final Path driverTempDir;
private Path preinstalledNodePath;
@@ -63,7 +64,7 @@ public class DriverJar extends Driver {
env.put(PLAYWRIGHT_NODEJS_PATH, preinstalledNodePath.toString());
}
extractDriverToTempDir();
logMessage("extracted driver from jar to " + driverDir());
logMessage("extracted driver from jar to " + driverPath());
if (installBrowsers)
installBrowsers(env);
}
@@ -81,7 +82,7 @@ public class DriverJar extends Driver {
logMessage("Skipping browsers download because `SELENIUM_REMOTE_URL` env variable is set");
return;
}
Path driver = driverDir();
Path driver = driverPath();
if (!Files.exists(driver)) {
throw new RuntimeException("Failed to find driver: " + driver);
}
@@ -203,7 +204,7 @@ public class DriverJar extends Driver {
}
@Override
public Path driverDir() {
protected Path driverDir() {
return driverTempDir;
}
}
@@ -32,7 +32,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import static com.microsoft.playwright.impl.driver.Driver.PLAYWRIGHT_NODEJS_PATH;
import static com.microsoft.playwright.impl.driver.jar.DriverJar.PLAYWRIGHT_NODEJS_PATH;
import static java.util.Collections.singletonMap;
import static org.junit.jupiter.api.Assertions.*;
@@ -83,7 +83,7 @@ public class TestInstall {
@Test
void playwrightCliInstalled() throws Exception {
Driver driver = Driver.createAndInstall(Collections.emptyMap(), false);
assertTrue(Files.exists(driver.driverDir()));
assertTrue(Files.exists(driver.driverPath()));
ProcessBuilder pb = driver.createProcessBuilder();
pb.command().add("install");
@@ -98,7 +98,7 @@ public class TestInstall {
void playwrightDriverInAlternativeTmpdir(@TempDir Path tmpdir) throws Exception {
System.setProperty("playwright.driver.tmpdir", tmpdir.toString());
DriverJar driver = new DriverJar();
assertTrue(driver.driverDir().startsWith(tmpdir), "Driver path: " + driver.driverDir() + " tmp: " + tmpdir);
assertTrue(driver.driverPath().startsWith(tmpdir), "Driver path: " + driver.driverPath() + " tmp: " + tmpdir);
}
@Test
@@ -135,7 +135,7 @@ public class TestInstall {
private static String extractNodeJsToTemp() throws URISyntaxException, IOException {
DriverJar auxDriver = new DriverJar();
auxDriver.extractDriverToTempDir();
String nodePath = auxDriver.driverDir().resolve(isWindows() ? "node.exe" : "node").toString();
String nodePath = auxDriver.driverPath().getParent().resolve(isWindows() ? "node.exe" : "node").toString();
return nodePath;
}
@@ -145,9 +145,9 @@ public class TestInstall {
}
private static void canSpecifyPreinstalledNodeJsShared(Driver driver, Path tmpDir) throws IOException, URISyntaxException, InterruptedException {
Path builtinNode = driver.driverDir().resolve("node");
Path builtinNode = driver.driverPath().getParent().resolve("node");
assertFalse(Files.exists(builtinNode), builtinNode.toString());
Path builtinNodeExe = driver.driverDir().resolve("node.exe");
Path builtinNodeExe = driver.driverPath().getParent().resolve("node.exe");
assertFalse(Files.exists(builtinNodeExe), builtinNodeExe.toString());
ProcessBuilder pb = driver.createProcessBuilder();
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.44.0</version>
<version>1.42.0</version>
</parent>
<artifactId>driver</artifactId>
@@ -18,6 +18,7 @@ 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;
@@ -29,8 +30,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<>(System.getenv());
public static final String PLAYWRIGHT_NODEJS_PATH = "PLAYWRIGHT_NODEJS_PATH";
protected final Map<String, String> env = new LinkedHashMap<>();
private static Driver instance;
@@ -47,7 +47,7 @@ public abstract class Driver {
}
@Override
public Path driverDir() {
protected Path driverDir() {
return driverDir;
}
}
@@ -65,14 +65,14 @@ public abstract class Driver {
}
protected abstract void initialize(Boolean installBrowsers) throws Exception;
public Path driverPath() {
String cliFileName = System.getProperty("os.name").toLowerCase().contains("windows") ?
"playwright.cmd" : "playwright.sh";
return driverDir().resolve(cliFileName);
}
public ProcessBuilder createProcessBuilder() {
String nodePath = env.get("PLAYWRIGHT_NODEJS_PATH");
if (nodePath == null) {
String node = System.getProperty("os.name").toLowerCase().contains("windows") ? "node.exe" : "node";
nodePath = driverDir().resolve(node).toAbsolutePath().toString();
}
ProcessBuilder pb = new ProcessBuilder(nodePath);
pb.command().add(driverDir().resolve("package").resolve("cli.js").toAbsolutePath().toString());
ProcessBuilder pb = new ProcessBuilder(driverPath().toString());
pb.environment().putAll(env);
pb.environment().put("PW_LANG_NAME", "java");
pb.environment().put("PW_LANG_NAME_VERSION", getMajorJavaVersion());
@@ -118,7 +118,7 @@ public abstract class Driver {
return (Driver) jarDriver.getDeclaredConstructor().newInstance();
}
public abstract Path driverDir();
protected abstract Path driverDir();
protected static void logMessage(String message) {
// This matches log format produced by the server.
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>org.example</groupId>
<artifactId>examples</artifactId>
<version>1.44.0</version>
<version>1.42.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.44.0</version>
<version>1.42.0</version>
</parent>
<artifactId>playwright</artifactId>
@@ -23,14 +23,14 @@ import java.util.*;
/**
* Exposes API that can be used for the Web API testing. This class is used for creating {@code APIRequestContext} instance
* which in turn can be used for sending web requests. An instance of this class can be obtained via {@link
* com.microsoft.playwright.Playwright#request Playwright.request()}. For more information see {@code APIRequestContext}.
* Playwright#request Playwright.request()}. For more information see {@code APIRequestContext}.
*/
public interface APIRequest {
class NewContextOptions {
/**
* Methods like {@link com.microsoft.playwright.APIRequestContext#get APIRequestContext.get()} take the base URL into
* consideration by using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a>
* constructor for building the corresponding URL. Examples:
* Methods like {@link APIRequestContext#get APIRequestContext.get()} take the base URL into consideration by using the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* corresponding URL. Examples:
* <ul>
* <li> baseURL: {@code http://localhost:3000} and sending request to {@code /bar.html} results in {@code
* http://localhost:3000/bar.html}</li>
@@ -60,17 +60,16 @@ public interface APIRequest {
public Proxy proxy;
/**
* Populates context with given storage state. This option can be used to initialize context with logged-in information
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()} or {@link
* com.microsoft.playwright.APIRequestContext#storageState APIRequestContext.storageState()}. Either a path to the file
* with saved storage, or the value returned by one of {@link com.microsoft.playwright.BrowserContext#storageState
* BrowserContext.storageState()} or {@link com.microsoft.playwright.APIRequestContext#storageState
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()} or {@link APIRequestContext#storageState
* APIRequestContext.storageState()}. Either a path to the file with saved storage, or the value returned by one of {@link
* BrowserContext#storageState BrowserContext.storageState()} or {@link APIRequestContext#storageState
* APIRequestContext.storageState()} methods.
*/
public String storageState;
/**
* Populates context with given storage state. This option can be used to initialize context with logged-in information
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}. Path to the
* file with saved storage state.
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved storage
* state.
*/
public Path storageStatePath;
/**
@@ -84,9 +83,9 @@ public interface APIRequest {
public String userAgent;
/**
* Methods like {@link com.microsoft.playwright.APIRequestContext#get APIRequestContext.get()} take the base URL into
* consideration by using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a>
* constructor for building the corresponding URL. Examples:
* Methods like {@link APIRequestContext#get APIRequestContext.get()} take the base URL into consideration by using the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* corresponding URL. Examples:
* <ul>
* <li> baseURL: {@code http://localhost:3000} and sending request to {@code /bar.html} results in {@code
* http://localhost:3000/bar.html}</li>
@@ -144,10 +143,9 @@ public interface APIRequest {
}
/**
* Populates context with given storage state. This option can be used to initialize context with logged-in information
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()} or {@link
* com.microsoft.playwright.APIRequestContext#storageState APIRequestContext.storageState()}. Either a path to the file
* with saved storage, or the value returned by one of {@link com.microsoft.playwright.BrowserContext#storageState
* BrowserContext.storageState()} or {@link com.microsoft.playwright.APIRequestContext#storageState
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()} or {@link APIRequestContext#storageState
* APIRequestContext.storageState()}. Either a path to the file with saved storage, or the value returned by one of {@link
* BrowserContext#storageState BrowserContext.storageState()} or {@link APIRequestContext#storageState
* APIRequestContext.storageState()} methods.
*/
public NewContextOptions setStorageState(String storageState) {
@@ -156,8 +154,8 @@ public interface APIRequest {
}
/**
* Populates context with given storage state. This option can be used to initialize context with logged-in information
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}. Path to the
* file with saved storage state.
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved storage
* state.
*/
public NewContextOptions setStorageStatePath(Path storageStatePath) {
this.storageStatePath = storageStatePath;
@@ -24,23 +24,21 @@ import java.nio.file.Path;
* environment or the service to your e2e test.
*
* <p> Each Playwright browser context has associated with it {@code APIRequestContext} instance which shares cookie storage
* with the browser context and can be accessed via {@link com.microsoft.playwright.BrowserContext#request
* BrowserContext.request()} or {@link com.microsoft.playwright.Page#request Page.request()}. It is also possible to create
* a new APIRequestContext instance manually by calling {@link com.microsoft.playwright.APIRequest#newContext
* APIRequest.newContext()}.
* with the browser context and can be accessed via {@link BrowserContext#request BrowserContext.request()} or {@link
* Page#request Page.request()}. It is also possible to create a new APIRequestContext instance manually by calling {@link
* APIRequest#newContext APIRequest.newContext()}.
*
* <p> <strong>Cookie management</strong>
* <p> **Cookie management**
*
* <p> {@code APIRequestContext} returned by {@link com.microsoft.playwright.BrowserContext#request BrowserContext.request()}
* and {@link com.microsoft.playwright.Page#request Page.request()} shares cookie storage with the corresponding {@code
* BrowserContext}. Each API request will have {@code Cookie} header populated with the values from the browser context. If
* the API response contains {@code Set-Cookie} header it will automatically update {@code BrowserContext} cookies and
* requests made from the page will pick them up. This means that if you log in using this API, your e2e test will be
* logged in and vice versa.
* <p> {@code APIRequestContext} returned by {@link BrowserContext#request BrowserContext.request()} and {@link Page#request
* Page.request()} shares cookie storage with the corresponding {@code BrowserContext}. Each API request will have {@code
* Cookie} header populated with the values from the browser context. If the API response contains {@code Set-Cookie}
* header it will automatically update {@code BrowserContext} cookies and requests made from the page will pick them up.
* This means that if you log in using this API, your e2e test will be logged in and vice versa.
*
* <p> If you want API requests to not interfere with the browser cookies you should create a new {@code APIRequestContext} by
* calling {@link com.microsoft.playwright.APIRequest#newContext APIRequest.newContext()}. Such {@code APIRequestContext}
* object will have its own isolated cookie storage.
* calling {@link APIRequest#newContext APIRequest.newContext()}. Such {@code APIRequestContext} object will have its own
* isolated cookie storage.
*/
public interface APIRequestContext {
class StorageStateOptions {
@@ -81,21 +79,19 @@ public interface APIRequestContext {
*/
APIResponse delete(String url, RequestOptions params);
/**
* 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.
* All responses returned by {@link APIRequestContext#get APIRequestContext.get()} and similar methods are stored in the
* memory, so that you can later call {@link 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();
/**
* 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.
* context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly
* to the request.
*
* <p> <strong>Usage</strong>
*
* <p> JSON objects can be passed directly to the request:
* <p> **Usage**
* <pre>{@code
* Map<String, Object> data = new HashMap();
* data.put("title", "Book Title");
@@ -103,9 +99,8 @@ 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 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:
* <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:
* <pre>{@code
* // Pass file path to the form data constructor:
* Path file = Paths.get("team.csv");
@@ -116,7 +111,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/uploadScript",
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
* RequestOptions.create().setMethod("post").setMultipart(
* FormData.create().set("fileField", filePayload)));
* }</pre>
@@ -129,11 +124,10 @@ 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.
* context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly
* to the request.
*
* <p> <strong>Usage</strong>
*
* <p> JSON objects can be passed directly to the request:
* <p> **Usage**
* <pre>{@code
* Map<String, Object> data = new HashMap();
* data.put("title", "Book Title");
@@ -141,9 +135,8 @@ 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 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:
* <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:
* <pre>{@code
* // Pass file path to the form data constructor:
* Path file = Paths.get("team.csv");
@@ -154,7 +147,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/uploadScript",
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
* RequestOptions.create().setMethod("post").setMultipart(
* FormData.create().set("fileField", filePayload)));
* }</pre>
@@ -166,11 +159,10 @@ 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.
* context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly
* to the request.
*
* <p> <strong>Usage</strong>
*
* <p> JSON objects can be passed directly to the request:
* <p> **Usage**
* <pre>{@code
* Map<String, Object> data = new HashMap();
* data.put("title", "Book Title");
@@ -178,9 +170,8 @@ 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 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:
* <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:
* <pre>{@code
* // Pass file path to the form data constructor:
* Path file = Paths.get("team.csv");
@@ -191,7 +182,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/uploadScript",
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
* RequestOptions.create().setMethod("post").setMultipart(
* FormData.create().set("fileField", filePayload)));
* }</pre>
@@ -204,11 +195,10 @@ 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.
* context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly
* to the request.
*
* <p> <strong>Usage</strong>
*
* <p> JSON objects can be passed directly to the request:
* <p> **Usage**
* <pre>{@code
* Map<String, Object> data = new HashMap();
* data.put("title", "Book Title");
@@ -216,9 +206,8 @@ 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 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:
* <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:
* <pre>{@code
* // Pass file path to the form data constructor:
* Path file = Paths.get("team.csv");
@@ -229,7 +218,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/uploadScript",
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
* RequestOptions.create().setMethod("post").setMultipart(
* FormData.create().set("fileField", filePayload)));
* }</pre>
@@ -244,7 +233,7 @@ public interface APIRequestContext {
* response. The method will populate request cookies from the context and update context cookies from the response. The
* method will automatically follow redirects.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Request parameters can be configured with {@code params} option, they will be serialized into the URL search parameters:
* <pre>{@code
@@ -264,7 +253,7 @@ public interface APIRequestContext {
* response. The method will populate request cookies from the context and update context cookies from the response. The
* method will automatically follow redirects.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Request parameters can be configured with {@code params} option, they will be serialized into the URL search parameters:
* <pre>{@code
@@ -325,7 +314,7 @@ public interface APIRequestContext {
* response. The method will populate request cookies from the context and update context cookies from the response. The
* method will automatically follow redirects.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> JSON objects can be passed directly to the request:
* <pre>{@code
@@ -345,8 +334,7 @@ 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. Use {@code FormData} to construct request body and pass it to the request as {@code
* multipart} parameter:
* multipart/form-data} encoding. You can achieve that with Playwright API like this:
* <pre>{@code
* // Pass file path to the form data constructor:
* Path file = Paths.get("team.csv");
@@ -355,9 +343,9 @@ public interface APIRequestContext {
* FormData.create().set("fileField", file)));
*
* // Or you can pass the file content directly as FilePayload object:
* FilePayload filePayload1 = new FilePayload("f1.js", "text/javascript",
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
* APIResponse response = request.post("https://example.com/api/uploadScript",
* APIResponse response = request.post("https://example.com/api/uploadTeamList",
* RequestOptions.create().setMultipart(
* FormData.create().set("fileField", filePayload)));
* }</pre>
@@ -373,7 +361,7 @@ public interface APIRequestContext {
* response. The method will populate request cookies from the context and update context cookies from the response. The
* method will automatically follow redirects.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> JSON objects can be passed directly to the request:
* <pre>{@code
@@ -393,8 +381,7 @@ 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. Use {@code FormData} to construct request body and pass it to the request as {@code
* multipart} parameter:
* multipart/form-data} encoding. You can achieve that with Playwright API like this:
* <pre>{@code
* // Pass file path to the form data constructor:
* Path file = Paths.get("team.csv");
@@ -403,9 +390,9 @@ public interface APIRequestContext {
* FormData.create().set("fileField", file)));
*
* // Or you can pass the file content directly as FilePayload object:
* FilePayload filePayload1 = new FilePayload("f1.js", "text/javascript",
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
* APIResponse response = request.post("https://example.com/api/uploadScript",
* APIResponse response = request.post("https://example.com/api/uploadTeamList",
* RequestOptions.create().setMultipart(
* FormData.create().set("fileField", filePayload)));
* }</pre>
@@ -20,8 +20,8 @@ import com.microsoft.playwright.options.*;
import java.util.*;
/**
* {@code APIResponse} class represents responses returned by {@link com.microsoft.playwright.APIRequestContext#get
* APIRequestContext.get()} and similar methods.
* {@code APIResponse} class represents responses returned by {@link APIRequestContext#get APIRequestContext.get()} and
* similar methods.
*/
public interface APIResponse {
/**
@@ -23,8 +23,8 @@ import java.util.function.Consumer;
import java.util.regex.Pattern;
/**
* A Browser is created via {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}. An example of using a
* {@code Browser} to create a {@code Page}:
* A Browser is created via {@link BrowserType#launch BrowserType.launch()}. An example of using a {@code Browser} to
* create a {@code Page}:
* <pre>{@code
* import com.microsoft.playwright.*;
*
@@ -47,7 +47,7 @@ public interface Browser extends AutoCloseable {
* Emitted when Browser gets disconnected from the browser application. This might happen because of one of the following:
* <ul>
* <li> Browser application is closed or crashed.</li>
* <li> The {@link com.microsoft.playwright.Browser#close Browser.close()} method was called.</li>
* <li> The {@link Browser#close Browser.close()} method was called.</li>
* </ul>
*/
void onDisconnected(Consumer<Browser> handler);
@@ -76,11 +76,10 @@ public interface Browser extends AutoCloseable {
*/
public Boolean acceptDownloads;
/**
* When using {@link com.microsoft.playwright.Page#navigate Page.navigate()}, {@link com.microsoft.playwright.Page#route
* Page.route()}, {@link com.microsoft.playwright.Page#waitForURL Page.waitForURL()}, {@link
* com.microsoft.playwright.Page#waitForRequest Page.waitForRequest()}, or {@link
* com.microsoft.playwright.Page#waitForResponse Page.waitForResponse()} it takes the base URL in consideration by using
* the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* When using {@link Page#navigate Page.navigate()}, {@link Page#route Page.route()}, {@link Page#waitForURL
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* corresponding URL. Unset by default. Examples:
* <ul>
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
@@ -98,8 +97,8 @@ public interface Browser extends AutoCloseable {
public Boolean bypassCSP;
/**
* 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
* {@code null} resets emulation to system defaults. Defaults to {@code "light"}.
* "no-preference"}. See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
* emulation to system defaults. Defaults to {@code "light"}.
*/
public Optional<ColorScheme> colorScheme;
/**
@@ -113,8 +112,8 @@ public interface Browser extends AutoCloseable {
public Map<String, String> extraHTTPHeaders;
/**
* Emulates {@code "forced-colors"} media feature, supported values are {@code "active"}, {@code "none"}. See {@link
* com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation
* to system defaults. Defaults to {@code "none"}.
* Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system defaults.
* Defaults to {@code "none"}.
*/
public Optional<ForcedColors> forcedColors;
public Geolocation geolocation;
@@ -156,9 +155,8 @@ public interface Browser extends AutoCloseable {
*/
public Boolean offline;
/**
* A list of permissions to grant to all pages in this context. See {@link
* com.microsoft.playwright.BrowserContext#grantPermissions BrowserContext.grantPermissions()} for more details. Defaults
* to none.
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
* BrowserContext.grantPermissions()} for more details. Defaults to none.
*/
public List<String> permissions;
/**
@@ -187,14 +185,14 @@ public interface Browser extends AutoCloseable {
public Boolean recordHarOmitContent;
/**
* Enables <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> recording for all pages into the specified HAR
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link
* com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for the HAR to be saved.
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link BrowserContext#close
* BrowserContext.close()} for the HAR to be saved.
*/
public Path recordHarPath;
public Object recordHarUrlFilter;
/**
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
* to call {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for videos to be saved.
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
*/
public Path recordVideoDir;
/**
@@ -205,8 +203,8 @@ public interface Browser extends AutoCloseable {
public RecordVideoSize recordVideoSize;
/**
* Emulates {@code "prefers-reduced-motion"} media feature, supported values are {@code "reduce"}, {@code "no-preference"}.
* See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
* emulation to system defaults. Defaults to {@code "no-preference"}.
* See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system
* defaults. Defaults to {@code "no-preference"}.
*/
public Optional<ReducedMotion> reducedMotion;
/**
@@ -225,13 +223,13 @@ public interface Browser extends AutoCloseable {
public ServiceWorkerPolicy serviceWorkers;
/**
* Populates context with given storage state. This option can be used to initialize context with logged-in information
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}.
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}.
*/
public String storageState;
/**
* Populates context with given storage state. This option can be used to initialize context with logged-in information
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}. Path to the
* file with saved storage state.
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved storage
* state.
*/
public Path storageStatePath;
/**
@@ -269,11 +267,10 @@ public interface Browser extends AutoCloseable {
return this;
}
/**
* When using {@link com.microsoft.playwright.Page#navigate Page.navigate()}, {@link com.microsoft.playwright.Page#route
* Page.route()}, {@link com.microsoft.playwright.Page#waitForURL Page.waitForURL()}, {@link
* com.microsoft.playwright.Page#waitForRequest Page.waitForRequest()}, or {@link
* com.microsoft.playwright.Page#waitForResponse Page.waitForResponse()} it takes the base URL in consideration by using
* the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* When using {@link Page#navigate Page.navigate()}, {@link Page#route Page.route()}, {@link Page#waitForURL
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* corresponding URL. Unset by default. Examples:
* <ul>
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
@@ -297,8 +294,8 @@ public interface Browser extends AutoCloseable {
}
/**
* 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
* {@code null} resets emulation to system defaults. Defaults to {@code "light"}.
* "no-preference"}. See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
* emulation to system defaults. Defaults to {@code "light"}.
*/
public NewContextOptions setColorScheme(ColorScheme colorScheme) {
this.colorScheme = Optional.ofNullable(colorScheme);
@@ -321,8 +318,8 @@ public interface Browser extends AutoCloseable {
}
/**
* Emulates {@code "forced-colors"} media feature, supported values are {@code "active"}, {@code "none"}. See {@link
* com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation
* to system defaults. Defaults to {@code "none"}.
* Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system defaults.
* Defaults to {@code "none"}.
*/
public NewContextOptions setForcedColors(ForcedColors forcedColors) {
this.forcedColors = Optional.ofNullable(forcedColors);
@@ -401,9 +398,8 @@ public interface Browser extends AutoCloseable {
return this;
}
/**
* A list of permissions to grant to all pages in this context. See {@link
* com.microsoft.playwright.BrowserContext#grantPermissions BrowserContext.grantPermissions()} for more details. Defaults
* to none.
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
* BrowserContext.grantPermissions()} for more details. Defaults to none.
*/
public NewContextOptions setPermissions(List<String> permissions) {
this.permissions = permissions;
@@ -457,8 +453,8 @@ public interface Browser extends AutoCloseable {
}
/**
* Enables <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> recording for all pages into the specified HAR
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link
* com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for the HAR to be saved.
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link BrowserContext#close
* BrowserContext.close()} for the HAR to be saved.
*/
public NewContextOptions setRecordHarPath(Path recordHarPath) {
this.recordHarPath = recordHarPath;
@@ -474,7 +470,7 @@ public interface Browser extends AutoCloseable {
}
/**
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
* to call {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for videos to be saved.
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
*/
public NewContextOptions setRecordVideoDir(Path recordVideoDir) {
this.recordVideoDir = recordVideoDir;
@@ -499,8 +495,8 @@ public interface Browser extends AutoCloseable {
}
/**
* Emulates {@code "prefers-reduced-motion"} media feature, supported values are {@code "reduce"}, {@code "no-preference"}.
* See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
* emulation to system defaults. Defaults to {@code "no-preference"}.
* See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system
* defaults. Defaults to {@code "no-preference"}.
*/
public NewContextOptions setReducedMotion(ReducedMotion reducedMotion) {
this.reducedMotion = Optional.ofNullable(reducedMotion);
@@ -535,7 +531,7 @@ public interface Browser extends AutoCloseable {
}
/**
* Populates context with given storage state. This option can be used to initialize context with logged-in information
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}.
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}.
*/
public NewContextOptions setStorageState(String storageState) {
this.storageState = storageState;
@@ -543,8 +539,8 @@ public interface Browser extends AutoCloseable {
}
/**
* Populates context with given storage state. This option can be used to initialize context with logged-in information
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}. Path to the
* file with saved storage state.
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved storage
* state.
*/
public NewContextOptions setStorageStatePath(Path storageStatePath) {
this.storageStatePath = storageStatePath;
@@ -606,11 +602,10 @@ public interface Browser extends AutoCloseable {
*/
public Boolean acceptDownloads;
/**
* When using {@link com.microsoft.playwright.Page#navigate Page.navigate()}, {@link com.microsoft.playwright.Page#route
* Page.route()}, {@link com.microsoft.playwright.Page#waitForURL Page.waitForURL()}, {@link
* com.microsoft.playwright.Page#waitForRequest Page.waitForRequest()}, or {@link
* com.microsoft.playwright.Page#waitForResponse Page.waitForResponse()} it takes the base URL in consideration by using
* the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* When using {@link Page#navigate Page.navigate()}, {@link Page#route Page.route()}, {@link Page#waitForURL
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* corresponding URL. Unset by default. Examples:
* <ul>
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
@@ -628,8 +623,8 @@ public interface Browser extends AutoCloseable {
public Boolean bypassCSP;
/**
* 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
* {@code null} resets emulation to system defaults. Defaults to {@code "light"}.
* "no-preference"}. See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
* emulation to system defaults. Defaults to {@code "light"}.
*/
public Optional<ColorScheme> colorScheme;
/**
@@ -643,8 +638,8 @@ public interface Browser extends AutoCloseable {
public Map<String, String> extraHTTPHeaders;
/**
* Emulates {@code "forced-colors"} media feature, supported values are {@code "active"}, {@code "none"}. See {@link
* com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation
* to system defaults. Defaults to {@code "none"}.
* Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system defaults.
* Defaults to {@code "none"}.
*/
public Optional<ForcedColors> forcedColors;
public Geolocation geolocation;
@@ -686,9 +681,8 @@ public interface Browser extends AutoCloseable {
*/
public Boolean offline;
/**
* A list of permissions to grant to all pages in this context. See {@link
* com.microsoft.playwright.BrowserContext#grantPermissions BrowserContext.grantPermissions()} for more details. Defaults
* to none.
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
* BrowserContext.grantPermissions()} for more details. Defaults to none.
*/
public List<String> permissions;
/**
@@ -717,14 +711,14 @@ public interface Browser extends AutoCloseable {
public Boolean recordHarOmitContent;
/**
* Enables <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> recording for all pages into the specified HAR
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link
* com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for the HAR to be saved.
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link BrowserContext#close
* BrowserContext.close()} for the HAR to be saved.
*/
public Path recordHarPath;
public Object recordHarUrlFilter;
/**
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
* to call {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for videos to be saved.
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
*/
public Path recordVideoDir;
/**
@@ -735,8 +729,8 @@ public interface Browser extends AutoCloseable {
public RecordVideoSize recordVideoSize;
/**
* Emulates {@code "prefers-reduced-motion"} media feature, supported values are {@code "reduce"}, {@code "no-preference"}.
* See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
* emulation to system defaults. Defaults to {@code "no-preference"}.
* See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system
* defaults. Defaults to {@code "no-preference"}.
*/
public Optional<ReducedMotion> reducedMotion;
/**
@@ -755,13 +749,13 @@ public interface Browser extends AutoCloseable {
public ServiceWorkerPolicy serviceWorkers;
/**
* Populates context with given storage state. This option can be used to initialize context with logged-in information
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}.
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}.
*/
public String storageState;
/**
* Populates context with given storage state. This option can be used to initialize context with logged-in information
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}. Path to the
* file with saved storage state.
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved storage
* state.
*/
public Path storageStatePath;
/**
@@ -799,11 +793,10 @@ public interface Browser extends AutoCloseable {
return this;
}
/**
* When using {@link com.microsoft.playwright.Page#navigate Page.navigate()}, {@link com.microsoft.playwright.Page#route
* Page.route()}, {@link com.microsoft.playwright.Page#waitForURL Page.waitForURL()}, {@link
* com.microsoft.playwright.Page#waitForRequest Page.waitForRequest()}, or {@link
* com.microsoft.playwright.Page#waitForResponse Page.waitForResponse()} it takes the base URL in consideration by using
* the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* When using {@link Page#navigate Page.navigate()}, {@link Page#route Page.route()}, {@link Page#waitForURL
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* corresponding URL. Unset by default. Examples:
* <ul>
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
@@ -827,8 +820,8 @@ public interface Browser extends AutoCloseable {
}
/**
* 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
* {@code null} resets emulation to system defaults. Defaults to {@code "light"}.
* "no-preference"}. See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
* emulation to system defaults. Defaults to {@code "light"}.
*/
public NewPageOptions setColorScheme(ColorScheme colorScheme) {
this.colorScheme = Optional.ofNullable(colorScheme);
@@ -851,8 +844,8 @@ public interface Browser extends AutoCloseable {
}
/**
* Emulates {@code "forced-colors"} media feature, supported values are {@code "active"}, {@code "none"}. See {@link
* com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation
* to system defaults. Defaults to {@code "none"}.
* Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system defaults.
* Defaults to {@code "none"}.
*/
public NewPageOptions setForcedColors(ForcedColors forcedColors) {
this.forcedColors = Optional.ofNullable(forcedColors);
@@ -931,9 +924,8 @@ public interface Browser extends AutoCloseable {
return this;
}
/**
* A list of permissions to grant to all pages in this context. See {@link
* com.microsoft.playwright.BrowserContext#grantPermissions BrowserContext.grantPermissions()} for more details. Defaults
* to none.
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
* BrowserContext.grantPermissions()} for more details. Defaults to none.
*/
public NewPageOptions setPermissions(List<String> permissions) {
this.permissions = permissions;
@@ -987,8 +979,8 @@ public interface Browser extends AutoCloseable {
}
/**
* Enables <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> recording for all pages into the specified HAR
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link
* com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for the HAR to be saved.
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link BrowserContext#close
* BrowserContext.close()} for the HAR to be saved.
*/
public NewPageOptions setRecordHarPath(Path recordHarPath) {
this.recordHarPath = recordHarPath;
@@ -1004,7 +996,7 @@ public interface Browser extends AutoCloseable {
}
/**
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
* to call {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for videos to be saved.
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
*/
public NewPageOptions setRecordVideoDir(Path recordVideoDir) {
this.recordVideoDir = recordVideoDir;
@@ -1029,8 +1021,8 @@ public interface Browser extends AutoCloseable {
}
/**
* Emulates {@code "prefers-reduced-motion"} media feature, supported values are {@code "reduce"}, {@code "no-preference"}.
* See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
* emulation to system defaults. Defaults to {@code "no-preference"}.
* See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system
* defaults. Defaults to {@code "no-preference"}.
*/
public NewPageOptions setReducedMotion(ReducedMotion reducedMotion) {
this.reducedMotion = Optional.ofNullable(reducedMotion);
@@ -1065,7 +1057,7 @@ public interface Browser extends AutoCloseable {
}
/**
* Populates context with given storage state. This option can be used to initialize context with logged-in information
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}.
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}.
*/
public NewPageOptions setStorageState(String storageState) {
this.storageState = storageState;
@@ -1073,8 +1065,8 @@ public interface Browser extends AutoCloseable {
}
/**
* Populates context with given storage state. This option can be used to initialize context with logged-in information
* obtained via {@link com.microsoft.playwright.BrowserContext#storageState BrowserContext.storageState()}. Path to the
* file with saved storage state.
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved storage
* state.
*/
public NewPageOptions setStorageStatePath(Path storageStatePath) {
this.storageStatePath = storageStatePath;
@@ -1173,16 +1165,15 @@ public interface Browser extends AutoCloseable {
*/
BrowserType browserType();
/**
* In case this browser is obtained using {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}, closes
* the browser and all of its pages (if any were opened).
* In case this browser is obtained using {@link BrowserType#launch BrowserType.launch()}, closes the browser and all of
* its pages (if any were opened).
*
* <p> In case this browser is connected to, clears all created contexts belonging to this browser and disconnects from the
* browser server.
*
* <p> <strong>NOTE:</strong> This is similar to force quitting the browser. Therefore, you should call {@link
* com.microsoft.playwright.BrowserContext#close BrowserContext.close()} on any {@code BrowserContext}'s you explicitly
* created earlier with {@link com.microsoft.playwright.Browser#newContext Browser.newContext()} **before** calling {@link
* com.microsoft.playwright.Browser#close Browser.close()}.
* <p> <strong>NOTE:</strong> This is similar to force quitting the browser. Therefore, you should call {@link BrowserContext#close
* BrowserContext.close()} on any {@code BrowserContext}'s you explicitly created earlier with {@link Browser#newContext
* Browser.newContext()} **before** calling {@link Browser#close Browser.close()}.
*
* <p> The {@code Browser} object itself is considered to be disposed and cannot be used anymore.
*
@@ -1192,16 +1183,15 @@ public interface Browser extends AutoCloseable {
close(null);
}
/**
* In case this browser is obtained using {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}, closes
* the browser and all of its pages (if any were opened).
* In case this browser is obtained using {@link BrowserType#launch BrowserType.launch()}, closes the browser and all of
* its pages (if any were opened).
*
* <p> In case this browser is connected to, clears all created contexts belonging to this browser and disconnects from the
* browser server.
*
* <p> <strong>NOTE:</strong> This is similar to force quitting the browser. Therefore, you should call {@link
* com.microsoft.playwright.BrowserContext#close BrowserContext.close()} on any {@code BrowserContext}'s you explicitly
* created earlier with {@link com.microsoft.playwright.Browser#newContext Browser.newContext()} **before** calling {@link
* com.microsoft.playwright.Browser#close Browser.close()}.
* <p> <strong>NOTE:</strong> This is similar to force quitting the browser. Therefore, you should call {@link BrowserContext#close
* BrowserContext.close()} on any {@code BrowserContext}'s you explicitly created earlier with {@link Browser#newContext
* Browser.newContext()} **before** calling {@link Browser#close Browser.close()}.
*
* <p> The {@code Browser} object itself is considered to be disposed and cannot be used anymore.
*
@@ -1211,7 +1201,7 @@ public interface Browser extends AutoCloseable {
/**
* Returns an array of all open browser contexts. In a newly created browser, this will return zero browser contexts.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* Browser browser = pw.webkit().launch();
* System.out.println(browser.contexts().size()); // prints "0"
@@ -1240,11 +1230,11 @@ public interface Browser extends AutoCloseable {
* Creates a new browser context. It won't share cookies/cache with other browser contexts.
*
* <p> <strong>NOTE:</strong> If directly using this method to create {@code BrowserContext}s, it is best practice to explicitly close the returned
* context via {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} when your code is done with the
* {@code BrowserContext}, and before calling {@link com.microsoft.playwright.Browser#close Browser.close()}. This will
* ensure the {@code context} is closed gracefully and any artifacts—like HARs and videos—are fully flushed and saved.
* context via {@link BrowserContext#close BrowserContext.close()} when your code is done with the {@code BrowserContext},
* and before calling {@link Browser#close Browser.close()}. This will ensure the {@code context} is closed gracefully and
* any artifacts—like HARs and videos—are fully flushed and saved.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* Browser browser = playwright.firefox().launch(); // Or 'chromium' or 'webkit'.
* // Create a new incognito browser context.
@@ -1267,11 +1257,11 @@ public interface Browser extends AutoCloseable {
* Creates a new browser context. It won't share cookies/cache with other browser contexts.
*
* <p> <strong>NOTE:</strong> If directly using this method to create {@code BrowserContext}s, it is best practice to explicitly close the returned
* context via {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} when your code is done with the
* {@code BrowserContext}, and before calling {@link com.microsoft.playwright.Browser#close Browser.close()}. This will
* ensure the {@code context} is closed gracefully and any artifacts—like HARs and videos—are fully flushed and saved.
* context via {@link BrowserContext#close BrowserContext.close()} when your code is done with the {@code BrowserContext},
* and before calling {@link Browser#close Browser.close()}. This will ensure the {@code context} is closed gracefully and
* any artifacts—like HARs and videos—are fully flushed and saved.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* Browser browser = playwright.firefox().launch(); // Or 'chromium' or 'webkit'.
* // Create a new incognito browser context.
@@ -1292,9 +1282,8 @@ public interface Browser extends AutoCloseable {
* Creates a new page in a new browser context. Closing this page will close the context as well.
*
* <p> This is a convenience API that should only be used for the single-page scenarios and short snippets. Production code and
* testing frameworks should explicitly create {@link com.microsoft.playwright.Browser#newContext Browser.newContext()}
* followed by the {@link com.microsoft.playwright.BrowserContext#newPage BrowserContext.newPage()} to control their exact
* life times.
* testing frameworks should explicitly create {@link Browser#newContext Browser.newContext()} followed by the {@link
* BrowserContext#newPage BrowserContext.newPage()} to control their exact life times.
*
* @since v1.8
*/
@@ -1305,9 +1294,8 @@ public interface Browser extends AutoCloseable {
* Creates a new page in a new browser context. Closing this page will close the context as well.
*
* <p> This is a convenience API that should only be used for the single-page scenarios and short snippets. Production code and
* testing frameworks should explicitly create {@link com.microsoft.playwright.Browser#newContext Browser.newContext()}
* followed by the {@link com.microsoft.playwright.BrowserContext#newPage BrowserContext.newPage()} to control their exact
* life times.
* testing frameworks should explicitly create {@link Browser#newContext Browser.newContext()} followed by the {@link
* BrowserContext#newPage BrowserContext.newPage()} to control their exact life times.
*
* @since v1.8
*/
@@ -1318,11 +1306,10 @@ public interface Browser extends AutoCloseable {
* href="https://playwright.dev/java/docs/trace-viewer">Playwright Tracing</a> could be found <a
* href="https://playwright.dev/java/docs/api/class-tracing">here</a>.
*
* <p> You can use {@link com.microsoft.playwright.Browser#startTracing Browser.startTracing()} and {@link
* com.microsoft.playwright.Browser#stopTracing Browser.stopTracing()} to create a trace file that can be opened in Chrome
* DevTools performance panel.
* <p> You can use {@link Browser#startTracing Browser.startTracing()} and {@link Browser#stopTracing Browser.stopTracing()} to
* create a trace file that can be opened in Chrome DevTools performance panel.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* browser.startTracing(page, new Browser.StartTracingOptions()
* .setPath(Paths.get("trace.json")));
@@ -1342,11 +1329,10 @@ public interface Browser extends AutoCloseable {
* href="https://playwright.dev/java/docs/trace-viewer">Playwright Tracing</a> could be found <a
* href="https://playwright.dev/java/docs/api/class-tracing">here</a>.
*
* <p> You can use {@link com.microsoft.playwright.Browser#startTracing Browser.startTracing()} and {@link
* com.microsoft.playwright.Browser#stopTracing Browser.stopTracing()} to create a trace file that can be opened in Chrome
* DevTools performance panel.
* <p> You can use {@link Browser#startTracing Browser.startTracing()} and {@link Browser#stopTracing Browser.stopTracing()} to
* create a trace file that can be opened in Chrome DevTools performance panel.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* browser.startTracing(page, new Browser.StartTracingOptions()
* .setPath(Paths.get("trace.json")));
@@ -1365,11 +1351,10 @@ public interface Browser extends AutoCloseable {
* href="https://playwright.dev/java/docs/trace-viewer">Playwright Tracing</a> could be found <a
* href="https://playwright.dev/java/docs/api/class-tracing">here</a>.
*
* <p> You can use {@link com.microsoft.playwright.Browser#startTracing Browser.startTracing()} and {@link
* com.microsoft.playwright.Browser#stopTracing Browser.stopTracing()} to create a trace file that can be opened in Chrome
* DevTools performance panel.
* <p> You can use {@link Browser#startTracing Browser.startTracing()} and {@link Browser#stopTracing Browser.stopTracing()} to
* create a trace file that can be opened in Chrome DevTools performance panel.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* browser.startTracing(page, new Browser.StartTracingOptions()
* .setPath(Paths.get("trace.json")));
@@ -30,8 +30,8 @@ import java.util.regex.Pattern;
* <p> If a page opens another page, e.g. with a {@code window.open} call, the popup will belong to the parent page's browser
* context.
*
* <p> Playwright allows creating "incognito" browser contexts with {@link com.microsoft.playwright.Browser#newContext
* Browser.newContext()} method. "Incognito" browser contexts don't write any browsing data to disk.
* <p> Playwright allows creating "incognito" browser contexts with {@link Browser#newContext Browser.newContext()} method.
* "Incognito" browser contexts don't write any browsing data to disk.
* <pre>{@code
* // Create a new incognito browser context
* BrowserContext context = browser.newContext();
@@ -44,28 +44,12 @@ import java.util.regex.Pattern;
*/
public interface BrowserContext extends AutoCloseable {
/**
* <strong>NOTE:</strong> Only works with Chromium browser's persistent context.
*
* <p> Emitted when new background page is created in the context.
* <pre>{@code
* context.onBackgroundPage(backgroundPage -> {
* System.out.println(backgroundPage.url());
* });
* }</pre>
*/
void onBackgroundPage(Consumer<Page> handler);
/**
* Removes handler that was previously added with {@link #onBackgroundPage onBackgroundPage(handler)}.
*/
void offBackgroundPage(Consumer<Page> handler);
/**
* Emitted when Browser context gets closed. This might happen because of one of the following:
* <ul>
* <li> Browser context is closed.</li>
* <li> Browser application is closed or crashed.</li>
* <li> The {@link com.microsoft.playwright.Browser#close Browser.close()} method was called.</li>
* <li> The {@link Browser#close Browser.close()} method was called.</li>
* </ul>
*/
void onClose(Consumer<BrowserContext> handler);
@@ -81,7 +65,7 @@ public interface BrowserContext extends AutoCloseable {
* <p> The arguments passed into {@code console.log} and the page are available on the {@code ConsoleMessage} event handler
* argument.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* context.onConsoleMessage(msg -> {
* for (int i = 0; i < msg.args().size(); ++i)
@@ -98,21 +82,20 @@ public interface BrowserContext extends AutoCloseable {
/**
* Emitted when a JavaScript dialog appears, such as {@code alert}, {@code prompt}, {@code confirm} or {@code
* beforeunload}. Listener **must** either {@link com.microsoft.playwright.Dialog#accept Dialog.accept()} or {@link
* com.microsoft.playwright.Dialog#dismiss Dialog.dismiss()} the dialog - otherwise the page will <a
* beforeunload}. Listener **must** either {@link Dialog#accept Dialog.accept()} or {@link Dialog#dismiss Dialog.dismiss()}
* the dialog - otherwise the page will <a
* href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking">freeze</a> waiting for the
* dialog, and actions like click will never finish.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* context.onDialog(dialog -> {
* dialog.accept();
* });
* }</pre>
*
* <p> <strong>NOTE:</strong> When no {@link com.microsoft.playwright.Page#onDialog Page.onDialog()} or {@link
* com.microsoft.playwright.BrowserContext#onDialog BrowserContext.onDialog()} listeners are present, all dialogs are
* automatically dismissed.
* <p> <strong>NOTE:</strong> When no {@link Page#onDialog Page.onDialog()} or {@link BrowserContext#onDialog BrowserContext.onDialog()} listeners are
* present, all dialogs are automatically dismissed.
*/
void onDialog(Consumer<Dialog> handler);
/**
@@ -122,15 +105,12 @@ public interface BrowserContext extends AutoCloseable {
/**
* The event is emitted when a new Page is created in the BrowserContext. The page may still be loading. The event will
* also fire for popup pages. See also {@link com.microsoft.playwright.Page#onPopup Page.onPopup()} to receive events about
* popups relevant to a specific page.
* also fire for popup pages. See also {@link Page#onPopup Page.onPopup()} to receive events about popups relevant to a
* specific page.
*
* <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. 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}.
* "http://example.com" is done and its response has started loading in the popup.
* <pre>{@code
* Page newPage = context.waitForPage(() -> {
* page.getByText("open new page").click();
@@ -138,8 +118,8 @@ public interface BrowserContext extends AutoCloseable {
* System.out.println(newPage.evaluate("location.href"));
* }</pre>
*
* <p> <strong>NOTE:</strong> Use {@link com.microsoft.playwright.Page#waitForLoadState Page.waitForLoadState()} to wait until the page gets to a
* particular state (you should not need it in most cases).
* <p> <strong>NOTE:</strong> Use {@link Page#waitForLoadState Page.waitForLoadState()} to wait until the page gets to a particular state (you should
* not need it in most cases).
*/
void onPage(Consumer<Page> handler);
/**
@@ -149,7 +129,7 @@ public interface BrowserContext extends AutoCloseable {
/**
* Emitted when exception is unhandled in any of the pages in this context. To listen for errors from a particular page,
* use {@link com.microsoft.playwright.Page#onPageError Page.onPageError()} instead.
* use {@link Page#onPageError Page.onPageError()} instead.
*/
void onWebError(Consumer<WebError> handler);
/**
@@ -159,10 +139,10 @@ public interface BrowserContext extends AutoCloseable {
/**
* Emitted when a request is issued from any pages created through this context. The [request] object is read-only. To only
* listen for requests from a particular page, use {@link com.microsoft.playwright.Page#onRequest Page.onRequest()}.
* listen for requests from a particular page, use {@link Page#onRequest Page.onRequest()}.
*
* <p> In order to intercept and mutate requests, see {@link com.microsoft.playwright.BrowserContext#route
* BrowserContext.route()} or {@link com.microsoft.playwright.Page#route Page.route()}.
* <p> In order to intercept and mutate requests, see {@link BrowserContext#route BrowserContext.route()} or {@link Page#route
* Page.route()}.
*/
void onRequest(Consumer<Request> handler);
/**
@@ -172,11 +152,11 @@ public interface BrowserContext extends AutoCloseable {
/**
* Emitted when a request fails, for example by timing out. To only listen for failed requests from a particular page, use
* {@link com.microsoft.playwright.Page#onRequestFailed Page.onRequestFailed()}.
* {@link Page#onRequestFailed Page.onRequestFailed()}.
*
* <p> <strong>NOTE:</strong> HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete
* with {@link com.microsoft.playwright.BrowserContext#onRequestFinished BrowserContext.onRequestFinished()} event and not
* with {@link com.microsoft.playwright.BrowserContext#onRequestFailed BrowserContext.onRequestFailed()}.
* with {@link BrowserContext#onRequestFinished BrowserContext.onRequestFinished()} event and not with {@link
* BrowserContext#onRequestFailed BrowserContext.onRequestFailed()}.
*/
void onRequestFailed(Consumer<Request> handler);
/**
@@ -187,7 +167,7 @@ public interface BrowserContext extends AutoCloseable {
/**
* Emitted when a request finishes successfully after downloading the response body. For a successful response, the
* sequence of events is {@code request}, {@code response} and {@code requestfinished}. To listen for successful requests
* from a particular page, use {@link com.microsoft.playwright.Page#onRequestFinished Page.onRequestFinished()}.
* from a particular page, use {@link Page#onRequestFinished Page.onRequestFinished()}.
*/
void onRequestFinished(Consumer<Request> handler);
/**
@@ -198,7 +178,7 @@ public interface BrowserContext extends AutoCloseable {
/**
* Emitted when [response] status and headers are received for a request. For a successful response, the sequence of events
* is {@code request}, {@code response} and {@code requestfinished}. To listen for response events from a particular page,
* use {@link com.microsoft.playwright.Page#onResponse Page.onResponse()}.
* use {@link Page#onResponse Page.onResponse()}.
*/
void onResponse(Consumer<Response> handler);
/**
@@ -206,63 +186,6 @@ public interface BrowserContext extends AutoCloseable {
*/
void offResponse(Consumer<Response> handler);
class ClearCookiesOptions {
/**
* Only removes cookies with the given domain.
*/
public Object domain;
/**
* Only removes cookies with the given name.
*/
public Object name;
/**
* Only removes cookies with the given path.
*/
public Object path;
/**
* Only removes cookies with the given domain.
*/
public ClearCookiesOptions setDomain(String domain) {
this.domain = domain;
return this;
}
/**
* Only removes cookies with the given domain.
*/
public ClearCookiesOptions setDomain(Pattern domain) {
this.domain = domain;
return this;
}
/**
* Only removes cookies with the given name.
*/
public ClearCookiesOptions setName(String name) {
this.name = name;
return this;
}
/**
* Only removes cookies with the given name.
*/
public ClearCookiesOptions setName(Pattern name) {
this.name = name;
return this;
}
/**
* Only removes cookies with the given path.
*/
public ClearCookiesOptions setPath(String path) {
this.path = path;
return this;
}
/**
* Only removes cookies with the given path.
*/
public ClearCookiesOptions setPath(Pattern path) {
this.path = path;
return this;
}
}
class CloseOptions {
/**
* The reason to be reported to the operations interrupted by the context closure.
@@ -333,7 +256,7 @@ public interface BrowserContext extends AutoCloseable {
public HarNotFound notFound;
/**
* If specified, updates the given HAR with the actual network information instead of serving from file. The file is
* written to disk when {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} is called.
* written to disk when {@link BrowserContext#close BrowserContext.close()} is called.
*/
public Boolean update;
/**
@@ -367,7 +290,7 @@ public interface BrowserContext extends AutoCloseable {
}
/**
* If specified, updates the given HAR with the actual network information instead of serving from file. The file is
* written to disk when {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} is called.
* written to disk when {@link BrowserContext#close BrowserContext.close()} is called.
*/
public RouteFromHAROptions setUpdate(boolean update) {
this.update = update;
@@ -426,17 +349,15 @@ public interface BrowserContext extends AutoCloseable {
class WaitForConditionOptions {
/**
* Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* default value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or
* {@link Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
* Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* default value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or
* {@link Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public WaitForConditionOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -450,8 +371,7 @@ public interface BrowserContext extends AutoCloseable {
public Predicate<ConsoleMessage> predicate;
/**
* Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()}.
* default value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
*/
public Double timeout;
@@ -464,8 +384,7 @@ public interface BrowserContext extends AutoCloseable {
}
/**
* Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()}.
* default value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
*/
public WaitForConsoleMessageOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -479,8 +398,7 @@ public interface BrowserContext extends AutoCloseable {
public Predicate<Page> predicate;
/**
* Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()}.
* default value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
*/
public Double timeout;
@@ -493,8 +411,7 @@ public interface BrowserContext extends AutoCloseable {
}
/**
* Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()}.
* default value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
*/
public WaitForPageOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -503,9 +420,9 @@ public interface BrowserContext extends AutoCloseable {
}
/**
* 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()}.
* obtained via {@link BrowserContext#cookies BrowserContext.cookies()}.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* browserContext.addCookies(Arrays.asList(cookieObject1, cookieObject2));
* }</pre>
@@ -527,7 +444,7 @@ public interface BrowserContext extends AutoCloseable {
* <p> The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend
* the JavaScript environment, e.g. to seed {@code Math.random}.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> An example of overriding {@code Math.random} before the page loads:
* <pre>{@code
@@ -535,9 +452,8 @@ public interface BrowserContext extends AutoCloseable {
* browserContext.addInitScript(Paths.get("preload.js"));
* }</pre>
*
* <p> <strong>NOTE:</strong> The order of evaluation of multiple scripts installed via {@link com.microsoft.playwright.BrowserContext#addInitScript
* BrowserContext.addInitScript()} and {@link com.microsoft.playwright.Page#addInitScript Page.addInitScript()} is not
* defined.
* <p> <strong>NOTE:</strong> The order of evaluation of multiple scripts installed via {@link BrowserContext#addInitScript
* BrowserContext.addInitScript()} and {@link Page#addInitScript Page.addInitScript()} is not defined.
*
* @param script Script to be evaluated in all pages in the browser context.
* @since v1.8
@@ -554,7 +470,7 @@ public interface BrowserContext extends AutoCloseable {
* <p> The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend
* the JavaScript environment, e.g. to seed {@code Math.random}.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> An example of overriding {@code Math.random} before the page loads:
* <pre>{@code
@@ -562,22 +478,13 @@ public interface BrowserContext extends AutoCloseable {
* browserContext.addInitScript(Paths.get("preload.js"));
* }</pre>
*
* <p> <strong>NOTE:</strong> The order of evaluation of multiple scripts installed via {@link com.microsoft.playwright.BrowserContext#addInitScript
* BrowserContext.addInitScript()} and {@link com.microsoft.playwright.Page#addInitScript Page.addInitScript()} is not
* defined.
* <p> <strong>NOTE:</strong> The order of evaluation of multiple scripts installed via {@link BrowserContext#addInitScript
* BrowserContext.addInitScript()} and {@link Page#addInitScript Page.addInitScript()} is not defined.
*
* @param script Script to be evaluated in all pages in the browser context.
* @since v1.8
*/
void addInitScript(Path script);
/**
* <strong>NOTE:</strong> Background pages are only supported on Chromium-based browsers.
*
* <p> All existing background pages in the context.
*
* @since v1.11
*/
List<Page> backgroundPages();
/**
* Returns the browser instance of the context. If it was launched as a persistent context null gets returned.
*
@@ -585,45 +492,15 @@ public interface BrowserContext extends AutoCloseable {
*/
Browser browser();
/**
* Removes cookies from context. Accepts optional filter.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* context.clearCookies();
* context.clearCookies(new BrowserContext.ClearCookiesOptions().setName("session-id"));
* context.clearCookies(new BrowserContext.ClearCookiesOptions().setDomain("my-origin.com"));
* context.clearCookies(new BrowserContext.ClearCookiesOptions().setPath("/api/v1"));
* context.clearCookies(new BrowserContext.ClearCookiesOptions()
* .setName("session-id")
* .setDomain("my-origin.com"));
* }</pre>
* Clears context cookies.
*
* @since v1.8
*/
default void clearCookies() {
clearCookies(null);
}
/**
* Removes cookies from context. Accepts optional filter.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* context.clearCookies();
* context.clearCookies(new BrowserContext.ClearCookiesOptions().setName("session-id"));
* context.clearCookies(new BrowserContext.ClearCookiesOptions().setDomain("my-origin.com"));
* context.clearCookies(new BrowserContext.ClearCookiesOptions().setPath("/api/v1"));
* context.clearCookies(new BrowserContext.ClearCookiesOptions()
* .setName("session-id")
* .setDomain("my-origin.com"));
* }</pre>
*
* @since v1.8
*/
void clearCookies(ClearCookiesOptions options);
void clearCookies();
/**
* Clears all permission overrides for the browser context.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* BrowserContext context = browser.newContext();
* context.grantPermissions(Arrays.asList("clipboard-read"));
@@ -688,9 +565,9 @@ public interface BrowserContext extends AutoCloseable {
* <p> The first argument of the {@code callback} function contains information about the caller: {@code { browserContext:
* BrowserContext, page: Page, frame: Frame }}.
*
* <p> See {@link com.microsoft.playwright.Page#exposeBinding Page.exposeBinding()} for page-only version.
* <p> See {@link Page#exposeBinding Page.exposeBinding()} for page-only version.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> An example of exposing page URL to all frames in all pages in the context:
* <pre>{@code
@@ -750,9 +627,9 @@ public interface BrowserContext extends AutoCloseable {
* <p> The first argument of the {@code callback} function contains information about the caller: {@code { browserContext:
* BrowserContext, page: Page, frame: Frame }}.
*
* <p> See {@link com.microsoft.playwright.Page#exposeBinding Page.exposeBinding()} for page-only version.
* <p> See {@link Page#exposeBinding Page.exposeBinding()} for page-only version.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> An example of exposing page URL to all frames in all pages in the context:
* <pre>{@code
@@ -809,9 +686,9 @@ public interface BrowserContext extends AutoCloseable {
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, it will be
* awaited.
*
* <p> See {@link com.microsoft.playwright.Page#exposeFunction Page.exposeFunction()} for page-only version.
* <p> See {@link Page#exposeFunction Page.exposeFunction()} for page-only version.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> An example of adding a {@code sha256} function to all pages in the context:
* <pre>{@code
@@ -951,11 +828,11 @@ public interface BrowserContext extends AutoCloseable {
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
* is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
*
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
* Service Worker. See <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 BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <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>Usage</strong>
* <p> **Usage**
*
* <p> An example of a naive handler that aborts all image requests:
* <pre>{@code
@@ -986,11 +863,10 @@ public interface BrowserContext extends AutoCloseable {
* });
* }</pre>
*
* <p> Page routes (set up with {@link com.microsoft.playwright.Page#route Page.route()}) take precedence over browser context
* routes when request matches both handlers.
* <p> Page routes (set up with {@link Page#route Page.route()}) take precedence over browser context routes when request
* matches both handlers.
*
* <p> To remove a route with its handler you can use {@link com.microsoft.playwright.BrowserContext#unroute
* BrowserContext.unroute()}.
* <p> To remove a route with its handler you can use {@link BrowserContext#unroute BrowserContext.unroute()}.
*
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
*
@@ -1007,11 +883,11 @@ public interface BrowserContext extends AutoCloseable {
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
* is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
*
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
* Service Worker. See <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 BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <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>Usage</strong>
* <p> **Usage**
*
* <p> An example of a naive handler that aborts all image requests:
* <pre>{@code
@@ -1042,11 +918,10 @@ public interface BrowserContext extends AutoCloseable {
* });
* }</pre>
*
* <p> Page routes (set up with {@link com.microsoft.playwright.Page#route Page.route()}) take precedence over browser context
* routes when request matches both handlers.
* <p> Page routes (set up with {@link Page#route Page.route()}) take precedence over browser context routes when request
* matches both handlers.
*
* <p> To remove a route with its handler you can use {@link com.microsoft.playwright.BrowserContext#unroute
* BrowserContext.unroute()}.
* <p> To remove a route with its handler you can use {@link BrowserContext#unroute BrowserContext.unroute()}.
*
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
*
@@ -1061,11 +936,11 @@ public interface BrowserContext extends AutoCloseable {
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
* is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
*
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
* Service Worker. See <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 BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <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>Usage</strong>
* <p> **Usage**
*
* <p> An example of a naive handler that aborts all image requests:
* <pre>{@code
@@ -1096,11 +971,10 @@ public interface BrowserContext extends AutoCloseable {
* });
* }</pre>
*
* <p> Page routes (set up with {@link com.microsoft.playwright.Page#route Page.route()}) take precedence over browser context
* routes when request matches both handlers.
* <p> Page routes (set up with {@link Page#route Page.route()}) take precedence over browser context routes when request
* matches both handlers.
*
* <p> To remove a route with its handler you can use {@link com.microsoft.playwright.BrowserContext#unroute
* BrowserContext.unroute()}.
* <p> To remove a route with its handler you can use {@link BrowserContext#unroute BrowserContext.unroute()}.
*
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
*
@@ -1117,11 +991,11 @@ public interface BrowserContext extends AutoCloseable {
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
* is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
*
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
* Service Worker. See <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 BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <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>Usage</strong>
* <p> **Usage**
*
* <p> An example of a naive handler that aborts all image requests:
* <pre>{@code
@@ -1152,11 +1026,10 @@ public interface BrowserContext extends AutoCloseable {
* });
* }</pre>
*
* <p> Page routes (set up with {@link com.microsoft.playwright.Page#route Page.route()}) take precedence over browser context
* routes when request matches both handlers.
* <p> Page routes (set up with {@link Page#route Page.route()}) take precedence over browser context routes when request
* matches both handlers.
*
* <p> To remove a route with its handler you can use {@link com.microsoft.playwright.BrowserContext#unroute
* BrowserContext.unroute()}.
* <p> To remove a route with its handler you can use {@link BrowserContext#unroute BrowserContext.unroute()}.
*
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
*
@@ -1171,11 +1044,11 @@ public interface BrowserContext extends AutoCloseable {
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
* is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
*
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
* Service Worker. See <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 BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <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>Usage</strong>
* <p> **Usage**
*
* <p> An example of a naive handler that aborts all image requests:
* <pre>{@code
@@ -1206,11 +1079,10 @@ public interface BrowserContext extends AutoCloseable {
* });
* }</pre>
*
* <p> Page routes (set up with {@link com.microsoft.playwright.Page#route Page.route()}) take precedence over browser context
* routes when request matches both handlers.
* <p> Page routes (set up with {@link Page#route Page.route()}) take precedence over browser context routes when request
* matches both handlers.
*
* <p> To remove a route with its handler you can use {@link com.microsoft.playwright.BrowserContext#unroute
* BrowserContext.unroute()}.
* <p> To remove a route with its handler you can use {@link BrowserContext#unroute BrowserContext.unroute()}.
*
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
*
@@ -1227,11 +1099,11 @@ public interface BrowserContext extends AutoCloseable {
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
* is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
*
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by
* Service Worker. See <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 BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <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>Usage</strong>
* <p> **Usage**
*
* <p> An example of a naive handler that aborts all image requests:
* <pre>{@code
@@ -1262,11 +1134,10 @@ public interface BrowserContext extends AutoCloseable {
* });
* }</pre>
*
* <p> Page routes (set up with {@link com.microsoft.playwright.Page#route Page.route()}) take precedence over browser context
* routes when request matches both handlers.
* <p> Page routes (set up with {@link Page#route Page.route()}) take precedence over browser context routes when request
* matches both handlers.
*
* <p> To remove a route with its handler you can use {@link com.microsoft.playwright.BrowserContext#unroute
* BrowserContext.unroute()}.
* <p> To remove a route with its handler you can use {@link BrowserContext#unroute BrowserContext.unroute()}.
*
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
*
@@ -1308,17 +1179,17 @@ public interface BrowserContext extends AutoCloseable {
/**
* This setting will change the default maximum navigation time for the following methods and related shortcuts:
* <ul>
* <li> {@link com.microsoft.playwright.Page#goBack Page.goBack()}</li>
* <li> {@link com.microsoft.playwright.Page#goForward Page.goForward()}</li>
* <li> {@link com.microsoft.playwright.Page#navigate Page.navigate()}</li>
* <li> {@link com.microsoft.playwright.Page#reload Page.reload()}</li>
* <li> {@link com.microsoft.playwright.Page#setContent Page.setContent()}</li>
* <li> {@link com.microsoft.playwright.Page#waitForNavigation Page.waitForNavigation()}</li>
* <li> {@link Page#goBack Page.goBack()}</li>
* <li> {@link Page#goForward Page.goForward()}</li>
* <li> {@link Page#navigate Page.navigate()}</li>
* <li> {@link Page#reload Page.reload()}</li>
* <li> {@link Page#setContent Page.setContent()}</li>
* <li> {@link Page#waitForNavigation Page.waitForNavigation()}</li>
* </ul>
*
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#setDefaultNavigationTimeout Page.setDefaultNavigationTimeout()} and {@link
* com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()} take priority over {@link
* com.microsoft.playwright.BrowserContext#setDefaultNavigationTimeout BrowserContext.setDefaultNavigationTimeout()}.
* <p> <strong>NOTE:</strong> {@link Page#setDefaultNavigationTimeout Page.setDefaultNavigationTimeout()} and {@link Page#setDefaultTimeout
* Page.setDefaultTimeout()} take priority over {@link BrowserContext#setDefaultNavigationTimeout
* BrowserContext.setDefaultNavigationTimeout()}.
*
* @param timeout Maximum navigation time in milliseconds
* @since v1.8
@@ -1327,10 +1198,10 @@ public interface BrowserContext extends AutoCloseable {
/**
* This setting will change the default maximum time for all the methods accepting {@code timeout} option.
*
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.Page#setDefaultNavigationTimeout Page.setDefaultNavigationTimeout()}, {@link
* com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()} and {@link
* com.microsoft.playwright.BrowserContext#setDefaultNavigationTimeout BrowserContext.setDefaultNavigationTimeout()} take
* priority over {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
* <p> <strong>NOTE:</strong> {@link Page#setDefaultNavigationTimeout Page.setDefaultNavigationTimeout()}, {@link Page#setDefaultTimeout
* Page.setDefaultTimeout()} and {@link BrowserContext#setDefaultNavigationTimeout
* BrowserContext.setDefaultNavigationTimeout()} take priority over {@link BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()}.
*
* @param timeout Maximum time in milliseconds
* @since v1.8
@@ -1338,12 +1209,11 @@ public interface BrowserContext extends AutoCloseable {
void setDefaultTimeout(double timeout);
/**
* The extra HTTP headers will be sent with every request initiated by any page in the context. These headers are merged
* with page-specific extra HTTP headers set with {@link com.microsoft.playwright.Page#setExtraHTTPHeaders
* Page.setExtraHTTPHeaders()}. If page overrides a particular header, page-specific header value will be used instead of
* the browser context header value.
* with page-specific extra HTTP headers set with {@link Page#setExtraHTTPHeaders Page.setExtraHTTPHeaders()}. If page
* overrides a particular header, page-specific header value will be used instead of the browser context header value.
*
* <p> <strong>NOTE:</strong> {@link com.microsoft.playwright.BrowserContext#setExtraHTTPHeaders BrowserContext.setExtraHTTPHeaders()} does not
* guarantee the order of headers in the outgoing requests.
* <p> <strong>NOTE:</strong> {@link BrowserContext#setExtraHTTPHeaders BrowserContext.setExtraHTTPHeaders()} does not guarantee the order of headers
* in the outgoing requests.
*
* @param headers An object containing additional HTTP headers to be sent with every request. All header values must be strings.
* @since v1.8
@@ -1352,13 +1222,13 @@ public interface BrowserContext extends AutoCloseable {
/**
* Sets the context's geolocation. Passing {@code null} or {@code undefined} emulates position unavailable.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* browserContext.setGeolocation(new Geolocation(59.95, 30.31667));
* }</pre>
*
* <p> <strong>NOTE:</strong> Consider using {@link com.microsoft.playwright.BrowserContext#grantPermissions BrowserContext.grantPermissions()} to
* grant permissions for the browser context pages to read its geolocation.
* <p> <strong>NOTE:</strong> Consider using {@link BrowserContext#grantPermissions BrowserContext.grantPermissions()} to grant permissions for the
* browser context pages to read its geolocation.
*
* @since v1.8
*/
@@ -1391,75 +1261,72 @@ public interface BrowserContext extends AutoCloseable {
*/
Tracing tracing();
/**
* Removes all routes created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} and {@link
* com.microsoft.playwright.BrowserContext#routeFromHAR BrowserContext.routeFromHAR()}.
* Removes all routes created with {@link BrowserContext#route BrowserContext.route()} and {@link
* BrowserContext#routeFromHAR BrowserContext.routeFromHAR()}.
*
* @since v1.41
*/
void unrouteAll();
/**
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
* handler} is not specified, removes all routes for the {@code url}.
* Removes a route created with {@link BrowserContext#route BrowserContext.route()}. When {@code handler} is not specified,
* removes all routes for the {@code url}.
*
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link BrowserContext#route
* BrowserContext.route()}.
* @since v1.8
*/
default void unroute(String url) {
unroute(url, null);
}
/**
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
* handler} is not specified, removes all routes for the {@code url}.
* Removes a route created with {@link BrowserContext#route BrowserContext.route()}. When {@code handler} is not specified,
* removes all routes for the {@code url}.
*
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
* @param handler Optional handler function used to register a routing with {@link com.microsoft.playwright.BrowserContext#route
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link BrowserContext#route
* BrowserContext.route()}.
* @param handler Optional handler function used to register a routing with {@link BrowserContext#route BrowserContext.route()}.
* @since v1.8
*/
void unroute(String url, Consumer<Route> handler);
/**
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
* handler} is not specified, removes all routes for the {@code url}.
* Removes a route created with {@link BrowserContext#route BrowserContext.route()}. When {@code handler} is not specified,
* removes all routes for the {@code url}.
*
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link BrowserContext#route
* BrowserContext.route()}.
* @since v1.8
*/
default void unroute(Pattern url) {
unroute(url, null);
}
/**
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
* handler} is not specified, removes all routes for the {@code url}.
* Removes a route created with {@link BrowserContext#route BrowserContext.route()}. When {@code handler} is not specified,
* removes all routes for the {@code url}.
*
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
* @param handler Optional handler function used to register a routing with {@link com.microsoft.playwright.BrowserContext#route
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link BrowserContext#route
* BrowserContext.route()}.
* @param handler Optional handler function used to register a routing with {@link BrowserContext#route BrowserContext.route()}.
* @since v1.8
*/
void unroute(Pattern url, Consumer<Route> handler);
/**
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
* handler} is not specified, removes all routes for the {@code url}.
* Removes a route created with {@link BrowserContext#route BrowserContext.route()}. When {@code handler} is not specified,
* removes all routes for the {@code url}.
*
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link BrowserContext#route
* BrowserContext.route()}.
* @since v1.8
*/
default void unroute(Predicate<String> url) {
unroute(url, null);
}
/**
* Removes a route created with {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()}. When {@code
* handler} is not specified, removes all routes for the {@code url}.
* Removes a route created with {@link BrowserContext#route BrowserContext.route()}. When {@code handler} is not specified,
* removes all routes for the {@code url}.
*
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}.
* @param handler Optional handler function used to register a routing with {@link com.microsoft.playwright.BrowserContext#route
* @param url A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with {@link BrowserContext#route
* BrowserContext.route()}.
* @param handler Optional handler function used to register a routing with {@link BrowserContext#route BrowserContext.route()}.
* @since v1.8
*/
void unroute(Predicate<String> url, Consumer<Route> handler);
@@ -1467,7 +1334,7 @@ public interface BrowserContext extends AutoCloseable {
* The method will block until the condition returns true. All Playwright events will be dispatched while the method is
* waiting for the condition.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Use the method to wait for a condition that depends on page events:
* <pre>{@code
@@ -1492,7 +1359,7 @@ public interface BrowserContext extends AutoCloseable {
* The method will block until the condition returns true. All Playwright events will be dispatched while the method is
* waiting for the condition.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Use the method to wait for a condition that depends on page events:
* <pre>{@code
@@ -1515,7 +1382,7 @@ public interface BrowserContext extends AutoCloseable {
* Performs action and waits for a {@code ConsoleMessage} to be logged by in the pages in the context. If predicate is
* provided, it passes {@code ConsoleMessage} value into the {@code predicate} function and waits for {@code
* predicate(message)} to return a truthy value. Will throw an error if the page is closed before the {@link
* com.microsoft.playwright.BrowserContext#onConsoleMessage BrowserContext.onConsoleMessage()} event is fired.
* BrowserContext#onConsoleMessage BrowserContext.onConsoleMessage()} event is fired.
*
* @param callback Callback that performs the action triggering the event.
* @since v1.34
@@ -1527,7 +1394,7 @@ public interface BrowserContext extends AutoCloseable {
* Performs action and waits for a {@code ConsoleMessage} to be logged by in the pages in the context. If predicate is
* provided, it passes {@code ConsoleMessage} value into the {@code predicate} function and waits for {@code
* predicate(message)} to return a truthy value. Will throw an error if the page is closed before the {@link
* com.microsoft.playwright.BrowserContext#onConsoleMessage BrowserContext.onConsoleMessage()} event is fired.
* BrowserContext#onConsoleMessage BrowserContext.onConsoleMessage()} event is fired.
*
* @param callback Callback that performs the action triggering the event.
* @since v1.34
@@ -182,7 +182,8 @@ public interface BrowserType {
*/
public Boolean chromiumSandbox;
/**
* @deprecated Use <a href="https://playwright.dev/java/docs/debug">debugging tools</a> instead.
* **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is {@code true}, the {@code
* headless} option will be set {@code false}.
*/
public Boolean devtools;
/**
@@ -290,7 +291,8 @@ public interface BrowserType {
return this;
}
/**
* @deprecated Use <a href="https://playwright.dev/java/docs/debug">debugging tools</a> instead.
* **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is {@code true}, the {@code
* headless} option will be set {@code false}.
*/
public LaunchOptions setDevtools(boolean devtools) {
this.devtools = devtools;
@@ -425,11 +427,10 @@ public interface BrowserType {
*/
public List<String> args;
/**
* When using {@link com.microsoft.playwright.Page#navigate Page.navigate()}, {@link com.microsoft.playwright.Page#route
* Page.route()}, {@link com.microsoft.playwright.Page#waitForURL Page.waitForURL()}, {@link
* com.microsoft.playwright.Page#waitForRequest Page.waitForRequest()}, or {@link
* com.microsoft.playwright.Page#waitForResponse Page.waitForResponse()} it takes the base URL in consideration by using
* the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* When using {@link Page#navigate Page.navigate()}, {@link Page#route Page.route()}, {@link Page#waitForURL
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* corresponding URL. Unset by default. Examples:
* <ul>
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
@@ -457,8 +458,8 @@ public interface BrowserType {
public Boolean chromiumSandbox;
/**
* 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
* {@code null} resets emulation to system defaults. Defaults to {@code "light"}.
* "no-preference"}. See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
* emulation to system defaults. Defaults to {@code "light"}.
*/
public Optional<ColorScheme> colorScheme;
/**
@@ -467,7 +468,8 @@ public interface BrowserType {
*/
public Double deviceScaleFactor;
/**
* @deprecated Use <a href="https://playwright.dev/java/docs/debug">debugging tools</a> instead.
* **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is {@code true}, the {@code
* headless} option will be set {@code false}.
*/
public Boolean devtools;
/**
@@ -497,8 +499,8 @@ public interface BrowserType {
public Map<String, Object> firefoxUserPrefs;
/**
* Emulates {@code "forced-colors"} media feature, supported values are {@code "active"}, {@code "none"}. See {@link
* com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation
* to system defaults. Defaults to {@code "none"}.
* Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system defaults.
* Defaults to {@code "none"}.
*/
public Optional<ForcedColors> forcedColors;
public Geolocation geolocation;
@@ -569,9 +571,8 @@ public interface BrowserType {
*/
public Boolean offline;
/**
* A list of permissions to grant to all pages in this context. See {@link
* com.microsoft.playwright.BrowserContext#grantPermissions BrowserContext.grantPermissions()} for more details. Defaults
* to none.
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
* BrowserContext.grantPermissions()} for more details. Defaults to none.
*/
public List<String> permissions;
/**
@@ -596,14 +597,14 @@ public interface BrowserType {
public Boolean recordHarOmitContent;
/**
* Enables <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> recording for all pages into the specified HAR
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link
* com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for the HAR to be saved.
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link BrowserContext#close
* BrowserContext.close()} for the HAR to be saved.
*/
public Path recordHarPath;
public Object recordHarUrlFilter;
/**
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
* to call {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for videos to be saved.
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
*/
public Path recordVideoDir;
/**
@@ -614,8 +615,8 @@ public interface BrowserType {
public RecordVideoSize recordVideoSize;
/**
* Emulates {@code "prefers-reduced-motion"} media feature, supported values are {@code "reduce"}, {@code "no-preference"}.
* See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
* emulation to system defaults. Defaults to {@code "no-preference"}.
* See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system
* defaults. Defaults to {@code "no-preference"}.
*/
public Optional<ReducedMotion> reducedMotion;
/**
@@ -690,11 +691,10 @@ public interface BrowserType {
return this;
}
/**
* When using {@link com.microsoft.playwright.Page#navigate Page.navigate()}, {@link com.microsoft.playwright.Page#route
* Page.route()}, {@link com.microsoft.playwright.Page#waitForURL Page.waitForURL()}, {@link
* com.microsoft.playwright.Page#waitForRequest Page.waitForRequest()}, or {@link
* com.microsoft.playwright.Page#waitForResponse Page.waitForResponse()} it takes the base URL in consideration by using
* the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* When using {@link Page#navigate Page.navigate()}, {@link Page#route Page.route()}, {@link Page#waitForURL
* Page.waitForURL()}, {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse
* Page.waitForResponse()} it takes the base URL in consideration by using the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a> constructor for building the
* corresponding URL. Unset by default. Examples:
* <ul>
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code
@@ -744,8 +744,8 @@ public interface BrowserType {
}
/**
* 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
* {@code null} resets emulation to system defaults. Defaults to {@code "light"}.
* "no-preference"}. See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
* emulation to system defaults. Defaults to {@code "light"}.
*/
public LaunchPersistentContextOptions setColorScheme(ColorScheme colorScheme) {
this.colorScheme = Optional.ofNullable(colorScheme);
@@ -760,7 +760,8 @@ public interface BrowserType {
return this;
}
/**
* @deprecated Use <a href="https://playwright.dev/java/docs/debug">debugging tools</a> instead.
* **Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option is {@code true}, the {@code
* headless} option will be set {@code false}.
*/
public LaunchPersistentContextOptions setDevtools(boolean devtools) {
this.devtools = devtools;
@@ -808,8 +809,8 @@ public interface BrowserType {
}
/**
* Emulates {@code "forced-colors"} media feature, supported values are {@code "active"}, {@code "none"}. See {@link
* com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation
* to system defaults. Defaults to {@code "none"}.
* Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system defaults.
* Defaults to {@code "none"}.
*/
public LaunchPersistentContextOptions setForcedColors(ForcedColors forcedColors) {
this.forcedColors = Optional.ofNullable(forcedColors);
@@ -935,9 +936,8 @@ public interface BrowserType {
return this;
}
/**
* A list of permissions to grant to all pages in this context. See {@link
* com.microsoft.playwright.BrowserContext#grantPermissions BrowserContext.grantPermissions()} for more details. Defaults
* to none.
* A list of permissions to grant to all pages in this context. See {@link BrowserContext#grantPermissions
* BrowserContext.grantPermissions()} for more details. Defaults to none.
*/
public LaunchPersistentContextOptions setPermissions(List<String> permissions) {
this.permissions = permissions;
@@ -983,8 +983,8 @@ public interface BrowserType {
}
/**
* Enables <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> recording for all pages into the specified HAR
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link
* com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for the HAR to be saved.
* file on the filesystem. If not specified, the HAR is not recorded. Make sure to call {@link BrowserContext#close
* BrowserContext.close()} for the HAR to be saved.
*/
public LaunchPersistentContextOptions setRecordHarPath(Path recordHarPath) {
this.recordHarPath = recordHarPath;
@@ -1000,7 +1000,7 @@ public interface BrowserType {
}
/**
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
* to call {@link com.microsoft.playwright.BrowserContext#close BrowserContext.close()} for videos to be saved.
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
*/
public LaunchPersistentContextOptions setRecordVideoDir(Path recordVideoDir) {
this.recordVideoDir = recordVideoDir;
@@ -1025,8 +1025,8 @@ public interface BrowserType {
}
/**
* Emulates {@code "prefers-reduced-motion"} media feature, supported values are {@code "reduce"}, {@code "no-preference"}.
* See {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
* emulation to system defaults. Defaults to {@code "no-preference"}.
* See {@link Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets emulation to system
* defaults. Defaults to {@code "no-preference"}.
*/
public LaunchPersistentContextOptions setReducedMotion(ReducedMotion reducedMotion) {
this.reducedMotion = Optional.ofNullable(reducedMotion);
@@ -1154,11 +1154,11 @@ public interface BrowserType {
/**
* This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
*
* <p> The default browser context is accessible via {@link com.microsoft.playwright.Browser#contexts Browser.contexts()}.
* <p> The default browser context is accessible via {@link Browser#contexts Browser.contexts()}.
*
* <p> <strong>NOTE:</strong> Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* Browser browser = playwright.chromium().connectOverCDP("http://localhost:9222");
* BrowserContext defaultContext = browser.contexts().get(0);
@@ -1175,11 +1175,11 @@ public interface BrowserType {
/**
* This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
*
* <p> The default browser context is accessible via {@link com.microsoft.playwright.Browser#contexts Browser.contexts()}.
* <p> The default browser context is accessible via {@link Browser#contexts Browser.contexts()}.
*
* <p> <strong>NOTE:</strong> Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* Browser browser = playwright.chromium().connectOverCDP("http://localhost:9222");
* BrowserContext defaultContext = browser.contexts().get(0);
@@ -1200,7 +1200,7 @@ public interface BrowserType {
/**
* Returns the browser instance.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> You can use {@code ignoreDefaultArgs} to filter out {@code --mute-audio} from default arguments:
* <pre>{@code
@@ -1236,7 +1236,7 @@ public interface BrowserType {
/**
* Returns the browser instance.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> You can use {@code ignoreDefaultArgs} to filter out {@code --mute-audio} from default arguments:
* <pre>{@code
@@ -31,7 +31,6 @@ import com.google.gson.JsonObject;
* <li> Documentation on DevTools Protocol can be found here: <a
* href="https://chromedevtools.github.io/devtools-protocol/">DevTools Protocol Viewer</a>.</li>
* <li> Getting Started with DevTools Protocol: https://github.com/aslushnikov/getting-started-with-cdp/blob/master/README.md</li>
* </ul>
* <pre>{@code
* CDPSession client = page.context().newCDPSession(page);
* client.send("Runtime.enable");
@@ -46,6 +45,7 @@ import com.google.gson.JsonObject;
* params.addProperty("playbackRate", playbackRate / 2);
* client.send("Animation.setPlaybackRate", params);
* }</pre>
* </ul>
*/
public interface CDPSession {
/**
@@ -19,9 +19,8 @@ package com.microsoft.playwright;
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
* Playwright context.
* {@code ConsoleMessage} objects are dispatched by page via the {@link Page#onConsoleMessage Page.onConsoleMessage()}
* event. For each console messages logged in the page there will be corresponding event in the Playwright context.
* <pre>{@code
* // Listen for all console messages and print them to the standard output.
* page.onConsoleMessage(msg -> System.out.println(msg.text()));
@@ -45,8 +44,8 @@ import java.util.*;
*/
public interface ConsoleMessage {
/**
* List of arguments passed to a {@code console} function call. See also {@link
* com.microsoft.playwright.Page#onConsoleMessage Page.onConsoleMessage()}.
* List of arguments passed to a {@code console} function call. See also {@link Page#onConsoleMessage
* Page.onConsoleMessage()}.
*
* @since v1.8
*/
@@ -18,8 +18,7 @@ package com.microsoft.playwright;
/**
* {@code Dialog} objects are dispatched by page via the {@link com.microsoft.playwright.Page#onDialog Page.onDialog()}
* event.
* {@code Dialog} objects are dispatched by page via the {@link Page#onDialog Page.onDialog()} event.
*
* <p> An example of using {@code Dialog} class:
* <pre>{@code
@@ -42,9 +41,9 @@ package com.microsoft.playwright;
* }
* }</pre>
*
* <p> <strong>NOTE:</strong> Dialogs are dismissed automatically, unless there is a {@link com.microsoft.playwright.Page#onDialog Page.onDialog()}
* listener. When listener is present, it **must** either {@link com.microsoft.playwright.Dialog#accept Dialog.accept()} or
* {@link com.microsoft.playwright.Dialog#dismiss Dialog.dismiss()} the dialog - otherwise the page will <a
* <p> <strong>NOTE:</strong> Dialogs are dismissed automatically, unless there is a {@link Page#onDialog Page.onDialog()} listener. When listener is
* present, it **must** either {@link Dialog#accept Dialog.accept()} or {@link Dialog#dismiss Dialog.dismiss()} the dialog
* - otherwise the page will <a
* href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking">freeze</a> waiting for the
* dialog, and actions like click will never finish.
*/
@@ -20,8 +20,7 @@ import java.io.InputStream;
import java.nio.file.Path;
/**
* {@code Download} objects are dispatched by page via the {@link com.microsoft.playwright.Page#onDownload
* Page.onDownload()} event.
* {@code Download} objects are dispatched by page via the {@link Page#onDownload Page.onDownload()} event.
*
* <p> All the downloaded files belonging to the browser context are deleted when the browser context is closed.
*
@@ -73,8 +72,8 @@ public interface Download {
* Returns path to the downloaded file for a successful download, or throws for a failed/canceled download. The method will
* wait for the download to finish if necessary. The method throws when connected remotely.
*
* <p> Note that the download's file name is a random GUID, use {@link com.microsoft.playwright.Download#suggestedFilename
* Download.suggestedFilename()} to get suggested file name.
* <p> Note that the download's file name is a random GUID, use {@link Download#suggestedFilename Download.suggestedFilename()}
* to get suggested file name.
*
* @since v1.8
*/
@@ -83,7 +82,7 @@ public interface Download {
* Copy the download to a user-specified path. It is safe to call this method while the download is still in progress. Will
* wait for the download to finish if necessary.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* download.saveAs(Paths.get("/path/to/save/at/", download.suggestedFilename()));
* }</pre>
@@ -21,8 +21,8 @@ import java.nio.file.Path;
import java.util.*;
/**
* ElementHandle represents an in-page DOM element. ElementHandles can be created with the {@link
* com.microsoft.playwright.Page#querySelector Page.querySelector()} method.
* ElementHandle represents an in-page DOM element. ElementHandles can be created with the {@link Page#querySelector
* Page.querySelector()} method.
*
* <p> <strong>NOTE:</strong> The use of ElementHandle is discouraged, use {@code Locator} objects and web-first assertions instead.
* <pre>{@code
@@ -30,12 +30,11 @@ import java.util.*;
* hrefElement.click();
* }</pre>
*
* <p> ElementHandle prevents DOM element from garbage collection unless the handle is disposed with {@link
* com.microsoft.playwright.JSHandle#dispose JSHandle.dispose()}. ElementHandles are auto-disposed when their origin frame
* gets navigated.
* <p> ElementHandle prevents DOM element from garbage collection unless the handle is disposed with {@link JSHandle#dispose
* JSHandle.dispose()}. ElementHandles are auto-disposed when their origin frame gets navigated.
*
* <p> ElementHandle instances can be used as an argument in {@link com.microsoft.playwright.Page#evalOnSelector
* Page.evalOnSelector()} and {@link com.microsoft.playwright.Page#evaluate Page.evaluate()} methods.
* <p> ElementHandle instances can be used as an argument in {@link Page#evalOnSelector Page.evalOnSelector()} and {@link
* Page#evaluate Page.evaluate()} methods.
*
* <p> The difference between the {@code Locator} and ElementHandle is that the ElementHandle points to a particular element,
* while {@code Locator} captures the logic of how to retrieve an element.
@@ -77,9 +76,8 @@ public interface ElementHandle extends JSHandle {
public Position position;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
@@ -123,9 +121,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public CheckOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -161,8 +158,7 @@ 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. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
* modifiers back. If not specified, currently pressed modifiers are used.
*/
public List<KeyboardModifier> modifiers;
/**
@@ -178,9 +174,8 @@ public interface ElementHandle extends JSHandle {
public Position position;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
@@ -221,8 +216,7 @@ 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. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
* modifiers back. If not specified, currently pressed modifiers are used.
*/
public ClickOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
@@ -254,9 +248,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public ClickOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -288,8 +281,7 @@ 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. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
* modifiers back. If not specified, currently pressed modifiers are used.
*/
public List<KeyboardModifier> modifiers;
/**
@@ -305,9 +297,8 @@ public interface ElementHandle extends JSHandle {
public Position position;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
@@ -341,8 +332,7 @@ 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. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
* modifiers back. If not specified, currently pressed modifiers are used.
*/
public DblclickOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
@@ -374,9 +364,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public DblclickOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -406,9 +395,8 @@ public interface ElementHandle extends JSHandle {
public Boolean noWaitAfter;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
@@ -431,9 +419,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public FillOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -448,8 +435,7 @@ 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. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
* modifiers back. If not specified, currently pressed modifiers are used.
*/
public List<KeyboardModifier> modifiers;
/**
@@ -465,9 +451,8 @@ public interface ElementHandle extends JSHandle {
public Position position;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
@@ -487,8 +472,7 @@ 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. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
* modifiers back. If not specified, currently pressed modifiers are used.
*/
public HoverOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
@@ -520,9 +504,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public HoverOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -541,17 +524,15 @@ public interface ElementHandle extends JSHandle {
class InputValueOptions {
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public InputValueOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -571,9 +552,8 @@ public interface ElementHandle extends JSHandle {
public Boolean noWaitAfter;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
@@ -595,9 +575,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public PressOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -663,9 +642,8 @@ public interface ElementHandle extends JSHandle {
public String style;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
@@ -758,9 +736,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public ScreenshotOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -777,17 +754,15 @@ public interface ElementHandle extends JSHandle {
class ScrollIntoViewIfNeededOptions {
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public ScrollIntoViewIfNeededOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -808,9 +783,8 @@ public interface ElementHandle extends JSHandle {
public Boolean noWaitAfter;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
@@ -833,9 +807,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public SelectOptionOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -850,9 +823,8 @@ public interface ElementHandle extends JSHandle {
public Boolean force;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
@@ -866,9 +838,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public SelectTextOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -894,9 +865,8 @@ public interface ElementHandle extends JSHandle {
public Position position;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
@@ -940,9 +910,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public SetCheckedOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -967,9 +936,8 @@ public interface ElementHandle extends JSHandle {
public Boolean noWaitAfter;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
@@ -984,9 +952,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public SetInputFilesOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -1001,8 +968,7 @@ 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. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
* modifiers back. If not specified, currently pressed modifiers are used.
*/
public List<KeyboardModifier> modifiers;
/**
@@ -1018,9 +984,8 @@ public interface ElementHandle extends JSHandle {
public Position position;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
@@ -1040,8 +1005,7 @@ 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. "ControlOrMeta" resolves to "Control" on Windows
* and Linux and to "Meta" on macOS.
* modifiers back. If not specified, currently pressed modifiers are used.
*/
public TapOptions setModifiers(List<KeyboardModifier> modifiers) {
this.modifiers = modifiers;
@@ -1073,9 +1037,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public TapOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -1104,9 +1067,8 @@ public interface ElementHandle extends JSHandle {
public Boolean noWaitAfter;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
@@ -1128,9 +1090,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public TypeOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -1156,9 +1117,8 @@ public interface ElementHandle extends JSHandle {
public Position position;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
@@ -1202,9 +1162,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public UncheckOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -1223,17 +1182,15 @@ public interface ElementHandle extends JSHandle {
class WaitForElementStateOptions {
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public WaitForElementStateOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -1260,9 +1217,8 @@ public interface ElementHandle extends JSHandle {
public Boolean strict;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
@@ -1291,9 +1247,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public WaitForSelectorOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -1314,7 +1269,7 @@ public interface ElementHandle extends JSHandle {
* <p> Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following
* snippet should click the center of the element.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* BoundingBox box = elementHandle.boundingBox();
* page.mouse().click(box.x + box.width / 2, box.y + box.height / 2);
@@ -1331,7 +1286,7 @@ public interface ElementHandle extends JSHandle {
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Use {@link 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>
@@ -1354,7 +1309,7 @@ public interface ElementHandle extends JSHandle {
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Use {@link 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>
@@ -1373,8 +1328,7 @@ public interface ElementHandle extends JSHandle {
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element, or the specified
* {@code position}.</li>
* <li> Use {@link Page#mouse Page.mouse()} to 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.</li>
* </ol>
*
@@ -1394,8 +1348,7 @@ public interface ElementHandle extends JSHandle {
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element, or the specified
* {@code position}.</li>
* <li> Use {@link Page#mouse Page.mouse()} to 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.</li>
* </ol>
*
@@ -1419,8 +1372,7 @@ public interface ElementHandle extends JSHandle {
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to double click in the center of the element, or the
* specified {@code position}.</li>
* <li> Use {@link 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>
@@ -1443,8 +1395,7 @@ public interface ElementHandle extends JSHandle {
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to double click in the center of the element, or the
* specified {@code position}.</li>
* <li> Use {@link 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>
@@ -1464,7 +1415,7 @@ public interface ElementHandle extends JSHandle {
* {@code click} is dispatched. This is equivalent to calling <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click">element.click()</a>.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* elementHandle.dispatchEvent("click");
* }</pre>
@@ -1508,7 +1459,7 @@ public interface ElementHandle extends JSHandle {
* {@code click} is dispatched. This is equivalent to calling <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click">element.click()</a>.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* elementHandle.dispatchEvent("click");
* }</pre>
@@ -1554,10 +1505,9 @@ public interface ElementHandle extends JSHandle {
*
* <p> If {@code expression} returns a <a
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
* com.microsoft.playwright.ElementHandle#evalOnSelector ElementHandle.evalOnSelector()} would wait for the promise to
* resolve and return its value.
* ElementHandle#evalOnSelector ElementHandle.evalOnSelector()} would wait for the promise to resolve and return its value.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* ElementHandle tweetHandle = page.querySelector(".tweet");
* assertEquals("100", tweetHandle.evalOnSelector(".like", "node => node.innerText"));
@@ -1580,10 +1530,9 @@ public interface ElementHandle extends JSHandle {
*
* <p> If {@code expression} returns a <a
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
* com.microsoft.playwright.ElementHandle#evalOnSelector ElementHandle.evalOnSelector()} would wait for the promise to
* resolve and return its value.
* ElementHandle#evalOnSelector ElementHandle.evalOnSelector()} would wait for the promise to resolve and return its value.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* ElementHandle tweetHandle = page.querySelector(".tweet");
* assertEquals("100", tweetHandle.evalOnSelector(".like", "node => node.innerText"));
@@ -1605,10 +1554,10 @@ public interface ElementHandle extends JSHandle {
*
* <p> If {@code expression} returns a <a
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
* com.microsoft.playwright.ElementHandle#evalOnSelectorAll ElementHandle.evalOnSelectorAll()} would wait for the promise
* to resolve and return its value.
* ElementHandle#evalOnSelectorAll ElementHandle.evalOnSelectorAll()} would wait for the promise to resolve and return its
* value.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* ElementHandle feedHandle = page.querySelector(".feed");
* assertEquals(Arrays.asList("Hello!", "Hi!"), feedHandle.evalOnSelectorAll(".tweet", "nodes => nodes.map(n => n.innerText)"));
@@ -1630,10 +1579,10 @@ public interface ElementHandle extends JSHandle {
*
* <p> If {@code expression} returns a <a
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
* com.microsoft.playwright.ElementHandle#evalOnSelectorAll ElementHandle.evalOnSelectorAll()} would wait for the promise
* to resolve and return its value.
* ElementHandle#evalOnSelectorAll ElementHandle.evalOnSelectorAll()} would wait for the promise to resolve and return its
* value.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* ElementHandle feedHandle = page.querySelector(".feed");
* assertEquals(Arrays.asList("Hello!", "Hi!"), feedHandle.evalOnSelectorAll(".tweet", "nodes => nodes.map(n => n.innerText)"));
@@ -1656,8 +1605,7 @@ public interface ElementHandle extends JSHandle {
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be filled
* instead.
*
* <p> To send fine-grained keyboard events, use {@link com.microsoft.playwright.Locator#pressSequentially
* Locator.pressSequentially()}.
* <p> To send fine-grained keyboard events, use {@link Locator#pressSequentially Locator.pressSequentially()}.
*
* @param value Value to set for the {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element.
* @since v1.8
@@ -1675,8 +1623,7 @@ public interface ElementHandle extends JSHandle {
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be filled
* instead.
*
* <p> To send fine-grained keyboard events, use {@link com.microsoft.playwright.Locator#pressSequentially
* Locator.pressSequentially()}.
* <p> To send fine-grained keyboard events, use {@link Locator#pressSequentially Locator.pressSequentially()}.
*
* @param value Value to set for the {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element.
* @since v1.8
@@ -1701,8 +1648,7 @@ public interface ElementHandle extends JSHandle {
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to hover over the center of the element, or the specified
* {@code position}.</li>
* <li> Use {@link 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>
*
@@ -1722,8 +1668,7 @@ public interface ElementHandle extends JSHandle {
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to hover over the center of the element, or the specified
* {@code position}.</li>
* <li> Use {@link 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>
*
@@ -1814,8 +1759,7 @@ public interface ElementHandle extends JSHandle {
*/
Frame ownerFrame();
/**
* Focuses the element, and then uses {@link com.microsoft.playwright.Keyboard#down Keyboard.down()} and {@link
* com.microsoft.playwright.Keyboard#up Keyboard.up()}.
* Focuses the element, and then uses {@link Keyboard#down Keyboard.down()} and {@link Keyboard#up Keyboard.up()}.
*
* <p> {@code key} can specify the intended <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key">keyboardEvent.key</a> value or a single
@@ -1828,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}, {@code ControlOrMeta}.
* ShiftLeft}.
*
* <p> Holding down {@code Shift} will type the text that corresponds to the {@code key} in the upper case.
*
@@ -1845,8 +1789,7 @@ public interface ElementHandle extends JSHandle {
press(key, null);
}
/**
* Focuses the element, and then uses {@link com.microsoft.playwright.Keyboard#down Keyboard.down()} and {@link
* com.microsoft.playwright.Keyboard#up Keyboard.up()}.
* Focuses the element, and then uses {@link Keyboard#down Keyboard.down()} and {@link Keyboard#up Keyboard.up()}.
*
* <p> {@code key} can specify the intended <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key">keyboardEvent.key</a> value or a single
@@ -1859,7 +1802,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}, {@code ControlOrMeta}.
* ShiftLeft}.
*
* <p> Holding down {@code Shift} will type the text that corresponds to the {@code key} in the upper case.
*
@@ -1956,7 +1899,7 @@ public interface ElementHandle extends JSHandle {
*
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* // Single selection matching the value or label
* handle.selectOption("blue");
@@ -1987,7 +1930,7 @@ public interface ElementHandle extends JSHandle {
*
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* // Single selection matching the value or label
* handle.selectOption("blue");
@@ -2016,7 +1959,7 @@ public interface ElementHandle extends JSHandle {
*
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* // Single selection matching the value or label
* handle.selectOption("blue");
@@ -2047,7 +1990,7 @@ public interface ElementHandle extends JSHandle {
*
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* // Single selection matching the value or label
* handle.selectOption("blue");
@@ -2076,7 +2019,7 @@ public interface ElementHandle extends JSHandle {
*
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* // Single selection matching the value or label
* handle.selectOption("blue");
@@ -2107,7 +2050,7 @@ public interface ElementHandle extends JSHandle {
*
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* // Single selection matching the value or label
* handle.selectOption("blue");
@@ -2136,7 +2079,7 @@ public interface ElementHandle extends JSHandle {
*
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* // Single selection matching the value or label
* handle.selectOption("blue");
@@ -2167,7 +2110,7 @@ public interface ElementHandle extends JSHandle {
*
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* // Single selection matching the value or label
* handle.selectOption("blue");
@@ -2196,7 +2139,7 @@ public interface ElementHandle extends JSHandle {
*
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* // Single selection matching the value or label
* handle.selectOption("blue");
@@ -2227,7 +2170,7 @@ public interface ElementHandle extends JSHandle {
*
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* // Single selection matching the value or label
* handle.selectOption("blue");
@@ -2256,7 +2199,7 @@ public interface ElementHandle extends JSHandle {
*
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* // Single selection matching the value or label
* handle.selectOption("blue");
@@ -2287,7 +2230,7 @@ public interface ElementHandle extends JSHandle {
*
* <p> Triggers a {@code change} and {@code input} event once all the provided options have been selected.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* // Single selection matching the value or label
* handle.selectOption("blue");
@@ -2335,7 +2278,7 @@ public interface ElementHandle extends JSHandle {
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the matched element,
* unless {@code force} option is set. If the element is detached during the checks, the whole action is retried.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Use {@link 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>
@@ -2357,7 +2300,7 @@ public interface ElementHandle extends JSHandle {
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the matched element,
* unless {@code force} option is set. If the element is detached during the checks, the whole action is retried.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Use {@link 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>
@@ -2487,8 +2430,7 @@ public interface ElementHandle extends JSHandle {
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#touchscreen Page.touchscreen()} to tap the center of the element, or the
* specified {@code position}.</li>
* <li> Use {@link 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>
*
@@ -2510,8 +2452,7 @@ public interface ElementHandle extends JSHandle {
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#touchscreen Page.touchscreen()} to tap the center of the element, or the
* specified {@code position}.</li>
* <li> Use {@link 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>
*
@@ -2532,9 +2473,9 @@ public interface ElementHandle extends JSHandle {
*/
String textContent();
/**
* @deprecated In most cases, you should use {@link com.microsoft.playwright.Locator#fill Locator.fill()} instead. You only need to
* press keys one by one if there is special keyboard handling on the page - in this case use {@link
* com.microsoft.playwright.Locator#pressSequentially Locator.pressSequentially()}.
* @deprecated In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
* there is special keyboard handling on the page - in this case use {@link Locator#pressSequentially
* Locator.pressSequentially()}.
*
* @param text A text to type into a focused element.
* @since v1.8
@@ -2543,9 +2484,9 @@ public interface ElementHandle extends JSHandle {
type(text, null);
}
/**
* @deprecated In most cases, you should use {@link com.microsoft.playwright.Locator#fill Locator.fill()} instead. You only need to
* press keys one by one if there is special keyboard handling on the page - in this case use {@link
* com.microsoft.playwright.Locator#pressSequentially Locator.pressSequentially()}.
* @deprecated In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
* there is special keyboard handling on the page - in this case use {@link Locator#pressSequentially
* Locator.pressSequentially()}.
*
* @param text A text to type into a focused element.
* @since v1.8
@@ -2559,7 +2500,7 @@ public interface ElementHandle extends JSHandle {
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Use {@link 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>
@@ -2582,7 +2523,7 @@ public interface ElementHandle extends JSHandle {
* <li> Wait for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks on the element, unless {@code
* force} option is set.</li>
* <li> Scroll the element into view if needed.</li>
* <li> Use {@link com.microsoft.playwright.Page#mouse Page.mouse()} to click in the center of the element.</li>
* <li> Use {@link 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>
@@ -2662,7 +2603,7 @@ public interface ElementHandle extends JSHandle {
* condition, the method will return immediately. If the selector doesn't satisfy the condition for the {@code timeout}
* milliseconds, the function will throw.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* page.setContent("<div><span></span></div>");
* ElementHandle div = page.querySelector("div");
@@ -2671,8 +2612,7 @@ public interface ElementHandle extends JSHandle {
* .setState(WaitForSelectorState.ATTACHED));
* }</pre>
*
* <p> <strong>NOTE:</strong> This method does not work across navigations, use {@link com.microsoft.playwright.Page#waitForSelector
* Page.waitForSelector()} instead.
* <p> <strong>NOTE:</strong> This method does not work across navigations, use {@link Page#waitForSelector Page.waitForSelector()} instead.
*
* @param selector A selector to query for.
* @since v1.8
@@ -2689,7 +2629,7 @@ public interface ElementHandle extends JSHandle {
* condition, the method will return immediately. If the selector doesn't satisfy the condition for the {@code timeout}
* milliseconds, the function will throw.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* page.setContent("<div><span></span></div>");
* ElementHandle div = page.querySelector("div");
@@ -2698,8 +2638,7 @@ public interface ElementHandle extends JSHandle {
* .setState(WaitForSelectorState.ATTACHED));
* }</pre>
*
* <p> <strong>NOTE:</strong> This method does not work across navigations, use {@link com.microsoft.playwright.Page#waitForSelector
* Page.waitForSelector()} instead.
* <p> <strong>NOTE:</strong> This method does not work across navigations, use {@link Page#waitForSelector Page.waitForSelector()} instead.
*
* @param selector A selector to query for.
* @since v1.8
@@ -20,8 +20,7 @@ import com.microsoft.playwright.options.*;
import java.nio.file.Path;
/**
* {@code FileChooser} objects are dispatched by the page in the {@link com.microsoft.playwright.Page#onFileChooser
* Page.onFileChooser()} event.
* {@code FileChooser} objects are dispatched by the page in the {@link Page#onFileChooser Page.onFileChooser()} event.
* <pre>{@code
* FileChooser fileChooser = page.waitForFileChooser(() -> page.getByText("Upload file").click());
* fileChooser.setFiles(Paths.get("myfile.pdf"));
@@ -37,9 +36,8 @@ public interface FileChooser {
public Boolean noWaitAfter;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;
@@ -54,9 +52,8 @@ public interface FileChooser {
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()} or {@link com.microsoft.playwright.Page#setDefaultTimeout Page.setDefaultTimeout()}
* methods.
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public SetFilesOptions setTimeout(double timeout) {
this.timeout = timeout;
File diff suppressed because it is too large Load Diff
@@ -21,15 +21,14 @@ import java.util.regex.Pattern;
/**
* FrameLocator represents a view to the {@code iframe} on the page. It captures the logic sufficient to retrieve the
* {@code iframe} and locate elements in that iframe. FrameLocator can be created with either {@link
* com.microsoft.playwright.Page#frameLocator Page.frameLocator()} or {@link com.microsoft.playwright.Locator#frameLocator
* Locator.frameLocator()} method.
* {@code iframe} and locate elements in that iframe. FrameLocator can be created with either {@link Page#frameLocator
* Page.frameLocator()} or {@link Locator#frameLocator Locator.frameLocator()} method.
* <pre>{@code
* Locator locator = page.frameLocator("#my-frame").getByText("Submit");
* locator.click();
* }</pre>
*
* <p> <strong>Strictness</strong>
* <p> **Strictness**
*
* <p> Frame locators are strict. This means that all operations on frame locators will throw if more than one element matches
* a given selector.
@@ -41,15 +40,13 @@ import java.util.regex.Pattern;
* page.frame_locator(".result-frame").first().getByRole(AriaRole.BUTTON).click();
* }</pre>
*
* <p> <strong>Converting Locator to FrameLocator</strong>
* <p> **Converting Locator to FrameLocator**
*
* <p> If you have a {@code Locator} object pointing to an {@code iframe} it can be converted to {@code FrameLocator} using
* {@link com.microsoft.playwright.Locator#contentFrame Locator.contentFrame()}.
*
* <p> <strong>Converting FrameLocator to Locator</strong>
*
* <p> If you have a {@code FrameLocator} object it can be converted to {@code Locator} pointing to the same {@code iframe}
* using {@link com.microsoft.playwright.FrameLocator#owner FrameLocator.owner()}.
* <p> If you have a {@code Locator} object pointing to an {@code iframe} it can be converted to {@code FrameLocator} using <a
* href="https://developer.mozilla.org/en-US/docs/Web/CSS/:scope">{@code :scope}</a> CSS selector:
* <pre>{@code
* Locator frameLocator = locator.frameLocator(':scope');
* }</pre>
*/
public interface FrameLocator {
class GetByAltTextOptions {
@@ -399,7 +396,7 @@ public interface FrameLocator {
/**
* Allows locating elements by their alt text.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, this method will find the image by alt text "Playwright logo":
* <pre>{@code
@@ -415,7 +412,7 @@ public interface FrameLocator {
/**
* Allows locating elements by their alt text.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, this method will find the image by alt text "Playwright logo":
* <pre>{@code
@@ -429,7 +426,7 @@ public interface FrameLocator {
/**
* Allows locating elements by their alt text.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, this method will find the image by alt text "Playwright logo":
* <pre>{@code
@@ -445,7 +442,7 @@ public interface FrameLocator {
/**
* Allows locating elements by their alt text.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, this method will find the image by alt text "Playwright logo":
* <pre>{@code
@@ -460,7 +457,7 @@ public interface FrameLocator {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
* <pre>{@code
@@ -478,7 +475,7 @@ public interface FrameLocator {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
* <pre>{@code
@@ -494,7 +491,7 @@ public interface FrameLocator {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
* <pre>{@code
@@ -512,7 +509,7 @@ public interface FrameLocator {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
* <pre>{@code
@@ -527,7 +524,7 @@ public interface FrameLocator {
/**
* Allows locating input elements by the placeholder text.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, consider the following DOM structure.
*
@@ -545,7 +542,7 @@ public interface FrameLocator {
/**
* Allows locating input elements by the placeholder text.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, consider the following DOM structure.
*
@@ -561,7 +558,7 @@ public interface FrameLocator {
/**
* Allows locating input elements by the placeholder text.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, consider the following DOM structure.
*
@@ -579,7 +576,7 @@ public interface FrameLocator {
/**
* Allows locating input elements by the placeholder text.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, consider the following DOM structure.
*
@@ -597,7 +594,7 @@ public interface FrameLocator {
* href="https://www.w3.org/TR/wai-aria-1.2/#aria-attributes">ARIA attributes</a> and <a
* href="https://w3c.github.io/accname/#dfn-accessible-name">accessible name</a>.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Consider the following DOM structure.
*
@@ -618,7 +615,7 @@ public interface FrameLocator {
* .click();
* }</pre>
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> Role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback about the
* ARIA guidelines.
@@ -640,7 +637,7 @@ public interface FrameLocator {
* href="https://www.w3.org/TR/wai-aria-1.2/#aria-attributes">ARIA attributes</a> and <a
* href="https://w3c.github.io/accname/#dfn-accessible-name">accessible name</a>.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Consider the following DOM structure.
*
@@ -661,7 +658,7 @@ public interface FrameLocator {
* .click();
* }</pre>
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> Role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback about the
* ARIA guidelines.
@@ -679,7 +676,7 @@ public interface FrameLocator {
/**
* Locate element by the test id.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Consider the following DOM structure.
*
@@ -688,11 +685,10 @@ public interface FrameLocator {
* page.getByTestId("directions").click();
* }</pre>
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> By default, the {@code data-testid} attribute is used as a test id. Use {@link
* com.microsoft.playwright.Selectors#setTestIdAttribute Selectors.setTestIdAttribute()} to configure a different test id
* attribute if necessary.
* <p> By default, the {@code data-testid} attribute is used as a test id. Use {@link Selectors#setTestIdAttribute
* Selectors.setTestIdAttribute()} to configure a different test id attribute if necessary.
*
* @param testId Id to locate the element by.
* @since v1.27
@@ -701,7 +697,7 @@ public interface FrameLocator {
/**
* Locate element by the test id.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Consider the following DOM structure.
*
@@ -710,11 +706,10 @@ public interface FrameLocator {
* page.getByTestId("directions").click();
* }</pre>
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> By default, the {@code data-testid} attribute is used as a test id. Use {@link
* com.microsoft.playwright.Selectors#setTestIdAttribute Selectors.setTestIdAttribute()} to configure a different test id
* attribute if necessary.
* <p> By default, the {@code data-testid} attribute is used as a test id. Use {@link Selectors#setTestIdAttribute
* Selectors.setTestIdAttribute()} to configure a different test id attribute if necessary.
*
* @param testId Id to locate the element by.
* @since v1.27
@@ -723,10 +718,10 @@ public interface FrameLocator {
/**
* Allows locating elements that contain given text.
*
* <p> See also {@link com.microsoft.playwright.Locator#filter Locator.filter()} that allows to match by another criteria, like
* an accessible role, and then filter by the text content.
* <p> See also {@link Locator#filter Locator.filter()} that allows to match by another criteria, like an accessible role, and
* then filter by the text content.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Consider the following DOM structure:
*
@@ -748,7 +743,7 @@ public interface FrameLocator {
* page.getByText(Pattern.compile("^hello$", Pattern.CASE_INSENSITIVE))
* }</pre>
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one,
* turns line breaks into spaces and ignores leading and trailing whitespace.
@@ -765,10 +760,10 @@ public interface FrameLocator {
/**
* Allows locating elements that contain given text.
*
* <p> See also {@link com.microsoft.playwright.Locator#filter Locator.filter()} that allows to match by another criteria, like
* an accessible role, and then filter by the text content.
* <p> See also {@link Locator#filter Locator.filter()} that allows to match by another criteria, like an accessible role, and
* then filter by the text content.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Consider the following DOM structure:
*
@@ -790,7 +785,7 @@ public interface FrameLocator {
* page.getByText(Pattern.compile("^hello$", Pattern.CASE_INSENSITIVE))
* }</pre>
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one,
* turns line breaks into spaces and ignores leading and trailing whitespace.
@@ -805,10 +800,10 @@ public interface FrameLocator {
/**
* Allows locating elements that contain given text.
*
* <p> See also {@link com.microsoft.playwright.Locator#filter Locator.filter()} that allows to match by another criteria, like
* an accessible role, and then filter by the text content.
* <p> See also {@link Locator#filter Locator.filter()} that allows to match by another criteria, like an accessible role, and
* then filter by the text content.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Consider the following DOM structure:
*
@@ -830,7 +825,7 @@ public interface FrameLocator {
* page.getByText(Pattern.compile("^hello$", Pattern.CASE_INSENSITIVE))
* }</pre>
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one,
* turns line breaks into spaces and ignores leading and trailing whitespace.
@@ -847,10 +842,10 @@ public interface FrameLocator {
/**
* Allows locating elements that contain given text.
*
* <p> See also {@link com.microsoft.playwright.Locator#filter Locator.filter()} that allows to match by another criteria, like
* an accessible role, and then filter by the text content.
* <p> See also {@link Locator#filter Locator.filter()} that allows to match by another criteria, like an accessible role, and
* then filter by the text content.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Consider the following DOM structure:
*
@@ -872,7 +867,7 @@ public interface FrameLocator {
* page.getByText(Pattern.compile("^hello$", Pattern.CASE_INSENSITIVE))
* }</pre>
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one,
* turns line breaks into spaces and ignores leading and trailing whitespace.
@@ -887,7 +882,7 @@ public interface FrameLocator {
/**
* Allows locating elements by their title attribute.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Consider the following DOM structure.
*
@@ -905,7 +900,7 @@ public interface FrameLocator {
/**
* Allows locating elements by their title attribute.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Consider the following DOM structure.
*
@@ -921,7 +916,7 @@ public interface FrameLocator {
/**
* Allows locating elements by their title attribute.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Consider the following DOM structure.
*
@@ -939,7 +934,7 @@ public interface FrameLocator {
/**
* Allows locating elements by their title attribute.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Consider the following DOM structure.
*
@@ -960,7 +955,7 @@ public interface FrameLocator {
FrameLocator last();
/**
* The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options,
* similar to {@link com.microsoft.playwright.Locator#filter Locator.filter()} method.
* similar to {@link Locator#filter Locator.filter()} method.
*
* <p> <a href="https://playwright.dev/java/docs/locators">Learn more about locators</a>.
*
@@ -972,7 +967,7 @@ public interface FrameLocator {
}
/**
* The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options,
* similar to {@link com.microsoft.playwright.Locator#filter Locator.filter()} method.
* similar to {@link Locator#filter Locator.filter()} method.
*
* <p> <a href="https://playwright.dev/java/docs/locators">Learn more about locators</a>.
*
@@ -982,7 +977,7 @@ public interface FrameLocator {
Locator locator(String selectorOrLocator, LocatorOptions options);
/**
* The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options,
* similar to {@link com.microsoft.playwright.Locator#filter Locator.filter()} method.
* similar to {@link Locator#filter Locator.filter()} method.
*
* <p> <a href="https://playwright.dev/java/docs/locators">Learn more about locators</a>.
*
@@ -994,7 +989,7 @@ public interface FrameLocator {
}
/**
* The method finds an element matching the specified selector in the locator's subtree. It also accepts filter options,
* similar to {@link com.microsoft.playwright.Locator#filter Locator.filter()} method.
* similar to {@link Locator#filter Locator.filter()} method.
*
* <p> <a href="https://playwright.dev/java/docs/locators">Learn more about locators</a>.
*
@@ -1008,24 +1003,5 @@ public interface FrameLocator {
* @since v1.17
*/
FrameLocator nth(int index);
/**
* Returns a {@code Locator} object pointing to the same {@code iframe} as this frame locator.
*
* <p> Useful when you have a {@code FrameLocator} object obtained somewhere, and later on would like to interact with the
* {@code iframe} element.
*
* <p> For a reverse operation, use {@link com.microsoft.playwright.Locator#contentFrame Locator.contentFrame()}.
*
* <p> <strong>Usage</strong>
* <pre>{@code
* FrameLocator frameLocator = page.frameLocator("iframe[name=\"embedded\"]");
* // ...
* Locator locator = frameLocator.owner();
* assertThat(locator).isVisible();
* }</pre>
*
* @since v1.43
*/
Locator owner();
}
@@ -19,20 +19,19 @@ package com.microsoft.playwright;
import java.util.*;
/**
* JSHandle represents an in-page JavaScript object. JSHandles can be created with the {@link
* com.microsoft.playwright.Page#evaluateHandle Page.evaluateHandle()} method.
* JSHandle represents an in-page JavaScript object. JSHandles can be created with the {@link Page#evaluateHandle
* Page.evaluateHandle()} method.
* <pre>{@code
* JSHandle windowHandle = page.evaluateHandle("() => window");
* // ...
* }</pre>
*
* <p> JSHandle prevents the referenced JavaScript object being garbage collected unless the handle is exposed with {@link
* com.microsoft.playwright.JSHandle#dispose JSHandle.dispose()}. JSHandles are auto-disposed when their origin frame gets
* navigated or the parent context gets destroyed.
* JSHandle#dispose JSHandle.dispose()}. JSHandles are auto-disposed when their origin frame gets navigated or the parent
* context gets destroyed.
*
* <p> JSHandle instances can be used as an argument in {@link com.microsoft.playwright.Page#evalOnSelector
* Page.evalOnSelector()}, {@link com.microsoft.playwright.Page#evaluate Page.evaluate()} and {@link
* com.microsoft.playwright.Page#evaluateHandle Page.evaluateHandle()} methods.
* <p> JSHandle instances can be used as an argument in {@link Page#evalOnSelector Page.evalOnSelector()}, {@link Page#evaluate
* Page.evaluate()} and {@link Page#evaluateHandle Page.evaluateHandle()} methods.
*/
public interface JSHandle {
/**
@@ -56,7 +55,7 @@ public interface JSHandle {
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@code
* handle.evaluate} would wait for the promise to resolve and return its value.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* ElementHandle tweetHandle = page.querySelector(".tweet .retweets");
* assertEquals("10 retweets", tweetHandle.evaluate("node => node.innerText"));
@@ -78,7 +77,7 @@ public interface JSHandle {
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@code
* handle.evaluate} would wait for the promise to resolve and return its value.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* ElementHandle tweetHandle = page.querySelector(".tweet .retweets");
* assertEquals("10 retweets", tweetHandle.evaluate("node => node.innerText"));
@@ -102,7 +101,7 @@ public interface JSHandle {
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@code
* jsHandle.evaluateHandle} would wait for the promise to resolve and return its value.
*
* <p> See {@link com.microsoft.playwright.Page#evaluateHandle Page.evaluateHandle()} for more details.
* <p> See {@link Page#evaluateHandle Page.evaluateHandle()} for more details.
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
@@ -123,7 +122,7 @@ public interface JSHandle {
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@code
* jsHandle.evaluateHandle} would wait for the promise to resolve and return its value.
*
* <p> See {@link com.microsoft.playwright.Page#evaluateHandle Page.evaluateHandle()} for more details.
* <p> See {@link Page#evaluateHandle Page.evaluateHandle()} for more details.
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
@@ -134,7 +133,7 @@ public interface JSHandle {
/**
* The method returns a map with **own property names** as keys and JSHandle instances for the property values.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* JSHandle handle = page.evaluateHandle("() => ({ window, document })");
* Map<String, JSHandle> properties = handle.getProperties();
@@ -19,13 +19,12 @@ package com.microsoft.playwright;
import com.microsoft.playwright.options.*;
/**
* Keyboard provides an api for managing a virtual keyboard. The high level api is {@link
* com.microsoft.playwright.Keyboard#type Keyboard.type()}, which takes raw characters and generates proper {@code
* keydown}, {@code keypress}/{@code input}, and {@code keyup} events on your page.
* Keyboard provides an api for managing a virtual keyboard. The high level api is {@link Keyboard#type Keyboard.type()},
* which takes raw characters and generates proper {@code keydown}, {@code keypress}/{@code input}, and {@code keyup}
* events on your page.
*
* <p> For finer control, you can use {@link com.microsoft.playwright.Keyboard#down Keyboard.down()}, {@link
* com.microsoft.playwright.Keyboard#up Keyboard.up()}, and {@link com.microsoft.playwright.Keyboard#insertText
* Keyboard.insertText()} to manually fire events as if they were generated from a real keyboard.
* <p> For finer control, you can use {@link Keyboard#down Keyboard.down()}, {@link Keyboard#up Keyboard.up()}, and {@link
* Keyboard#insertText Keyboard.insertText()} to manually fire events as if they were generated from a real keyboard.
*
* <p> An example of holding down {@code Shift} in order to select and delete some text:
* <pre>{@code
@@ -97,8 +96,7 @@ public interface Keyboard {
* ArrowUp}, etc.
*
* <p> Following modification shortcuts are also supported: {@code Shift}, {@code Control}, {@code Alt}, {@code Meta}, {@code
* ShiftLeft}, {@code ControlOrMeta}. {@code ControlOrMeta} resolves to {@code Control} on Windows and Linux and to {@code
* Meta} on macOS.
* ShiftLeft}.
*
* <p> Holding down {@code Shift} will type the text that corresponds to the {@code key} in the upper case.
*
@@ -106,12 +104,11 @@ public interface Keyboard {
* different respective texts.
*
* <p> If {@code key} is a modifier key, {@code Shift}, {@code Meta}, {@code Control}, or {@code Alt}, subsequent key presses
* will be sent with that modifier active. To release the modifier key, use {@link com.microsoft.playwright.Keyboard#up
* Keyboard.up()}.
* will be sent with that modifier active. To release the modifier key, use {@link Keyboard#up Keyboard.up()}.
*
* <p> After the key is pressed once, subsequent calls to {@link com.microsoft.playwright.Keyboard#down Keyboard.down()} will
* have <a href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat">repeat</a> set to true. To release
* the key, use {@link com.microsoft.playwright.Keyboard#up Keyboard.up()}.
* <p> After the key is pressed once, subsequent calls to {@link Keyboard#down Keyboard.down()} will have <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat">repeat</a> set to true. To release the key,
* use {@link Keyboard#up Keyboard.up()}.
*
* <p> <strong>NOTE:</strong> Modifier keys DO influence {@code keyboard.down}. Holding down {@code Shift} will type the text in upper case.
*
@@ -122,7 +119,7 @@ public interface Keyboard {
/**
* Dispatches only {@code input} event, does not emit the {@code keydown}, {@code keyup} or {@code keypress} events.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* page.keyboard().insertText("嗨");
* }</pre>
@@ -135,7 +132,7 @@ public interface Keyboard {
*/
void insertText(String text);
/**
* <strong>NOTE:</strong> In most cases, you should use {@link com.microsoft.playwright.Locator#press Locator.press()} instead.
* <strong>NOTE:</strong> In most cases, you should use {@link Locator#press Locator.press()} instead.
*
* <p> {@code key} can specify the intended <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key">keyboardEvent.key</a> value or a single
@@ -148,8 +145,7 @@ public interface Keyboard {
* ArrowUp}, etc.
*
* <p> Following modification shortcuts are also supported: {@code Shift}, {@code Control}, {@code Alt}, {@code Meta}, {@code
* ShiftLeft}, {@code ControlOrMeta}. {@code ControlOrMeta} resolves to {@code Control} on Windows and Linux and to {@code
* Meta} on macOS.
* ShiftLeft}.
*
* <p> Holding down {@code Shift} will type the text that corresponds to the {@code key} in the upper case.
*
@@ -159,7 +155,7 @@ public interface Keyboard {
* <p> Shortcuts such as {@code key: "Control+o"}, {@code key: "Control++} or {@code key: "Control+Shift+T"} are supported as
* well. When specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* Page page = browser.newPage();
* page.navigate("https://keycode.info");
@@ -172,8 +168,7 @@ public interface Keyboard {
* browser.close();
* }</pre>
*
* <p> Shortcut for {@link com.microsoft.playwright.Keyboard#down Keyboard.down()} and {@link
* com.microsoft.playwright.Keyboard#up Keyboard.up()}.
* <p> Shortcut for {@link Keyboard#down Keyboard.down()} and {@link Keyboard#up Keyboard.up()}.
*
* @param key Name of the key to press or a character to generate, such as {@code ArrowLeft} or {@code a}.
* @since v1.8
@@ -182,7 +177,7 @@ public interface Keyboard {
press(key, null);
}
/**
* <strong>NOTE:</strong> In most cases, you should use {@link com.microsoft.playwright.Locator#press Locator.press()} instead.
* <strong>NOTE:</strong> In most cases, you should use {@link Locator#press Locator.press()} instead.
*
* <p> {@code key} can specify the intended <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key">keyboardEvent.key</a> value or a single
@@ -195,8 +190,7 @@ public interface Keyboard {
* ArrowUp}, etc.
*
* <p> Following modification shortcuts are also supported: {@code Shift}, {@code Control}, {@code Alt}, {@code Meta}, {@code
* ShiftLeft}, {@code ControlOrMeta}. {@code ControlOrMeta} resolves to {@code Control} on Windows and Linux and to {@code
* Meta} on macOS.
* ShiftLeft}.
*
* <p> Holding down {@code Shift} will type the text that corresponds to the {@code key} in the upper case.
*
@@ -206,7 +200,7 @@ public interface Keyboard {
* <p> Shortcuts such as {@code key: "Control+o"}, {@code key: "Control++} or {@code key: "Control+Shift+T"} are supported as
* well. When specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* Page page = browser.newPage();
* page.navigate("https://keycode.info");
@@ -219,24 +213,22 @@ public interface Keyboard {
* browser.close();
* }</pre>
*
* <p> Shortcut for {@link com.microsoft.playwright.Keyboard#down Keyboard.down()} and {@link
* com.microsoft.playwright.Keyboard#up Keyboard.up()}.
* <p> Shortcut for {@link Keyboard#down Keyboard.down()} and {@link Keyboard#up Keyboard.up()}.
*
* @param key Name of the key to press or a character to generate, such as {@code ArrowLeft} or {@code a}.
* @since v1.8
*/
void press(String key, PressOptions options);
/**
* <strong>NOTE:</strong> In most cases, you should use {@link com.microsoft.playwright.Locator#fill Locator.fill()} instead. You only need to
* press keys one by one if there is special keyboard handling on the page - in this case use {@link
* com.microsoft.playwright.Locator#pressSequentially Locator.pressSequentially()}.
* <strong>NOTE:</strong> In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
* there is special keyboard handling on the page - in this case use {@link Locator#pressSequentially
* Locator.pressSequentially()}.
*
* <p> Sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each character in the text.
*
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link com.microsoft.playwright.Keyboard#press
* Keyboard.press()}.
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Keyboard#press Keyboard.press()}.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* // Types instantly
* page.keyboard().type("Hello");
@@ -255,16 +247,15 @@ public interface Keyboard {
type(text, null);
}
/**
* <strong>NOTE:</strong> In most cases, you should use {@link com.microsoft.playwright.Locator#fill Locator.fill()} instead. You only need to
* press keys one by one if there is special keyboard handling on the page - in this case use {@link
* com.microsoft.playwright.Locator#pressSequentially Locator.pressSequentially()}.
* <strong>NOTE:</strong> In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
* there is special keyboard handling on the page - in this case use {@link Locator#pressSequentially
* Locator.pressSequentially()}.
*
* <p> Sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each character in the text.
*
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link com.microsoft.playwright.Keyboard#press
* Keyboard.press()}.
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Keyboard#press Keyboard.press()}.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* // Types instantly
* page.keyboard().type("Hello");
File diff suppressed because it is too large Load Diff
@@ -21,7 +21,7 @@ import com.microsoft.playwright.options.*;
/**
* The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.
*
* <p> Every {@code page} object has its own Mouse, accessible with {@link com.microsoft.playwright.Page#mouse Page.mouse()}.
* <p> Every {@code page} object has its own Mouse, accessible with {@link Page#mouse Page.mouse()}.
* <pre>{@code
* // Using page.mouse to trace a 100x100 square.
* page.mouse().move(0, 0);
@@ -160,8 +160,7 @@ 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()}.
* Shortcut for {@link Mouse#move Mouse.move()}, {@link Mouse#down Mouse.down()}, {@link Mouse#up Mouse.up()}.
*
* @since v1.8
*/
@@ -169,16 +168,14 @@ public interface Mouse {
click(x, y, null);
}
/**
* 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()}.
* Shortcut for {@link Mouse#move Mouse.move()}, {@link Mouse#down Mouse.down()}, {@link Mouse#up Mouse.up()}.
*
* @since v1.8
*/
void click(double x, double y, ClickOptions options);
/**
* 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()}, {@link com.microsoft.playwright.Mouse#down
* Mouse.down()} and {@link com.microsoft.playwright.Mouse#up Mouse.up()}.
* Shortcut for {@link Mouse#move Mouse.move()}, {@link Mouse#down Mouse.down()}, {@link Mouse#up Mouse.up()}, {@link
* Mouse#down Mouse.down()} and {@link Mouse#up Mouse.up()}.
*
* @since v1.8
*/
@@ -186,9 +183,8 @@ public interface Mouse {
dblclick(x, y, null);
}
/**
* 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()}, {@link com.microsoft.playwright.Mouse#down
* Mouse.down()} and {@link com.microsoft.playwright.Mouse#up Mouse.up()}.
* Shortcut for {@link Mouse#move Mouse.move()}, {@link Mouse#down Mouse.down()}, {@link Mouse#up Mouse.up()}, {@link
* Mouse#down Mouse.down()} and {@link Mouse#up Mouse.up()}.
*
* @since v1.8
*/
File diff suppressed because it is too large Load Diff
@@ -94,8 +94,8 @@ public interface Playwright extends AutoCloseable {
*/
void close();
/**
* Launches new Playwright driver process and connects to it. {@link com.microsoft.playwright.Playwright#close
* Playwright.close()} should be called when the instance is no longer needed.
* Launches new Playwright driver process and connects to it. {@link Playwright#close Playwright.close()} should be called
* when the instance is no longer needed.
* <pre>{@code
* Playwright playwright = Playwright.create();
* Browser browser = playwright.webkit().launch();
@@ -22,15 +22,14 @@ import java.util.*;
/**
* Whenever the page sends a request for a network resource the following sequence of events are emitted by {@code Page}:
* <ul>
* <li> {@link com.microsoft.playwright.Page#onRequest Page.onRequest()} emitted when the request is issued by the page.</li>
* <li> {@link com.microsoft.playwright.Page#onResponse Page.onResponse()} emitted when/if the response status and headers are
* received for the request.</li>
* <li> {@link com.microsoft.playwright.Page#onRequestFinished Page.onRequestFinished()} emitted when the response body is
* downloaded and the request is complete.</li>
* <li> {@link Page#onRequest Page.onRequest()} emitted when the request is issued by the page.</li>
* <li> {@link Page#onResponse Page.onResponse()} emitted when/if the response status and headers are received for the request.</li>
* <li> {@link Page#onRequestFinished Page.onRequestFinished()} emitted when the response body is downloaded and the request is
* complete.</li>
* </ul>
*
* <p> If request fails at some point, then instead of {@code "requestfinished"} event (and possibly instead of 'response'
* event), the {@link com.microsoft.playwright.Page#onRequestFailed Page.onRequestFailed()} event is emitted.
* event), the {@link Page#onRequestFailed Page.onRequestFailed()} event is emitted.
*
* <p> <strong>NOTE:</strong> HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete
* with {@code "requestfinished"} event.
@@ -48,7 +47,7 @@ public interface Request {
/**
* The method returns {@code null} unless this request has failed, as reported by {@code requestfailed} event.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> Example of logging of all the failed requests:
* <pre>{@code
@@ -63,18 +62,18 @@ public interface Request {
/**
* Returns the {@code Frame} that initiated this request.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* String frameUrl = request.frame().url();
* }</pre>
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> Note that in some cases the frame is not available, and this method will throw.
* <ul>
* <li> When request originates in the Service Worker. You can use {@code request.serviceWorker()} to check that.</li>
* <li> When navigation request is issued before the corresponding frame is created. You can use {@link
* com.microsoft.playwright.Request#isNavigationRequest Request.isNavigationRequest()} to check that.</li>
* Request#isNavigationRequest Request.isNavigationRequest()} to check that.</li>
* </ul>
*
* <p> Here is an example that handles all the cases:
@@ -84,16 +83,16 @@ public interface Request {
Frame frame();
/**
* An object with the request HTTP headers. The header names are lower-cased. Note that this method does not return
* security-related headers, including cookie-related ones. You can use {@link com.microsoft.playwright.Request#allHeaders
* Request.allHeaders()} for complete list of headers that include {@code cookie} information.
* security-related headers, including cookie-related ones. You can use {@link Request#allHeaders Request.allHeaders()} for
* complete list of headers that include {@code cookie} information.
*
* @since v1.8
*/
Map<String, String> headers();
/**
* An array with all the request HTTP headers associated with this request. Unlike {@link
* com.microsoft.playwright.Request#allHeaders Request.allHeaders()}, header names are NOT lower-cased. Headers with
* multiple entries, such as {@code Set-Cookie}, appear in the array multiple times.
* An array with all the request HTTP headers associated with this request. Unlike {@link Request#allHeaders
* Request.allHeaders()}, header names are NOT lower-cased. Headers with multiple entries, such as {@code Set-Cookie},
* appear in the array multiple times.
*
* @since v1.15
*/
@@ -109,7 +108,7 @@ public interface Request {
* Whether this request is driving frame's navigation.
*
* <p> Some navigation requests are issued before the corresponding frame is created, and therefore do not have {@link
* com.microsoft.playwright.Request#frame Request.frame()} available.
* Request#frame Request.frame()} available.
*
* @since v1.8
*/
@@ -139,7 +138,7 @@ public interface Request {
* connected by {@code redirectedFrom()} and {@code redirectedTo()} methods. When multiple server redirects has happened,
* it is possible to construct the whole redirect chain by repeatedly calling {@code redirectedFrom()}.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, if the website {@code http://example.com} redirects to {@code https://example.com}:
* <pre>{@code
@@ -159,9 +158,9 @@ public interface Request {
/**
* New request issued by the browser if the server responded with redirect.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> This method is the opposite of {@link com.microsoft.playwright.Request#redirectedFrom Request.redirectedFrom()}:
* <p> This method is the opposite of {@link Request#redirectedFrom Request.redirectedFrom()}:
* <pre>{@code
* System.out.println(request.redirectedFrom().redirectedTo() == request); // true
* }</pre>
@@ -194,7 +193,7 @@ public interface Request {
* {@code responseEnd} becomes available when request finishes. Find more information at <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming">Resource Timing API</a>.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* page.onRequestFinished(request -> {
* Timing timing = request.timing();
@@ -56,16 +56,16 @@ public interface Response {
boolean fromServiceWorker();
/**
* An object with the response HTTP headers. The header names are lower-cased. Note that this method does not return
* security-related headers, including cookie-related ones. You can use {@link com.microsoft.playwright.Response#allHeaders
* Response.allHeaders()} for complete list of headers that include {@code cookie} information.
* security-related headers, including cookie-related ones. You can use {@link Response#allHeaders Response.allHeaders()}
* for complete list of headers that include {@code cookie} information.
*
* @since v1.8
*/
Map<String, String> headers();
/**
* An array with all the request HTTP headers associated with this response. Unlike {@link
* com.microsoft.playwright.Response#allHeaders Response.allHeaders()}, header names are NOT lower-cased. Headers with
* multiple entries, such as {@code Set-Cookie}, appear in the array multiple times.
* An array with all the request HTTP headers associated with this response. Unlike {@link Response#allHeaders
* Response.allHeaders()}, header names are NOT lower-cased. Headers with multiple entries, such as {@code Set-Cookie},
* appear in the array multiple times.
*
* @since v1.15
*/
@@ -20,9 +20,8 @@ import java.nio.file.Path;
import java.util.*;
/**
* Whenever a network route is set up with {@link com.microsoft.playwright.Page#route Page.route()} or {@link
* com.microsoft.playwright.BrowserContext#route BrowserContext.route()}, the {@code Route} object allows to handle the
* route.
* Whenever a network route is set up with {@link Page#route Page.route()} or {@link BrowserContext#route
* BrowserContext.route()}, the {@code Route} object allows to handle the route.
*
* <p> Learn more about <a href="https://playwright.dev/java/docs/network">networking</a>.
*/
@@ -335,7 +334,7 @@ public interface Route {
/**
* Continues route's request with optional overrides.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* page.route("**\/*", route -> {
* // Override headers
@@ -346,12 +345,12 @@ public interface Route {
* });
* }</pre>
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> Note that any overrides such as {@code url} or {@code headers} only apply to the request being routed. If this request
* results in a redirect, overrides will not be applied to the new redirected request. If you want to propagate a header
* through redirects, use the combination of {@link com.microsoft.playwright.Route#fetch Route.fetch()} and {@link
* com.microsoft.playwright.Route#fulfill Route.fulfill()} instead.
* through redirects, use the combination of {@link Route#fetch Route.fetch()} and {@link Route#fulfill Route.fulfill()}
* instead.
*
* @since v1.8
*/
@@ -361,7 +360,7 @@ public interface Route {
/**
* Continues route's request with optional overrides.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* page.route("**\/*", route -> {
* // Override headers
@@ -372,12 +371,12 @@ public interface Route {
* });
* }</pre>
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> Note that any overrides such as {@code url} or {@code headers} only apply to the request being routed. If this request
* results in a redirect, overrides will not be applied to the new redirected request. If you want to propagate a header
* through redirects, use the combination of {@link com.microsoft.playwright.Route#fetch Route.fetch()} and {@link
* com.microsoft.playwright.Route#fulfill Route.fulfill()} instead.
* through redirects, use the combination of {@link Route#fetch Route.fetch()} and {@link Route#fulfill Route.fulfill()}
* instead.
*
* @since v1.8
*/
@@ -388,7 +387,7 @@ public interface Route {
* bottom-most handler first, then it'll fall back to the previous one and in the end will be aborted by the first
* registered route.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* page.route("**\/*", route -> {
* // Runs last.
@@ -453,7 +452,7 @@ public interface Route {
* bottom-most handler first, then it'll fall back to the previous one and in the end will be aborted by the first
* registered route.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* page.route("**\/*", route -> {
* // Runs last.
@@ -514,7 +513,7 @@ public interface Route {
* Performs the request and fetches result without fulfilling it, so that the response could be modified and then
* fulfilled.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* page.route("https://dog.ceo/api/breeds/list/all", route -> {
* APIResponse response = route.fetch();
@@ -527,11 +526,11 @@ public interface Route {
* });
* }</pre>
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> Note that {@code headers} option will apply to the fetched request as well as any redirects initiated by it. If you want
* to only apply {@code headers} to the original request, but not to redirects, look into {@link
* com.microsoft.playwright.Route#resume Route.resume()} instead.
* to only apply {@code headers} to the original request, but not to redirects, look into {@link Route#resume
* Route.resume()} instead.
*
* @since v1.29
*/
@@ -542,7 +541,7 @@ public interface Route {
* Performs the request and fetches result without fulfilling it, so that the response could be modified and then
* fulfilled.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* page.route("https://dog.ceo/api/breeds/list/all", route -> {
* APIResponse response = route.fetch();
@@ -555,11 +554,11 @@ public interface Route {
* });
* }</pre>
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> Note that {@code headers} option will apply to the fetched request as well as any redirects initiated by it. If you want
* to only apply {@code headers} to the original request, but not to redirects, look into {@link
* com.microsoft.playwright.Route#resume Route.resume()} instead.
* to only apply {@code headers} to the original request, but not to redirects, look into {@link Route#resume
* Route.resume()} instead.
*
* @since v1.29
*/
@@ -567,7 +566,7 @@ public interface Route {
/**
* Fulfills route's request with given response.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> An example of fulfilling all requests with 404 responses:
* <pre>{@code
@@ -593,7 +592,7 @@ public interface Route {
/**
* Fulfills route's request with given response.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> An example of fulfilling all requests with 404 responses:
* <pre>{@code
@@ -44,7 +44,7 @@ public interface Selectors {
/**
* Selectors must be registered before creating the page.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> An example of registering selector engine that queries elements based on a tag name:
* <pre>{@code
@@ -84,7 +84,7 @@ public interface Selectors {
/**
* Selectors must be registered before creating the page.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> An example of registering selector engine that queries elements based on a tag name:
* <pre>{@code
@@ -122,7 +122,7 @@ public interface Selectors {
/**
* Selectors must be registered before creating the page.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> An example of registering selector engine that queries elements based on a tag name:
* <pre>{@code
@@ -162,7 +162,7 @@ public interface Selectors {
/**
* Selectors must be registered before creating the page.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> An example of registering selector engine that queries elements based on a tag name:
* <pre>{@code
@@ -198,8 +198,8 @@ public interface Selectors {
*/
void register(String name, Path script, RegisterOptions options);
/**
* Defines custom attribute name to be used in {@link com.microsoft.playwright.Page#getByTestId Page.getByTestId()}. {@code
* data-testid} is used by default.
* Defines custom attribute name to be used in {@link Page#getByTestId Page.getByTestId()}. {@code data-testid} is used by
* default.
*
* @param attributeName Test id attribute name.
* @since v1.27
@@ -25,8 +25,7 @@ public interface Touchscreen {
/**
* Dispatches a {@code touchstart} and {@code touchend} event with a single touch at the position ({@code x},{@code y}).
*
* <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.
* <p> <strong>NOTE:</strong> {@link Page#tap Page.tap()} the method will throw if {@code hasTouch} option of the browser context is false.
*
* @since v1.8
*/
@@ -39,9 +39,8 @@ public interface Tracing {
class StartOptions {
/**
* If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the {@code
* tracesDir} folder specified in {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}. To specify the
* final trace zip file name, you need to pass {@code path} option to {@link com.microsoft.playwright.Tracing#stop
* Tracing.stop()} instead.
* tracesDir} folder specified in {@link BrowserType#launch BrowserType.launch()}. To specify the final trace zip file
* name, you need to pass {@code path} option to {@link Tracing#stop Tracing.stop()} instead.
*/
public String name;
/**
@@ -69,9 +68,8 @@ public interface Tracing {
/**
* If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the {@code
* tracesDir} folder specified in {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}. To specify the
* final trace zip file name, you need to pass {@code path} option to {@link com.microsoft.playwright.Tracing#stop
* Tracing.stop()} instead.
* tracesDir} folder specified in {@link BrowserType#launch BrowserType.launch()}. To specify the final trace zip file
* name, you need to pass {@code path} option to {@link Tracing#stop Tracing.stop()} instead.
*/
public StartOptions setName(String name) {
this.name = name;
@@ -115,9 +113,8 @@ public interface Tracing {
class StartChunkOptions {
/**
* If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the {@code
* tracesDir} folder specified in {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}. To specify the
* final trace zip file name, you need to pass {@code path} option to {@link com.microsoft.playwright.Tracing#stopChunk
* Tracing.stopChunk()} instead.
* tracesDir} folder specified in {@link BrowserType#launch BrowserType.launch()}. To specify the final trace zip file
* name, you need to pass {@code path} option to {@link Tracing#stopChunk Tracing.stopChunk()} instead.
*/
public String name;
/**
@@ -127,9 +124,8 @@ public interface Tracing {
/**
* If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the {@code
* tracesDir} folder specified in {@link com.microsoft.playwright.BrowserType#launch BrowserType.launch()}. To specify the
* final trace zip file name, you need to pass {@code path} option to {@link com.microsoft.playwright.Tracing#stopChunk
* Tracing.stopChunk()} instead.
* tracesDir} folder specified in {@link BrowserType#launch BrowserType.launch()}. To specify the final trace zip file
* name, you need to pass {@code path} option to {@link Tracing#stopChunk Tracing.stopChunk()} instead.
*/
public StartChunkOptions setName(String name) {
this.name = name;
@@ -159,14 +155,14 @@ public interface Tracing {
}
class StopChunkOptions {
/**
* Export trace collected since the last {@link com.microsoft.playwright.Tracing#startChunk Tracing.startChunk()} call into
* the file with the given path.
* Export trace collected since the last {@link Tracing#startChunk Tracing.startChunk()} call into the file with the given
* path.
*/
public Path path;
/**
* Export trace collected since the last {@link com.microsoft.playwright.Tracing#startChunk Tracing.startChunk()} call into
* the file with the given path.
* Export trace collected since the last {@link Tracing#startChunk Tracing.startChunk()} call into the file with the given
* path.
*/
public StopChunkOptions setPath(Path path) {
this.path = path;
@@ -176,7 +172,7 @@ public interface Tracing {
/**
* Start tracing.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* context.tracing().start(new Tracing.StartOptions()
* .setScreenshots(true)
@@ -195,7 +191,7 @@ public interface Tracing {
/**
* Start tracing.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* context.tracing().start(new Tracing.StartOptions()
* .setScreenshots(true)
@@ -211,11 +207,10 @@ public interface Tracing {
void start(StartOptions options);
/**
* Start a new trace chunk. If you'd like to record multiple traces on the same {@code BrowserContext}, use {@link
* com.microsoft.playwright.Tracing#start Tracing.start()} once, and then create multiple trace chunks with {@link
* com.microsoft.playwright.Tracing#startChunk Tracing.startChunk()} and {@link com.microsoft.playwright.Tracing#stopChunk
* Tracing.stopChunk()}.
* Tracing#start Tracing.start()} once, and then create multiple trace chunks with {@link Tracing#startChunk
* Tracing.startChunk()} and {@link Tracing#stopChunk Tracing.stopChunk()}.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* context.tracing().start(new Tracing.StartOptions()
* .setScreenshots(true)
@@ -243,11 +238,10 @@ public interface Tracing {
}
/**
* Start a new trace chunk. If you'd like to record multiple traces on the same {@code BrowserContext}, use {@link
* com.microsoft.playwright.Tracing#start Tracing.start()} once, and then create multiple trace chunks with {@link
* com.microsoft.playwright.Tracing#startChunk Tracing.startChunk()} and {@link com.microsoft.playwright.Tracing#stopChunk
* Tracing.stopChunk()}.
* Tracing#start Tracing.start()} once, and then create multiple trace chunks with {@link Tracing#startChunk
* Tracing.startChunk()} and {@link Tracing#stopChunk Tracing.stopChunk()}.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* context.tracing().start(new Tracing.StartOptions()
* .setScreenshots(true)
@@ -286,8 +280,7 @@ public interface Tracing {
*/
void stop(StopOptions options);
/**
* Stop the trace chunk. See {@link com.microsoft.playwright.Tracing#startChunk Tracing.startChunk()} for more details
* about multiple trace chunks.
* Stop the trace chunk. See {@link Tracing#startChunk Tracing.startChunk()} for more details about multiple trace chunks.
*
* @since v1.15
*/
@@ -295,8 +288,7 @@ public interface Tracing {
stopChunk(null);
}
/**
* Stop the trace chunk. See {@link com.microsoft.playwright.Tracing#startChunk Tracing.startChunk()} for more details
* about multiple trace chunks.
* Stop the trace chunk. See {@link Tracing#startChunk Tracing.startChunk()} for more details about multiple trace chunks.
*
* @since v1.15
*/
@@ -19,7 +19,7 @@ package com.microsoft.playwright;
/**
* {@code WebError} class represents an unhandled exception thrown in the page. It is dispatched via the {@link
* com.microsoft.playwright.BrowserContext#onWebError BrowserContext.onWebError()} event.
* BrowserContext#onWebError BrowserContext.onWebError()} event.
* <pre>{@code
* // Log all uncaught errors to the terminal
* context.onWebError(webError -> {
@@ -67,8 +67,7 @@ public interface WebSocket {
public Predicate<WebSocketFrame> predicate;
/**
* Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()}.
* default value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
*/
public Double timeout;
@@ -81,8 +80,7 @@ public interface WebSocket {
}
/**
* Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()}.
* default value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
*/
public WaitForFrameReceivedOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -96,8 +94,7 @@ public interface WebSocket {
public Predicate<WebSocketFrame> predicate;
/**
* Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()}.
* default value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
*/
public Double timeout;
@@ -110,8 +107,7 @@ public interface WebSocket {
}
/**
* Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()}.
* default value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
*/
public WaitForFrameSentOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -19,8 +19,8 @@ package com.microsoft.playwright;
/**
* The {@code WebSocketFrame} class represents frames sent over {@code WebSocket} connections in the page. Frame payload is
* returned by either {@link com.microsoft.playwright.WebSocketFrame#text WebSocketFrame.text()} or {@link
* com.microsoft.playwright.WebSocketFrame#binary WebSocketFrame.binary()} method depending on the its type.
* returned by either {@link WebSocketFrame#text WebSocketFrame.text()} or {@link WebSocketFrame#binary
* WebSocketFrame.binary()} method depending on the its type.
*/
public interface WebSocketFrame {
/**
@@ -47,15 +47,13 @@ public interface Worker {
class WaitForCloseOptions {
/**
* Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()}.
* default value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
*/
public Double timeout;
/**
* Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The
* default value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
* BrowserContext.setDefaultTimeout()}.
* default value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
*/
public WaitForCloseOptions setTimeout(double timeout) {
this.timeout = timeout;
@@ -65,14 +63,13 @@ public interface Worker {
/**
* Returns the return value of {@code expression}.
*
* <p> If the function passed to the {@link com.microsoft.playwright.Worker#evaluate Worker.evaluate()} returns a <a
* <p> If the function passed to the {@link Worker#evaluate Worker.evaluate()} returns a <a
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
* com.microsoft.playwright.Worker#evaluate Worker.evaluate()} would wait for the promise to resolve and return its value.
* Worker#evaluate Worker.evaluate()} would wait for the promise to resolve and return its value.
*
* <p> If the function passed to the {@link com.microsoft.playwright.Worker#evaluate Worker.evaluate()} returns a
* non-[Serializable] value, then {@link com.microsoft.playwright.Worker#evaluate Worker.evaluate()} returns {@code
* undefined}. Playwright also supports transferring some additional values that are not serializable by {@code JSON}:
* {@code -0}, {@code NaN}, {@code Infinity}, {@code -Infinity}.
* <p> If the function passed to the {@link Worker#evaluate Worker.evaluate()} returns a non-[Serializable] value, then {@link
* Worker#evaluate Worker.evaluate()} returns {@code undefined}. Playwright also supports transferring some additional
* values that are not serializable by {@code JSON}: {@code -0}, {@code NaN}, {@code Infinity}, {@code -Infinity}.
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
@@ -84,14 +81,13 @@ public interface Worker {
/**
* Returns the return value of {@code expression}.
*
* <p> If the function passed to the {@link com.microsoft.playwright.Worker#evaluate Worker.evaluate()} returns a <a
* <p> If the function passed to the {@link Worker#evaluate Worker.evaluate()} returns a <a
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
* com.microsoft.playwright.Worker#evaluate Worker.evaluate()} would wait for the promise to resolve and return its value.
* Worker#evaluate Worker.evaluate()} would wait for the promise to resolve and return its value.
*
* <p> If the function passed to the {@link com.microsoft.playwright.Worker#evaluate Worker.evaluate()} returns a
* non-[Serializable] value, then {@link com.microsoft.playwright.Worker#evaluate Worker.evaluate()} returns {@code
* undefined}. Playwright also supports transferring some additional values that are not serializable by {@code JSON}:
* {@code -0}, {@code NaN}, {@code Infinity}, {@code -Infinity}.
* <p> If the function passed to the {@link Worker#evaluate Worker.evaluate()} returns a non-[Serializable] value, then {@link
* Worker#evaluate Worker.evaluate()} returns {@code undefined}. Playwright also supports transferring some additional
* values that are not serializable by {@code JSON}: {@code -0}, {@code NaN}, {@code Infinity}, {@code -Infinity}.
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
@@ -102,14 +98,12 @@ public interface Worker {
/**
* Returns the return value of {@code expression} as a {@code JSHandle}.
*
* <p> The only difference between {@link com.microsoft.playwright.Worker#evaluate Worker.evaluate()} and {@link
* com.microsoft.playwright.Worker#evaluateHandle Worker.evaluateHandle()} is that {@link
* com.microsoft.playwright.Worker#evaluateHandle Worker.evaluateHandle()} returns {@code JSHandle}.
* <p> The only difference between {@link Worker#evaluate Worker.evaluate()} and {@link Worker#evaluateHandle
* Worker.evaluateHandle()} is that {@link Worker#evaluateHandle Worker.evaluateHandle()} returns {@code JSHandle}.
*
* <p> If the function passed to the {@link com.microsoft.playwright.Worker#evaluateHandle Worker.evaluateHandle()} returns a
* <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then
* {@link com.microsoft.playwright.Worker#evaluateHandle Worker.evaluateHandle()} would wait for the promise to resolve and
* return its value.
* <p> If the function passed to the {@link Worker#evaluateHandle Worker.evaluateHandle()} returns a <a
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
* Worker#evaluateHandle Worker.evaluateHandle()} would wait for the promise to resolve and return its value.
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
@@ -121,14 +115,12 @@ public interface Worker {
/**
* Returns the return value of {@code expression} as a {@code JSHandle}.
*
* <p> The only difference between {@link com.microsoft.playwright.Worker#evaluate Worker.evaluate()} and {@link
* com.microsoft.playwright.Worker#evaluateHandle Worker.evaluateHandle()} is that {@link
* com.microsoft.playwright.Worker#evaluateHandle Worker.evaluateHandle()} returns {@code JSHandle}.
* <p> The only difference between {@link Worker#evaluate Worker.evaluate()} and {@link Worker#evaluateHandle
* Worker.evaluateHandle()} is that {@link Worker#evaluateHandle Worker.evaluateHandle()} returns {@code JSHandle}.
*
* <p> If the function passed to the {@link com.microsoft.playwright.Worker#evaluateHandle Worker.evaluateHandle()} returns a
* <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then
* {@link com.microsoft.playwright.Worker#evaluateHandle Worker.evaluateHandle()} would wait for the promise to resolve and
* return its value.
* <p> If the function passed to the {@link Worker#evaluateHandle Worker.evaluateHandle()} returns a <a
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
* Worker#evaluateHandle Worker.evaluateHandle()} would wait for the promise to resolve and return its value.
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
@@ -49,7 +49,7 @@ public interface APIResponseAssertions {
/**
* Ensures the response status code is within {@code 200..299} range.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(response).isOK();
* }</pre>
@@ -17,7 +17,6 @@
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
@@ -254,60 +253,6 @@ 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
@@ -405,20 +350,6 @@ 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
@@ -499,7 +430,7 @@ public interface LocatorAssertions {
* Ensures that {@code Locator} points to an element that is <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected">connected</a> to a Document or a ShadowRoot.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByText("Hidden text")).isAttached();
* }</pre>
@@ -513,7 +444,7 @@ public interface LocatorAssertions {
* Ensures that {@code Locator} points to an element that is <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected">connected</a> to a Document or a ShadowRoot.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByText("Hidden text")).isAttached();
* }</pre>
@@ -524,7 +455,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to a checked input.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByLabel("Subscribe to newsletter")).isChecked();
* }</pre>
@@ -537,7 +468,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to a checked input.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByLabel("Subscribe to newsletter")).isChecked();
* }</pre>
@@ -553,7 +484,7 @@ public interface LocatorAssertions {
* {@code option}, {@code optgroup} can be disabled by setting "disabled" attribute. "disabled" attribute on other elements
* is ignored by the browser.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("button.submit")).isDisabled();
* }</pre>
@@ -571,7 +502,7 @@ public interface LocatorAssertions {
* {@code option}, {@code optgroup} can be disabled by setting "disabled" attribute. "disabled" attribute on other elements
* is ignored by the browser.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("button.submit")).isDisabled();
* }</pre>
@@ -582,7 +513,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to an editable element.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByRole(AriaRole.TEXTBOX)).isEditable();
* }</pre>
@@ -595,7 +526,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to an editable element.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByRole(AriaRole.TEXTBOX)).isEditable();
* }</pre>
@@ -606,7 +537,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to an empty editable element or to a DOM node that has no text.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("div.warning")).isEmpty();
* }</pre>
@@ -619,7 +550,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to an empty editable element or to a DOM node that has no text.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("div.warning")).isEmpty();
* }</pre>
@@ -630,7 +561,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to an enabled element.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("button.submit")).isEnabled();
* }</pre>
@@ -643,7 +574,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to an enabled element.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("button.submit")).isEnabled();
* }</pre>
@@ -654,7 +585,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to a focused DOM node.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByRole(AriaRole.TEXTBOX)).isFocused();
* }</pre>
@@ -667,7 +598,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to a focused DOM node.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByRole(AriaRole.TEXTBOX)).isFocused();
* }</pre>
@@ -679,7 +610,7 @@ public interface LocatorAssertions {
* Ensures that {@code Locator} either does not resolve to any DOM node, or resolves to a <a
* href="https://playwright.dev/java/docs/actionability#visible">non-visible</a> one.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".my-element")).isHidden();
* }</pre>
@@ -693,7 +624,7 @@ public interface LocatorAssertions {
* Ensures that {@code Locator} either does not resolve to any DOM node, or resolves to a <a
* href="https://playwright.dev/java/docs/actionability#visible">non-visible</a> one.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".my-element")).isHidden();
* }</pre>
@@ -705,7 +636,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that intersects viewport, according to the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API">intersection observer API</a>.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* Locator locator = page.getByRole(AriaRole.BUTTON);
* // Make sure at least some part of element intersects viewport.
@@ -725,7 +656,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that intersects viewport, according to the <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API">intersection observer API</a>.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* Locator locator = page.getByRole(AriaRole.BUTTON);
* // Make sure at least some part of element intersects viewport.
@@ -743,10 +674,9 @@ public interface LocatorAssertions {
* Ensures that {@code Locator} points to an attached and <a
* href="https://playwright.dev/java/docs/actionability#visible">visible</a> DOM node.
*
* <p> To check that at least one element from the list is visible, use {@link com.microsoft.playwright.Locator#first
* Locator.first()}.
* <p> To check that at least one element from the list is visible, use {@link Locator#first Locator.first()}.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* // A specific element is visible.
* assertThat(page.getByText("Welcome")).isVisible();
@@ -771,10 +701,9 @@ public interface LocatorAssertions {
* Ensures that {@code Locator} points to an attached and <a
* href="https://playwright.dev/java/docs/actionability#visible">visible</a> DOM node.
*
* <p> To check that at least one element from the list is visible, use {@link com.microsoft.playwright.Locator#first
* Locator.first()}.
* <p> To check that at least one element from the list is visible, use {@link Locator#first Locator.first()}.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* // A specific element is visible.
* assertThat(page.getByText("Welcome")).isVisible();
@@ -797,12 +726,12 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that contains 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.
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".title")).containsText("substring");
* }</pre>
@@ -842,12 +771,12 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that contains 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.
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".title")).containsText("substring");
* }</pre>
@@ -885,12 +814,12 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that contains 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.
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".title")).containsText("substring");
* }</pre>
@@ -930,12 +859,12 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that contains 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.
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".title")).containsText("substring");
* }</pre>
@@ -973,12 +902,12 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that contains 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.
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".title")).containsText("substring");
* }</pre>
@@ -1018,12 +947,12 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that contains 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.
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".title")).containsText("substring");
* }</pre>
@@ -1061,12 +990,12 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that contains 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.
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".title")).containsText("substring");
* }</pre>
@@ -1106,12 +1035,12 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that contains 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.
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".title")).containsText("substring");
* }</pre>
@@ -1145,130 +1074,10 @@ 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.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("input")).hasAttribute("type", "text");
* }</pre>
@@ -1283,7 +1092,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to an element with given attribute.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("input")).hasAttribute("type", "text");
* }</pre>
@@ -1296,7 +1105,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to an element with given attribute.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("input")).hasAttribute("type", "text");
* }</pre>
@@ -1311,7 +1120,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to an element with given attribute.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("input")).hasAttribute("type", "text");
* }</pre>
@@ -1325,7 +1134,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with given CSS classes. This needs to be a full match or using a
* relaxed regular expression.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
* assertThat(page.locator("#component")).hasClass("selected row");
@@ -1346,7 +1155,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with given CSS classes. This needs to be a full match or using a
* relaxed regular expression.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
* assertThat(page.locator("#component")).hasClass("selected row");
@@ -1365,7 +1174,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with given CSS classes. This needs to be a full match or using a
* relaxed regular expression.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
* assertThat(page.locator("#component")).hasClass("selected row");
@@ -1386,7 +1195,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with given CSS classes. This needs to be a full match or using a
* relaxed regular expression.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
* assertThat(page.locator("#component")).hasClass("selected row");
@@ -1405,7 +1214,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with given CSS classes. This needs to be a full match or using a
* relaxed regular expression.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
* assertThat(page.locator("#component")).hasClass("selected row");
@@ -1426,7 +1235,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with given CSS classes. This needs to be a full match or using a
* relaxed regular expression.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
* assertThat(page.locator("#component")).hasClass("selected row");
@@ -1445,7 +1254,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with given CSS classes. This needs to be a full match or using a
* relaxed regular expression.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
* assertThat(page.locator("#component")).hasClass("selected row");
@@ -1466,7 +1275,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with given CSS classes. This needs to be a full match or using a
* relaxed regular expression.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
* assertThat(page.locator("#component")).hasClass("selected row");
@@ -1484,7 +1293,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} resolves to an exact number of DOM nodes.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("list > .component")).hasCount(3);
* }</pre>
@@ -1498,7 +1307,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} resolves to an exact number of DOM nodes.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("list > .component")).hasCount(3);
* }</pre>
@@ -1510,7 +1319,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} resolves to an element with the given computed CSS style.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByRole(AriaRole.BUTTON)).hasCSS("display", "flex");
* }</pre>
@@ -1525,7 +1334,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} resolves to an element with the given computed CSS style.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByRole(AriaRole.BUTTON)).hasCSS("display", "flex");
* }</pre>
@@ -1538,7 +1347,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} resolves to an element with the given computed CSS style.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByRole(AriaRole.BUTTON)).hasCSS("display", "flex");
* }</pre>
@@ -1553,7 +1362,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} resolves to an element with the given computed CSS style.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByRole(AriaRole.BUTTON)).hasCSS("display", "flex");
* }</pre>
@@ -1566,7 +1375,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to an element with the given DOM Node ID.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByRole(AriaRole.TEXTBOX)).hasId("lastname");
* }</pre>
@@ -1580,7 +1389,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to an element with the given DOM Node ID.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByRole(AriaRole.TEXTBOX)).hasId("lastname");
* }</pre>
@@ -1592,7 +1401,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to an element with the given DOM Node ID.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByRole(AriaRole.TEXTBOX)).hasId("lastname");
* }</pre>
@@ -1606,7 +1415,7 @@ public interface LocatorAssertions {
/**
* Ensures the {@code Locator} points to an element with the given DOM Node ID.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.getByRole(AriaRole.TEXTBOX)).hasId("lastname");
* }</pre>
@@ -1619,7 +1428,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with given JavaScript property. Note that this property can be of a
* primitive type as well as a plain serializable JavaScript object.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("input")).hasJSProperty("loaded", true);
* }</pre>
@@ -1635,7 +1444,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with given JavaScript property. Note that this property can be of a
* primitive type as well as a plain serializable JavaScript object.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("input")).hasJSProperty("loaded", true);
* }</pre>
@@ -1645,52 +1454,16 @@ 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.
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
@@ -1730,12 +1503,12 @@ public interface LocatorAssertions {
* 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.
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
@@ -1773,12 +1546,12 @@ public interface LocatorAssertions {
* 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.
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
@@ -1818,12 +1591,12 @@ public interface LocatorAssertions {
* 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.
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
@@ -1861,12 +1634,12 @@ public interface LocatorAssertions {
* 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.
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
@@ -1906,12 +1679,12 @@ public interface LocatorAssertions {
* 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.
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
@@ -1949,12 +1722,12 @@ public interface LocatorAssertions {
* 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.
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
@@ -1994,12 +1767,12 @@ public interface LocatorAssertions {
* 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.
*
* <p> <strong>Details</strong>
* <p> **Details**
*
* <p> When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
* text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
@@ -2037,7 +1810,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with the given input value. You can use regular expressions for the
* value as well.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("input[type=number]")).hasValue(Pattern.compile("[0-9]"));
* }</pre>
@@ -2052,7 +1825,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with the given input value. You can use regular expressions for the
* value as well.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("input[type=number]")).hasValue(Pattern.compile("[0-9]"));
* }</pre>
@@ -2065,7 +1838,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with the given input value. You can use regular expressions for the
* value as well.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("input[type=number]")).hasValue(Pattern.compile("[0-9]"));
* }</pre>
@@ -2080,7 +1853,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with the given input value. You can use regular expressions for the
* value as well.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page.locator("input[type=number]")).hasValue(Pattern.compile("[0-9]"));
* }</pre>
@@ -2093,7 +1866,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to multi-select/combobox (i.e. a {@code select} with the {@code multiple} attribute)
* and the specified values are selected.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, given the following element:
* <pre>{@code
@@ -2111,7 +1884,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to multi-select/combobox (i.e. a {@code select} with the {@code multiple} attribute)
* and the specified values are selected.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, given the following element:
* <pre>{@code
@@ -2127,7 +1900,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to multi-select/combobox (i.e. a {@code select} with the {@code multiple} attribute)
* and the specified values are selected.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, given the following element:
* <pre>{@code
@@ -2145,7 +1918,7 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to multi-select/combobox (i.e. a {@code select} with the {@code multiple} attribute)
* and the specified values are selected.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
*
* <p> For example, given the following element:
* <pre>{@code
@@ -52,24 +52,11 @@ 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}.
*/
@@ -91,7 +78,7 @@ public interface PageAssertions {
/**
* Ensures the page has the given title.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page).hasTitle("Playwright");
* }</pre>
@@ -105,7 +92,7 @@ public interface PageAssertions {
/**
* Ensures the page has the given title.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page).hasTitle("Playwright");
* }</pre>
@@ -117,7 +104,7 @@ public interface PageAssertions {
/**
* Ensures the page has the given title.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page).hasTitle("Playwright");
* }</pre>
@@ -131,7 +118,7 @@ public interface PageAssertions {
/**
* Ensures the page has the given title.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page).hasTitle("Playwright");
* }</pre>
@@ -143,7 +130,7 @@ public interface PageAssertions {
/**
* Ensures the page is navigated to the given URL.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page).hasURL(".com");
* }</pre>
@@ -157,7 +144,7 @@ public interface PageAssertions {
/**
* Ensures the page is navigated to the given URL.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page).hasURL(".com");
* }</pre>
@@ -169,7 +156,7 @@ public interface PageAssertions {
/**
* Ensures the page is navigated to the given URL.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page).hasURL(".com");
* }</pre>
@@ -183,7 +170,7 @@ public interface PageAssertions {
/**
* Ensures the page is navigated to the given URL.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* assertThat(page).hasURL(".com");
* }</pre>
@@ -54,7 +54,7 @@ public interface PlaywrightAssertions {
/**
* Creates a {@code APIResponseAssertions} object for the given {@code APIResponse}.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* PlaywrightAssertions.assertThat(response).isOK();
* }</pre>
@@ -69,7 +69,7 @@ public interface PlaywrightAssertions {
/**
* Creates a {@code LocatorAssertions} object for the given {@code Locator}.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* PlaywrightAssertions.assertThat(locator).isVisible();
* }</pre>
@@ -84,7 +84,7 @@ public interface PlaywrightAssertions {
/**
* Creates a {@code PageAssertions} object for the given {@code Page}.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* PlaywrightAssertions.assertThat(page).hasTitle("News");
* }</pre>
@@ -99,7 +99,7 @@ public interface PlaywrightAssertions {
/**
* Changes default timeout for Playwright assertions from 5 seconds to the specified value.
*
* <p> <strong>Usage</strong>
* <p> **Usage**
* <pre>{@code
* PlaywrightAssertions.setDefaultAssertionTimeout(30_000);
* }</pre>
@@ -107,8 +107,8 @@ public interface PlaywrightAssertions {
* @param timeout Timeout in milliseconds.
* @since v1.25
*/
static void setDefaultAssertionTimeout(double timeout) {
AssertionsTimeout.setDefaultTimeout(timeout);
static void setDefaultAssertionTimeout(double milliseconds) {
AssertionsTimeout.setDefaultTimeout(milliseconds);
}
}
@@ -17,6 +17,7 @@
package com.microsoft.playwright.impl;
import com.google.gson.*;
import com.google.gson.stream.JsonReader;
import com.microsoft.playwright.APIRequestContext;
import com.microsoft.playwright.APIResponse;
import com.microsoft.playwright.PlaywrightException;
@@ -25,11 +26,11 @@ import com.microsoft.playwright.options.FilePayload;
import com.microsoft.playwright.options.RequestOptions;
import java.io.File;
import java.io.StringReader;
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.*;
@@ -87,7 +88,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.entrySet()));
params.add("params", toNameValueArray(queryParams));
}
if (options.method != null) {
params.addProperty("method", options.method);
@@ -150,9 +151,9 @@ class APIRequestContextImpl extends ChannelOwner implements APIRequestContext {
return false;
}
private static JsonArray serializeMultipartData(List<? extends Map.Entry<String, Object>> data) {
private static JsonArray serializeMultipartData(Map<String, Object> data) {
JsonArray result = new JsonArray();
for (Map.Entry<String, ?> e : data) {
for (Map.Entry<String, Object> e : data.entrySet()) {
FilePayload filePayload = null;
if (e.getValue() instanceof FilePayload) {
filePayload = (FilePayload) e.getValue();
@@ -20,7 +20,6 @@ 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;
@@ -92,17 +91,4 @@ 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;
}
}
}
@@ -37,7 +37,6 @@ 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 java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.readAllBytes;
import static java.util.Arrays.asList;
@@ -47,8 +46,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
private final TracingImpl tracing;
private final APIRequestContextImpl request;
final List<PageImpl> pages = new ArrayList<>();
final List<PageImpl> backgroundPages = new ArrayList<>();
final Router routes = new Router();
private boolean closeWasCalled;
private final WaitableEvent<EventType, ?> closePromise;
@@ -83,7 +80,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
}
enum EventType {
BACKGROUNDPAGE,
CLOSE,
CONSOLE,
DIALOG,
@@ -131,16 +127,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
return null;
}
@Override
public void onBackgroundPage(Consumer<Page> handler) {
listeners.add(EventType.BACKGROUNDPAGE, handler);
}
@Override
public void offBackgroundPage(Consumer<Page> handler) {
listeners.remove(EventType.BACKGROUNDPAGE, handler);
}
@Override
public void onClose(Consumer<BrowserContext> handler) {
listeners.add(EventType.CLOSE, handler);
@@ -337,11 +323,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
});
}
@Override
public List<Page> backgroundPages() {
return new ArrayList<>(backgroundPages);
}
private void addInitScriptImpl(String script) {
JsonObject params = new JsonObject();
params.addProperty("source", script);
@@ -354,29 +335,8 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
}
@Override
public void clearCookies(ClearCookiesOptions options) {
withLogging("BrowserContext.clearCookies", () -> clearCookiesImpl(options));
}
private void clearCookiesImpl(ClearCookiesOptions options) {
if (options == null) {
options = new ClearCookiesOptions();
}
JsonObject params = new JsonObject();
setStringOrRegex(params, "name", options.name);
setStringOrRegex(params, "domain", options.domain);
setStringOrRegex(params, "path", options.path);
sendMessage("clearCookies", params);
}
private static void setStringOrRegex(JsonObject params, String name, Object value) {
if (value instanceof String) {
params.addProperty(name, (String) value);
} else if (value instanceof Pattern) {
Pattern pattern = (Pattern) value;
params.addProperty(name + "RegexSource", pattern.pattern());
params.addProperty(name + "RegexFlags", toJsRegexFlags(pattern));
}
public void clearCookies() {
withLogging("BrowserContext.clearCookies", () -> sendMessage("clearCookies"));
}
@Override
@@ -730,10 +690,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
if (page.opener() != null && !page.opener().isClosed()) {
page.opener().notifyPopup(page);
}
} else if ("backgroundPage".equals(event)) {
PageImpl page = connection.getExistingObject(params.getAsJsonObject("page").get("guid").getAsString());
backgroundPages.add(page);
listeners.notify(EventType.BACKGROUNDPAGE, page);
} else if ("bindingCall".equals(event)) {
BindingCall bindingCall = connection.getExistingObject(params.getAsJsonObject("binding").get("guid").getAsString());
BindingCallback binding = bindings.get(bindingCall.name());
@@ -35,10 +35,7 @@ public class CDPSessionImpl extends ChannelOwner implements CDPSession {
super.handleEvent(event, parameters);
if ("event".equals(event)) {
String method = parameters.get("method").getAsString();
JsonObject params = null;
if (parameters.has("params")) {
params = parameters.get("params").getAsJsonObject();
}
JsonObject params = parameters.get("params").getAsJsonObject();
listeners.notify(method, params);
}
}
@@ -20,93 +20,39 @@ import com.microsoft.playwright.options.FilePayload;
import com.microsoft.playwright.options.FormData;
import java.nio.file.Path;
import java.util.*;
import java.util.stream.Collectors;
import java.util.LinkedHashMap;
import java.util.Map;
public class FormDataImpl implements FormData {
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);
}
Map<String, Object> fields = new LinkedHashMap<>();
@Override
public FormData set(String name, String value) {
return setImpl(name, value);
fields.put(name, value);
return this;
}
@Override
public FormData set(String name, boolean value) {
return setImpl(name, value);
fields.put(name, value);
return this;
}
@Override
public FormData set(String name, int value) {
return setImpl(name, value);
fields.put(name, value);
return this;
}
@Override
public FormData set(String name, Path value) {
return setImpl(name, value);
fields.put(name, value);
return this;
}
@Override
public FormData set(String name, FilePayload 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));
fields.put(name, value);
return this;
}
}
@@ -133,9 +133,4 @@ class FrameLocatorImpl implements FrameLocator {
public FrameLocator nth(int index) {
return new FrameLocatorImpl(frame, frameSelector + " >> nth=" + index);
}
@Override
public Locator owner() {
return new LocatorImpl(frame, frameSelector);
}
}
@@ -41,12 +41,7 @@ public class JSHandleImpl extends ChannelOwner implements JSHandle {
@Override
public void dispose() {
withLogging("JSHandle.dispose", () -> {
try {
sendMessage("dispose");
} catch (TargetClosedError e) {
}
});
withLogging("JSHandle.dispose", () -> sendMessage("dispose"));
}
@Override
@@ -33,7 +33,6 @@ 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);
@@ -98,19 +97,13 @@ 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(closeReason);
throw new PlaywrightException("Browser has been closed");
}
}
}
@@ -18,7 +18,6 @@ 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;
@@ -83,36 +82,6 @@ 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();
@@ -237,13 +206,6 @@ 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();
@@ -404,4 +366,17 @@ 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;
}
}
}
@@ -39,10 +39,6 @@ class LocatorImpl implements Locator {
final FrameImpl frame;
final String selector;
LocatorImpl(FrameImpl frame, String frameSelector) {
this(frame, frameSelector, null);
}
public LocatorImpl(FrameImpl frame, String selector, LocatorOptions options) {
this.frame = frame;
if (options != null) {
@@ -207,11 +203,6 @@ class LocatorImpl implements Locator {
return frame.querySelectorAll(selector);
}
@Override
public FrameLocator contentFrame() {
return new FrameLocatorImpl(frame, selector);
}
@Override
public Object evaluate(String expression, Object arg, EvaluateOptions options) {
return withElement((h, o) -> h.evaluate(expression, arg), options);
@@ -624,20 +615,6 @@ 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,7 +21,6 @@ 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;
@@ -58,7 +57,6 @@ 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,34 +49,7 @@ 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, 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 final Map<Integer, Runnable> locatorHandlers = new HashMap<>();
private static final Map<EventType, String> eventSubscriptions() {
Map<EventType, String> result = new HashMap<>();
@@ -230,7 +203,6 @@ public class PageImpl extends ChannelOwner implements Page {
void didClose() {
isClosed = true;
browserContext.pages.remove(this);
browserContext.backgroundPages.remove(this);
listeners.notify(EventType.CLOSE, this);
}
@@ -557,58 +529,29 @@ public class PageImpl extends ChannelOwner implements Page {
}
@Override
public void addLocatorHandler(Locator locator, Consumer<Locator> handler, AddLocatorHandlerOptions options) {
public void addLocatorHandler(Locator locator, Runnable handler) {
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, new LocatorHandler(locator, handler, finalOptions.times));
locatorHandlers.put(uid, handler);
});
}
@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);
Runnable handler = locatorHandlers.get(uid);
if (handler != null) {
handler.run();
}
} finally {
JsonObject params = new JsonObject();
params.addProperty("uid", uid);
params.addProperty("remove", remove);
sendMessageAsync("resolveLocatorHandlerNoReply", params);
}
}
@@ -351,7 +351,7 @@ class Serialization {
throw new PlaywrightException("Value cannot be null");
}
}
return toNameValueArray(map.entrySet());
return toNameValueArray(map);
}
static void addHarUrlFilter(JsonObject options, Object urlFilter) {
@@ -364,9 +364,9 @@ class Serialization {
}
}
static JsonArray toNameValueArray(Iterable<? extends Map.Entry<String, ?>> collection) {
static JsonArray toNameValueArray(Map<String, ?> map) {
JsonArray array = new JsonArray();
for (Map.Entry<String, ?> e : collection) {
for (Map.Entry<String, ?> e : map.entrySet()) {
JsonObject item = new JsonObject();
item.addProperty("name", e.getKey());
if (e.getValue() instanceof FilePayload) {
@@ -24,10 +24,6 @@ public class TargetClosedError extends PlaywrightException {
}
public TargetClosedError(String message) {
this(message, null);
}
public TargetClosedError(String message, Throwable cause) {
super(message != null ? message : "Target page, context or browser has been closed", cause);
super(message != null ? message : "Target page, context or browser has been closed");
}
}
@@ -50,8 +50,6 @@ class WaitableResult<T> implements Waitable<T> {
if (exception != null) {
if (exception instanceof TimeoutError) {
throw new TimeoutError(exception.getMessage(), exception);
} if (exception instanceof TargetClosedError) {
throw new TargetClosedError(exception.getMessage(), exception);
}
throw new PlaywrightException(exception.getMessage(), exception);
}
@@ -43,20 +43,6 @@ 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;
@@ -16,10 +16,14 @@
package com.microsoft.playwright.junit;
import com.microsoft.playwright.impl.junit.*;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.junit.impl.*;
import org.junit.jupiter.api.extension.ExtendWith;
import java.lang.annotation.*;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* <strong>NOTE:</strong> this API is experimental and is subject to changes.
@@ -76,7 +80,6 @@ import java.lang.annotation.*;
PageExtension.class, APIRequestContextExtension.class})
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
public @interface UsePlaywright {
Class<? extends OptionsFactory> value() default DefaultOptions.class;
}
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.microsoft.playwright.impl.junit;
package com.microsoft.playwright.junit.impl;
import com.microsoft.playwright.APIRequest;
import com.microsoft.playwright.APIRequestContext;
@@ -23,7 +23,7 @@ import com.microsoft.playwright.impl.Utils;
import com.microsoft.playwright.junit.Options;
import org.junit.jupiter.api.extension.*;
import static com.microsoft.playwright.impl.junit.ExtensionUtils.isParameterSupported;
import static com.microsoft.playwright.junit.impl.ExtensionUtils.isParameterSupported;
public class APIRequestContextExtension implements ParameterResolver, BeforeEachCallback, AfterAllCallback {
private static final ThreadLocal<APIRequestContext> threadLocalAPIRequestContext = new ThreadLocal<>();
@@ -48,13 +48,7 @@ public class APIRequestContextExtension implements ParameterResolver, BeforeEach
return getOrCreateAPIRequestContext(extensionContext);
}
/**
* Returns the APIRequestContext that belongs to the current test. Will be created if it doesn't already exist.
* <strong>NOTE:</strong> this method is subject to change.
* @param extensionContext the context in which the current test or container is being executed.
* @return The APIRequestContext that belongs to the current test.
*/
public static APIRequestContext getOrCreateAPIRequestContext(ExtensionContext extensionContext) {
static APIRequestContext getOrCreateAPIRequestContext(ExtensionContext extensionContext) {
APIRequestContext apiRequestContext = threadLocalAPIRequestContext.get();
if (apiRequestContext != null) {
return apiRequestContext;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.microsoft.playwright.impl.junit;
package com.microsoft.playwright.junit.impl;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserContext;
@@ -24,7 +24,7 @@ import com.microsoft.playwright.impl.Utils;
import com.microsoft.playwright.junit.Options;
import org.junit.jupiter.api.extension.*;
import static com.microsoft.playwright.impl.junit.ExtensionUtils.*;
import static com.microsoft.playwright.junit.impl.ExtensionUtils.*;
public class BrowserContextExtension implements ParameterResolver, AfterEachCallback {
private static final ThreadLocal<BrowserContext> threadLocalBrowserContext = new ThreadLocal<>();
@@ -48,13 +48,7 @@ public class BrowserContextExtension implements ParameterResolver, AfterEachCall
return getOrCreateBrowserContext(extensionContext);
}
/**
* Returns the BrowserContext that belongs to the current test. Will be created if it doesn't already exist.
* <strong>NOTE:</strong> this method is subject to change.
* @param extensionContext the context in which the current test or container is being executed.
* @return The BrowserContext that belongs to the current test.
*/
public static BrowserContext getOrCreateBrowserContext(ExtensionContext extensionContext) {
static BrowserContext getOrCreateBrowserContext(ExtensionContext extensionContext) {
BrowserContext browserContext = threadLocalBrowserContext.get();
if (browserContext != null) {
return browserContext;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.microsoft.playwright.impl.junit;
package com.microsoft.playwright.junit.impl;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserType;
@@ -24,8 +24,7 @@ import com.microsoft.playwright.impl.Utils;
import com.microsoft.playwright.junit.Options;
import org.junit.jupiter.api.extension.*;
import static com.microsoft.playwright.impl.junit.ExtensionUtils.*;
import static com.microsoft.playwright.junit.impl.ExtensionUtils.isParameterSupported;
public class BrowserExtension implements ParameterResolver, AfterAllCallback {
private static final ThreadLocal<Browser> threadLocalBrowser = new ThreadLocal<>();
@@ -48,13 +47,7 @@ public class BrowserExtension implements ParameterResolver, AfterAllCallback {
return getOrCreateBrowser(extensionContext);
}
/**
* Returns the Browser that belongs to the current test. Will be created if it doesn't already exist.
* <strong>NOTE:</strong> this method is subject to change.
* @param extensionContext the context in which the current test or container is being executed.
* @return The Browser that belongs to the current test.
*/
public static Browser getOrCreateBrowser(ExtensionContext extensionContext) {
static Browser getOrCreateBrowser(ExtensionContext extensionContext) {
Browser browser = threadLocalBrowser.get();
if (browser != null) {
return browser;
@@ -62,7 +55,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,27 +66,12 @@ public class BrowserExtension implements ParameterResolver, AfterAllCallback {
browserType = getBrowserTypeForName(playwright, deviceDescriptor.defaultBrowserType);
}
}
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);
}
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":
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.microsoft.playwright.impl.junit;
package com.microsoft.playwright.junit.impl;
import com.microsoft.playwright.junit.Options;
import com.microsoft.playwright.junit.OptionsFactory;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.microsoft.playwright.impl.junit;
package com.microsoft.playwright.junit.impl;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.microsoft.playwright.impl.junit;
package com.microsoft.playwright.junit.impl;
import com.microsoft.playwright.Playwright;
import com.microsoft.playwright.junit.Options;
@@ -27,13 +27,11 @@ import static org.junit.platform.commons.support.AnnotationSupport.findAnnotatio
class ExtensionUtils {
static boolean hasUsePlaywrightAnnotation(ExtensionContext extensionContext) {
Class<?> outerClass = getOuterClass(extensionContext.getRequiredTestClass());
return AnnotationSupport.isAnnotated(outerClass, UsePlaywright.class);
return AnnotationSupport.isAnnotated(extensionContext.getTestClass(), UsePlaywright.class);
}
static UsePlaywright getUsePlaywrightAnnotation(ExtensionContext extensionContext) {
Class<?> topLevelClass = getOuterClass(extensionContext.getRequiredTestClass());
return findAnnotation(topLevelClass, UsePlaywright.class).get();
return findAnnotation(extensionContext.getTestClass(), UsePlaywright.class).get();
}
static boolean isClassHook(ExtensionContext extensionContext) {
@@ -51,13 +49,6 @@ class ExtensionUtils {
static void setTestIdAttribute(Playwright playwright, Options options) {
String testIdAttribute = options.testIdAttribute == null ? "data-testid" : options.testIdAttribute;
playwright.selectors().setTestIdAttribute(testIdAttribute);
}
private static Class<?> getOuterClass(Class<?> clazz) {
if (clazz.getDeclaringClass() == null) {
return clazz;
} else {
return getOuterClass(clazz.getDeclaringClass());
}
}
}
@@ -14,15 +14,16 @@
* limitations under the License.
*/
package com.microsoft.playwright.impl.junit;
package com.microsoft.playwright.junit.impl;
import com.microsoft.playwright.PlaywrightException;
import com.microsoft.playwright.junit.Options;
import com.microsoft.playwright.junit.OptionsFactory;
import com.microsoft.playwright.junit.UsePlaywright;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import static com.microsoft.playwright.impl.junit.ExtensionUtils.*;
import static com.microsoft.playwright.junit.impl.ExtensionUtils.getUsePlaywrightAnnotation;
public class OptionsExtension implements AfterAllCallback {
private static final ThreadLocal<Options> threadLocalOptions = new ThreadLocal<>();
@@ -14,13 +14,14 @@
* limitations under the License.
*/
package com.microsoft.playwright.impl.junit;
package com.microsoft.playwright.junit.impl;
import com.microsoft.playwright.BrowserContext;
import com.microsoft.playwright.Page;
import org.junit.jupiter.api.extension.*;
import static com.microsoft.playwright.impl.junit.ExtensionUtils.*;
import static com.microsoft.playwright.junit.impl.ExtensionUtils.isClassHook;
import static com.microsoft.playwright.junit.impl.ExtensionUtils.isParameterSupported;
public class PageExtension implements ParameterResolver, AfterEachCallback {
private static final ThreadLocal<Page> threadLocalPage = new ThreadLocal<>();
@@ -44,13 +45,7 @@ public class PageExtension implements ParameterResolver, AfterEachCallback {
return getOrCreatePage(extensionContext);
}
/**
* Returns the Page that belongs to the current test. Will be created if it doesn't already exist.
* <strong>NOTE:</strong> this method is subject to change.
* @param extensionContext the context in which the current test or container is being executed.
* @return The Page that belongs to the current test.
*/
public static Page getOrCreatePage(ExtensionContext extensionContext) {
static Page getOrCreatePage(ExtensionContext extensionContext) {
Page page = threadLocalPage.get();
if (page != null) {
return page;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.microsoft.playwright.impl.junit;
package com.microsoft.playwright.junit.impl;
import com.microsoft.playwright.Playwright;
import com.microsoft.playwright.junit.Options;
@@ -27,7 +27,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static com.microsoft.playwright.impl.junit.ExtensionUtils.*;
import static com.microsoft.playwright.junit.impl.ExtensionUtils.isParameterSupported;
import static com.microsoft.playwright.junit.impl.ExtensionUtils.setTestIdAttribute;
public class PlaywrightExtension implements ParameterResolver {
private static final ThreadLocal<Playwright> threadLocalPlaywright = new ThreadLocal<>();
@@ -78,13 +79,7 @@ public class PlaywrightExtension implements ParameterResolver {
return getOrCreatePlaywright(extensionContext);
}
/**
* Returns the Playwright that belongs to the current test. Will be created if it doesn't already exist.
* <strong>NOTE:</strong> this method is subject to change.
* @param extensionContext the context in which the current test or container is being executed.
* @return The Playwright that belongs to the current test.
*/
public static Playwright getOrCreatePlaywright(ExtensionContext extensionContext) {
static Playwright getOrCreatePlaywright(ExtensionContext extensionContext) {
Playwright playwright = threadLocalPlaywright.get();
if (playwright != null) {
return playwright;
@@ -32,141 +32,6 @@ 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}.
*
@@ -186,7 +51,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>
@@ -207,7 +72,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>
@@ -228,7 +93,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>
@@ -249,7 +114,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>
@@ -270,7 +135,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>
@@ -19,7 +19,6 @@ package com.microsoft.playwright.options;
public enum KeyboardModifier {
ALT,
CONTROL,
CONTROLORMETA,
META,
SHIFT
}
@@ -29,7 +29,7 @@ import com.microsoft.playwright.impl.RequestOptionsImpl;
* .setData("My data"));
* }</pre>
*
* <p> <strong>Uploading html form data</strong>
* <p> **Uploading html form data**
*
* <p> {@code FormData} class can be used to send a form to the server, by default the request will use {@code
* application/x-www-form-urlencoded} encoding:
@@ -16,8 +16,6 @@
package com.microsoft.playwright;
import com.microsoft.playwright.junit.FixtureTest;
import com.microsoft.playwright.junit.UsePlaywright;
import org.junit.jupiter.api.Test;
import org.opentest4j.AssertionFailedError;
@@ -27,23 +25,21 @@ import java.io.Writer;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
@FixtureTest
@UsePlaywright(TestOptionsFactories.BasicOptionsFactory.class)
public class TestAPIResponseAssertions {
public class TestAPIResponseAssertions extends TestBase {
@Test
void passWithResponse(Page page, Server server) {
void passWithResponse() {
APIResponse res = page.request().get(server.EMPTY_PAGE);
assertThat(res).isOK();
}
@Test
void passWithNot(Page page, Server server) {
void passWithNot() {
APIResponse res = page.request().get(server.PREFIX + "/unknown");
assertThat(res).not().isOK();
}
@Test
void fail(Page page, Server server) {
void fail() {
APIResponse res = page.request().get(server.PREFIX + "/unknown");
AssertionFailedError e = assertThrows(AssertionFailedError.class, () -> assertThat(res).isOK());
assertTrue(e.getMessage().contains("→ GET " + server.PREFIX + "/unknown"), "Actual error: " + e.toString());
@@ -51,14 +47,14 @@ public class TestAPIResponseAssertions {
}
@Test
void shouldPrintResponseTextIfIdOkFails(Page page, Server server) {
void shouldPrintResponseTextIfIdOkFails() {
APIResponse res = page.request().get(server.PREFIX + "/unknown");
AssertionFailedError e = assertThrows(AssertionFailedError.class, () -> assertThat(res).isOK());
assertTrue(e.getMessage().contains("File not found"), "Actual error: " + e.toString());
}
@Test
void shouldOnlyPrintResponseWithTextContentTypeIfIsOkFails(Page page, Server server) {
void shouldOnlyPrintResponseWithTextContentTypeIfIsOkFails() {
{
server.setRoute("/text-content-type", exchange -> {
exchange.getResponseHeaders().set("Content-type", "text/plain");
@@ -17,8 +17,6 @@
package com.microsoft.playwright;
import com.microsoft.playwright.assertions.LocatorAssertions;
import com.microsoft.playwright.junit.FixtureTest;
import com.microsoft.playwright.junit.UsePlaywright;
import org.junit.jupiter.api.Test;
import org.opentest4j.AssertionFailedError;
@@ -26,11 +24,9 @@ import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertTha
import static org.junit.jupiter.api.Assertions.*;
// Copied from expect-misc.spec.ts > toBeInViewport
@FixtureTest
@UsePlaywright(TestOptionsFactories.BasicOptionsFactory.class)
public class TestAssertThatIsInViewport {
public class TestAssertThatIsInViewport extends TestBase {
@Test
void shouldWork(Page page) {
void shouldWork() {
page.setContent("<div id=big style=\"height: 10000px;\"></div>\n" +
" <div id=small>foo</div>");
assertThat(page.locator("#big")).isInViewport();
@@ -41,7 +37,7 @@ public class TestAssertThatIsInViewport {
}
@Test
void shouldRespectRatioOption(Page page) {
void shouldRespectRatioOption() {
page.setContent("<style>body, div, html { padding: 0; margin: 0; }</style>\n" +
" <div id=big style=\"height: 400vh;\"></div>");
assertThat(page.locator("div")).isInViewport();
@@ -59,14 +55,14 @@ public class TestAssertThatIsInViewport {
}
@Test
void shouldHaveGoodStack(Page page) {
void shouldHaveGoodStack() {
AssertionFailedError error = assertThrows(AssertionFailedError.class, () -> assertThat(page.locator("body")).not().isInViewport(new LocatorAssertions.IsInViewportOptions().setTimeout(100)));
assertNotNull(error);
assertTrue(error.getMessage().contains("Locator expected not to be in viewport"), error.getMessage());
}
@Test
void shouldReportIntersectionEvenIfFullyCoveredByOtherElement(Page page) {
void shouldReportIntersectionEvenIfFullyCoveredByOtherElement() {
page.setContent("<h1>hello</h1>\n" +
" <div style=\"position: relative; height: 10000px; top: -5000px;></div>");
assertThat(page.locator("h1")).isInViewport();
@@ -16,15 +16,11 @@
package com.microsoft.playwright;
import com.microsoft.playwright.junit.FixtureTest;
import com.microsoft.playwright.junit.UsePlaywright;
import org.junit.jupiter.api.Test;
@FixtureTest
@UsePlaywright(TestOptionsFactories.BasicOptionsFactory.class)
public class TestBeforeunload {
public class TestBeforeunload extends TestBase {
@Test
void shouldBeAbleToNavigateAwayFromPageWithBeforeunload(Page page, Server server) {
void shouldBeAbleToNavigateAwayFromPageWithBeforeunload() {
page.navigate(server.PREFIX + "/beforeunload.html");
// We have to interact with a page so that "beforeunload" handlers
// fire.
@@ -18,7 +18,6 @@ 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;
@@ -26,9 +25,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 {
@@ -74,8 +73,8 @@ public class TestBrowser1 {
}
@Test
void shouldReturnBrowserType(BrowserType browserType, Browser browser) {
assertEquals(browserType, browser.browserType());
void shouldReturnBrowserType(Playwright playwright, Browser browser) {
assertEquals(getBrowserTypeFromEnv(playwright), browser.browserType());
}
@Test
@@ -16,7 +16,6 @@
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;
@@ -29,7 +28,6 @@ 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 {
@@ -72,11 +70,12 @@ public class TestBrowser2 {
}
@Test
void shouldSupportDeprecatedChannelEnum(BrowserType browserType) {
void shouldSupportDeprecatedChannelEnum(Playwright playwright) {
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();
@@ -16,8 +16,6 @@
package com.microsoft.playwright;
import com.microsoft.playwright.junit.FixtureTest;
import com.microsoft.playwright.junit.UsePlaywright;
import com.microsoft.playwright.options.Cookie;
import org.junit.jupiter.api.Test;
@@ -26,18 +24,14 @@ 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.TestOptionsFactories.isFirefox;
import static com.microsoft.playwright.Utils.assertJsonEquals;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static org.junit.jupiter.api.Assertions.*;
@FixtureTest
@UsePlaywright(TestOptionsFactories.BasicOptionsFactory.class)
public class TestBrowserContextAddCookies {
public class TestBrowserContextAddCookies extends TestBase {
@Test
void shouldWork(Page page, Server server, BrowserContext context) {
void shouldWork() {
page.navigate(server.EMPTY_PAGE);
context.addCookies(asList(
new Cookie("password", "123456").setUrl(server.EMPTY_PAGE)));
@@ -53,7 +47,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldRoundtripCookie(Page page, Server server, BrowserContext context) {
void shouldRoundtripCookie() {
page.navigate(server.EMPTY_PAGE);
// @see https://en.wikipedia.org/wiki/Year_2038_problem
Object documentCookie = page.evaluate("() => {\n" +
@@ -71,7 +65,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldSendCookieHeader(Server server, BrowserContext context) throws ExecutionException, InterruptedException {
void shouldSendCookieHeader() throws ExecutionException, InterruptedException {
Future<Server.Request> request = server.futureRequest("/empty.html");
context.addCookies(asList(
new Cookie("cookie", "value").setUrl(server.EMPTY_PAGE)));
@@ -82,7 +76,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldIsolateCookiesInBrowserContexts(Browser browser, BrowserContext context, Server server) {
void shouldIsolateCookiesInBrowserContexts() {
BrowserContext anotherContext = browser.newContext();
context.addCookies(asList(
new Cookie("isolatecookie", "page1value").setUrl(server.EMPTY_PAGE)));
@@ -100,7 +94,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldIsolateSessionCookies(Server server, BrowserContext context, Browser browser) {
void shouldIsolateSessionCookies() {
server.setRoute("/setcookie.html", exchange -> {
exchange.getResponseHeaders().add("Set-Cookie", "session=value");
exchange.sendResponseHeaders(200, 0);
@@ -128,7 +122,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldIsolatePersistentCookies(Server server, BrowserContext context, Browser browser) {
void shouldIsolatePersistentCookies() {
server.setRoute("/setcookie.html", exchange -> {
exchange.getResponseHeaders().add("Set-Cookie", "persistent=persistent-value; max-age=3600");
exchange.sendResponseHeaders(200, 0);
@@ -153,7 +147,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldIsolateSendCookieHeader(BrowserContext context, Server server, Browser browser) throws ExecutionException, InterruptedException {
void shouldIsolateSendCookieHeader() throws ExecutionException, InterruptedException {
context.addCookies(asList(
new Cookie("sendcookie", "value").setUrl(server.EMPTY_PAGE)));
{
@@ -164,20 +158,19 @@ public class TestBrowserContextAddCookies {
assertEquals(asList("sendcookie=value"), cookies);
}
{
BrowserContext newContext = browser.newContext();
Page page = newContext.newPage();
BrowserContext context = browser.newContext();
Page page = context.newPage();
Future<Server.Request> request = server.futureRequest("/empty.html");
page.navigate(server.EMPTY_PAGE);
List<String> cookies = request.get().headers.get("cookie");
assertNull(cookies);
newContext.close();
context.close();
}
}
@Test
void shouldIsolateCookiesBetweenLaunches(Playwright playwright, Server server) {
void shouldIsolateCookiesBetweenLaunches() {
// test.slow();
// TODO: const browser1 = browserType.launch(browserOptions);
BrowserType browserType = Utils.getBrowserTypeFromEnv(playwright);
Browser browser1 = browserType.launch();
BrowserContext context1 = browser1.newContext();
context1.addCookies(asList(new Cookie("cookie-in-context-1", "value")
@@ -194,7 +187,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldSetMultipleCookies(Page page, BrowserContext context, Server server) {
void shouldSetMultipleCookies() {
page.navigate(server.EMPTY_PAGE);
context.addCookies(asList(
new Cookie("multiple-1", "123456").setUrl(server.EMPTY_PAGE),
@@ -207,7 +200,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldHaveExpiresSetTo1ForSessionCookies(BrowserContext context, Server server) {
void shouldHaveExpiresSetTo1ForSessionCookies() {
context.addCookies(asList(
new Cookie("expires", "123456").setUrl(server.EMPTY_PAGE)));
List<Cookie> cookies = context.cookies();
@@ -215,7 +208,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldSetCookieWithReasonableDefaults(BrowserContext context, Server server) {
void shouldSetCookieWithReasonableDefaults() {
context.addCookies(asList(
new Cookie("defaults", "123456").setUrl(server.EMPTY_PAGE)));
List<Cookie> cookies = context.cookies();
@@ -232,7 +225,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldSetACookieWithAPath(Page page, Server server, BrowserContext context) {
void shouldSetACookieWithAPath() {
page.navigate(server.PREFIX + "/grid.html");
context.addCookies(asList(new Cookie("gridcookie", "GRID")
.setDomain("localhost")
@@ -256,7 +249,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldNotSetACookieWithBlankPageURL(BrowserContext context, Server server) {
void shouldNotSetACookieWithBlankPageURL() {
PlaywrightException e = assertThrows(PlaywrightException.class, () -> context.addCookies(asList(
new Cookie("example-cookie", "best").setUrl(server.EMPTY_PAGE),
new Cookie("example-cookie-blank", "best").setUrl("about:blank")
@@ -265,7 +258,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldNotSetACookieOnADataURLPage(BrowserContext context) {
void shouldNotSetACookieOnADataURLPage() {
PlaywrightException e = assertThrows(PlaywrightException.class, () -> context.addCookies(asList(
new Cookie("example-cookie", "best").setUrl("data:,Hello%2C%20World!")
)));
@@ -273,7 +266,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldDefaultToSettingSecureCookieForHTTPSWebsites(Page page, Server server, BrowserContext context) {
void shouldDefaultToSettingSecureCookieForHTTPSWebsites() {
page.navigate(server.EMPTY_PAGE);
String SECURE_URL = "https://example.com";
context.addCookies(asList(
@@ -285,7 +278,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldBeAbleToSetUnsecureCookieForHTTPWebsite(Page page, Server server, BrowserContext context) {
void shouldBeAbleToSetUnsecureCookieForHTTPWebsite() {
page.navigate(server.EMPTY_PAGE);
String HTTP_URL = "http://example.com";
context.addCookies(asList(
@@ -297,7 +290,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldSetACookieOnADifferentDomain(Page page, Server server, BrowserContext context) {
void shouldSetACookieOnADifferentDomain() {
page.navigate(server.EMPTY_PAGE);
context.addCookies(asList(
new Cookie("example-cookie", "best").setUrl("https://www.example.com")
@@ -316,7 +309,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldSetCookiesForAFrame(Page page, Server server, BrowserContext context) {
void shouldSetCookiesForAFrame() {
page.navigate(server.EMPTY_PAGE);
context.addCookies(asList(
new Cookie("frame-cookie", "value").setUrl(server.PREFIX)
@@ -334,7 +327,7 @@ public class TestBrowserContextAddCookies {
}
@Test
void shouldNotBlockThirdPartyCookies(Page page, Server server, BrowserContext context) {
void shouldNotBlockThirdPartyCookies() {
page.navigate(server.EMPTY_PAGE);
page.evaluate("src => {\n" +
" let fulfill;\n" +
@@ -16,8 +16,6 @@
package com.microsoft.playwright;
import com.microsoft.playwright.junit.FixtureTest;
import com.microsoft.playwright.junit.UsePlaywright;
import org.junit.jupiter.api.Test;
import java.net.MalformedURLException;
@@ -25,11 +23,9 @@ import java.net.MalformedURLException;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@FixtureTest
@UsePlaywright(TestOptionsFactories.BasicOptionsFactory.class)
public class TestBrowserContextBaseUrl {
public class TestBrowserContextBaseUrl extends TestBase {
@Test
void shouldConstructANewURLWhenABaseURLInBrowserNewContextIsPassedToPageGoto(Browser browser, Server server) {
void shouldConstructANewURLWhenABaseURLInBrowserNewContextIsPassedToPageGoto() throws MalformedURLException {
try (BrowserContext context = browser.newContext(new Browser.NewContextOptions().setBaseURL(server.PREFIX))) {
Page page = context.newPage();
assertEquals(server.EMPTY_PAGE, page.navigate("/empty.html").url());
@@ -37,13 +33,13 @@ public class TestBrowserContextBaseUrl {
}
@Test
void shouldConstructANewURLWhenABaseURLInBrowserNewPageIsPassedToPageGoto(Browser browser, Server server) {
void shouldConstructANewURLWhenABaseURLInBrowserNewPageIsPassedToPageGoto() {
try (Page page = browser.newPage(new Browser.NewPageOptions().setBaseURL(server.PREFIX))) {
assertEquals(server.EMPTY_PAGE, page.navigate("/empty.html").url());
}
}
@Test
void shouldConstructTheURLsCorrectlyWhenABaseURLWithoutATrailingSlashInBrowserNewPageIsPassedToPageGoto(Browser browser, Server server) {
void shouldConstructTheURLsCorrectlyWhenABaseURLWithoutATrailingSlashInBrowserNewPageIsPassedToPageGoto() {
try (Page page = browser.newPage(new Browser.NewPageOptions().setBaseURL(server.PREFIX + "/url-construction"))) {
assertEquals(server.PREFIX + "/mypage.html", page.navigate("mypage.html").url());
assertEquals(server.PREFIX + "/mypage.html", page.navigate("./mypage.html").url());
@@ -52,7 +48,7 @@ public class TestBrowserContextBaseUrl {
}
@Test
void shouldConstructTheURLsCorrectlyWhenABaseURLWithATrailingSlashInBrowserNewPageIsPassedToPageGoto(Browser browser, Server server) {
void shouldConstructTheURLsCorrectlyWhenABaseURLWithATrailingSlashInBrowserNewPageIsPassedToPageGoto() {
try (Page page = browser.newPage(new Browser.NewPageOptions().setBaseURL(server.PREFIX + "/url-construction/"))) {
assertEquals(server.PREFIX + "/url-construction/mypage.html", page.navigate("mypage.html").url());
assertEquals(server.PREFIX + "/url-construction/mypage.html", page.navigate("./mypage.html").url());
@@ -63,7 +59,7 @@ public class TestBrowserContextBaseUrl {
}
@Test
void shouldNotConstructANewURLWhenValidURLsArePassed(Browser browser, Server server) {
void shouldNotConstructANewURLWhenValidURLsArePassed() {
try (Page page = browser.newPage(new Browser.NewPageOptions().setBaseURL("http://microsoft.com"))) {
assertEquals(server.EMPTY_PAGE, page.navigate(server.EMPTY_PAGE).url());
@@ -76,7 +72,7 @@ public class TestBrowserContextBaseUrl {
}
@Test
void shouldBeAbleToMatchAURLRelativeToItsGivenURLWithUrlMatcher(Browser browser, Server server) {
void shouldBeAbleToMatchAURLRelativeToItsGivenURLWithUrlMatcher() {
try (Page page = browser.newPage(new Browser.NewPageOptions().setBaseURL(server.PREFIX + "/foobar/"))) {
page.navigate("/kek/index.html");
page.waitForURL("/kek/index.html");
@@ -16,37 +16,32 @@
package com.microsoft.playwright;
import com.microsoft.playwright.junit.FixtureTest;
import com.microsoft.playwright.junit.UsePlaywright;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
import static com.microsoft.playwright.TestOptionsFactories.isFirefox;
import static com.microsoft.playwright.TestOptionsFactories.isWebKit;
import static com.microsoft.playwright.Utils.verifyViewport;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.*;
@FixtureTest
@UsePlaywright(TestOptionsFactories.BasicOptionsFactory.class)
public class TestBrowserContextBasic {
public class TestBrowserContextBasic extends TestBase {
@Test
void shouldCreateNewContext(Browser browser) {
assertEquals(0, browser.contexts().size());
BrowserContext context = browser.newContext();
void shouldCreateNewContext() {
assertEquals(1, browser.contexts().size());
BrowserContext context = browser.newContext();
assertEquals(2, browser.contexts().size());
assertTrue(browser.contexts().indexOf(context) != -1);
assertEquals(context.browser(), browser);
context.close();
assertEquals(0, browser.contexts().size());
assertEquals(1, browser.contexts().size());
assertEquals(context.browser(), browser);
}
@Test
void windowOpenShouldUseParentTabContext(Browser browser, Server server) {
void windowOpenShouldUseParentTabContext() {
BrowserContext context = browser.newContext();
Page page = context.newPage();
page.navigate(server.EMPTY_PAGE);
@@ -56,7 +51,7 @@ public class TestBrowserContextBasic {
}
@Test
void shouldIsolateLocalStorageAndCookies(Browser browser, Server server) {
void shouldIsolateLocalStorageAndCookies() {
// Create two incognito contexts.
BrowserContext context1 = browser.newContext();
BrowserContext context2 = browser.newContext();
@@ -97,11 +92,11 @@ public class TestBrowserContextBasic {
context1.close();
context2.close();
assertEquals(0, browser.contexts().size());
assertEquals(1, browser.contexts().size());
}
@Test
void shouldPropagateDefaultViewportToThePage(Browser browser) {
void shouldPropagateDefaultViewportToThePage() {
BrowserContext context = browser.newContext(new Browser.NewContextOptions().setViewportSize(456, 789));
Page page = context.newPage();
verifyViewport(page, 456, 789);
@@ -113,7 +108,7 @@ public class TestBrowserContextBasic {
}
@Test
void shouldRespectDeviceScaleFactor(Browser browser) {
void shouldRespectDeviceScaleFactor() {
BrowserContext context = browser.newContext(new Browser.NewContextOptions().setDeviceScaleFactor(3.0));
Page page = context.newPage();
assertEquals(3, page.evaluate("window.devicePixelRatio"));
@@ -122,7 +117,7 @@ public class TestBrowserContextBasic {
@Test
void shouldNotAllowDeviceScaleFactorWithNullViewport(Browser browser) {
void shouldNotAllowDeviceScaleFactorWithNullViewport() {
PlaywrightException e = assertThrows(PlaywrightException.class, () -> {
browser.newContext(new Browser.NewContextOptions().setDeviceScaleFactor(1.0).setViewportSize(null));
});
@@ -130,7 +125,7 @@ public class TestBrowserContextBasic {
}
@Test
void shouldNotAllowIsMobileWithNullViewport(Browser browser) {
void shouldNotAllowIsMobileWithNullViewport() {
PlaywrightException e = assertThrows(PlaywrightException.class, () -> {
browser.newContext(new Browser.NewContextOptions().setIsMobile(true).setViewportSize(null));
});
@@ -138,13 +133,13 @@ public class TestBrowserContextBasic {
}
@Test
void closeShouldWorkForEmptyContext(Browser browser) {
void closeShouldWorkForEmptyContext() {
BrowserContext context = browser.newContext();
context.close();
}
@Test
void closeShouldAbortFutureEvent(Browser browser) {
void closeShouldAbortFutureEvent() {
BrowserContext context = browser.newContext();
PlaywrightException e = assertThrows(PlaywrightException.class, () -> {
context.waitForPage(() -> context.close());
@@ -153,7 +148,7 @@ public class TestBrowserContextBasic {
}
@Test
void closeShouldBeCallableTwice(Browser browser) {
void closeShouldBeCallableTwice() {
BrowserContext context = browser.newContext();
context.close();
context.close();
@@ -161,7 +156,7 @@ public class TestBrowserContextBasic {
}
@Test
void shouldNotReportFramelessPagesOnError(Browser browser, Server server) {
void shouldNotReportFramelessPagesOnError() {
BrowserContext context = browser.newContext();
Page page = context.newPage();
server.setRoute("/empty.html", exchange -> {
@@ -186,7 +181,7 @@ public class TestBrowserContextBasic {
}
@Test
void shouldReturnAllOfThePages(Browser browser) {
void shouldReturnAllOfThePages() {
BrowserContext context = browser.newContext();
Page page = context.newPage();
Page second = context.newPage();
@@ -198,7 +193,7 @@ public class TestBrowserContextBasic {
}
@Test
void shouldCloseAllBelongingPagesOnceClosingContext(Browser browser) {
void shouldCloseAllBelongingPagesOnceClosingContext() {
BrowserContext context = browser.newContext();
context.newPage();
assertEquals(1, context.pages().size());
@@ -207,7 +202,7 @@ public class TestBrowserContextBasic {
}
@Test
void shouldDisableJavascript(Browser browser) {
void shouldDisableJavascript() {
{
BrowserContext context = browser.newContext(new Browser.NewContextOptions().setJavaScriptEnabled(false));
Page page = context.newPage();
@@ -230,7 +225,7 @@ public class TestBrowserContextBasic {
}
@Test
void shouldBeAbleToNavigateAfterDisablingJavascript(Browser browser, Server server) {
void shouldBeAbleToNavigateAfterDisablingJavascript() {
BrowserContext context = browser.newContext(new Browser.NewContextOptions().setJavaScriptEnabled(false));
Page page = context.newPage();
page.navigate(server.EMPTY_PAGE);
@@ -238,7 +233,7 @@ public class TestBrowserContextBasic {
}
@Test
void shouldWorkWithOfflineOption(Browser browser, Server server) {
void shouldWorkWithOfflineOption() {
BrowserContext context = browser.newContext(new Browser.NewContextOptions().setOffline(true));
Page page = context.newPage();
if (isFirefox()) {
@@ -259,7 +254,7 @@ public class TestBrowserContextBasic {
}
@Test
void shouldEmulateNavigatorOnLine(Browser browser) {
void shouldEmulateNavigatorOnLine() {
BrowserContext context = browser.newContext();
Page page = context.newPage();
assertEquals(true, page.evaluate("() => window.navigator.onLine"));
@@ -271,7 +266,7 @@ public class TestBrowserContextBasic {
}
@Test
void shouldWaitForCondition(Page page, BrowserContext context) {
void shouldWaitForCondition() {
List<String> messages = new ArrayList<>();
page.onConsoleMessage(m -> messages.add(m.text()));
page.evaluate("setTimeout(() => {\n" +
@@ -283,14 +278,13 @@ public class TestBrowserContextBasic {
}
@Test
void waitForConditionTimeout(BrowserContext context) {
void waitForConditionTimeout() {
PlaywrightException e = assertThrows(PlaywrightException.class,
() -> context.waitForCondition(() -> false, new BrowserContext.WaitForConditionOptions().setTimeout(100)));
assertTrue(e.getMessage().contains("Timeout"), e.getMessage());
}
@Test
void waitForConditionPageClosed(BrowserContext context) {
void waitForConditionPageClosed() {
PlaywrightException e = assertThrows(PlaywrightException.class,
() -> context.waitForCondition(() -> {
context.close();
@@ -300,7 +294,7 @@ public class TestBrowserContextBasic {
}
@Test
void shouldPropagateCloseReasonToPendingActions(Browser browser) {
void shouldPropagateCloseReasonToPendingActions() {
BrowserContext context = browser.newContext();
Page page = context.newPage();
PlaywrightException e = assertThrows(PlaywrightException.class, () -> page.waitForPopup(() -> {
@@ -16,25 +16,16 @@
package com.microsoft.playwright;
import com.microsoft.playwright.junit.FixtureTest;
import com.microsoft.playwright.junit.UsePlaywright;
import com.microsoft.playwright.options.Cookie;
import org.junit.jupiter.api.Test;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.regex.Pattern;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static org.junit.jupiter.api.Assertions.assertEquals;
@FixtureTest
@UsePlaywright(TestOptionsFactories.BasicOptionsFactory.class)
public class TestBrowserContextClearCookies {
public class TestBrowserContextClearCookies extends TestBase {
@Test
void shouldClearCookies(Page page, BrowserContext context, Server server) {
void shouldClearCookies() {
page.navigate(server.EMPTY_PAGE);
context.addCookies(asList(
new Cookie("cookie1", "1").setUrl(server.EMPTY_PAGE)));
@@ -46,7 +37,7 @@ public class TestBrowserContextClearCookies {
}
@Test
void shouldIsolateCookiesWhenClearing(BrowserContext context, Browser browser, Server server) {
void shouldIsolateCookiesWhenClearing() {
BrowserContext anotherContext = browser.newContext();
context.addCookies(asList(
new Cookie("page1cookie", "page1value").setUrl(server.EMPTY_PAGE)));
@@ -65,77 +56,4 @@ public class TestBrowserContextClearCookies {
assertEquals(0, (anotherContext.cookies()).size());
anotherContext.close();
}
@Test
void shouldRemoveCookiesByName(Page page, BrowserContext context, Server server) throws MalformedURLException {
context.addCookies(Arrays.asList(
new Cookie("cookie1", "1").setDomain(new URL(server.PREFIX).getHost()).setPath("/"),
new Cookie("cookie2", "2").setDomain(new URL(server.PREFIX).getHost()).setPath("/")
));
page.navigate(server.PREFIX);
assertEquals("cookie1=1; cookie2=2", page.evaluate("document.cookie"));
context.clearCookies(new BrowserContext.ClearCookiesOptions().setName("cookie1"));
assertEquals("cookie2=2", page.evaluate("document.cookie"));
}
@Test
public void shouldRemoveCookiesByNameRegex(Page page, BrowserContext context, Server server) throws MalformedURLException {
context.addCookies(Arrays.asList(
new Cookie("cookie1", "1").setDomain(new URL(server.PREFIX).getHost()).setPath("/"),
new Cookie("cookie2", "2").setDomain(new URL(server.PREFIX).getHost()).setPath("/")
));
page.navigate(server.PREFIX);
assertEquals("cookie1=1; cookie2=2", page.evaluate("document.cookie"));
context.clearCookies(new BrowserContext.ClearCookiesOptions().setName(Pattern.compile("coo.*1")));
assertEquals("cookie2=2", page.evaluate("document.cookie"));
}
@Test
public void shouldRemoveCookiesByDomain(Page page, BrowserContext context, Server server) throws MalformedURLException {
context.addCookies(Arrays.asList(
new Cookie("cookie1", "1").setDomain(new URL(server.PREFIX).getHost()).setPath("/"),
new Cookie("cookie2", "2").setDomain(new URL(server.CROSS_PROCESS_PREFIX).getHost()).setPath("/")
));
page.navigate(server.PREFIX);
assertEquals("cookie1=1", page.evaluate("document.cookie"));
page.navigate(server.CROSS_PROCESS_PREFIX);
assertEquals("cookie2=2", page.evaluate("document.cookie"));
context.clearCookies(new BrowserContext.ClearCookiesOptions().setDomain(new URL(server.CROSS_PROCESS_PREFIX).getHost()));
assertEquals("", page.evaluate("document.cookie"));
page.navigate(server.PREFIX);
assertEquals("cookie1=1", page.evaluate("document.cookie"));
}
@Test
public void shouldRemoveCookiesByPath(Page page, BrowserContext context, Server server) throws MalformedURLException {
context.addCookies(Arrays.asList(
new Cookie("cookie1", "1").setDomain(new URL(server.PREFIX).getHost()).setPath("/api/v1"),
new Cookie("cookie2", "2").setDomain(new URL(server.PREFIX).getHost()).setPath("/api/v2"),
new Cookie("cookie3", "3").setDomain(new URL(server.PREFIX).getHost()).setPath("/")
));
page.navigate(server.PREFIX + "/api/v1");
assertEquals("cookie1=1; cookie3=3", page.evaluate("document.cookie"));
context.clearCookies(new BrowserContext.ClearCookiesOptions().setPath("/api/v1"));
assertEquals("cookie3=3", page.evaluate("document.cookie"));
page.navigate(server.PREFIX + "/api/v2");
assertEquals("cookie2=2; cookie3=3", page.evaluate("document.cookie"));
page.navigate(server.PREFIX + "/");
assertEquals("cookie3=3", page.evaluate("document.cookie"));
}
@Test
public void shouldRemoveCookiesByNameAndDomain(Page page, BrowserContext context, Server server) throws MalformedURLException {
context.addCookies(Arrays.asList(
new Cookie("cookie1", "1").setDomain(new URL(server.PREFIX).getHost()).setPath("/"),
new Cookie("cookie1", "1").setDomain(new URL(server.CROSS_PROCESS_PREFIX).getHost()).setPath("/")
));
page.navigate(server.PREFIX);
assertEquals("cookie1=1", page.evaluate("document.cookie"));
context.clearCookies(new BrowserContext.ClearCookiesOptions().setName("cookie1").setDomain(new URL(server.PREFIX).getHost()));
assertEquals("", page.evaluate("document.cookie"));
page.navigate(server.CROSS_PROCESS_PREFIX);
assertEquals("cookie1=1", page.evaluate("document.cookie"));
}
}
@@ -591,46 +591,6 @@ 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");
@@ -46,17 +46,17 @@ public class TestBrowserContextStorageState extends TestBase {
assertJsonEquals("{" +
"cookies:[]," +
"origins:[{\n" +
" origin: 'https://www.domain.com',\n" +
" localStorage: [{\n" +
" name: 'name2',\n" +
" value: 'value2'\n" +
" }]\n" +
"}, {\n" +
" origin: 'https://www.example.com',\n" +
" localStorage: [{\n" +
" name: 'name1',\n" +
" value: 'value1'\n" +
" }]\n" +
"}, {\n" +
" origin: 'https://www.domain.com',\n" +
" localStorage: [{\n" +
" name: 'name2',\n" +
" value: 'value2'\n" +
" }]\n" +
"}]}", new Gson().fromJson(storageState, JsonObject.class));
}
@@ -64,7 +64,7 @@ public class TestBrowserTypeConnect extends TestBase {
private static BrowserServer launchBrowserServer(BrowserType browserType) {
try {
Driver driver = Driver.ensureDriverInstalled(Collections.emptyMap(), false);
Path dir = driver.driverDir();
Path dir = driver.driverPath().getParent();
String node = dir.resolve(isWindows ? "node.exe" : "node").toString();
String cliJs = dir.resolve("package/cli.js").toString();
// We launch node process directly instead of using playwright.sh script as killing the script
@@ -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().contains("Browser closed"), e.getMessage());
assertTrue(e.getMessage().contains("Browser has been 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("Browser closed") || e.getMessage().contains("Page closed") || e.getMessage().contains("Browser has been closed"), e.getMessage());
assertTrue(e.getMessage().contains("Page closed") || e.getMessage().contains("Browser has been closed"), e.getMessage());
}
@Test
@@ -20,7 +20,6 @@ import org.junit.jupiter.api.Test;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class TestElementHandleMisc extends TestBase {
@Test
@@ -109,12 +108,4 @@ public class TestElementHandleMisc extends TestBase {
assertEquals(asList("blue"), page.evaluate("() => window['result'].onChange"));
}
@Test
void shouldAllowDisposingTwice() {
page.setContent("<section>39</section>");
ElementHandle element = page.querySelector("section");
assertNotNull(element);
element.dispose();
element.dispose();
}
}
@@ -18,18 +18,8 @@ package com.microsoft.playwright;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
import org.junit.jupiter.api.io.TempDir;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import static com.microsoft.playwright.Utils.mapOf;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.*;
public class TestLaunch extends TestBase {
@@ -50,39 +40,4 @@ public class TestLaunch extends TestBase {
options.setEnv(mapOf("DEBUG", "pw:protocol"));
launchBrowser(options);
}
public static boolean canRunHeaded() {
// On linux headed browser requires xvfb.
return isHeadful() || isMac || isWindows;
}
public static boolean canRunExtensionTest() {
return canRunHeaded() && isChromium();
}
@Test
@EnabledIf(value="com.microsoft.playwright.TestLaunch#canRunExtensionTest", disabledReason="Only Chromium Headed")
void shouldReturnBackgroundPages(@TempDir Path tmpDir) throws IOException {
Path profileDir = tmpDir.resolve("profile");
Files.createDirectories(profileDir);
String extensionPath = Paths.get("src/test/resources/simple-extension").toAbsolutePath().toString();
initBrowserType();
BrowserContext context = browserType.launchPersistentContext(profileDir, new BrowserType.LaunchPersistentContextOptions()
.setHeadless(false)
.setArgs(asList(
"--disable-extensions-except=" + extensionPath,
"--load-extension=" + extensionPath
)));
List<Page> backgroundPages = context.backgroundPages();
context.onBackgroundPage(page1 -> backgroundPages.add(page1));
context.waitForCondition(() -> !backgroundPages.isEmpty(),
new BrowserContext.WaitForConditionOptions().setTimeout(10_000));
Page backgroundPage = backgroundPages.get(0);
assertNotNull(backgroundPage);
assertTrue(context.backgroundPages().contains(backgroundPage));
assertFalse(context.pages().contains(backgroundPage));
context.close();
assertEquals(0, context.pages().size());
assertEquals(0, context.backgroundPages().size());
}
}
@@ -17,12 +17,9 @@
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.*;
@@ -118,36 +115,4 @@ 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);
}
}
@@ -28,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.*;
public class TestLocatorFrame extends TestBase {
private static void routeIframe(Page page) {
page.route("**/empty.html", route -> route.fulfill(new Route.FulfillOptions()
.setBody("<iframe src='iframe.html' name='frame1'></iframe>").setContentType("text/html")));
.setBody("<iframe src='iframe.html'></iframe>").setContentType("text/html")));
page.route("**/iframe.html", route -> {
route.fulfill(new Route.FulfillOptions().setBody("<html>\n" +
" <div>\n" +
@@ -263,25 +263,4 @@ public class TestLocatorFrame extends TestBase {
assertThat(input4).hasValue("");
}
@Test
void locatorContentFrameShouldWork() {
routeIframe(page);
page.navigate(server.EMPTY_PAGE);
Locator locator = page.locator("iframe");
FrameLocator frameLocator = locator.contentFrame();
Locator button = frameLocator.locator("button");
assertEquals("Hello iframe", button.innerText());
assertThat(button).hasText("Hello iframe");
button.click();
}
@Test
void frameLocatorOwnerShouldWork() {
routeIframe(page);
page.navigate(server.EMPTY_PAGE);
FrameLocator frameLocator = page.frameLocator("iframe");
Locator locator = frameLocator.owner();
assertThat(locator).isVisible();
assertEquals("frame1", locator.getAttribute("name"));
}
}
@@ -55,15 +55,4 @@ public class TestOptionsFactories {
public static boolean isChromium() {
return getBrowserName().equals("chromium");
}
public static boolean isFirefox() {
return getBrowserName().equals("firefox");
}
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,8 +16,6 @@
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;
@@ -31,13 +29,11 @@ public class TestPageAddLocatorHandler extends TestBase {
int[] beforeCount = {0};
int[] afterCount = {0};
Locator originalLocator = page.getByText("This interstitial covers the button");
page.addLocatorHandler(originalLocator, locator -> {
assertEquals(originalLocator, locator);
page.addLocatorHandler(page.getByText("This interstitial covers the button"), () -> {
++beforeCount[0];
page.locator("#close").click();
++afterCount[0];
}, new Page.AddLocatorHandlerOptions().setNoWaitAfter(true));
});
String[][] argsList = {
{"mouseover", "1"},
@@ -77,10 +73,10 @@ public class TestPageAddLocatorHandler extends TestBase {
void shouldWorkWithCustomCheck() {
page.navigate(server.PREFIX + "/input/handle-locator.html");
page.addLocatorHandler(page.locator("body"), locator -> {
page.addLocatorHandler(page.locator("body"), () -> {
if (page.getByText("This interstitial covers the button").isVisible())
page.locator("#close").click();
}, new Page.AddLocatorHandlerOptions().setNoWaitAfter(true));
});
String[][] argsList = {
{"mouseover", "2"},
@@ -107,7 +103,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"), locator -> {
page.addLocatorHandler(page.getByText("This interstitial covers the button"), () -> {
page.locator("#close").click();
});
@@ -124,7 +120,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"), locator -> {
page.addLocatorHandler(page.getByText("This interstitial covers the button"), () -> {
page.locator("#close").click();
});
@@ -142,7 +138,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"), locator -> {
page.addLocatorHandler(page.getByText("This interstitial covers the button"), () -> {
page.close();
});
@@ -160,7 +156,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"), locator -> {
page.addLocatorHandler(page.getByText("This interstitial covers the button"), () -> {
++called[0];
page.locator("#close").click();
});
@@ -173,168 +169,4 @@ 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,12 +58,6 @@ 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>");
@@ -343,9 +343,10 @@ public class TestPageKeyboard extends TestBase {
page.navigate(server.PREFIX + "/input/textarea.html");
ElementHandle textarea = page.querySelector("textarea");
textarea.type("some text");
page.keyboard().down("ControlOrMeta");
String modifier = isMac ? "Meta" : "Control";
page.keyboard().down(modifier);
page.keyboard().press("a");
page.keyboard().up("ControlOrMeta");
page.keyboard().up(modifier);
page.keyboard().press("Backspace");
assertTrue(((String)page.evalOnSelector("textarea", "textarea => textarea.value")).isEmpty());
}
@@ -361,9 +362,10 @@ public class TestPageKeyboard extends TestBase {
" event.preventDefault();\n" +
" }, false);\n" +
"}");
page.keyboard().down("ControlOrMeta");
String modifier = isMac ? "Meta" : "Control";
page.keyboard().down(modifier);
page.keyboard().press("a");
page.keyboard().up("ControlOrMeta");
page.keyboard().up(modifier);
page.keyboard().press("Backspace");
assertEquals("some tex", page.evalOnSelector("textarea", "textarea => textarea.value"));
}
@@ -134,31 +134,4 @@ public class TestPageNetworkRequest extends TestBase {
assertTrue(request[0].isNavigationRequest());
assertTrue(error[0].getMessage().contains("Frame for this navigation request is not available"), error[0].getMessage());
}
@Test
void shouldParseDataIfContentTypeIsApplicationFormUrlEncoded() {
page.navigate(server.EMPTY_PAGE);
server.setRoute("/post", exchange -> exchange.close());
Request[] request = {null};
page.onRequest(r -> request[0] = r);
page.setContent("<form method='POST' action='/post'><input type='text' name='foo' value='bar'><input type='number' name='baz' value='123'><input type='submit'></form>");
page.click("input[type=submit]");
assertNotNull(request[0]);
assertEquals("foo=bar&baz=123", request[0].postData());
}
@Test
void shouldParseDataIfContentTypeIsApplicationFormUrlEncodedCharsetUTF8() {
page.navigate(server.EMPTY_PAGE);
Request request = page.waitForRequest("**/post", () -> {
page.evaluate("() => fetch('./post', {\n" +
" method: 'POST',\n" +
" headers: {\n" +
" 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',\n" +
" },\n" +
" body: 'foo=bar&baz=123'\n" +
"})");
});
assertEquals("foo=bar&baz=123", request.postData());
}
}
@@ -252,20 +252,8 @@ 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.TestPageScreenshot#isScreenshotTestDisabled", disabledReason="array lengths differ")
@DisabledIf(value="com.microsoft.playwright.TestBase#isWebKit", disabledReason="array lengths differ")
void shouldHideElementsBasedOnAttr() throws IOException {
page.setViewportSize(500, 500);
page.navigate(server.PREFIX + "/grid.html");
@@ -281,7 +269,7 @@ public class TestPageScreenshot extends TestBase {
}
@Test
@DisabledIf(value="com.microsoft.playwright.TestPageScreenshot#isScreenshotTestDisabled", disabledReason="array lengths differ")
@DisabledIf(value="com.microsoft.playwright.TestBase#isWebKit", disabledReason="array lengths differ")
void shouldRemoveElementsBasedOnAttr() throws IOException {
page.setViewportSize(500, 500);
page.navigate(server.PREFIX + "/grid.html");
@@ -182,7 +182,7 @@ public class Utils {
return browserName;
}
public static BrowserType getBrowserTypeFromEnv(Playwright playwright) {
static BrowserType getBrowserTypeFromEnv(Playwright playwright) {
String browserName = getBrowserNameFromEnv();
switch (browserName) {
case "webkit":
@@ -1,9 +0,0 @@
package com.microsoft.playwright.impl;
import com.microsoft.playwright.Browser;
public class ImplUtils {
public static boolean isRemoteBrowser(Browser browser) {
return ((BrowserImpl) browser).isConnectedOverWebSocket;
}
}
@@ -1,24 +0,0 @@
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);
}
}
@@ -1,6 +0,0 @@
package com.microsoft.playwright.junit;
@UsePlaywright
public abstract class FixtureAbstractClass {
}
@@ -24,7 +24,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@ExtendWith({ServerLifecycle.class, BrowserTypeParameterResolver.class})
@ExtendWith(ServerLifecycle.class)
@Tag("fixtures")
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)

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