1
0
mirror of synced 2026-05-22 18:53:15 +00:00

chore: roll driver to 1.28.0-alpha-oct-26-2022 (#1106)

This commit is contained in:
Yury Semikhatsky
2022-10-26 10:34:05 -07:00
committed by GitHub
parent 4275ee3455
commit 48d9528675
22 changed files with 628 additions and 95 deletions
+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 -->107.0.5304.18<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Chromium <!-- GEN:chromium-version -->107.0.5304.62<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit <!-- GEN:webkit-version -->16.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->105.0.1<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Firefox <!-- GEN:firefox-version -->106.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/next/intro/#system-requirements) for details.
@@ -17,13 +17,11 @@
package com.microsoft.playwright.impl.driver.jar;
import com.microsoft.playwright.impl.driver.Driver;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.io.IOException;
import java.lang.reflect.Field;
import java.net.ServerSocket;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
@@ -185,7 +185,8 @@ public interface BrowserContext extends AutoCloseable {
*/
public HarNotFound notFound;
/**
* If specified, updates the given HAR with the actual network information instead of serving from file.
* If specified, updates the given HAR with the actual network information instead of serving from file. The file is
* written to disk when {@link BrowserContext#close BrowserContext.close()} is called.
*/
public Boolean update;
/**
@@ -207,7 +208,8 @@ public interface BrowserContext extends AutoCloseable {
return this;
}
/**
* If specified, updates the given HAR with the actual network information instead of serving from file.
* If specified, updates the given HAR with the actual network information instead of serving from file. The file is
* written to disk when {@link BrowserContext#close BrowserContext.close()} is called.
*/
public RouteFromHAROptions setUpdate(boolean update) {
this.update = update;
@@ -138,6 +138,52 @@ public interface ElementHandle extends JSHandle {
return this;
}
}
class ClearOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public Boolean noWaitAfter;
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
* using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link Page#setDefaultTimeout
* Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public ClearOptions setForce(boolean force) {
this.force = force;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public ClearOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
return this;
}
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
* using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link Page#setDefaultTimeout
* Page.setDefaultTimeout()} methods.
*/
public ClearOptions setTimeout(double timeout) {
this.timeout = timeout;
return this;
}
}
class ClickOptions {
/**
* Defaults to {@code left}.
@@ -438,6 +484,12 @@ public interface ElementHandle extends JSHandle {
* modifiers back. If not specified, currently pressed modifiers are used.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public Boolean noWaitAfter;
/**
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
* element.
@@ -472,6 +524,15 @@ public interface ElementHandle extends JSHandle {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public HoverOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
return this;
}
/**
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
* element.
@@ -607,7 +668,7 @@ public interface ElementHandle extends JSHandle {
public Integer quality;
/**
* When set to {@code "css"}, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using {@code "device"} option will produce a single pixel per each device pixel, so screenhots of
* keep screenshots small. Using {@code "device"} option will produce a single pixel per each device pixel, so screenshots of
* high-dpi devices will be twice as large or even larger.
*
* <p> Defaults to {@code "device"}.
@@ -680,7 +741,7 @@ public interface ElementHandle extends JSHandle {
}
/**
* When set to {@code "css"}, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using {@code "device"} option will produce a single pixel per each device pixel, so screenhots of
* keep screenshots small. Using {@code "device"} option will produce a single pixel per each device pixel, so screenshots of
* high-dpi devices will be twice as large or even larger.
*
* <p> Defaults to {@code "device"}.
@@ -1269,6 +1330,28 @@ public interface ElementHandle extends JSHandle {
* zero timeout disables this.
*/
void check(CheckOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, focuses the
* element, clears it and triggers an {@code input} event after clearing.
*
* <p> If the target element is not an {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element, this method throws an error.
* However, if the element is inside the {@code <label>} element that has an associated <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be
* cleared instead.
*/
default void clear() {
clear(null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, focuses the
* element, clears it and triggers an {@code input} event after clearing.
*
* <p> If the target element is not an {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element, this method throws an error.
* However, if the element is inside the {@code <label>} element that has an associated <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be
* cleared instead.
*/
void clear(ClearOptions options);
/**
* This method clicks the element by performing the following steps:
* <ol>
@@ -1438,7 +1521,7 @@ public interface ElementHandle extends JSHandle {
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default Object evalOnSelector(String selector, String expression) {
@@ -1464,7 +1547,7 @@ public interface ElementHandle extends JSHandle {
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -1489,7 +1572,7 @@ public interface ElementHandle extends JSHandle {
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default Object evalOnSelectorAll(String selector, String expression) {
@@ -1515,7 +1598,7 @@ public interface ElementHandle extends JSHandle {
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -243,6 +243,65 @@ public interface Frame {
return this;
}
}
class ClearOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public Boolean noWaitAfter;
/**
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
* element, the call throws an exception.
*/
public Boolean strict;
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
* using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link Page#setDefaultTimeout
* Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public ClearOptions setForce(boolean force) {
this.force = force;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public ClearOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
return this;
}
/**
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
* element, the call throws an exception.
*/
public ClearOptions setStrict(boolean strict) {
this.strict = strict;
return this;
}
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
* using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link Page#setDefaultTimeout
* Page.setDefaultTimeout()} methods.
*/
public ClearOptions setTimeout(double timeout) {
this.timeout = timeout;
return this;
}
}
class ClickOptions {
/**
* Defaults to {@code left}.
@@ -1081,6 +1140,12 @@ public interface Frame {
* modifiers back. If not specified, currently pressed modifiers are used.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public Boolean noWaitAfter;
/**
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
* element.
@@ -1120,6 +1185,15 @@ public interface Frame {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public HoverOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
return this;
}
/**
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
* element.
@@ -2386,6 +2460,36 @@ public interface Frame {
*/
void check(String selector, CheckOptions options);
List<Frame> childFrames();
/**
* This method waits for an element matching {@code selector}, waits for <a
* href="https://playwright.dev/java/docs/actionability">actionability</a> checks, focuses the element, clears it and
* triggers an {@code input} event after clearing.
*
* <p> If the target element is not an {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element, this method throws an error.
* However, if the element is inside the {@code <label>} element that has an associated <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be
* cleared instead.
*
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See
* <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more details.
*/
default void clear(String selector) {
clear(selector, null);
}
/**
* This method waits for an element matching {@code selector}, waits for <a
* href="https://playwright.dev/java/docs/actionability">actionability</a> checks, focuses the element, clears it and
* triggers an {@code input} event after clearing.
*
* <p> If the target element is not an {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element, this method throws an error.
* However, if the element is inside the {@code <label>} element that has an associated <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be
* cleared instead.
*
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See
* <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more details.
*/
void clear(String selector, ClearOptions options);
/**
* This method clicks an element matching {@code selector} by performing the following steps:
* <ol>
@@ -2629,7 +2733,7 @@ public interface Frame {
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -2659,7 +2763,7 @@ public interface Frame {
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default Object evalOnSelector(String selector, String expression) {
@@ -2688,7 +2792,7 @@ public interface Frame {
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -2714,7 +2818,7 @@ public interface Frame {
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default Object evalOnSelectorAll(String selector, String expression) {
@@ -2741,7 +2845,7 @@ public interface Frame {
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -2775,7 +2879,7 @@ public interface Frame {
* bodyHandle.dispose();
* }</pre>
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default Object evaluate(String expression) {
@@ -2810,7 +2914,7 @@ public interface Frame {
* bodyHandle.dispose();
* }</pre>
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -2842,7 +2946,7 @@ public interface Frame {
* resultHandle.dispose();
* }</pre>
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default JSHandle evaluateHandle(String expression) {
@@ -2875,7 +2979,7 @@ public interface Frame {
* resultHandle.dispose();
* }</pre>
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -3009,7 +3113,7 @@ public interface Frame {
Locator getByAltText(Pattern text, GetByAltTextOptions options);
/**
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
* label text Password in the following DOM:
* label text "Password" in the following DOM:
*
* @param text Text to locate the element for.
*/
@@ -3018,14 +3122,14 @@ public interface Frame {
}
/**
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
* label text Password in the following DOM:
* label text "Password" in the following DOM:
*
* @param text Text to locate the element for.
*/
Locator getByLabel(String text, GetByLabelOptions options);
/**
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
* label text Password in the following DOM:
* label text "Password" in the following DOM:
*
* @param text Text to locate the element for.
*/
@@ -3034,7 +3138,7 @@ public interface Frame {
}
/**
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
* label text Password in the following DOM:
* label text "Password" in the following DOM:
*
* @param text Text to locate the element for.
*/
@@ -3139,7 +3243,7 @@ public interface Frame {
*/
Locator getByText(Pattern text, GetByTextOptions options);
/**
* Allows locating elements by their title. For example, this method will find the button by its title "Submit":
* Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
*
* @param text Text to locate the element for.
*/
@@ -3147,13 +3251,13 @@ public interface Frame {
return getByTitle(text, null);
}
/**
* Allows locating elements by their title. For example, this method will find the button by its title "Submit":
* Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
*
* @param text Text to locate the element for.
*/
Locator getByTitle(String text, GetByTitleOptions options);
/**
* Allows locating elements by their title. For example, this method will find the button by its title "Submit":
* Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
*
* @param text Text to locate the element for.
*/
@@ -3161,7 +3265,7 @@ public interface Frame {
return getByTitle(text, null);
}
/**
* Allows locating elements by their title. For example, this method will find the button by its title "Submit":
* Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
*
* @param text Text to locate the element for.
*/
@@ -4270,7 +4374,7 @@ public interface Frame {
* frame.waitForFunction("selector => !!document.querySelector(selector)", selector);
* }</pre>
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -4304,7 +4408,7 @@ public interface Frame {
* frame.waitForFunction("selector => !!document.querySelector(selector)", selector);
* }</pre>
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default JSHandle waitForFunction(String expression) {
@@ -4337,7 +4441,7 @@ public interface Frame {
* frame.waitForFunction("selector => !!document.querySelector(selector)", selector);
* }</pre>
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -355,7 +355,7 @@ public interface FrameLocator {
Locator getByAltText(Pattern text, GetByAltTextOptions options);
/**
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
* label text Password in the following DOM:
* label text "Password" in the following DOM:
*
* @param text Text to locate the element for.
*/
@@ -364,14 +364,14 @@ public interface FrameLocator {
}
/**
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
* label text Password in the following DOM:
* label text "Password" in the following DOM:
*
* @param text Text to locate the element for.
*/
Locator getByLabel(String text, GetByLabelOptions options);
/**
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
* label text Password in the following DOM:
* label text "Password" in the following DOM:
*
* @param text Text to locate the element for.
*/
@@ -380,7 +380,7 @@ public interface FrameLocator {
}
/**
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
* label text Password in the following DOM:
* label text "Password" in the following DOM:
*
* @param text Text to locate the element for.
*/
@@ -485,7 +485,7 @@ public interface FrameLocator {
*/
Locator getByText(Pattern text, GetByTextOptions options);
/**
* Allows locating elements by their title. For example, this method will find the button by its title "Submit":
* Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
*
* @param text Text to locate the element for.
*/
@@ -493,13 +493,13 @@ public interface FrameLocator {
return getByTitle(text, null);
}
/**
* Allows locating elements by their title. For example, this method will find the button by its title "Submit":
* Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
*
* @param text Text to locate the element for.
*/
Locator getByTitle(String text, GetByTitleOptions options);
/**
* Allows locating elements by their title. For example, this method will find the button by its title "Submit":
* Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
*
* @param text Text to locate the element for.
*/
@@ -507,7 +507,7 @@ public interface FrameLocator {
return getByTitle(text, null);
}
/**
* Allows locating elements by their title. For example, this method will find the button by its title "Submit":
* Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
*
* @param text Text to locate the element for.
*/
@@ -57,7 +57,7 @@ public interface JSHandle {
* assertEquals("10 retweets", tweetHandle.evaluate("node => node.innerText"));
* }</pre>
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default Object evaluate(String expression) {
@@ -78,7 +78,7 @@ public interface JSHandle {
* assertEquals("10 retweets", tweetHandle.evaluate("node => node.innerText"));
* }</pre>
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -97,7 +97,7 @@ public interface JSHandle {
*
* <p> See {@link Page#evaluateHandle Page.evaluateHandle()} for more details.
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default JSHandle evaluateHandle(String expression) {
@@ -117,7 +117,7 @@ public interface JSHandle {
*
* <p> See {@link Page#evaluateHandle Page.evaluateHandle()} for more details.
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -20,7 +20,7 @@ import com.microsoft.playwright.options.*;
/**
* 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 keydown, keypress/input, and keyup events on your page.
* 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 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.
@@ -29,6 +29,24 @@ import java.util.regex.Pattern;
* <p> <a href="https://playwright.dev/java/docs/locators">Learn more about locators</a>.
*/
public interface Locator {
class BlurOptions {
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
* using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link Page#setDefaultTimeout
* Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
* using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link Page#setDefaultTimeout
* Page.setDefaultTimeout()} methods.
*/
public BlurOptions setTimeout(double timeout) {
this.timeout = timeout;
return this;
}
}
class BoundingBoxOptions {
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
@@ -128,6 +146,52 @@ public interface Locator {
return this;
}
}
class ClearOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public Boolean noWaitAfter;
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
* using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link Page#setDefaultTimeout
* Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public ClearOptions setForce(boolean force) {
this.force = force;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public ClearOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
return this;
}
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
* using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link Page#setDefaultTimeout
* Page.setDefaultTimeout()} methods.
*/
public ClearOptions setTimeout(double timeout) {
this.timeout = timeout;
return this;
}
}
class ClickOptions {
/**
* Defaults to {@code left}.
@@ -901,6 +965,12 @@ public interface Locator {
* modifiers back. If not specified, currently pressed modifiers are used.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public Boolean noWaitAfter;
/**
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
* element.
@@ -935,6 +1005,15 @@ public interface Locator {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public HoverOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
return this;
}
/**
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
* element.
@@ -1254,7 +1333,7 @@ public interface Locator {
public Integer quality;
/**
* When set to {@code "css"}, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using {@code "device"} option will produce a single pixel per each device pixel, so screenhots of
* keep screenshots small. Using {@code "device"} option will produce a single pixel per each device pixel, so screenshots of
* high-dpi devices will be twice as large or even larger.
*
* <p> Defaults to {@code "device"}.
@@ -1327,7 +1406,7 @@ public interface Locator {
}
/**
* When set to {@code "css"}, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using {@code "device"} option will produce a single pixel per each device pixel, so screenhots of
* keep screenshots small. Using {@code "device"} option will produce a single pixel per each device pixel, so screenshots of
* high-dpi devices will be twice as large or even larger.
*
* <p> Defaults to {@code "device"}.
@@ -1852,6 +1931,16 @@ public interface Locator {
* Returns an array of {@code node.textContent} values for all matching nodes.
*/
List<String> allTextContents();
/**
* Calls <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur">blur</a> on the element.
*/
default void blur() {
blur(null);
}
/**
* Calls <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur">blur</a> on the element.
*/
void blur(BlurOptions options);
/**
* This method returns the bounding box of the element, or {@code null} if the element is not visible. The bounding box is
* calculated relative to the main frame viewport - which is usually the same as the browser window.
@@ -1932,6 +2021,28 @@ public interface Locator {
* zero timeout disables this.
*/
void check(CheckOptions options);
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, focuses the
* element, clears it and triggers an {@code input} event after clearing.
*
* <p> If the target element is not an {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element, this method throws an error.
* However, if the element is inside the {@code <label>} element that has an associated <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be
* cleared instead.
*/
default void clear() {
clear(null);
}
/**
* This method waits for <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks, focuses the
* element, clears it and triggers an {@code input} event after clearing.
*
* <p> If the target element is not an {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element, this method throws an error.
* However, if the element is inside the {@code <label>} element that has an associated <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be
* cleared instead.
*/
void clear(ClearOptions options);
/**
* This method clicks the element by performing the following steps:
* <ol>
@@ -2183,7 +2294,7 @@ public interface Locator {
* assertEquals("10 retweets", tweets.evaluate("node => node.innerText"));
* }</pre>
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -2205,7 +2316,7 @@ public interface Locator {
* assertEquals("10 retweets", tweets.evaluate("node => node.innerText"));
* }</pre>
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default Object evaluate(String expression) {
@@ -2226,7 +2337,7 @@ public interface Locator {
* assertEquals("10 retweets", tweets.evaluate("node => node.innerText"));
* }</pre>
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -2245,7 +2356,7 @@ public interface Locator {
* boolean divCounts = (boolean) elements.evaluateAll("(divs, min) => divs.length >= min", 10);
* }</pre>
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default Object evaluateAll(String expression) {
@@ -2265,7 +2376,7 @@ public interface Locator {
* boolean divCounts = (boolean) elements.evaluateAll("(divs, min) => divs.length >= min", 10);
* }</pre>
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -2284,7 +2395,7 @@ public interface Locator {
*
* <p> See {@link Page#evaluateHandle Page.evaluateHandle()} for more details.
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -2305,7 +2416,7 @@ public interface Locator {
*
* <p> See {@link Page#evaluateHandle Page.evaluateHandle()} for more details.
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default JSHandle evaluateHandle(String expression) {
@@ -2325,7 +2436,7 @@ public interface Locator {
*
* <p> See {@link Page#evaluateHandle Page.evaluateHandle()} for more details.
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -2464,7 +2575,7 @@ public interface Locator {
Locator getByAltText(Pattern text, GetByAltTextOptions options);
/**
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
* label text Password in the following DOM:
* label text "Password" in the following DOM:
*
* @param text Text to locate the element for.
*/
@@ -2473,14 +2584,14 @@ public interface Locator {
}
/**
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
* label text Password in the following DOM:
* label text "Password" in the following DOM:
*
* @param text Text to locate the element for.
*/
Locator getByLabel(String text, GetByLabelOptions options);
/**
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
* label text Password in the following DOM:
* label text "Password" in the following DOM:
*
* @param text Text to locate the element for.
*/
@@ -2489,7 +2600,7 @@ public interface Locator {
}
/**
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
* label text Password in the following DOM:
* label text "Password" in the following DOM:
*
* @param text Text to locate the element for.
*/
@@ -2594,7 +2705,7 @@ public interface Locator {
*/
Locator getByText(Pattern text, GetByTextOptions options);
/**
* Allows locating elements by their title. For example, this method will find the button by its title "Submit":
* Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
*
* @param text Text to locate the element for.
*/
@@ -2602,13 +2713,13 @@ public interface Locator {
return getByTitle(text, null);
}
/**
* Allows locating elements by their title. For example, this method will find the button by its title "Submit":
* Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
*
* @param text Text to locate the element for.
*/
Locator getByTitle(String text, GetByTitleOptions options);
/**
* Allows locating elements by their title. For example, this method will find the button by its title "Submit":
* Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
*
* @param text Text to locate the element for.
*/
@@ -2616,7 +2727,7 @@ public interface Locator {
return getByTitle(text, null);
}
/**
* Allows locating elements by their title. For example, this method will find the button by its title "Submit":
* Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
*
* @param text Text to locate the element for.
*/
@@ -504,6 +504,65 @@ public interface Page extends AutoCloseable {
return this;
}
}
class ClearOptions {
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public Boolean force;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public Boolean noWaitAfter;
/**
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
* element, the call throws an exception.
*/
public Boolean strict;
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
* using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link Page#setDefaultTimeout
* Page.setDefaultTimeout()} methods.
*/
public Double timeout;
/**
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability">actionability</a> checks. Defaults to
* {@code false}.
*/
public ClearOptions setForce(boolean force) {
this.force = force;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public ClearOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
return this;
}
/**
* When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
* element, the call throws an exception.
*/
public ClearOptions setStrict(boolean strict) {
this.strict = strict;
return this;
}
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
* using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link Page#setDefaultTimeout
* Page.setDefaultTimeout()} methods.
*/
public ClearOptions setTimeout(double timeout) {
this.timeout = timeout;
return this;
}
}
class ClickOptions {
/**
* Defaults to {@code left}.
@@ -1515,6 +1574,12 @@ public interface Page extends AutoCloseable {
* modifiers back. If not specified, currently pressed modifiers are used.
*/
public List<KeyboardModifier> modifiers;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public Boolean noWaitAfter;
/**
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
* element.
@@ -1554,6 +1619,15 @@ public interface Page extends AutoCloseable {
this.modifiers = modifiers;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public HoverOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
return this;
}
/**
* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
* element.
@@ -2222,7 +2296,8 @@ public interface Page extends AutoCloseable {
*/
public HarNotFound notFound;
/**
* If specified, updates the given HAR with the actual network information instead of serving from file.
* If specified, updates the given HAR with the actual network information instead of serving from file. The file is
* written to disk when {@link BrowserContext#close BrowserContext.close()} is called.
*/
public Boolean update;
/**
@@ -2244,7 +2319,8 @@ public interface Page extends AutoCloseable {
return this;
}
/**
* If specified, updates the given HAR with the actual network information instead of serving from file.
* If specified, updates the given HAR with the actual network information instead of serving from file. The file is
* written to disk when {@link BrowserContext#close BrowserContext.close()} is called.
*/
public RouteFromHAROptions setUpdate(boolean update) {
this.update = update;
@@ -2315,7 +2391,7 @@ public interface Page extends AutoCloseable {
public Integer quality;
/**
* When set to {@code "css"}, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using {@code "device"} option will produce a single pixel per each device pixel, so screenhots of
* keep screenshots small. Using {@code "device"} option will produce a single pixel per each device pixel, so screenshots of
* high-dpi devices will be twice as large or even larger.
*
* <p> Defaults to {@code "device"}.
@@ -2409,7 +2485,7 @@ public interface Page extends AutoCloseable {
}
/**
* When set to {@code "css"}, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using {@code "device"} option will produce a single pixel per each device pixel, so screenhots of
* keep screenshots small. Using {@code "device"} option will produce a single pixel per each device pixel, so screenshots of
* high-dpi devices will be twice as large or even larger.
*
* <p> Defaults to {@code "device"}.
@@ -3561,6 +3637,36 @@ public interface Page extends AutoCloseable {
* <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more details.
*/
void check(String selector, CheckOptions options);
/**
* This method waits for an element matching {@code selector}, waits for <a
* href="https://playwright.dev/java/docs/actionability">actionability</a> checks, focuses the element, clears it and
* triggers an {@code input} event after clearing. Note that you can pass an empty string to clear the input field.
*
* <p> If the target element is not an {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element, this method throws an error.
* However, if the element is inside the {@code <label>} element that has an associated <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be
* cleared instead.
*
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See
* <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more details.
*/
default void clear(String selector) {
clear(selector, null);
}
/**
* This method waits for an element matching {@code selector}, waits for <a
* href="https://playwright.dev/java/docs/actionability">actionability</a> checks, focuses the element, clears it and
* triggers an {@code input} event after clearing. Note that you can pass an empty string to clear the input field.
*
* <p> If the target element is not an {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element, this method throws an error.
* However, if the element is inside the {@code <label>} element that has an associated <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be
* cleared instead.
*
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See
* <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more details.
*/
void clear(String selector, ClearOptions options);
/**
* This method clicks an element matching {@code selector} by performing the following steps:
* <ol>
@@ -3917,7 +4023,7 @@ public interface Page extends AutoCloseable {
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -3946,7 +4052,7 @@ public interface Page extends AutoCloseable {
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default Object evalOnSelector(String selector, String expression) {
@@ -3974,7 +4080,7 @@ public interface Page extends AutoCloseable {
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -3997,7 +4103,7 @@ public interface Page extends AutoCloseable {
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default Object evalOnSelectorAll(String selector, String expression) {
@@ -4021,7 +4127,7 @@ public interface Page extends AutoCloseable {
*
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors">working with selectors</a> for more
* details.
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -4059,7 +4165,7 @@ public interface Page extends AutoCloseable {
*
* <p> Shortcut for main frame's {@link Frame#evaluate Frame.evaluate()}.
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default Object evaluate(String expression) {
@@ -4098,7 +4204,7 @@ public interface Page extends AutoCloseable {
*
* <p> Shortcut for main frame's {@link Frame#evaluate Frame.evaluate()}.
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -4130,7 +4236,7 @@ public interface Page extends AutoCloseable {
* resultHandle.dispose();
* }</pre>
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default JSHandle evaluateHandle(String expression) {
@@ -4163,7 +4269,7 @@ public interface Page extends AutoCloseable {
* resultHandle.dispose();
* }</pre>
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -4502,7 +4608,7 @@ public interface Page extends AutoCloseable {
Locator getByAltText(Pattern text, GetByAltTextOptions options);
/**
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
* label text Password in the following DOM:
* label text "Password" in the following DOM:
*
* @param text Text to locate the element for.
*/
@@ -4511,14 +4617,14 @@ public interface Page extends AutoCloseable {
}
/**
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
* label text Password in the following DOM:
* label text "Password" in the following DOM:
*
* @param text Text to locate the element for.
*/
Locator getByLabel(String text, GetByLabelOptions options);
/**
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
* label text Password in the following DOM:
* label text "Password" in the following DOM:
*
* @param text Text to locate the element for.
*/
@@ -4527,7 +4633,7 @@ public interface Page extends AutoCloseable {
}
/**
* Allows locating input elements by the text of the associated label. For example, this method will find the input by
* label text Password in the following DOM:
* label text "Password" in the following DOM:
*
* @param text Text to locate the element for.
*/
@@ -4632,7 +4738,7 @@ public interface Page extends AutoCloseable {
*/
Locator getByText(Pattern text, GetByTextOptions options);
/**
* Allows locating elements by their title. For example, this method will find the button by its title "Submit":
* Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
*
* @param text Text to locate the element for.
*/
@@ -4640,13 +4746,13 @@ public interface Page extends AutoCloseable {
return getByTitle(text, null);
}
/**
* Allows locating elements by their title. For example, this method will find the button by its title "Submit":
* Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
*
* @param text Text to locate the element for.
*/
Locator getByTitle(String text, GetByTitleOptions options);
/**
* Allows locating elements by their title. For example, this method will find the button by its title "Submit":
* Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
*
* @param text Text to locate the element for.
*/
@@ -4654,7 +4760,7 @@ public interface Page extends AutoCloseable {
return getByTitle(text, null);
}
/**
* Allows locating elements by their title. For example, this method will find the button by its title "Submit":
* Allows locating elements by their title. For example, this method will find the button by its title "Place the order":
*
* @param text Text to locate the element for.
*/
@@ -6523,7 +6629,7 @@ public interface Page extends AutoCloseable {
*
* <p> Shortcut for main frame's {@link Frame#waitForFunction Frame.waitForFunction()}.
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -6559,7 +6665,7 @@ public interface Page extends AutoCloseable {
*
* <p> Shortcut for main frame's {@link Frame#waitForFunction Frame.waitForFunction()}.
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default JSHandle waitForFunction(String expression) {
@@ -6594,7 +6700,7 @@ public interface Page extends AutoCloseable {
*
* <p> Shortcut for main frame's {@link Frame#waitForFunction Frame.waitForFunction()}.
*
* @param expression JavaScript expression to be evaluated in the browser context. If the expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -34,7 +34,7 @@ import java.util.*;
* <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.
*
* <p> If request gets a 'redirect' response, the request is successfully finished with the 'requestfinished' event, and a new
* <p> If request gets a 'redirect' response, the request is successfully finished with the {@code requestfinished} event, and a new
* request is issued to a redirected url.
*/
public interface Request {
@@ -71,7 +71,7 @@ public interface Worker {
* 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 expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default Object evaluate(String expression) {
@@ -88,7 +88,7 @@ public interface Worker {
* 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 expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -103,7 +103,7 @@ public interface Worker {
* 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 expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
*/
default JSHandle evaluateHandle(String expression) {
@@ -119,7 +119,7 @@ public interface Worker {
* 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 expresion evaluates to a function, the function is
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
* automatically invoked.
* @param arg Optional argument to pass to {@code expression}.
*/
@@ -122,6 +122,11 @@ public class ElementHandleImpl extends JSHandleImpl implements ElementHandle {
withLogging("ElementHandle.check", () -> checkImpl(options));
}
@Override
public void clear(ClearOptions options) {
withLogging("ElementHandle.clear", () -> fillImpl("", convertType(options, FillOptions.class)));
}
private void checkImpl(CheckOptions options) {
if (options == null) {
options = new CheckOptions();
@@ -242,6 +242,15 @@ public class FrameImpl extends ChannelOwner implements Frame {
return new ArrayList<>(childFrames);
}
@Override
public void clear(String selector, ClearOptions options) {
withLogging("Frame.clear", () -> clearImpl(selector, options));
}
void clearImpl(String selector, ClearOptions options) {
fillImpl(selector, "", convertType(options, FillOptions.class));
}
@Override
public void click(String selector, ClickOptions options) {
withLogging("Frame.click", () -> clickImpl(selector, options));
@@ -72,6 +72,21 @@ class LocatorImpl implements Locator {
return (List<String>) frame.evalOnSelectorAll(selector, "ee => ee.map(e => e.textContent || '')");
}
@Override
public void blur(BlurOptions options) {
frame.withLogging("Locator.blur", () -> blurImpl(options));
}
private void blurImpl(BlurOptions options) {
if (options == null) {
options = new BlurOptions();
}
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
params.addProperty("selector", selector);
params.addProperty("strict", true);
frame.sendMessage("blur", params);
}
@Override
public BoundingBox boundingBox(BoundingBoxOptions options) {
return withElement((h, o) -> h.boundingBox(), options);
@@ -85,6 +100,11 @@ class LocatorImpl implements Locator {
frame.check(selector, convertType(options, Frame.CheckOptions.class).setStrict(true));
}
@Override
public void clear(ClearOptions options) {
fill("", convertType(options, FillOptions.class));
}
@Override
public void click(ClickOptions options) {
if (options == null) {
@@ -620,6 +620,12 @@ public class PageImpl extends ChannelOwner implements Page {
() -> mainFrame.checkImpl(selector, convertType(options, Frame.CheckOptions.class)));
}
@Override
public void clear(String selector, ClearOptions options) {
withLogging("Page.clear",
() -> mainFrame.clearImpl(selector, convertType(options, Frame.ClearOptions.class)));
}
@Override
public void click(String selector, ClickOptions options) {
withLogging("Page.click",
@@ -98,5 +98,5 @@ public enum AriaRole {
TOOLTIP,
TREE,
TREEGRID,
TREEITE
TREEITEM
}
@@ -83,4 +83,14 @@ public class TestElementHandleMisc extends TestBase {
input.setChecked(false);
assertEquals(false, page.evaluate("checkbox.checked"));
}
@Test
void shouldClearInput() {
page.navigate(server.PREFIX + "/input/textarea.html");
ElementHandle handle = page.querySelector("input");
handle.fill("some value");
assertEquals("some value", page.evaluate("() => window['result']"));
handle.clear();
assertEquals("", page.evaluate("() => window['result']"));
}
}
@@ -66,4 +66,40 @@ public class TestLocatorMisc extends TestBase{
assertTrue(e.getMessage().contains("Драматург"), e.getMessage());
}
}
@Test
void shouldClearInput() {
page.navigate(server.PREFIX + "/input/textarea.html");
Locator handle = page.locator("input");
handle.fill("some value");
assertEquals("some value", page.evaluate("() => window['result']"));
handle.clear();
assertEquals("", page.evaluate("() => window['result']"));
}
@Test
void shouldFocusAndBlurAButton() {
page.navigate(server.PREFIX + "/input/button.html");
Locator button = page.locator("button");
assertEquals(false, button.evaluate("button => document.activeElement === button"));
boolean[] focused = {false};
boolean[] blurred = {false};
page.exposeFunction("focusEvent", e -> focused[0] = true);
page.exposeFunction("blurEvent", e -> blurred[0] = true);
button.evaluate("button => {\n" +
" button.addEventListener('focus', window['focusEvent']);\n" +
" button.addEventListener('blur', window['blurEvent']);\n" +
" }");
button.focus();
assertTrue(focused[0]);
assertFalse(blurred[0]);
assertEquals(true, button.evaluate("button => document.activeElement === button"));
button.blur();
assertTrue(focused[0]);
assertTrue(blurred[0]);
assertEquals(false, button.evaluate("button => document.activeElement === button"));
}
}
@@ -243,4 +243,39 @@ public class TestPageFill extends TestBase {
page.fill("input", "");
assertEquals("", page.inputValue("input"));
}
@Test
void shouldThrowOnUnsupportedInputsWhenClear() {
page.navigate(server.PREFIX + "/input/textarea.html");
for (String type : new String[]{"button", "checkbox", "file", "image", "radio", "reset", "submit"}) {
page.evalOnSelector("input", "(input, type) => input.setAttribute('type', type)", type);
PlaywrightException e = assertThrows(PlaywrightException.class, () -> page.clear("input"));
assertTrue(e.getMessage().contains("input of type \"" + type + "\" cannot be filled"), e.getMessage());
}
}
@Test
void shouldThrowNiceErrorWithoutInjectedScriptStackWhenElementIsNotAnInputWhenClear() {
page.navigate(server.PREFIX + "/input/textarea.html");
PlaywrightException e = assertThrows(PlaywrightException.class, () -> page.clear("body"));
assertTrue(e.getMessage().contains("Error: Element is not an <input>, <textarea> or [contenteditable] element\n=========================== logs"), e.getMessage());
}
@Test
void shouldBeAbleToClearUsingFill() {
page.navigate(server.PREFIX + "/input/textarea.html");
page.fill("input", "some value");
assertEquals("some value", page.evaluate("() => window['result']"));
page.fill("input", "");
assertEquals("", page.evaluate("() => window['result']"));
}
@Test
void shouldBeAbleToClearUsingClear() {
page.navigate(server.PREFIX + "/input/textarea.html");
page.fill("input", "some value");
assertEquals("some value", page.evaluate("() => window['result']"));
page.clear("input");
assertEquals("", page.evaluate("() => window['result']"));
}
}
@@ -142,8 +142,16 @@ public class TestPopup extends TestBase {
page.navigate(server.EMPTY_PAGE);
Object[] size = {null};
Page popup = page.waitForPopup(() -> {
size[0] = page.evaluate("() => {\n" +
size[0] = page.evaluate("async () => {\n" +
" const win = window.open(window.location.href, 'Title', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=300,top=0,left=0');\n" +
" await new Promise(resolve => {\n" +
" const interval = setInterval(() => {\n" +
" if (win.innerWidth === 600 && win.innerHeight === 300) {\n" +
" clearInterval(interval);\n" +
" resolve();\n" +
" }\n" +
" }, 10);\n" +
" });\n" +
" return { width: win.innerWidth, height: win.innerHeight };\n" +
"}");
});
+1 -1
View File
@@ -1 +1 @@
1.27.0
1.28.0-alpha-oct-26-2022