feat: roll driver to 07/12, implement new features (#514)
This commit is contained in:
@@ -60,6 +60,17 @@ public interface Browser extends AutoCloseable {
|
||||
* Whether to automatically download all the attachments. Defaults to {@code false} where all the downloads are canceled.
|
||||
*/
|
||||
public Boolean acceptDownloads;
|
||||
/**
|
||||
* When using {@link Page#goto Page.goto()}, {@link Page#route Page.route()}, {@link Page#waitForURL Page.waitForURL()},
|
||||
* {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse Page.waitForResponse()} it takes the
|
||||
* base URL in consideration by using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a>
|
||||
* constructor for building the corresponding URL. Examples:
|
||||
* <ul>
|
||||
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code http://localhost:3000/bar.html}</li>
|
||||
* <li> baseURL: {@code http://localhost:3000/foo/} and navigating to {@code ./bar.html} results in {@code http://localhost:3000/foo/bar.html}</li>
|
||||
* </ul>
|
||||
*/
|
||||
public String baseURL;
|
||||
/**
|
||||
* Toggles bypassing page's Content-Security-Policy.
|
||||
*/
|
||||
@@ -182,6 +193,10 @@ public interface Browser extends AutoCloseable {
|
||||
this.acceptDownloads = acceptDownloads;
|
||||
return this;
|
||||
}
|
||||
public NewContextOptions setBaseURL(String baseURL) {
|
||||
this.baseURL = baseURL;
|
||||
return this;
|
||||
}
|
||||
public NewContextOptions setBypassCSP(boolean bypassCSP) {
|
||||
this.bypassCSP = bypassCSP;
|
||||
return this;
|
||||
@@ -306,6 +321,17 @@ public interface Browser extends AutoCloseable {
|
||||
* Whether to automatically download all the attachments. Defaults to {@code false} where all the downloads are canceled.
|
||||
*/
|
||||
public Boolean acceptDownloads;
|
||||
/**
|
||||
* When using {@link Page#goto Page.goto()}, {@link Page#route Page.route()}, {@link Page#waitForURL Page.waitForURL()},
|
||||
* {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse Page.waitForResponse()} it takes the
|
||||
* base URL in consideration by using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a>
|
||||
* constructor for building the corresponding URL. Examples:
|
||||
* <ul>
|
||||
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code http://localhost:3000/bar.html}</li>
|
||||
* <li> baseURL: {@code http://localhost:3000/foo/} and navigating to {@code ./bar.html} results in {@code http://localhost:3000/foo/bar.html}</li>
|
||||
* </ul>
|
||||
*/
|
||||
public String baseURL;
|
||||
/**
|
||||
* Toggles bypassing page's Content-Security-Policy.
|
||||
*/
|
||||
@@ -428,6 +454,10 @@ public interface Browser extends AutoCloseable {
|
||||
this.acceptDownloads = acceptDownloads;
|
||||
return this;
|
||||
}
|
||||
public NewPageOptions setBaseURL(String baseURL) {
|
||||
this.baseURL = baseURL;
|
||||
return this;
|
||||
}
|
||||
public NewPageOptions setBypassCSP(boolean bypassCSP) {
|
||||
this.bypassCSP = bypassCSP;
|
||||
return this;
|
||||
|
||||
@@ -555,7 +555,9 @@ public interface BrowserContext extends AutoCloseable {
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
|
||||
*
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing. When a {@code baseURL} via the context
|
||||
* options was provided and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param handler handler function to route the request.
|
||||
*/
|
||||
void route(String url, Consumer<Route> handler);
|
||||
@@ -599,7 +601,9 @@ public interface BrowserContext extends AutoCloseable {
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
|
||||
*
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing. When a {@code baseURL} via the context
|
||||
* options was provided and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param handler handler function to route the request.
|
||||
*/
|
||||
void route(Pattern url, Consumer<Route> handler);
|
||||
@@ -643,7 +647,9 @@ public interface BrowserContext extends AutoCloseable {
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
|
||||
*
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing. When a {@code baseURL} via the context
|
||||
* options was provided and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param handler handler function to route the request.
|
||||
*/
|
||||
void route(Predicate<String> url, Consumer<Route> handler);
|
||||
|
||||
@@ -278,6 +278,17 @@ public interface BrowserType {
|
||||
* href="http://peter.sh/experiments/chromium-command-line-switches/">here</a>.
|
||||
*/
|
||||
public List<String> args;
|
||||
/**
|
||||
* When using {@link Page#goto Page.goto()}, {@link Page#route Page.route()}, {@link Page#waitForURL Page.waitForURL()},
|
||||
* {@link Page#waitForRequest Page.waitForRequest()}, or {@link Page#waitForResponse Page.waitForResponse()} it takes the
|
||||
* base URL in consideration by using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code URL()}</a>
|
||||
* constructor for building the corresponding URL. Examples:
|
||||
* <ul>
|
||||
* <li> baseURL: {@code http://localhost:3000} and navigating to {@code /bar.html} results in {@code http://localhost:3000/bar.html}</li>
|
||||
* <li> baseURL: {@code http://localhost:3000/foo/} and navigating to {@code ./bar.html} results in {@code http://localhost:3000/foo/bar.html}</li>
|
||||
* </ul>
|
||||
*/
|
||||
public String baseURL;
|
||||
/**
|
||||
* Toggles bypassing page's Content-Security-Policy.
|
||||
*/
|
||||
@@ -461,6 +472,10 @@ public interface BrowserType {
|
||||
this.args = args;
|
||||
return this;
|
||||
}
|
||||
public LaunchPersistentContextOptions setBaseURL(String baseURL) {
|
||||
this.baseURL = baseURL;
|
||||
return this;
|
||||
}
|
||||
public LaunchPersistentContextOptions setBypassCSP(boolean bypassCSP) {
|
||||
this.bypassCSP = bypassCSP;
|
||||
return this;
|
||||
|
||||
@@ -48,12 +48,10 @@ import java.util.*;
|
||||
*/
|
||||
public interface Download {
|
||||
/**
|
||||
* **Chromium-only** Cancels a download. Will not fail if the download is already finished or canceled. Upon successful
|
||||
* cancellations, {@code download.failure()} would resolve to {@code "canceled"}.
|
||||
*
|
||||
* <p> Currently **experimental** and may subject to further changes.
|
||||
* Cancels a download. Will not fail if the download is already finished or canceled. Upon successful cancellations,
|
||||
* {@code download.failure()} would resolve to {@code "canceled"}.
|
||||
*/
|
||||
void _cancel();
|
||||
void cancel();
|
||||
/**
|
||||
* Returns readable stream for current download or {@code null} if download failed.
|
||||
*/
|
||||
@@ -73,6 +71,9 @@ public interface Download {
|
||||
/**
|
||||
* Returns path to the downloaded file in case of successful download. The method will wait for the download to finish if
|
||||
* necessary. The method throws when connected remotely.
|
||||
*
|
||||
* <p> Note that the download's file name is a random GUID, use {@link Download#suggestedFilename Download.suggestedFilename()}
|
||||
* to get suggested file name.
|
||||
*/
|
||||
Path path();
|
||||
/**
|
||||
|
||||
@@ -269,6 +269,11 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
}
|
||||
class FillOptions {
|
||||
/**
|
||||
* 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
|
||||
@@ -282,6 +287,10 @@ public interface ElementHandle extends JSHandle {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public FillOptions setForce(boolean force) {
|
||||
this.force = force;
|
||||
return this;
|
||||
}
|
||||
public FillOptions setNoWaitAfter(boolean noWaitAfter) {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
@@ -344,6 +353,19 @@ public interface ElementHandle extends JSHandle {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class InputValueOptions {
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public InputValueOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class PressOptions {
|
||||
/**
|
||||
* Time to wait between {@code keydown} and {@code keyup} in milliseconds. Defaults to 0.
|
||||
@@ -437,6 +459,11 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
}
|
||||
class SelectOptionOptions {
|
||||
/**
|
||||
* 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
|
||||
@@ -450,6 +477,10 @@ public interface ElementHandle extends JSHandle {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public SelectOptionOptions setForce(boolean force) {
|
||||
this.force = force;
|
||||
return this;
|
||||
}
|
||||
public SelectOptionOptions setNoWaitAfter(boolean noWaitAfter) {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
@@ -460,6 +491,11 @@ public interface ElementHandle extends JSHandle {
|
||||
}
|
||||
}
|
||||
class SelectTextOptions {
|
||||
/**
|
||||
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
|
||||
* {@code false}.
|
||||
*/
|
||||
public Boolean force;
|
||||
/**
|
||||
* 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
|
||||
@@ -467,6 +503,10 @@ public interface ElementHandle extends JSHandle {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public SelectTextOptions setForce(boolean force) {
|
||||
this.force = force;
|
||||
return this;
|
||||
}
|
||||
public SelectTextOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@@ -1079,6 +1119,16 @@ public interface ElementHandle extends JSHandle {
|
||||
* Returns the {@code element.innerText}.
|
||||
*/
|
||||
String innerText();
|
||||
/**
|
||||
* Returns {@code input.value} for {@code <input>} or {@code <textarea>} element. Throws for non-input elements.
|
||||
*/
|
||||
default String inputValue() {
|
||||
return inputValue(null);
|
||||
}
|
||||
/**
|
||||
* Returns {@code input.value} for {@code <input>} or {@code <textarea>} element. Throws for non-input elements.
|
||||
*/
|
||||
String inputValue(InputValueOptions options);
|
||||
/**
|
||||
* Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
|
||||
*/
|
||||
|
||||
@@ -359,6 +359,11 @@ public interface Frame {
|
||||
}
|
||||
}
|
||||
class FillOptions {
|
||||
/**
|
||||
* 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
|
||||
@@ -372,6 +377,10 @@ public interface Frame {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public FillOptions setForce(boolean force) {
|
||||
this.force = force;
|
||||
return this;
|
||||
}
|
||||
public FillOptions setNoWaitAfter(boolean noWaitAfter) {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
@@ -522,6 +531,19 @@ public interface Frame {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class InputValueOptions {
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public InputValueOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsCheckedOptions {
|
||||
/**
|
||||
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
|
||||
@@ -574,32 +596,6 @@ public interface Frame {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsHiddenOptions {
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public IsHiddenOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsVisibleOptions {
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public IsVisibleOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class PressOptions {
|
||||
/**
|
||||
* Time to wait between {@code keydown} and {@code keyup} in milliseconds. Defaults to 0.
|
||||
@@ -632,6 +628,11 @@ public interface Frame {
|
||||
}
|
||||
}
|
||||
class SelectOptionOptions {
|
||||
/**
|
||||
* 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
|
||||
@@ -645,6 +646,10 @@ public interface Frame {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public SelectOptionOptions setForce(boolean force) {
|
||||
this.force = force;
|
||||
return this;
|
||||
}
|
||||
public SelectOptionOptions setNoWaitAfter(boolean noWaitAfter) {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
@@ -1716,6 +1721,22 @@ public interface Frame {
|
||||
* href="https://playwright.dev/java/docs/selectors/">working with selectors</a> for more details.
|
||||
*/
|
||||
String innerText(String selector, InnerTextOptions options);
|
||||
/**
|
||||
* Returns {@code input.value} for the selected {@code <input>} or {@code <textarea>} element. Throws for non-input elements.
|
||||
*
|
||||
* @param selector A selector to search for 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 String inputValue(String selector) {
|
||||
return inputValue(selector, null);
|
||||
}
|
||||
/**
|
||||
* Returns {@code input.value} for the selected {@code <input>} or {@code <textarea>} element. Throws for non-input elements.
|
||||
*
|
||||
* @param selector A selector to search for 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.
|
||||
*/
|
||||
String inputValue(String selector, InputValueOptions options);
|
||||
/**
|
||||
* Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
|
||||
*
|
||||
@@ -1794,18 +1815,7 @@ public interface Frame {
|
||||
* @param selector A selector to search for 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 boolean isHidden(String selector) {
|
||||
return isHidden(selector, null);
|
||||
}
|
||||
/**
|
||||
* Returns whether the element is hidden, the opposite of <a
|
||||
* href="https://playwright.dev/java/docs/actionability/#visible">visible</a>. {@code selector} that does not match any elements
|
||||
* is considered hidden.
|
||||
*
|
||||
* @param selector A selector to search for 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.
|
||||
*/
|
||||
boolean isHidden(String selector, IsHiddenOptions options);
|
||||
boolean isHidden(String selector);
|
||||
/**
|
||||
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability/#visible">visible</a>. {@code selector}
|
||||
* that does not match any elements is considered not visible.
|
||||
@@ -1813,17 +1823,7 @@ public interface Frame {
|
||||
* @param selector A selector to search for 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 boolean isVisible(String selector) {
|
||||
return isVisible(selector, null);
|
||||
}
|
||||
/**
|
||||
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability/#visible">visible</a>. {@code selector}
|
||||
* that does not match any elements is considered not visible.
|
||||
*
|
||||
* @param selector A selector to search for 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.
|
||||
*/
|
||||
boolean isVisible(String selector, IsVisibleOptions options);
|
||||
boolean isVisible(String selector);
|
||||
/**
|
||||
* Returns frame's name attribute as specified in the tag.
|
||||
*
|
||||
|
||||
@@ -659,6 +659,11 @@ public interface Page extends AutoCloseable {
|
||||
}
|
||||
}
|
||||
class FillOptions {
|
||||
/**
|
||||
* 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
|
||||
@@ -672,6 +677,10 @@ public interface Page extends AutoCloseable {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public FillOptions setForce(boolean force) {
|
||||
this.force = force;
|
||||
return this;
|
||||
}
|
||||
public FillOptions setNoWaitAfter(boolean noWaitAfter) {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
@@ -876,6 +885,19 @@ public interface Page extends AutoCloseable {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class InputValueOptions {
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public InputValueOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsCheckedOptions {
|
||||
/**
|
||||
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
|
||||
@@ -928,32 +950,6 @@ public interface Page extends AutoCloseable {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsHiddenOptions {
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public IsHiddenOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsVisibleOptions {
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public IsVisibleOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class PdfOptions {
|
||||
/**
|
||||
* Display header and footer. Defaults to {@code false}.
|
||||
@@ -1198,6 +1194,11 @@ public interface Page extends AutoCloseable {
|
||||
}
|
||||
}
|
||||
class SelectOptionOptions {
|
||||
/**
|
||||
* 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
|
||||
@@ -1211,6 +1212,10 @@ public interface Page extends AutoCloseable {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public SelectOptionOptions setForce(boolean force) {
|
||||
this.force = force;
|
||||
return this;
|
||||
}
|
||||
public SelectOptionOptions setNoWaitAfter(boolean noWaitAfter) {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
@@ -2752,7 +2757,9 @@ public interface Page extends AutoCloseable {
|
||||
*
|
||||
* <p> Shortcut for main frame's {@link Frame#goto Frame.goto()}
|
||||
*
|
||||
* @param url URL to navigate page to. The url should include scheme, e.g. {@code https://}.
|
||||
* @param url URL to navigate page to. The url should include scheme, e.g. {@code https://}. When a {@code baseURL} via the context options was
|
||||
* provided and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
*/
|
||||
default Response navigate(String url) {
|
||||
return navigate(url, null);
|
||||
@@ -2782,7 +2789,9 @@ public interface Page extends AutoCloseable {
|
||||
*
|
||||
* <p> Shortcut for main frame's {@link Frame#goto Frame.goto()}
|
||||
*
|
||||
* @param url URL to navigate page to. The url should include scheme, e.g. {@code https://}.
|
||||
* @param url URL to navigate page to. The url should include scheme, e.g. {@code https://}. When a {@code baseURL} via the context options was
|
||||
* provided and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
*/
|
||||
Response navigate(String url, NavigateOptions options);
|
||||
/**
|
||||
@@ -2859,6 +2868,22 @@ public interface Page extends AutoCloseable {
|
||||
* href="https://playwright.dev/java/docs/selectors/">working with selectors</a> for more details.
|
||||
*/
|
||||
String innerText(String selector, InnerTextOptions options);
|
||||
/**
|
||||
* Returns {@code input.value} for the selected {@code <input>} or {@code <textarea>} element. Throws for non-input elements.
|
||||
*
|
||||
* @param selector A selector to search for 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 String inputValue(String selector) {
|
||||
return inputValue(selector, null);
|
||||
}
|
||||
/**
|
||||
* Returns {@code input.value} for the selected {@code <input>} or {@code <textarea>} element. Throws for non-input elements.
|
||||
*
|
||||
* @param selector A selector to search for 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.
|
||||
*/
|
||||
String inputValue(String selector, InputValueOptions options);
|
||||
/**
|
||||
* Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
|
||||
*
|
||||
@@ -2937,18 +2962,7 @@ public interface Page extends AutoCloseable {
|
||||
* @param selector A selector to search for 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 boolean isHidden(String selector) {
|
||||
return isHidden(selector, null);
|
||||
}
|
||||
/**
|
||||
* Returns whether the element is hidden, the opposite of <a
|
||||
* href="https://playwright.dev/java/docs/actionability/#visible">visible</a>. {@code selector} that does not match any elements
|
||||
* is considered hidden.
|
||||
*
|
||||
* @param selector A selector to search for 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.
|
||||
*/
|
||||
boolean isHidden(String selector, IsHiddenOptions options);
|
||||
boolean isHidden(String selector);
|
||||
/**
|
||||
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability/#visible">visible</a>. {@code selector}
|
||||
* that does not match any elements is considered not visible.
|
||||
@@ -2956,17 +2970,7 @@ public interface Page extends AutoCloseable {
|
||||
* @param selector A selector to search for 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 boolean isVisible(String selector) {
|
||||
return isVisible(selector, null);
|
||||
}
|
||||
/**
|
||||
* Returns whether the element is <a href="https://playwright.dev/java/docs/actionability/#visible">visible</a>. {@code selector}
|
||||
* that does not match any elements is considered not visible.
|
||||
*
|
||||
* @param selector A selector to search for 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.
|
||||
*/
|
||||
boolean isVisible(String selector, IsVisibleOptions options);
|
||||
boolean isVisible(String selector);
|
||||
Keyboard keyboard();
|
||||
/**
|
||||
* The page's main frame. Page is guaranteed to have a main frame which persists during navigations.
|
||||
@@ -3244,7 +3248,9 @@ public interface Page extends AutoCloseable {
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
|
||||
*
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing. When a {@code baseURL} via the context
|
||||
* options was provided and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param handler handler function to route the request.
|
||||
*/
|
||||
void route(String url, Consumer<Route> handler);
|
||||
@@ -3289,7 +3295,9 @@ public interface Page extends AutoCloseable {
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
|
||||
*
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing. When a {@code baseURL} via the context
|
||||
* options was provided and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param handler handler function to route the request.
|
||||
*/
|
||||
void route(Pattern url, Consumer<Route> handler);
|
||||
@@ -3334,7 +3342,9 @@ public interface Page extends AutoCloseable {
|
||||
*
|
||||
* <p> <strong>NOTE:</strong> Enabling routing disables http cache.
|
||||
*
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing.
|
||||
* @param url A glob pattern, regex pattern or predicate receiving [URL] to match while routing. When a {@code baseURL} via the context
|
||||
* options was provided and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param handler handler function to route the request.
|
||||
*/
|
||||
void route(Predicate<String> url, Consumer<Route> handler);
|
||||
@@ -4428,7 +4438,7 @@ public interface Page extends AutoCloseable {
|
||||
*/
|
||||
Page waitForPopup(WaitForPopupOptions options, Runnable callback);
|
||||
/**
|
||||
* Waits for the matching request and returns it. See <a
|
||||
* Waits for the matching request and returns it. See <a
|
||||
* href="https://playwright.dev/java/docs/events/#waiting-for-event">waiting for event</a> for more details about events.
|
||||
* <pre>{@code
|
||||
* // Waits for the next request with the specified url
|
||||
@@ -4444,14 +4454,16 @@ public interface Page extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Request} object.
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Request} object. When a {@code baseURL} via the context options was provided
|
||||
* and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param callback Callback that performs the action triggering the event.
|
||||
*/
|
||||
default Request waitForRequest(String urlOrPredicate, Runnable callback) {
|
||||
return waitForRequest(urlOrPredicate, null, callback);
|
||||
}
|
||||
/**
|
||||
* Waits for the matching request and returns it. See <a
|
||||
* Waits for the matching request and returns it. See <a
|
||||
* href="https://playwright.dev/java/docs/events/#waiting-for-event">waiting for event</a> for more details about events.
|
||||
* <pre>{@code
|
||||
* // Waits for the next request with the specified url
|
||||
@@ -4467,12 +4479,14 @@ public interface Page extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Request} object.
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Request} object. When a {@code baseURL} via the context options was provided
|
||||
* and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param callback Callback that performs the action triggering the event.
|
||||
*/
|
||||
Request waitForRequest(String urlOrPredicate, WaitForRequestOptions options, Runnable callback);
|
||||
/**
|
||||
* Waits for the matching request and returns it. See <a
|
||||
* Waits for the matching request and returns it. See <a
|
||||
* href="https://playwright.dev/java/docs/events/#waiting-for-event">waiting for event</a> for more details about events.
|
||||
* <pre>{@code
|
||||
* // Waits for the next request with the specified url
|
||||
@@ -4488,14 +4502,16 @@ public interface Page extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Request} object.
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Request} object. When a {@code baseURL} via the context options was provided
|
||||
* and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param callback Callback that performs the action triggering the event.
|
||||
*/
|
||||
default Request waitForRequest(Pattern urlOrPredicate, Runnable callback) {
|
||||
return waitForRequest(urlOrPredicate, null, callback);
|
||||
}
|
||||
/**
|
||||
* Waits for the matching request and returns it. See <a
|
||||
* Waits for the matching request and returns it. See <a
|
||||
* href="https://playwright.dev/java/docs/events/#waiting-for-event">waiting for event</a> for more details about events.
|
||||
* <pre>{@code
|
||||
* // Waits for the next request with the specified url
|
||||
@@ -4511,12 +4527,14 @@ public interface Page extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Request} object.
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Request} object. When a {@code baseURL} via the context options was provided
|
||||
* and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param callback Callback that performs the action triggering the event.
|
||||
*/
|
||||
Request waitForRequest(Pattern urlOrPredicate, WaitForRequestOptions options, Runnable callback);
|
||||
/**
|
||||
* Waits for the matching request and returns it. See <a
|
||||
* Waits for the matching request and returns it. See <a
|
||||
* href="https://playwright.dev/java/docs/events/#waiting-for-event">waiting for event</a> for more details about events.
|
||||
* <pre>{@code
|
||||
* // Waits for the next request with the specified url
|
||||
@@ -4532,14 +4550,16 @@ public interface Page extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Request} object.
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Request} object. When a {@code baseURL} via the context options was provided
|
||||
* and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param callback Callback that performs the action triggering the event.
|
||||
*/
|
||||
default Request waitForRequest(Predicate<Request> urlOrPredicate, Runnable callback) {
|
||||
return waitForRequest(urlOrPredicate, null, callback);
|
||||
}
|
||||
/**
|
||||
* Waits for the matching request and returns it. See <a
|
||||
* Waits for the matching request and returns it. See <a
|
||||
* href="https://playwright.dev/java/docs/events/#waiting-for-event">waiting for event</a> for more details about events.
|
||||
* <pre>{@code
|
||||
* // Waits for the next request with the specified url
|
||||
@@ -4555,7 +4575,9 @@ public interface Page extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Request} object.
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Request} object. When a {@code baseURL} via the context options was provided
|
||||
* and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param callback Callback that performs the action triggering the event.
|
||||
*/
|
||||
Request waitForRequest(Predicate<Request> urlOrPredicate, WaitForRequestOptions options, Runnable callback);
|
||||
@@ -4594,7 +4616,9 @@ public interface Page extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Response} object.
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Response} object. When a {@code baseURL} via the context options was
|
||||
* provided and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param callback Callback that performs the action triggering the event.
|
||||
*/
|
||||
default Response waitForResponse(String urlOrPredicate, Runnable callback) {
|
||||
@@ -4617,7 +4641,9 @@ public interface Page extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Response} object.
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Response} object. When a {@code baseURL} via the context options was
|
||||
* provided and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param callback Callback that performs the action triggering the event.
|
||||
*/
|
||||
Response waitForResponse(String urlOrPredicate, WaitForResponseOptions options, Runnable callback);
|
||||
@@ -4638,7 +4664,9 @@ public interface Page extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Response} object.
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Response} object. When a {@code baseURL} via the context options was
|
||||
* provided and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param callback Callback that performs the action triggering the event.
|
||||
*/
|
||||
default Response waitForResponse(Pattern urlOrPredicate, Runnable callback) {
|
||||
@@ -4661,7 +4689,9 @@ public interface Page extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Response} object.
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Response} object. When a {@code baseURL} via the context options was
|
||||
* provided and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param callback Callback that performs the action triggering the event.
|
||||
*/
|
||||
Response waitForResponse(Pattern urlOrPredicate, WaitForResponseOptions options, Runnable callback);
|
||||
@@ -4682,7 +4712,9 @@ public interface Page extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Response} object.
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Response} object. When a {@code baseURL} via the context options was
|
||||
* provided and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param callback Callback that performs the action triggering the event.
|
||||
*/
|
||||
default Response waitForResponse(Predicate<Response> urlOrPredicate, Runnable callback) {
|
||||
@@ -4705,7 +4737,9 @@ public interface Page extends AutoCloseable {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Response} object.
|
||||
* @param urlOrPredicate Request URL string, regex or predicate receiving {@code Response} object. When a {@code baseURL} via the context options was
|
||||
* provided and the passed URL is a path, it gets merged via the <a
|
||||
* href="https://developer.mozilla.org/en-US/docs/Web/API/URL/URL">{@code new URL()}</a> constructor.
|
||||
* @param callback Callback that performs the action triggering the event.
|
||||
*/
|
||||
Response waitForResponse(Predicate<Response> urlOrPredicate, WaitForResponseOptions options, Runnable callback);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.microsoft.playwright;
|
||||
|
||||
import com.microsoft.playwright.options.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -46,6 +47,14 @@ public interface Response {
|
||||
* Returns the matching {@code Request} object.
|
||||
*/
|
||||
Request request();
|
||||
/**
|
||||
* Returns SSL and other security information.
|
||||
*/
|
||||
SecurityDetails securityDetails();
|
||||
/**
|
||||
* Returns the IP address and port of the server.
|
||||
*/
|
||||
ServerAddr serverAddr();
|
||||
/**
|
||||
* Contains the status code of the response (e.g., 200 for a success).
|
||||
*/
|
||||
|
||||
@@ -40,6 +40,10 @@ class ArtifactImpl extends ChannelOwner {
|
||||
return stream.stream();
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
sendMessage("cancel");
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
sendMessage("delete");
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ class DownloadImpl extends LoggingSupport implements Download {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void _cancel() {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
public void cancel() {
|
||||
withLogging("Download.cancel", () -> artifact.cancel());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -236,6 +236,20 @@ public class ElementHandleImpl extends JSHandleImpl implements ElementHandle {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String inputValue(InputValueOptions options) {
|
||||
return withLogging("ElementHandle.inputValue", () -> inputValueImpl(options));
|
||||
}
|
||||
|
||||
private String inputValueImpl(InputValueOptions options) {
|
||||
if (options == null) {
|
||||
options = new InputValueOptions();
|
||||
}
|
||||
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
|
||||
JsonObject json = sendMessage("inputValue", params).getAsJsonObject();
|
||||
return json.get("value").getAsString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return withLogging("ElementHandle.isChecked", () -> {
|
||||
|
||||
@@ -41,6 +41,7 @@ public class FrameImpl extends ChannelOwner implements Frame {
|
||||
FrameImpl parentFrame;
|
||||
Set<FrameImpl> childFrames = new LinkedHashSet<>();
|
||||
private final Set<LoadState> loadStates = new HashSet<>();
|
||||
|
||||
enum InternalEventType { NAVIGATED, LOADSTATE }
|
||||
private final ListenerCollection<InternalEventType> internalListeners = new ListenerCollection<>();
|
||||
PageImpl page;
|
||||
@@ -437,6 +438,21 @@ public class FrameImpl extends ChannelOwner implements Frame {
|
||||
return json.get("value").getAsString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String inputValue(String selector, InputValueOptions options) {
|
||||
return withLogging("Frame.inputValue", () -> inputValueImpl(selector, options));
|
||||
}
|
||||
|
||||
String inputValueImpl(String selector, InputValueOptions options) {
|
||||
if (options == null) {
|
||||
options = new InputValueOptions();
|
||||
}
|
||||
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
|
||||
params.addProperty("selector", selector);
|
||||
JsonObject json = sendMessage("inputValue", params).getAsJsonObject();
|
||||
return json.get("value").getAsString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked(String selector, IsCheckedOptions options) {
|
||||
return withLogging("Page.isChecked", () -> isCheckedImpl(selector, options));
|
||||
@@ -503,30 +519,24 @@ public class FrameImpl extends ChannelOwner implements Frame {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden(String selector, IsHiddenOptions options) {
|
||||
return withLogging("Page.isHidden", () -> isHiddenImpl(selector, options));
|
||||
public boolean isHidden(String selector) {
|
||||
return withLogging("Page.isHidden", () -> isHiddenImpl(selector));
|
||||
}
|
||||
|
||||
boolean isHiddenImpl(String selector, IsHiddenOptions options) {
|
||||
if (options == null) {
|
||||
options = new IsHiddenOptions();
|
||||
}
|
||||
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
|
||||
boolean isHiddenImpl(String selector) {
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty("selector", selector);
|
||||
JsonObject json = sendMessage("isHidden", params).getAsJsonObject();
|
||||
return json.get("value").getAsBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(String selector, IsVisibleOptions options) {
|
||||
return withLogging("Page.isVisible", () -> isVisibleImpl(selector, options));
|
||||
public boolean isVisible(String selector) {
|
||||
return withLogging("Page.isVisible", () -> isVisibleImpl(selector));
|
||||
}
|
||||
|
||||
boolean isVisibleImpl(String selector, IsVisibleOptions options) {
|
||||
if (options == null) {
|
||||
options = new IsVisibleOptions();
|
||||
}
|
||||
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
|
||||
boolean isVisibleImpl(String selector) {
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty("selector", selector);
|
||||
JsonObject json = sendMessage("isVisible", params).getAsJsonObject();
|
||||
return json.get("value").getAsBoolean();
|
||||
|
||||
@@ -807,6 +807,12 @@ public class PageImpl extends ChannelOwner implements Page {
|
||||
() -> mainFrame.innerTextImpl(selector, convertViaJson(options, Frame.InnerTextOptions.class)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String inputValue(String selector, InputValueOptions options) {
|
||||
return withLogging("Page.inputValue",
|
||||
() -> mainFrame.inputValueImpl(selector, convertViaJson(options, Frame.InputValueOptions.class)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked(String selector, IsCheckedOptions options) {
|
||||
return withLogging("Page.isChecked",
|
||||
@@ -837,15 +843,15 @@ public class PageImpl extends ChannelOwner implements Page {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden(String selector, IsHiddenOptions options) {
|
||||
public boolean isHidden(String selector) {
|
||||
return withLogging("Page.isHidden",
|
||||
() -> mainFrame.isHiddenImpl(selector, convertViaJson(options, Frame.IsHiddenOptions.class)));
|
||||
() -> mainFrame.isHiddenImpl(selector));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(String selector, IsVisibleOptions options) {
|
||||
public boolean isVisible(String selector) {
|
||||
return withLogging("Page.isVisible",
|
||||
() -> mainFrame.isVisibleImpl(selector, convertViaJson(options, Frame.IsVisibleOptions.class)));
|
||||
() -> mainFrame.isVisibleImpl(selector));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,8 @@ import com.google.gson.JsonObject;
|
||||
import com.microsoft.playwright.Frame;
|
||||
import com.microsoft.playwright.Request;
|
||||
import com.microsoft.playwright.Response;
|
||||
import com.microsoft.playwright.options.SecurityDetails;
|
||||
import com.microsoft.playwright.options.ServerAddr;
|
||||
import com.microsoft.playwright.options.Timing;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -28,6 +30,8 @@ import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.microsoft.playwright.impl.Serialization.gson;
|
||||
|
||||
public class ResponseImpl extends ChannelOwner implements Response {
|
||||
private final Map<String, String> headers = new HashMap<>();
|
||||
private final RequestImpl request;
|
||||
@@ -46,7 +50,7 @@ public class ResponseImpl extends ChannelOwner implements Response {
|
||||
JsonObject item = e.getAsJsonObject();
|
||||
request.headers.put(item.get("name").getAsString().toLowerCase(), item.get("value").getAsString());
|
||||
}
|
||||
request.timing = Serialization.gson().fromJson(initializer.get("timing"), Timing.class);
|
||||
request.timing = gson().fromJson(initializer.get("timing"), Timing.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,6 +92,28 @@ public class ResponseImpl extends ChannelOwner implements Response {
|
||||
return request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityDetails securityDetails() {
|
||||
return withLogging("Response.securityDetails", () -> {
|
||||
JsonObject json = sendMessage("securityDetails").getAsJsonObject();
|
||||
if (json.has("value")) {
|
||||
return gson().fromJson(json.get("value"), SecurityDetails.class);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerAddr serverAddr() {
|
||||
return withLogging("Response.serverAddr", () -> {
|
||||
JsonObject json = sendMessage("serverAddr").getAsJsonObject();
|
||||
if (json.has("value")) {
|
||||
return gson().fromJson(json.get("value"), ServerAddr.class);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int status() {
|
||||
return initializer.get("status").getAsInt();
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.microsoft.playwright.options;
|
||||
|
||||
public class SecurityDetails {
|
||||
/**
|
||||
* Common Name component of the Issuer field. from the certificate. This should only be used for informational purposes.
|
||||
* Optional.
|
||||
*/
|
||||
public String issuer;
|
||||
/**
|
||||
* The specific TLS protocol used. (e.g. {@code TLS 1.3}). Optional.
|
||||
*/
|
||||
public String protocol;
|
||||
/**
|
||||
* Common Name component of the Subject field from the certificate. This should only be used for informational purposes.
|
||||
* Optional.
|
||||
*/
|
||||
public String subjectName;
|
||||
/**
|
||||
* Unix timestamp (in seconds) specifying when this cert becomes valid. Optional.
|
||||
*/
|
||||
public Integer validFrom;
|
||||
/**
|
||||
* Unix timestamp (in seconds) specifying when this cert becomes invalid. Optional.
|
||||
*/
|
||||
public Integer validTo;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.microsoft.playwright.options;
|
||||
|
||||
public class ServerAddr {
|
||||
/**
|
||||
* IPv4 or IPV6 address of the server.
|
||||
*/
|
||||
public String ipAddress;
|
||||
public int port;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.microsoft.playwright;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class TestBrowserContextBaseUrl extends TestBase {
|
||||
@Test
|
||||
void shouldConstructANewURLWhenABaseURLInBrowserNewContextIsPassedToPageGoto() {
|
||||
BrowserContext context = browser.newContext(new Browser.NewContextOptions().setBaseURL(server.PREFIX));
|
||||
Page page = context.newPage();
|
||||
assertEquals(server.EMPTY_PAGE, (page.navigate("/empty.html")).url());
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldConstructANewURLWhenABaseURLInBrowserNewPageIsPassedToPageGoto() {
|
||||
Page page = browser.newPage(new Browser.NewPageOptions().setBaseURL(server.PREFIX));
|
||||
assertEquals(server.EMPTY_PAGE, (page.navigate("/empty.html")).url());
|
||||
page.close();
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Collections;
|
||||
|
||||
import static com.microsoft.playwright.options.KeyboardModifier.ALT;
|
||||
import static com.microsoft.playwright.Utils.copy;
|
||||
@@ -58,6 +59,18 @@ public class TestDownload extends TestBase {
|
||||
writer.write("Hello world");
|
||||
}
|
||||
});
|
||||
|
||||
server.setRoute("/downloadWithDelay", exchange -> {
|
||||
exchange.getResponseHeaders().add("Content-Type", "application/octet-stream");
|
||||
exchange.getResponseHeaders().add("Content-Disposition", "attachment; filename=file.txt");
|
||||
exchange.sendResponseHeaders(200, 0);
|
||||
// Chromium requires a large enough payload to trigger the download event soon enough
|
||||
OutputStreamWriter writer = new OutputStreamWriter(exchange.getResponseBody());
|
||||
writer.write(String.join("", Collections.nCopies(4096, "a")));
|
||||
writer.write("foo");
|
||||
writer.flush();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -385,4 +398,30 @@ public class TestDownload extends TestBase {
|
||||
assertFalse(Files.exists(path2));
|
||||
assertFalse(Files.exists(path1.resolve("..")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldBeAbleToCancelPendingDownloads() {
|
||||
try (Page page = browser.newPage(new Browser.NewPageOptions().setAcceptDownloads(true))) {
|
||||
page.setContent("<a href='" + server.PREFIX + "/downloadWithDelay'>download</a>");
|
||||
Download download = page.waitForDownload(() -> page.click("a"));
|
||||
download.cancel();
|
||||
String failure = download.failure();
|
||||
assertEquals("canceled", failure);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldNotFailExplicitlyToCancelADownloadEvenIfThatIsAlreadyFinished() throws IOException {
|
||||
try (Page page = browser.newPage(new Browser.NewPageOptions().setAcceptDownloads(true))) {
|
||||
page.setContent("<a href='" + server.PREFIX + "/download'>download</a>");
|
||||
Download download = page.waitForDownload(() -> page.click("a"));
|
||||
|
||||
Path path = download.path();
|
||||
assertTrue(Files.exists(path));
|
||||
byte[] bytes = readAllBytes(path);
|
||||
assertEquals("Hello world", new String(bytes, UTF_8));
|
||||
download.cancel();
|
||||
assertNull(download.failure());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,33 @@ public class TestElementHandleConvenience extends TestBase {
|
||||
assertNull(page.getAttribute("#outer", "foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void inputValueShouldWork() {
|
||||
page.navigate(server.PREFIX + "/dom.html");
|
||||
|
||||
page.fill("#textarea", "text value");
|
||||
assertEquals("text value", page.inputValue("#textarea"));
|
||||
|
||||
page.fill("#input", "input value");
|
||||
assertEquals("input value", page.inputValue("#input"));
|
||||
ElementHandle handle = page.querySelector("#input");
|
||||
assertEquals("input value", handle.inputValue());
|
||||
|
||||
try {
|
||||
page.inputValue("#inner");
|
||||
fail("did not throw");
|
||||
} catch (PlaywrightException e) {
|
||||
assertTrue(e.getMessage().contains("Node is not an HTMLInputElement or HTMLTextAreaElement"), e.getMessage());
|
||||
}
|
||||
ElementHandle handle2 = page.querySelector("#inner");
|
||||
try {
|
||||
handle2.inputValue();
|
||||
fail("did not throw");
|
||||
} catch (PlaywrightException e) {
|
||||
assertTrue(e.getMessage().contains("Node is not an HTMLInputElement or HTMLTextAreaElement"), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void innerHTMLShouldWork() {
|
||||
page.navigate(server.PREFIX + "/dom.html");
|
||||
|
||||
@@ -20,8 +20,11 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledIf;
|
||||
import org.junit.jupiter.api.condition.EnabledIf;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
@@ -29,6 +32,7 @@ import java.io.Reader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static com.microsoft.playwright.Utils.getOS;
|
||||
import static com.microsoft.playwright.options.LoadState.DOMCONTENTLOADED;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.microsoft.playwright;
|
||||
|
||||
import com.microsoft.playwright.options.ServerAddr;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -26,6 +27,7 @@ import java.util.Arrays;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestNetworkResponse extends TestBase {
|
||||
@@ -141,4 +143,13 @@ public class TestNetworkResponse extends TestBase {
|
||||
Response response = page.navigate(server.PREFIX + "/cool");
|
||||
assertEquals("OK", response.statusText());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnServerAddress() {
|
||||
Response response = page.navigate(server.EMPTY_PAGE);
|
||||
ServerAddr address = response.serverAddr();
|
||||
assertNotNull(address);
|
||||
assertEquals(server.PORT, address.port);
|
||||
assertTrue(asList("127.0.0.1", "::1").contains(address.ipAddress), address.ipAddress);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,4 +237,13 @@ public class TestPageFill extends TestBase {
|
||||
page.fill("input", "");
|
||||
assertEquals("", page.evaluate("() => window['result']"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void inputValueShouldWork() {
|
||||
page.navigate(server.PREFIX + "/input/textarea.html");
|
||||
page.fill("input", "my-text-content");
|
||||
assertEquals("my-text-content", page.inputValue("input"));
|
||||
page.fill("input", "");
|
||||
assertEquals("", page.inputValue("input"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
<div id="outer" name="value"><div id="inner">Text,
|
||||
more text</div></div><input id="check" type=checkbox checked foo="bar"">
|
||||
<input id="input"></input>
|
||||
<textarea id="textarea"></textarea>
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1.13.0-next-1623789547000
|
||||
1.13.0-next-1626084467000
|
||||
|
||||
@@ -866,7 +866,7 @@ class Interface extends TypeDefinition {
|
||||
if ("Playwright".equals(jsonName)) {
|
||||
output.add("import com.microsoft.playwright.impl.PlaywrightImpl;");
|
||||
}
|
||||
if (asList("Page", "Request", "FileChooser", "Frame", "ElementHandle", "Browser", "BrowserContext", "BrowserType", "Mouse", "Keyboard").contains(jsonName)) {
|
||||
if (asList("Page", "Request", "Response", "FileChooser", "Frame", "ElementHandle", "Browser", "BrowserContext", "BrowserType", "Mouse", "Keyboard").contains(jsonName)) {
|
||||
output.add("import com.microsoft.playwright.options.*;");
|
||||
}
|
||||
if (jsonName.equals("Route")) {
|
||||
|
||||
Reference in New Issue
Block a user