diff --git a/playwright/src/main/java/com/microsoft/playwright/APIRequest.java b/playwright/src/main/java/com/microsoft/playwright/APIRequest.java
new file mode 100644
index 00000000..2f0e31ae
--- /dev/null
+++ b/playwright/src/main/java/com/microsoft/playwright/APIRequest.java
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) Microsoft Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.microsoft.playwright;
+
+import com.microsoft.playwright.options.*;
+import java.nio.file.Path;
+import java.util.*;
+
+/**
+ * Exposes API that can be used for the Web API testing.
+ */
+public interface APIRequest {
+ class NewContextOptions {
+ /**
+ * Methods like {@link APIRequestContext#get APIRequestContext.get()} take the base URL into consideration by using the {@code URL()} constructor for building the corresponding
+ * URL. Examples:
+ *
+ *
baseURL: {@code http://localhost:3000} and sending request to {@code /bar.html} results in {@code http://localhost:3000/bar.html}
+ *
baseURL: {@code http://localhost:3000/foo/} and sending request to {@code ./bar.html} results in
+ * {@code http://localhost:3000/foo/bar.html}
+ *
+ */
+ public String baseURL;
+ /**
+ * An object containing additional HTTP headers to be sent with every request.
+ */
+ public Map extraHTTPHeaders;
+ /**
+ * Credentials for HTTP authentication.
+ */
+ public HttpCredentials httpCredentials;
+ /**
+ * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}.
+ */
+ public Boolean ignoreHTTPSErrors;
+ /**
+ * Network proxy settings.
+ */
+ public Proxy proxy;
+ /**
+ * Populates context with given storage state. This option can be used to initialize context with logged-in information
+ * 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 BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved storage
+ * state.
+ */
+ public Path storageStatePath;
+ /**
+ * Maximum time in milliseconds to wait for the response. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
+ */
+ public Double timeout;
+ /**
+ * Specific user agent to use in this context.
+ */
+ public String userAgent;
+
+ /**
+ * Methods like {@link APIRequestContext#get APIRequestContext.get()} take the base URL into consideration by using the {@code URL()} constructor for building the corresponding
+ * URL. Examples:
+ *
+ *
baseURL: {@code http://localhost:3000} and sending request to {@code /bar.html} results in {@code http://localhost:3000/bar.html}
+ *
baseURL: {@code http://localhost:3000/foo/} and sending request to {@code ./bar.html} results in
+ * {@code http://localhost:3000/foo/bar.html}
+ *
+ */
+ public NewContextOptions setBaseURL(String baseURL) {
+ this.baseURL = baseURL;
+ return this;
+ }
+ /**
+ * An object containing additional HTTP headers to be sent with every request.
+ */
+ public NewContextOptions setExtraHTTPHeaders(Map extraHTTPHeaders) {
+ this.extraHTTPHeaders = extraHTTPHeaders;
+ return this;
+ }
+ /**
+ * Credentials for HTTP authentication.
+ */
+ public NewContextOptions setHttpCredentials(String username, String password) {
+ return setHttpCredentials(new HttpCredentials(username, password));
+ }
+ /**
+ * Credentials for HTTP authentication.
+ */
+ public NewContextOptions setHttpCredentials(HttpCredentials httpCredentials) {
+ this.httpCredentials = httpCredentials;
+ return this;
+ }
+ /**
+ * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}.
+ */
+ public NewContextOptions setIgnoreHTTPSErrors(boolean ignoreHTTPSErrors) {
+ this.ignoreHTTPSErrors = ignoreHTTPSErrors;
+ return this;
+ }
+ /**
+ * Network proxy settings.
+ */
+ public NewContextOptions setProxy(String server) {
+ return setProxy(new Proxy(server));
+ }
+ /**
+ * Network proxy settings.
+ */
+ public NewContextOptions setProxy(Proxy proxy) {
+ this.proxy = proxy;
+ return this;
+ }
+ /**
+ * Populates context with given storage state. This option can be used to initialize context with logged-in information
+ * 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) {
+ this.storageState = storageState;
+ return this;
+ }
+ /**
+ * Populates context with given storage state. This option can be used to initialize context with logged-in information
+ * obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved storage
+ * state.
+ */
+ public NewContextOptions setStorageStatePath(Path storageStatePath) {
+ this.storageStatePath = storageStatePath;
+ return this;
+ }
+ /**
+ * Maximum time in milliseconds to wait for the response. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
+ */
+ public NewContextOptions setTimeout(double timeout) {
+ this.timeout = timeout;
+ return this;
+ }
+ /**
+ * Specific user agent to use in this context.
+ */
+ public NewContextOptions setUserAgent(String userAgent) {
+ this.userAgent = userAgent;
+ return this;
+ }
+ }
+ /**
+ * Creates new instances of {@code APIRequestContext}.
+ */
+ default APIRequestContext newContext() {
+ return newContext(null);
+ }
+ /**
+ * Creates new instances of {@code APIRequestContext}.
+ */
+ APIRequestContext newContext(NewContextOptions options);
+}
+
diff --git a/playwright/src/main/java/com/microsoft/playwright/APIRequestContext.java b/playwright/src/main/java/com/microsoft/playwright/APIRequestContext.java
new file mode 100644
index 00000000..e568b817
--- /dev/null
+++ b/playwright/src/main/java/com/microsoft/playwright/APIRequestContext.java
@@ -0,0 +1,950 @@
+/*
+ * Copyright (c) Microsoft Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.microsoft.playwright;
+
+import java.nio.file.Path;
+import java.util.*;
+
+/**
+ * This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
+ * environment or the service to your e2e test. When used on {@code Page} or a {@code BrowserContext}, this API will automatically use
+ * the cookies from the corresponding {@code BrowserContext}. This means that if you log in using this API, your e2e test will be
+ * logged in and vice versa.
+ */
+public interface APIRequestContext {
+ class DeleteOptions {
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public Object data;
+ /**
+ * Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
+ */
+ public Boolean failOnStatusCode;
+ /**
+ * Provides an object that will be serialized as html form using {@code application/x-www-form-urlencoded} encoding and sent as
+ * this request body. If this parameter is specified {@code content-type} header will be set to
+ * {@code application/x-www-form-urlencoded} unless explicitly provided.
+ */
+ public Map form;
+ /**
+ * Allows to set HTTP headers.
+ */
+ public Map headers;
+ /**
+ * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}.
+ */
+ public Boolean ignoreHTTPSErrors;
+ /**
+ * Provides an object that will be serialized as html form using {@code multipart/form-data} encoding and sent as this request
+ * body. If this parameter is specified {@code content-type} header will be set to {@code multipart/form-data} unless explicitly
+ * provided. File values can be passed either as [File] or as file-like object [FilePayload] containing file name,
+ * mime-type and its content.
+ */
+ public Map multipart;
+ /**
+ * Query parameters to be sent with the URL.
+ */
+ public Map params;
+ /**
+ * Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
+ */
+ public Double timeout;
+
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public DeleteOptions setData(String data) {
+ this.data = data;
+ return this;
+ }
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public DeleteOptions setData(byte[] data) {
+ this.data = data;
+ return this;
+ }
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public DeleteOptions setData(Object data) {
+ this.data = data;
+ return this;
+ }
+ /**
+ * Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
+ */
+ public DeleteOptions setFailOnStatusCode(boolean failOnStatusCode) {
+ this.failOnStatusCode = failOnStatusCode;
+ return this;
+ }
+ /**
+ * Provides an object that will be serialized as html form using {@code application/x-www-form-urlencoded} encoding and sent as
+ * this request body. If this parameter is specified {@code content-type} header will be set to
+ * {@code application/x-www-form-urlencoded} unless explicitly provided.
+ */
+ public DeleteOptions setForm(Map form) {
+ this.form = form;
+ return this;
+ }
+ /**
+ * Allows to set HTTP headers.
+ */
+ public DeleteOptions setHeaders(Map headers) {
+ this.headers = headers;
+ return this;
+ }
+ /**
+ * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}.
+ */
+ public DeleteOptions setIgnoreHTTPSErrors(boolean ignoreHTTPSErrors) {
+ this.ignoreHTTPSErrors = ignoreHTTPSErrors;
+ return this;
+ }
+ /**
+ * Provides an object that will be serialized as html form using {@code multipart/form-data} encoding and sent as this request
+ * body. If this parameter is specified {@code content-type} header will be set to {@code multipart/form-data} unless explicitly
+ * provided. File values can be passed either as [File] or as file-like object [FilePayload] containing file name,
+ * mime-type and its content.
+ */
+ public DeleteOptions setMultipart(Map multipart) {
+ this.multipart = multipart;
+ return this;
+ }
+ /**
+ * Query parameters to be sent with the URL.
+ */
+ public DeleteOptions setParams(Map params) {
+ this.params = params;
+ return this;
+ }
+ /**
+ * Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
+ */
+ public DeleteOptions setTimeout(double timeout) {
+ this.timeout = timeout;
+ return this;
+ }
+ }
+ class FetchOptions {
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public Object data;
+ /**
+ * Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
+ */
+ public Boolean failOnStatusCode;
+ /**
+ * Provides an object that will be serialized as html form using {@code application/x-www-form-urlencoded} encoding and sent as
+ * this request body. If this parameter is specified {@code content-type} header will be set to
+ * {@code application/x-www-form-urlencoded} unless explicitly provided.
+ */
+ public Map form;
+ /**
+ * Allows to set HTTP headers.
+ */
+ public Map headers;
+ /**
+ * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}.
+ */
+ public Boolean ignoreHTTPSErrors;
+ /**
+ * If set changes the fetch method (e.g. PUT or
+ * POST). If not specified, GET method is
+ * used.
+ */
+ public String method;
+ /**
+ * Provides an object that will be serialized as html form using {@code multipart/form-data} encoding and sent as this request
+ * body. If this parameter is specified {@code content-type} header will be set to {@code multipart/form-data} unless explicitly
+ * provided. File values can be passed either as [File] or as file-like object [FilePayload] containing file name,
+ * mime-type and its content.
+ */
+ public Map multipart;
+ /**
+ * Query parameters to be sent with the URL.
+ */
+ public Map params;
+ /**
+ * Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
+ */
+ public Double timeout;
+
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public FetchOptions setData(String data) {
+ this.data = data;
+ return this;
+ }
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public FetchOptions setData(byte[] data) {
+ this.data = data;
+ return this;
+ }
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public FetchOptions setData(Object data) {
+ this.data = data;
+ return this;
+ }
+ /**
+ * Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
+ */
+ public FetchOptions setFailOnStatusCode(boolean failOnStatusCode) {
+ this.failOnStatusCode = failOnStatusCode;
+ return this;
+ }
+ /**
+ * Provides an object that will be serialized as html form using {@code application/x-www-form-urlencoded} encoding and sent as
+ * this request body. If this parameter is specified {@code content-type} header will be set to
+ * {@code application/x-www-form-urlencoded} unless explicitly provided.
+ */
+ public FetchOptions setForm(Map form) {
+ this.form = form;
+ return this;
+ }
+ /**
+ * Allows to set HTTP headers.
+ */
+ public FetchOptions setHeaders(Map headers) {
+ this.headers = headers;
+ return this;
+ }
+ /**
+ * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}.
+ */
+ public FetchOptions setIgnoreHTTPSErrors(boolean ignoreHTTPSErrors) {
+ this.ignoreHTTPSErrors = ignoreHTTPSErrors;
+ return this;
+ }
+ /**
+ * If set changes the fetch method (e.g. PUT or
+ * POST). If not specified, GET method is
+ * used.
+ */
+ public FetchOptions setMethod(String method) {
+ this.method = method;
+ return this;
+ }
+ /**
+ * Provides an object that will be serialized as html form using {@code multipart/form-data} encoding and sent as this request
+ * body. If this parameter is specified {@code content-type} header will be set to {@code multipart/form-data} unless explicitly
+ * provided. File values can be passed either as [File] or as file-like object [FilePayload] containing file name,
+ * mime-type and its content.
+ */
+ public FetchOptions setMultipart(Map multipart) {
+ this.multipart = multipart;
+ return this;
+ }
+ /**
+ * Query parameters to be sent with the URL.
+ */
+ public FetchOptions setParams(Map params) {
+ this.params = params;
+ return this;
+ }
+ /**
+ * Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
+ */
+ public FetchOptions setTimeout(double timeout) {
+ this.timeout = timeout;
+ return this;
+ }
+ }
+ class GetOptions {
+ /**
+ * Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
+ */
+ public Boolean failOnStatusCode;
+ /**
+ * Allows to set HTTP headers.
+ */
+ public Map headers;
+ /**
+ * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}.
+ */
+ public Boolean ignoreHTTPSErrors;
+ /**
+ * Query parameters to be sent with the URL.
+ */
+ public Map params;
+ /**
+ * Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
+ */
+ public Double timeout;
+
+ /**
+ * Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
+ */
+ public GetOptions setFailOnStatusCode(boolean failOnStatusCode) {
+ this.failOnStatusCode = failOnStatusCode;
+ return this;
+ }
+ /**
+ * Allows to set HTTP headers.
+ */
+ public GetOptions setHeaders(Map headers) {
+ this.headers = headers;
+ return this;
+ }
+ /**
+ * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}.
+ */
+ public GetOptions setIgnoreHTTPSErrors(boolean ignoreHTTPSErrors) {
+ this.ignoreHTTPSErrors = ignoreHTTPSErrors;
+ return this;
+ }
+ /**
+ * Query parameters to be sent with the URL.
+ */
+ public GetOptions setParams(Map params) {
+ this.params = params;
+ return this;
+ }
+ /**
+ * Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
+ */
+ public GetOptions setTimeout(double timeout) {
+ this.timeout = timeout;
+ return this;
+ }
+ }
+ class HeadOptions {
+ /**
+ * Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
+ */
+ public Boolean failOnStatusCode;
+ /**
+ * Allows to set HTTP headers.
+ */
+ public Map headers;
+ /**
+ * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}.
+ */
+ public Boolean ignoreHTTPSErrors;
+ /**
+ * Query parameters to be sent with the URL.
+ */
+ public Map params;
+ /**
+ * Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
+ */
+ public Double timeout;
+
+ /**
+ * Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
+ */
+ public HeadOptions setFailOnStatusCode(boolean failOnStatusCode) {
+ this.failOnStatusCode = failOnStatusCode;
+ return this;
+ }
+ /**
+ * Allows to set HTTP headers.
+ */
+ public HeadOptions setHeaders(Map headers) {
+ this.headers = headers;
+ return this;
+ }
+ /**
+ * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}.
+ */
+ public HeadOptions setIgnoreHTTPSErrors(boolean ignoreHTTPSErrors) {
+ this.ignoreHTTPSErrors = ignoreHTTPSErrors;
+ return this;
+ }
+ /**
+ * Query parameters to be sent with the URL.
+ */
+ public HeadOptions setParams(Map params) {
+ this.params = params;
+ return this;
+ }
+ /**
+ * Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
+ */
+ public HeadOptions setTimeout(double timeout) {
+ this.timeout = timeout;
+ return this;
+ }
+ }
+ class PatchOptions {
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public Object data;
+ /**
+ * Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
+ */
+ public Boolean failOnStatusCode;
+ /**
+ * Provides an object that will be serialized as html form using {@code application/x-www-form-urlencoded} encoding and sent as
+ * this request body. If this parameter is specified {@code content-type} header will be set to
+ * {@code application/x-www-form-urlencoded} unless explicitly provided.
+ */
+ public Map form;
+ /**
+ * Allows to set HTTP headers.
+ */
+ public Map headers;
+ /**
+ * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}.
+ */
+ public Boolean ignoreHTTPSErrors;
+ /**
+ * Provides an object that will be serialized as html form using {@code multipart/form-data} encoding and sent as this request
+ * body. If this parameter is specified {@code content-type} header will be set to {@code multipart/form-data} unless explicitly
+ * provided. File values can be passed either as [File] or as file-like object [FilePayload] containing file name,
+ * mime-type and its content.
+ */
+ public Map multipart;
+ /**
+ * Query parameters to be sent with the URL.
+ */
+ public Map params;
+ /**
+ * Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
+ */
+ public Double timeout;
+
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public PatchOptions setData(String data) {
+ this.data = data;
+ return this;
+ }
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public PatchOptions setData(byte[] data) {
+ this.data = data;
+ return this;
+ }
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public PatchOptions setData(Object data) {
+ this.data = data;
+ return this;
+ }
+ /**
+ * Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
+ */
+ public PatchOptions setFailOnStatusCode(boolean failOnStatusCode) {
+ this.failOnStatusCode = failOnStatusCode;
+ return this;
+ }
+ /**
+ * Provides an object that will be serialized as html form using {@code application/x-www-form-urlencoded} encoding and sent as
+ * this request body. If this parameter is specified {@code content-type} header will be set to
+ * {@code application/x-www-form-urlencoded} unless explicitly provided.
+ */
+ public PatchOptions setForm(Map form) {
+ this.form = form;
+ return this;
+ }
+ /**
+ * Allows to set HTTP headers.
+ */
+ public PatchOptions setHeaders(Map headers) {
+ this.headers = headers;
+ return this;
+ }
+ /**
+ * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}.
+ */
+ public PatchOptions setIgnoreHTTPSErrors(boolean ignoreHTTPSErrors) {
+ this.ignoreHTTPSErrors = ignoreHTTPSErrors;
+ return this;
+ }
+ /**
+ * Provides an object that will be serialized as html form using {@code multipart/form-data} encoding and sent as this request
+ * body. If this parameter is specified {@code content-type} header will be set to {@code multipart/form-data} unless explicitly
+ * provided. File values can be passed either as [File] or as file-like object [FilePayload] containing file name,
+ * mime-type and its content.
+ */
+ public PatchOptions setMultipart(Map multipart) {
+ this.multipart = multipart;
+ return this;
+ }
+ /**
+ * Query parameters to be sent with the URL.
+ */
+ public PatchOptions setParams(Map params) {
+ this.params = params;
+ return this;
+ }
+ /**
+ * Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
+ */
+ public PatchOptions setTimeout(double timeout) {
+ this.timeout = timeout;
+ return this;
+ }
+ }
+ class PostOptions {
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public Object data;
+ /**
+ * Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
+ */
+ public Boolean failOnStatusCode;
+ /**
+ * Provides an object that will be serialized as html form using {@code application/x-www-form-urlencoded} encoding and sent as
+ * this request body. If this parameter is specified {@code content-type} header will be set to
+ * {@code application/x-www-form-urlencoded} unless explicitly provided.
+ */
+ public Map form;
+ /**
+ * Allows to set HTTP headers.
+ */
+ public Map headers;
+ /**
+ * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}.
+ */
+ public Boolean ignoreHTTPSErrors;
+ /**
+ * Provides an object that will be serialized as html form using {@code multipart/form-data} encoding and sent as this request
+ * body. If this parameter is specified {@code content-type} header will be set to {@code multipart/form-data} unless explicitly
+ * provided. File values can be passed either as [File] or as file-like object [FilePayload] containing file name,
+ * mime-type and its content.
+ */
+ public Map multipart;
+ /**
+ * Query parameters to be sent with the URL.
+ */
+ public Map params;
+ /**
+ * Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
+ */
+ public Double timeout;
+
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public PostOptions setData(String data) {
+ this.data = data;
+ return this;
+ }
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public PostOptions setData(byte[] data) {
+ this.data = data;
+ return this;
+ }
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public PostOptions setData(Object data) {
+ this.data = data;
+ return this;
+ }
+ /**
+ * Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
+ */
+ public PostOptions setFailOnStatusCode(boolean failOnStatusCode) {
+ this.failOnStatusCode = failOnStatusCode;
+ return this;
+ }
+ /**
+ * Provides an object that will be serialized as html form using {@code application/x-www-form-urlencoded} encoding and sent as
+ * this request body. If this parameter is specified {@code content-type} header will be set to
+ * {@code application/x-www-form-urlencoded} unless explicitly provided.
+ */
+ public PostOptions setForm(Map form) {
+ this.form = form;
+ return this;
+ }
+ /**
+ * Allows to set HTTP headers.
+ */
+ public PostOptions setHeaders(Map headers) {
+ this.headers = headers;
+ return this;
+ }
+ /**
+ * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}.
+ */
+ public PostOptions setIgnoreHTTPSErrors(boolean ignoreHTTPSErrors) {
+ this.ignoreHTTPSErrors = ignoreHTTPSErrors;
+ return this;
+ }
+ /**
+ * Provides an object that will be serialized as html form using {@code multipart/form-data} encoding and sent as this request
+ * body. If this parameter is specified {@code content-type} header will be set to {@code multipart/form-data} unless explicitly
+ * provided. File values can be passed either as [File] or as file-like object [FilePayload] containing file name,
+ * mime-type and its content.
+ */
+ public PostOptions setMultipart(Map multipart) {
+ this.multipart = multipart;
+ return this;
+ }
+ /**
+ * Query parameters to be sent with the URL.
+ */
+ public PostOptions setParams(Map params) {
+ this.params = params;
+ return this;
+ }
+ /**
+ * Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
+ */
+ public PostOptions setTimeout(double timeout) {
+ this.timeout = timeout;
+ return this;
+ }
+ }
+ class PutOptions {
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public Object data;
+ /**
+ * Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
+ */
+ public Boolean failOnStatusCode;
+ /**
+ * Provides an object that will be serialized as html form using {@code application/x-www-form-urlencoded} encoding and sent as
+ * this request body. If this parameter is specified {@code content-type} header will be set to
+ * {@code application/x-www-form-urlencoded} unless explicitly provided.
+ */
+ public Map form;
+ /**
+ * Allows to set HTTP headers.
+ */
+ public Map headers;
+ /**
+ * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}.
+ */
+ public Boolean ignoreHTTPSErrors;
+ /**
+ * Provides an object that will be serialized as html form using {@code multipart/form-data} encoding and sent as this request
+ * body. If this parameter is specified {@code content-type} header will be set to {@code multipart/form-data} unless explicitly
+ * provided. File values can be passed either as [File] or as file-like object [FilePayload] containing file name,
+ * mime-type and its content.
+ */
+ public Map multipart;
+ /**
+ * Query parameters to be sent with the URL.
+ */
+ public Map params;
+ /**
+ * Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
+ */
+ public Double timeout;
+
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public PutOptions setData(String data) {
+ this.data = data;
+ return this;
+ }
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public PutOptions setData(byte[] data) {
+ this.data = data;
+ return this;
+ }
+ /**
+ * Allows to set post data of the request. If the data parameter is an object, it will be serialized to json string and
+ * {@code content-type} header will be set to {@code application/json} if not explicitly set. Otherwise the {@code content-type} header will
+ * be set to {@code application/octet-stream} if not explicitly set.
+ */
+ public PutOptions setData(Object data) {
+ this.data = data;
+ return this;
+ }
+ /**
+ * Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
+ */
+ public PutOptions setFailOnStatusCode(boolean failOnStatusCode) {
+ this.failOnStatusCode = failOnStatusCode;
+ return this;
+ }
+ /**
+ * Provides an object that will be serialized as html form using {@code application/x-www-form-urlencoded} encoding and sent as
+ * this request body. If this parameter is specified {@code content-type} header will be set to
+ * {@code application/x-www-form-urlencoded} unless explicitly provided.
+ */
+ public PutOptions setForm(Map form) {
+ this.form = form;
+ return this;
+ }
+ /**
+ * Allows to set HTTP headers.
+ */
+ public PutOptions setHeaders(Map headers) {
+ this.headers = headers;
+ return this;
+ }
+ /**
+ * Whether to ignore HTTPS errors when sending network requests. Defaults to {@code false}.
+ */
+ public PutOptions setIgnoreHTTPSErrors(boolean ignoreHTTPSErrors) {
+ this.ignoreHTTPSErrors = ignoreHTTPSErrors;
+ return this;
+ }
+ /**
+ * Provides an object that will be serialized as html form using {@code multipart/form-data} encoding and sent as this request
+ * body. If this parameter is specified {@code content-type} header will be set to {@code multipart/form-data} unless explicitly
+ * provided. File values can be passed either as [File] or as file-like object [FilePayload] containing file name,
+ * mime-type and its content.
+ */
+ public PutOptions setMultipart(Map multipart) {
+ this.multipart = multipart;
+ return this;
+ }
+ /**
+ * Query parameters to be sent with the URL.
+ */
+ public PutOptions setParams(Map params) {
+ this.params = params;
+ return this;
+ }
+ /**
+ * Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
+ */
+ public PutOptions setTimeout(double timeout) {
+ this.timeout = timeout;
+ return this;
+ }
+ }
+ class StorageStateOptions {
+ /**
+ * The file path to save the storage state to. If {@code path} is a relative path, then it is resolved relative to current
+ * working directory. If no path is provided, storage state is still returned, but won't be saved to the disk.
+ */
+ public Path path;
+
+ /**
+ * The file path to save the storage state to. If {@code path} is a relative path, then it is resolved relative to current
+ * working directory. If no path is provided, storage state is still returned, but won't be saved to the disk.
+ */
+ public StorageStateOptions setPath(Path path) {
+ this.path = path;
+ return this;
+ }
+ }
+ /**
+ * Sends HTTP(S) DELETE 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.
+ *
+ * @param url Target URL.
+ */
+ default APIResponse delete(String url) {
+ return delete(url, null);
+ }
+ /**
+ * Sends HTTP(S) DELETE 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.
+ *
+ * @param url Target URL.
+ */
+ APIResponse delete(String url, DeleteOptions options);
+ /**
+ * 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 stored
+ * responses, and makes {@link APIResponse#body APIResponse.body()} throw "Response disposed" error.
+ */
+ 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.
+ *
+ * @param urlOrRequest Target URL or Request to get all parameters from.
+ */
+ default APIResponse fetch(String urlOrRequest) {
+ return fetch(urlOrRequest, null);
+ }
+ /**
+ * 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.
+ *
+ * @param urlOrRequest Target URL or Request to get all parameters from.
+ */
+ APIResponse fetch(String urlOrRequest, FetchOptions options);
+ /**
+ * Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
+ * context cookies from the response. The method will automatically follow redirects.
+ *
+ * @param urlOrRequest Target URL or Request to get all parameters from.
+ */
+ default APIResponse fetch(Request urlOrRequest) {
+ return fetch(urlOrRequest, null);
+ }
+ /**
+ * 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.
+ *
+ * @param urlOrRequest Target URL or Request to get all parameters from.
+ */
+ APIResponse fetch(Request urlOrRequest, FetchOptions options);
+ /**
+ * Sends HTTP(S) GET 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.
+ *
+ * @param url Target URL.
+ */
+ default APIResponse get(String url) {
+ return get(url, null);
+ }
+ /**
+ * Sends HTTP(S) GET 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.
+ *
+ * @param url Target URL.
+ */
+ APIResponse get(String url, GetOptions options);
+ /**
+ * Sends HTTP(S) HEAD 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.
+ *
+ * @param url Target URL.
+ */
+ default APIResponse head(String url) {
+ return head(url, null);
+ }
+ /**
+ * Sends HTTP(S) HEAD 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.
+ *
+ * @param url Target URL.
+ */
+ APIResponse head(String url, HeadOptions options);
+ /**
+ * Sends HTTP(S) PATCH 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.
+ *
+ * @param url Target URL.
+ */
+ default APIResponse patch(String url) {
+ return patch(url, null);
+ }
+ /**
+ * Sends HTTP(S) PATCH 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.
+ *
+ * @param url Target URL.
+ */
+ APIResponse patch(String url, PatchOptions options);
+ /**
+ * Sends HTTP(S) POST 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.
+ *
+ * @param url Target URL.
+ */
+ default APIResponse post(String url) {
+ return post(url, null);
+ }
+ /**
+ * Sends HTTP(S) POST 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.
+ *
+ * @param url Target URL.
+ */
+ APIResponse post(String url, PostOptions options);
+ /**
+ * Sends HTTP(S) PUT 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.
+ *
+ * @param url Target URL.
+ */
+ default APIResponse put(String url) {
+ return put(url, null);
+ }
+ /**
+ * Sends HTTP(S) PUT 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.
+ *
+ * @param url Target URL.
+ */
+ APIResponse put(String url, PutOptions options);
+ /**
+ * Returns storage state for this request context, contains current cookies and local storage snapshot if it was passed to
+ * the constructor.
+ */
+ default String storageState() {
+ return storageState(null);
+ }
+ /**
+ * Returns storage state for this request context, contains current cookies and local storage snapshot if it was passed to
+ * the constructor.
+ */
+ String storageState(StorageStateOptions options);
+}
+
diff --git a/playwright/src/main/java/com/microsoft/playwright/APIResponse.java b/playwright/src/main/java/com/microsoft/playwright/APIResponse.java
new file mode 100644
index 00000000..5330fcad
--- /dev/null
+++ b/playwright/src/main/java/com/microsoft/playwright/APIResponse.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) Microsoft Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.microsoft.playwright;
+
+import com.microsoft.playwright.options.*;
+import java.util.*;
+
+/**
+ * {@code APIResponse} class represents responses returned by {@link APIRequestContext#get APIRequestContext.get()} and similar
+ * methods.
+ */
+public interface APIResponse {
+ /**
+ * Returns the buffer with response body.
+ */
+ byte[] body();
+ /**
+ * Disposes the body of this response. If not called then the body will stay in memory until the context closes.
+ */
+ void dispose();
+ /**
+ * An object with all the response HTTP headers associated with this response.
+ */
+ Map headers();
+ /**
+ * An array with all the request HTTP headers associated with this response. Header names are not lower-cased. Headers with
+ * multiple entries, such as {@code Set-Cookie}, appear in the array multiple times.
+ */
+ List headersArray();
+ /**
+ * Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
+ */
+ boolean ok();
+ /**
+ * Contains the status code of the response (e.g., 200 for a success).
+ */
+ int status();
+ /**
+ * Contains the status text of the response (e.g. usually an "OK" for a success).
+ */
+ String statusText();
+ /**
+ * Returns the text representation of response body.
+ */
+ String text();
+ /**
+ * Contains the URL of the response.
+ */
+ String url();
+}
+
diff --git a/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java b/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java
index 7a01d1c8..0ba13ce4 100644
--- a/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java
+++ b/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java
@@ -547,6 +547,10 @@ public interface BrowserContext extends AutoCloseable {
* Returns all open pages in the context.
*/
List pages();
+ /**
+ * API testing helper associated with this context. Requests made with this API will use context cookies.
+ */
+ APIRequestContext request();
/**
* 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.
diff --git a/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java b/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java
index eef4a2ca..c20b13fd 100644
--- a/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java
+++ b/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java
@@ -23,6 +23,8 @@ import java.util.*;
/**
* ElementHandle represents an in-page DOM element. ElementHandles can be created with the {@link Page#querySelector
* Page.querySelector()} method.
+ *
+ *
NOTE: The use of ElementHandle is discouraged, use {@code Locator} objects and web-first assertions instead.
*
ElementHandle instances can be used as an argument in {@link Page#evalOnSelector Page.evalOnSelector()} and {@link
* Page#evaluate Page.evaluate()} methods.
*
- *
NOTE: In most cases, you would want to use the {@code Locator} object instead. You should only use {@code ElementHandle} if you want to
- * retain a handle to a particular DOM Node that you intend to pass into {@link Page#evaluate Page.evaluate()} as an
- * argument.
- *
*
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.
*
diff --git a/playwright/src/main/java/com/microsoft/playwright/Frame.java b/playwright/src/main/java/com/microsoft/playwright/Frame.java
index 65bd6de1..b803e8db 100644
--- a/playwright/src/main/java/com/microsoft/playwright/Frame.java
+++ b/playwright/src/main/java/com/microsoft/playwright/Frame.java
@@ -2329,6 +2329,9 @@ public interface Frame {
/**
* Returns the return value of {@code expression}.
*
+ *
NOTE: This method does not wait for the element to pass actionability checks and therefore can lead to the flaky tests. Use
+ * {@link Locator#evaluate Locator.evaluate()}, other {@code Locator} helper methods or web-first assertions instead.
+ *
*
The method finds an element matching the specified selector within the frame and passes it as a first argument to
* {@code expression}. See Working with selectors for more details. If
* no elements match the selector, the method throws an error.
@@ -2356,6 +2359,9 @@ public interface Frame {
/**
* Returns the return value of {@code expression}.
*
+ *
NOTE: This method does not wait for the element to pass actionability checks and therefore can lead to the flaky tests. Use
+ * {@link Locator#evaluate Locator.evaluate()}, other {@code Locator} helper methods or web-first assertions instead.
+ *
*
The method finds an element matching the specified selector within the frame and passes it as a first argument to
* {@code expression}. See Working with selectors for more details. If
* no elements match the selector, the method throws an error.
@@ -2382,6 +2388,9 @@ public interface Frame {
/**
* Returns the return value of {@code expression}.
*
+ *
NOTE: This method does not wait for the element to pass actionability checks and therefore can lead to the flaky tests. Use
+ * {@link Locator#evaluate Locator.evaluate()}, other {@code Locator} helper methods or web-first assertions instead.
+ *
*
The method finds an element matching the specified selector within the frame and passes it as a first argument to
* {@code expression}. See Working with selectors for more details. If
* no elements match the selector, the method throws an error.
@@ -2407,6 +2416,9 @@ public interface Frame {
/**
* Returns the return value of {@code expression}.
*
+ *
NOTE: In most cases, {@link Locator#evaluateAll Locator.evaluateAll()}, other {@code Locator} helper methods and web-first
+ * assertions do a better job.
+ *
*
The method finds all elements matching the specified selector within the frame and passes an array of matched elements
* as a first argument to {@code expression}. See Working with
* selectors for more details.
@@ -2431,6 +2443,9 @@ public interface Frame {
/**
* Returns the return value of {@code expression}.
*
+ *
NOTE: In most cases, {@link Locator#evaluateAll Locator.evaluateAll()}, other {@code Locator} helper methods and web-first
+ * assertions do a better job.
+ *
*
The method finds all elements matching the specified selector within the frame and passes an array of matched elements
* as a first argument to {@code expression}. See Working with
* selectors for more details.
@@ -2475,7 +2490,7 @@ public interface Frame {
*
*
{@code ElementHandle} instances can be passed as an argument to the {@link Frame#evaluate Frame.evaluate()}:
*
@@ -3010,6 +3025,8 @@ public interface Frame {
/**
* Returns the ElementHandle pointing to the frame element.
*
+ *
NOTE: The use of {@code ElementHandle} is discouraged, use {@code Locator} objects and web-first assertions instead.
+ *
*
The method finds an element matching the specified selector within the frame. See Working with selectors for more details. If no elements match the
* selector, returns {@code null}.
@@ -3023,6 +3040,8 @@ public interface Frame {
/**
* Returns the ElementHandle pointing to the frame element.
*
+ *
NOTE: The use of {@code ElementHandle} is discouraged, use {@code Locator} objects and web-first assertions instead.
+ *
*
The method finds an element matching the specified selector within the frame. See Working with selectors for more details. If no elements match the
* selector, returns {@code null}.
@@ -3034,6 +3053,8 @@ public interface Frame {
/**
* Returns the ElementHandles pointing to the frame elements.
*
+ *
NOTE: The use of {@code ElementHandle} is discouraged, use {@code Locator} objects instead.
+ *
*
The method finds all elements matching the specified selector within the frame. See Working with selectors for more details. If no elements match the
* selector, returns empty array.
@@ -3904,6 +3925,9 @@ public interface Frame {
* Returns when element specified by selector satisfies {@code state} option. Returns {@code null} if waiting for {@code hidden} or
* {@code detached}.
*
+ *
NOTE: Playwright automatically waits for element to be ready before performing an action. Using {@code Locator} objects and
+ * web-first assertions make the code wait-for-selector-free.
+ *
*
Wait for the {@code selector} to satisfy {@code state} option (either appear/disappear from dom, or become visible/hidden). If at
* the moment of calling the method {@code selector} already satisfies the condition, the method will return immediately. If the
* selector doesn't satisfy the condition for the {@code timeout} milliseconds, the function will throw.
@@ -3939,6 +3963,9 @@ public interface Frame {
* Returns when element specified by selector satisfies {@code state} option. Returns {@code null} if waiting for {@code hidden} or
* {@code detached}.
*
+ *
NOTE: Playwright automatically waits for element to be ready before performing an action. Using {@code Locator} objects and
+ * web-first assertions make the code wait-for-selector-free.
+ *
*
Wait for the {@code selector} to satisfy {@code state} option (either appear/disappear from dom, or become visible/hidden). If at
* the moment of calling the method {@code selector} already satisfies the condition, the method will return immediately. If the
* selector doesn't satisfy the condition for the {@code timeout} milliseconds, the function will throw.
diff --git a/playwright/src/main/java/com/microsoft/playwright/Page.java b/playwright/src/main/java/com/microsoft/playwright/Page.java
index d5002845..9e5232ab 100644
--- a/playwright/src/main/java/com/microsoft/playwright/Page.java
+++ b/playwright/src/main/java/com/microsoft/playwright/Page.java
@@ -3467,7 +3467,10 @@ public interface Page extends AutoCloseable {
*/
void emulateMedia(EmulateMediaOptions options);
/**
- * The method finds an element matching the specified selector within the page and passes it as a first argument to
+ * NOTE: This method does not wait for the element to pass actionability checks and therefore can lead to the flaky tests. Use
+ * {@link Locator#evaluate Locator.evaluate()}, other {@code Locator} helper methods or web-first assertions instead.
+ *
+ *
The method finds an element matching the specified selector within the page and passes it as a first argument to
* {@code expression}. If no elements match the selector, the method throws an error. Returns the value of {@code expression}.
*
*
");
* // Use the selector prefixed with its name.
- * ElementHandle button = page.querySelector("tag=button");
+ * Locator button = page.locator("tag=button");
* // Combine it with other selector engines.
* page.click("tag=div >> text=\"Click me\"");
* // Can use it in any methods supporting selectors.
- * int buttonCount = (int) page.evalOnSelectorAll("tag=button", "buttons => buttons.length");
+ * int buttonCount = (int) page.locator("tag=button").count();
* browser.close();
* }