mirror of
https://github.com/microsoft/playwright-java.git
synced 2025-12-28 18:30:43 +00:00
feat: roll driver, implement locator (#532)
This commit is contained in:
parent
79529a7239
commit
3631357a35
@ -142,6 +142,11 @@ public interface Frame {
|
||||
* element.
|
||||
*/
|
||||
public Position position;
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -170,6 +175,10 @@ public interface Frame {
|
||||
this.position = position;
|
||||
return this;
|
||||
}
|
||||
public CheckOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public CheckOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -213,6 +222,11 @@ public interface Frame {
|
||||
* element.
|
||||
*/
|
||||
public Position position;
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -257,6 +271,10 @@ public interface Frame {
|
||||
this.position = position;
|
||||
return this;
|
||||
}
|
||||
public ClickOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public ClickOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -296,6 +314,11 @@ public interface Frame {
|
||||
* element.
|
||||
*/
|
||||
public Position position;
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -336,6 +359,10 @@ public interface Frame {
|
||||
this.position = position;
|
||||
return this;
|
||||
}
|
||||
public DblclickOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public DblclickOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -346,6 +373,11 @@ public interface Frame {
|
||||
}
|
||||
}
|
||||
class DispatchEventOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -353,6 +385,10 @@ public interface Frame {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public DispatchEventOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public DispatchEventOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -370,6 +406,11 @@ public interface Frame {
|
||||
* 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 then 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
|
||||
@ -391,6 +432,10 @@ public interface Frame {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
}
|
||||
public DragAndDropOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public DragAndDropOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -400,6 +445,18 @@ public interface Frame {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class EvalOnSelectorOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then one
|
||||
* element, the call throws an exception.
|
||||
*/
|
||||
public Boolean strict;
|
||||
|
||||
public EvalOnSelectorOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class FillOptions {
|
||||
/**
|
||||
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
|
||||
@ -412,6 +469,11 @@ public interface Frame {
|
||||
* 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 then 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
|
||||
@ -427,6 +489,10 @@ public interface Frame {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
}
|
||||
public FillOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public FillOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -434,18 +500,10 @@ public interface Frame {
|
||||
}
|
||||
class FocusOptions {
|
||||
/**
|
||||
* 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.
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then one
|
||||
* element, the call throws an exception.
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public FocusOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class GetAttributeOptions {
|
||||
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
|
||||
@ -453,6 +511,32 @@ public interface Frame {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public FocusOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public FocusOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class GetAttributeOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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;
|
||||
|
||||
public GetAttributeOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public GetAttributeOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -510,6 +594,11 @@ public interface Frame {
|
||||
* element.
|
||||
*/
|
||||
public Position position;
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -538,6 +627,10 @@ public interface Frame {
|
||||
this.position = position;
|
||||
return this;
|
||||
}
|
||||
public HoverOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public HoverOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -548,6 +641,11 @@ public interface Frame {
|
||||
}
|
||||
}
|
||||
class InnerHTMLOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -555,12 +653,21 @@ public interface Frame {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public InnerHTMLOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public InnerHTMLOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class InnerTextOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -568,12 +675,21 @@ public interface Frame {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public InnerTextOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public InnerTextOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class InputValueOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -581,12 +697,21 @@ public interface Frame {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public InputValueOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public InputValueOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsCheckedOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -594,12 +719,21 @@ public interface Frame {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public IsCheckedOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public IsCheckedOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsDisabledOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -607,12 +741,21 @@ public interface Frame {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public IsDisabledOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public IsDisabledOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsEditableOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -620,12 +763,21 @@ public interface Frame {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public IsEditableOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public IsEditableOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsEnabledOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -633,6 +785,10 @@ public interface Frame {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public IsEnabledOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public IsEnabledOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -640,18 +796,10 @@ public interface Frame {
|
||||
}
|
||||
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.
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then one
|
||||
* element, the call throws an exception.
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public IsHiddenOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsVisibleOptions {
|
||||
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
|
||||
@ -659,6 +807,32 @@ public interface Frame {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public IsHiddenOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public IsHiddenOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsVisibleOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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;
|
||||
|
||||
public IsVisibleOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public IsVisibleOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -675,6 +849,11 @@ public interface Frame {
|
||||
* 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 then 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
|
||||
@ -690,11 +869,27 @@ public interface Frame {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
}
|
||||
public PressOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public PressOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class QuerySelectorOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then one
|
||||
* element, the call throws an exception.
|
||||
*/
|
||||
public Boolean strict;
|
||||
|
||||
public QuerySelectorOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class SelectOptionOptions {
|
||||
/**
|
||||
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
|
||||
@ -707,6 +902,11 @@ public interface Frame {
|
||||
* 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 then 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
|
||||
@ -722,6 +922,10 @@ public interface Frame {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
}
|
||||
public SelectOptionOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public SelectOptionOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -761,6 +965,11 @@ public interface Frame {
|
||||
* 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 then 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
|
||||
@ -772,6 +981,10 @@ public interface Frame {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
}
|
||||
public SetInputFilesOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public SetInputFilesOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -799,6 +1012,11 @@ public interface Frame {
|
||||
* element.
|
||||
*/
|
||||
public Position position;
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -831,6 +1049,10 @@ public interface Frame {
|
||||
this.position = position;
|
||||
return this;
|
||||
}
|
||||
public TapOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public TapOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -841,6 +1063,11 @@ public interface Frame {
|
||||
}
|
||||
}
|
||||
class TextContentOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -848,6 +1075,10 @@ public interface Frame {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public TextContentOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public TextContentOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -864,6 +1095,11 @@ public interface Frame {
|
||||
* 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 then 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
|
||||
@ -879,6 +1115,10 @@ public interface Frame {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
}
|
||||
public TypeOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public TypeOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -901,6 +1141,11 @@ public interface Frame {
|
||||
* element.
|
||||
*/
|
||||
public Position position;
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -929,6 +1174,10 @@ public interface Frame {
|
||||
this.position = position;
|
||||
return this;
|
||||
}
|
||||
public UncheckOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public UncheckOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -1029,6 +1278,11 @@ public interface Frame {
|
||||
* </ul>
|
||||
*/
|
||||
public WaitForSelectorState state;
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -1040,6 +1294,10 @@ public interface Frame {
|
||||
this.state = state;
|
||||
return this;
|
||||
}
|
||||
public WaitForSelectorOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public WaitForSelectorOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -1351,6 +1609,33 @@ public interface Frame {
|
||||
dragAndDrop(source, target, null);
|
||||
}
|
||||
void dragAndDrop(String source, String target, DragAndDropOptions options);
|
||||
/**
|
||||
* Returns the return value of {@code expression}.
|
||||
*
|
||||
* <p> The method finds an element matching the specified selector within the frame and passes it as a first argument to
|
||||
* {@code expression}. See <a href="https://playwright.dev/java/docs/selectors/">Working with selectors</a> for more details. If
|
||||
* no elements match the selector, the method throws an error.
|
||||
*
|
||||
* <p> If {@code expression} returns a <a
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
|
||||
* Frame#evalOnSelector Frame.evalOnSelector()} would wait for the promise to resolve and return its value.
|
||||
*
|
||||
* <p> Examples:
|
||||
* <pre>{@code
|
||||
* String searchValue = (String) frame.evalOnSelector("#search", "el => el.value");
|
||||
* String preloadHref = (String) frame.evalOnSelector("link[rel=preload]", "el => el.href");
|
||||
* String html = (String) frame.evalOnSelector(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello");
|
||||
* }</pre>
|
||||
*
|
||||
* @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 it looks like a function declaration, it is interpreted
|
||||
* as a function. Otherwise, evaluated as an expression.
|
||||
* @param arg Optional argument to pass to {@code expression}.
|
||||
*/
|
||||
default Object evalOnSelector(String selector, String expression, Object arg) {
|
||||
return evalOnSelector(selector, expression, arg, null);
|
||||
}
|
||||
/**
|
||||
* Returns the return value of {@code expression}.
|
||||
*
|
||||
@ -1401,7 +1686,7 @@ public interface Frame {
|
||||
* as a function. Otherwise, evaluated as an expression.
|
||||
* @param arg Optional argument to pass to {@code expression}.
|
||||
*/
|
||||
Object evalOnSelector(String selector, String expression, Object arg);
|
||||
Object evalOnSelector(String selector, String expression, Object arg, EvalOnSelectorOptions options);
|
||||
/**
|
||||
* Returns the return value of {@code expression}.
|
||||
*
|
||||
@ -1917,6 +2202,17 @@ public interface Frame {
|
||||
* <a href="https://playwright.dev/java/docs/selectors/">working with selectors</a> for more details.
|
||||
*/
|
||||
boolean isVisible(String selector, IsVisibleOptions options);
|
||||
/**
|
||||
* The method returns an element locator that can be used to perform actions in the frame. Locator is resolved to the
|
||||
* element immediately before performing an action, so a series of actions on the same locator can in fact be performed on
|
||||
* different DOM elements. That would happen if the DOM structure between those actions has changed.
|
||||
*
|
||||
* <p> Note that locator always implies visibility, so it will always be locating visible elements.
|
||||
*
|
||||
* @param selector A selector to use when resolving DOM element. See <a href="https://playwright.dev/java/docs/selectors/">working with
|
||||
* selectors</a> for more details.
|
||||
*/
|
||||
Locator locator(String selector);
|
||||
/**
|
||||
* Returns frame's name attribute as specified in the tag.
|
||||
*
|
||||
@ -1993,7 +2289,20 @@ 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.
|
||||
*/
|
||||
ElementHandle querySelector(String selector);
|
||||
default ElementHandle querySelector(String selector) {
|
||||
return querySelector(selector, null);
|
||||
}
|
||||
/**
|
||||
* Returns the ElementHandle pointing to the frame element.
|
||||
*
|
||||
* <p> The method finds an element matching the specified selector within the frame. See <a
|
||||
* href="https://playwright.dev/java/docs/selectors/">Working with selectors</a> for more details. If no elements match the
|
||||
* selector, returns {@code null}.
|
||||
*
|
||||
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors/">working with selectors</a> for more
|
||||
* details.
|
||||
*/
|
||||
ElementHandle querySelector(String selector, QuerySelectorOptions options);
|
||||
/**
|
||||
* Returns the ElementHandles pointing to the frame elements.
|
||||
*
|
||||
|
||||
2155
playwright/src/main/java/com/microsoft/playwright/Locator.java
Normal file
2155
playwright/src/main/java/com/microsoft/playwright/Locator.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -388,6 +388,11 @@ public interface Page extends AutoCloseable {
|
||||
* element.
|
||||
*/
|
||||
public Position position;
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -416,6 +421,10 @@ public interface Page extends AutoCloseable {
|
||||
this.position = position;
|
||||
return this;
|
||||
}
|
||||
public CheckOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public CheckOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -459,6 +468,11 @@ public interface Page extends AutoCloseable {
|
||||
* element.
|
||||
*/
|
||||
public Position position;
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -503,6 +517,10 @@ public interface Page extends AutoCloseable {
|
||||
this.position = position;
|
||||
return this;
|
||||
}
|
||||
public ClickOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public ClickOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -554,6 +572,11 @@ public interface Page extends AutoCloseable {
|
||||
* element.
|
||||
*/
|
||||
public Position position;
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -594,6 +617,10 @@ public interface Page extends AutoCloseable {
|
||||
this.position = position;
|
||||
return this;
|
||||
}
|
||||
public DblclickOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public DblclickOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -604,6 +631,11 @@ public interface Page extends AutoCloseable {
|
||||
}
|
||||
}
|
||||
class DispatchEventOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -611,6 +643,10 @@ public interface Page extends AutoCloseable {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public DispatchEventOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public DispatchEventOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -628,6 +664,11 @@ public interface Page extends AutoCloseable {
|
||||
* 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 then 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
|
||||
@ -649,6 +690,10 @@ public interface Page extends AutoCloseable {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
}
|
||||
public DragAndDropOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public DragAndDropOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -688,6 +733,18 @@ public interface Page extends AutoCloseable {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class EvalOnSelectorOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then one
|
||||
* element, the call throws an exception.
|
||||
*/
|
||||
public Boolean strict;
|
||||
|
||||
public EvalOnSelectorOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class ExposeBindingOptions {
|
||||
/**
|
||||
* Whether to pass the argument as a handle, instead of passing by value. When passing a handle, only one argument is
|
||||
@ -712,6 +769,11 @@ public interface Page extends AutoCloseable {
|
||||
* 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 then 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
|
||||
@ -727,6 +789,10 @@ public interface Page extends AutoCloseable {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
}
|
||||
public FillOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public FillOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -734,18 +800,10 @@ public interface Page extends AutoCloseable {
|
||||
}
|
||||
class FocusOptions {
|
||||
/**
|
||||
* 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.
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then one
|
||||
* element, the call throws an exception.
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public FocusOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class GetAttributeOptions {
|
||||
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
|
||||
@ -753,6 +811,32 @@ public interface Page extends AutoCloseable {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public FocusOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public FocusOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class GetAttributeOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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;
|
||||
|
||||
public GetAttributeOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public GetAttributeOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -864,6 +948,11 @@ public interface Page extends AutoCloseable {
|
||||
* element.
|
||||
*/
|
||||
public Position position;
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -892,6 +981,10 @@ public interface Page extends AutoCloseable {
|
||||
this.position = position;
|
||||
return this;
|
||||
}
|
||||
public HoverOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public HoverOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -902,6 +995,11 @@ public interface Page extends AutoCloseable {
|
||||
}
|
||||
}
|
||||
class InnerHTMLOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -909,12 +1007,21 @@ public interface Page extends AutoCloseable {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public InnerHTMLOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public InnerHTMLOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class InnerTextOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -922,12 +1029,21 @@ public interface Page extends AutoCloseable {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public InnerTextOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public InnerTextOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class InputValueOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -935,12 +1051,21 @@ public interface Page extends AutoCloseable {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public InputValueOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public InputValueOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsCheckedOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -948,12 +1073,21 @@ public interface Page extends AutoCloseable {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public IsCheckedOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public IsCheckedOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsDisabledOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -961,12 +1095,21 @@ public interface Page extends AutoCloseable {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public IsDisabledOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public IsDisabledOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsEditableOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -974,12 +1117,21 @@ public interface Page extends AutoCloseable {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public IsEditableOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public IsEditableOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsEnabledOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -987,6 +1139,10 @@ public interface Page extends AutoCloseable {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public IsEnabledOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public IsEnabledOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -994,18 +1150,10 @@ public interface Page extends AutoCloseable {
|
||||
}
|
||||
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.
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then one
|
||||
* element, the call throws an exception.
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public IsHiddenOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsVisibleOptions {
|
||||
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
|
||||
@ -1013,6 +1161,32 @@ public interface Page extends AutoCloseable {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public IsHiddenOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public IsHiddenOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class IsVisibleOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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;
|
||||
|
||||
public IsVisibleOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public IsVisibleOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -1146,6 +1320,11 @@ public interface Page extends AutoCloseable {
|
||||
* 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 then 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
|
||||
@ -1161,11 +1340,27 @@ public interface Page extends AutoCloseable {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
}
|
||||
public PressOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public PressOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class QuerySelectorOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then one
|
||||
* element, the call throws an exception.
|
||||
*/
|
||||
public Boolean strict;
|
||||
|
||||
public QuerySelectorOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class ReloadOptions {
|
||||
/**
|
||||
* Maximum operation time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be
|
||||
@ -1273,6 +1468,11 @@ public interface Page extends AutoCloseable {
|
||||
* 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 then 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
|
||||
@ -1288,6 +1488,10 @@ public interface Page extends AutoCloseable {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
}
|
||||
public SelectOptionOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public SelectOptionOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -1327,6 +1531,11 @@ public interface Page extends AutoCloseable {
|
||||
* 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 then 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
|
||||
@ -1338,6 +1547,10 @@ public interface Page extends AutoCloseable {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
}
|
||||
public SetInputFilesOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public SetInputFilesOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -1365,6 +1578,11 @@ public interface Page extends AutoCloseable {
|
||||
* element.
|
||||
*/
|
||||
public Position position;
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -1397,6 +1615,10 @@ public interface Page extends AutoCloseable {
|
||||
this.position = position;
|
||||
return this;
|
||||
}
|
||||
public TapOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public TapOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -1407,6 +1629,11 @@ public interface Page extends AutoCloseable {
|
||||
}
|
||||
}
|
||||
class TextContentOptions {
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -1414,6 +1641,10 @@ public interface Page extends AutoCloseable {
|
||||
*/
|
||||
public Double timeout;
|
||||
|
||||
public TextContentOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public TextContentOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -1430,6 +1661,11 @@ public interface Page extends AutoCloseable {
|
||||
* 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 then 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
|
||||
@ -1445,6 +1681,10 @@ public interface Page extends AutoCloseable {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
}
|
||||
public TypeOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public TypeOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -1467,6 +1707,11 @@ public interface Page extends AutoCloseable {
|
||||
* element.
|
||||
*/
|
||||
public Position position;
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -1495,6 +1740,10 @@ public interface Page extends AutoCloseable {
|
||||
this.position = position;
|
||||
return this;
|
||||
}
|
||||
public UncheckOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public UncheckOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -1732,6 +1981,11 @@ public interface Page extends AutoCloseable {
|
||||
* </ul>
|
||||
*/
|
||||
public WaitForSelectorState state;
|
||||
/**
|
||||
* When true, the call requires selector to resolve to a single element. If given selector resolves to more then 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
|
||||
@ -1743,6 +1997,10 @@ public interface Page extends AutoCloseable {
|
||||
this.state = state;
|
||||
return this;
|
||||
}
|
||||
public WaitForSelectorOptions setStrict(boolean strict) {
|
||||
this.strict = strict;
|
||||
return this;
|
||||
}
|
||||
public WaitForSelectorOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
@ -2249,6 +2507,32 @@ public interface Page extends AutoCloseable {
|
||||
* }</pre>
|
||||
*/
|
||||
void emulateMedia(EmulateMediaOptions options);
|
||||
/**
|
||||
* The method finds an element matching the specified selector within the page and passes it as a first argument to
|
||||
* {@code expression}. If no elements match the selector, the method throws an error. Returns the value of {@code expression}.
|
||||
*
|
||||
* <p> If {@code expression} returns a <a
|
||||
* href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise'>Promise</a>, then {@link
|
||||
* Page#evalOnSelector Page.evalOnSelector()} would wait for the promise to resolve and return its value.
|
||||
*
|
||||
* <p> Examples:
|
||||
* <pre>{@code
|
||||
* String searchValue = (String) page.evalOnSelector("#search", "el => el.value");
|
||||
* String preloadHref = (String) page.evalOnSelector("link[rel=preload]", "el => el.href");
|
||||
* String html = (String) page.evalOnSelector(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello");
|
||||
* }</pre>
|
||||
*
|
||||
* <p> Shortcut for main frame's {@link Frame#evalOnSelector Frame.evalOnSelector()}.
|
||||
*
|
||||
* @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 it looks like a function declaration, it is interpreted
|
||||
* as a function. Otherwise, evaluated as an expression.
|
||||
* @param arg Optional argument to pass to {@code expression}.
|
||||
*/
|
||||
default Object evalOnSelector(String selector, String expression, Object arg) {
|
||||
return evalOnSelector(selector, expression, arg, null);
|
||||
}
|
||||
/**
|
||||
* The method finds an element matching the specified selector within the page and passes it as a first argument to
|
||||
* {@code expression}. If no elements match the selector, the method throws an error. Returns the value of {@code expression}.
|
||||
@ -2297,7 +2581,7 @@ public interface Page extends AutoCloseable {
|
||||
* as a function. Otherwise, evaluated as an expression.
|
||||
* @param arg Optional argument to pass to {@code expression}.
|
||||
*/
|
||||
Object evalOnSelector(String selector, String expression, Object arg);
|
||||
Object evalOnSelector(String selector, String expression, Object arg, EvalOnSelectorOptions options);
|
||||
/**
|
||||
* The method finds all elements matching the specified selector within the page and passes an array of matched elements as
|
||||
* a first argument to {@code expression}. Returns the result of {@code expression} invocation.
|
||||
@ -3065,6 +3349,19 @@ public interface Page extends AutoCloseable {
|
||||
*/
|
||||
boolean isVisible(String selector, IsVisibleOptions options);
|
||||
Keyboard keyboard();
|
||||
/**
|
||||
* The method returns an element locator that can be used to perform actions on the page. Locator is resolved to the
|
||||
* element immediately before performing an action, so a series of actions on the same locator can in fact be performed on
|
||||
* different DOM elements. That would happen if the DOM structure between those actions has changed.
|
||||
*
|
||||
* <p> Note that locator always implies visibility, so it will always be locating visible elements.
|
||||
*
|
||||
* <p> Shortcut for main frame's {@link Frame#locator Frame.locator()}.
|
||||
*
|
||||
* @param selector A selector to use when resolving DOM element. See <a href="https://playwright.dev/java/docs/selectors/">working with
|
||||
* selectors</a> for more details.
|
||||
*/
|
||||
Locator locator(String selector);
|
||||
/**
|
||||
* The page's main frame. Page is guaranteed to have a main frame which persists during navigations.
|
||||
*/
|
||||
@ -3277,7 +3574,20 @@ 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.
|
||||
*/
|
||||
ElementHandle querySelector(String selector);
|
||||
default ElementHandle querySelector(String selector) {
|
||||
return querySelector(selector, null);
|
||||
}
|
||||
/**
|
||||
* The method finds an element matching the specified selector within the page. If no elements match the selector, the
|
||||
* return value resolves to {@code null}. To wait for an element on the page, use {@link Page#waitForSelector
|
||||
* Page.waitForSelector()}.
|
||||
*
|
||||
* <p> Shortcut for main frame's {@link Frame#querySelector Frame.querySelector()}.
|
||||
*
|
||||
* @param selector A selector to query for. See <a href="https://playwright.dev/java/docs/selectors/">working with selectors</a> for more
|
||||
* details.
|
||||
*/
|
||||
ElementHandle querySelector(String selector, QuerySelectorOptions options);
|
||||
/**
|
||||
* The method finds all elements matching the specified selector within the page. If no elements match the selector, the
|
||||
* return value resolves to {@code []}.
|
||||
|
||||
@ -71,12 +71,15 @@ public class FrameImpl extends ChannelOwner implements Frame {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElementHandle querySelector(String selector) {
|
||||
return withLogging("Frame.querySelector", () -> querySelectorImpl(selector));
|
||||
public ElementHandle querySelector(String selector, QuerySelectorOptions options) {
|
||||
return withLogging("Frame.querySelector", () -> querySelectorImpl(selector, options));
|
||||
}
|
||||
|
||||
ElementHandleImpl querySelectorImpl(String selector) {
|
||||
JsonObject params = new JsonObject();
|
||||
ElementHandleImpl querySelectorImpl(String selector, QuerySelectorOptions options) {
|
||||
if (options == null) {
|
||||
options = new QuerySelectorOptions();
|
||||
}
|
||||
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
|
||||
params.addProperty("selector", selector);
|
||||
JsonElement json = sendMessage("querySelector", params);
|
||||
JsonObject element = json.getAsJsonObject().getAsJsonObject("element");
|
||||
@ -134,12 +137,15 @@ public class FrameImpl extends ChannelOwner implements Frame {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evalOnSelector(String selector, String pageFunction, Object arg) {
|
||||
return withLogging("Frame.evalOnSelector", () -> evalOnSelectorImpl(selector, pageFunction, arg));
|
||||
public Object evalOnSelector(String selector, String pageFunction, Object arg, EvalOnSelectorOptions options) {
|
||||
return withLogging("Frame.evalOnSelector", () -> evalOnSelectorImpl(selector, pageFunction, arg, options));
|
||||
}
|
||||
|
||||
Object evalOnSelectorImpl(String selector, String pageFunction, Object arg) {
|
||||
JsonObject params = new JsonObject();
|
||||
Object evalOnSelectorImpl(String selector, String pageFunction, Object arg, EvalOnSelectorOptions options) {
|
||||
if (options == null) {
|
||||
options = new EvalOnSelectorOptions();
|
||||
}
|
||||
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
|
||||
params.addProperty("selector", selector);
|
||||
params.addProperty("expression", pageFunction);
|
||||
params.add("arg", gson().toJsonTree(serializeArgument(arg)));
|
||||
@ -553,6 +559,11 @@ public class FrameImpl extends ChannelOwner implements Frame {
|
||||
return withLogging("Page.isVisible", () -> isVisibleImpl(selector, options));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locator locator(String selector) {
|
||||
return new LoccatorImpl(this, selector);
|
||||
}
|
||||
|
||||
boolean isVisibleImpl(String selector, IsVisibleOptions options) {
|
||||
if (options == null) {
|
||||
options = new IsVisibleOptions();
|
||||
|
||||
@ -0,0 +1,390 @@
|
||||
package com.microsoft.playwright.impl;
|
||||
|
||||
import com.microsoft.playwright.ElementHandle;
|
||||
import com.microsoft.playwright.Frame;
|
||||
import com.microsoft.playwright.JSHandle;
|
||||
import com.microsoft.playwright.Locator;
|
||||
import com.microsoft.playwright.options.BoundingBox;
|
||||
import com.microsoft.playwright.options.FilePayload;
|
||||
import com.microsoft.playwright.options.SelectOption;
|
||||
import com.microsoft.playwright.options.WaitForSelectorState;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import static com.microsoft.playwright.impl.Utils.convertViaJson;
|
||||
|
||||
class LoccatorImpl implements Locator {
|
||||
private final FrameImpl frame;
|
||||
private final String selector;
|
||||
private final String visibleSelector;
|
||||
|
||||
public LoccatorImpl(FrameImpl frame, String selector) {
|
||||
this.frame = frame;
|
||||
this.selector = selector;
|
||||
this.visibleSelector = selector + " >> _visible=true";
|
||||
}
|
||||
|
||||
private <R, O> R withElement(BiFunction<ElementHandle, O, R> callback, O options) {
|
||||
ElementHandleOptions handleOptions = convertViaJson(options, ElementHandleOptions.class);
|
||||
// TODO: support deadline based timeout
|
||||
// Double timeout = null;
|
||||
// if (handleOptions != null) {
|
||||
// timeout = handleOptions.timeout;
|
||||
// }
|
||||
// timeout = frame.page.timeoutSettings.timeout(timeout);
|
||||
// long deadline = System.nanoTime() + (long) timeout.doubleValue() * 1_000_000;
|
||||
ElementHandle handle = elementHandle(handleOptions);
|
||||
try {
|
||||
return callback.apply(handle, options);
|
||||
} finally {
|
||||
if (handle != null) {
|
||||
handle.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox boundingBox(BoundingBoxOptions options) {
|
||||
return withElement((h, o) -> h.boundingBox(), options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void check(CheckOptions options) {
|
||||
if (options == null) {
|
||||
options = new CheckOptions();
|
||||
}
|
||||
frame.check(visibleSelector, convertViaJson(options, Frame.CheckOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(ClickOptions options) {
|
||||
if (options == null) {
|
||||
options = new ClickOptions();
|
||||
}
|
||||
frame.click(visibleSelector, convertViaJson(options, Frame.ClickOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count() {
|
||||
return ((Number) evaluateAll("ee => ee.length")).intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dblclick(DblclickOptions options) {
|
||||
if (options == null) {
|
||||
options = new DblclickOptions();
|
||||
}
|
||||
frame.dblclick(visibleSelector, convertViaJson(options, Frame.DblclickOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatchEvent(String type, Object eventInit, DispatchEventOptions options) {
|
||||
if (options == null) {
|
||||
options = new DispatchEventOptions();
|
||||
}
|
||||
frame.dispatchEvent(visibleSelector, type, eventInit, convertViaJson(options, Frame.DispatchEventOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElementHandle elementHandle(ElementHandleOptions options) {
|
||||
if (options == null) {
|
||||
options = new ElementHandleOptions();
|
||||
}
|
||||
Frame.WaitForSelectorOptions frameOptions = convertViaJson(options, Frame.WaitForSelectorOptions.class);
|
||||
frameOptions.setStrict(true);
|
||||
frameOptions.setState(WaitForSelectorState.ATTACHED);
|
||||
return frame.waitForSelector(visibleSelector, frameOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ElementHandle> elementHandles() {
|
||||
return frame.querySelectorAll(visibleSelector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evaluate(String expression, Object arg, EvaluateOptions options) {
|
||||
return withElement((h, o) -> h.evaluate(expression, arg), options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evaluateAll(String expression, Object arg) {
|
||||
return frame.evalOnSelectorAll(visibleSelector, expression, arg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSHandle evaluateHandle(String expression, Object arg, EvaluateHandleOptions options) {
|
||||
return withElement((h, o) -> h.evaluateHandle(expression, arg), options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fill(String value, FillOptions options) {
|
||||
if (options == null) {
|
||||
options = new FillOptions();
|
||||
}
|
||||
frame.fill(visibleSelector, value, convertViaJson(options, Frame.FillOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locator first() {
|
||||
return new LoccatorImpl(frame, selector + " >> _nth=first");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focus(FocusOptions options) {
|
||||
if (options == null) {
|
||||
options = new FocusOptions();
|
||||
}
|
||||
frame.focus(visibleSelector, convertViaJson(options, Frame.FocusOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttribute(String name, GetAttributeOptions options) {
|
||||
if (options == null) {
|
||||
options = new GetAttributeOptions();
|
||||
}
|
||||
return frame.getAttribute(visibleSelector, name, convertViaJson(options, Frame.GetAttributeOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hover(HoverOptions options) {
|
||||
if (options == null) {
|
||||
options = new HoverOptions();
|
||||
}
|
||||
frame.hover(visibleSelector, convertViaJson(options, Frame.HoverOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String innerHTML(InnerHTMLOptions options) {
|
||||
if (options == null) {
|
||||
options = new InnerHTMLOptions();
|
||||
}
|
||||
return frame.innerHTML(visibleSelector, convertViaJson(options, Frame.InnerHTMLOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String innerText(InnerTextOptions options) {
|
||||
if (options == null) {
|
||||
options = new InnerTextOptions();
|
||||
}
|
||||
return frame.innerText(visibleSelector, convertViaJson(options, Frame.InnerTextOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String inputValue(InputValueOptions options) {
|
||||
if (options == null) {
|
||||
options = new InputValueOptions();
|
||||
}
|
||||
return frame.inputValue(visibleSelector, convertViaJson(options, Frame.InputValueOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked(IsCheckedOptions options) {
|
||||
if (options == null) {
|
||||
options = new IsCheckedOptions();
|
||||
}
|
||||
return frame.isChecked(visibleSelector, convertViaJson(options, Frame.IsCheckedOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled(IsDisabledOptions options) {
|
||||
if (options == null) {
|
||||
options = new IsDisabledOptions();
|
||||
}
|
||||
return frame.isDisabled(visibleSelector, convertViaJson(options, Frame.IsDisabledOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable(IsEditableOptions options) {
|
||||
if (options == null) {
|
||||
options = new IsEditableOptions();
|
||||
}
|
||||
return frame.isEditable(visibleSelector, convertViaJson(options, Frame.IsEditableOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(IsEnabledOptions options) {
|
||||
if (options == null) {
|
||||
options = new IsEnabledOptions();
|
||||
}
|
||||
return frame.isEnabled(visibleSelector, convertViaJson(options, Frame.IsEnabledOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden(IsHiddenOptions options) {
|
||||
if (options == null) {
|
||||
options = new IsHiddenOptions();
|
||||
}
|
||||
return frame.isHidden(visibleSelector, convertViaJson(options, Frame.IsHiddenOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(IsVisibleOptions options) {
|
||||
if (options == null) {
|
||||
options = new IsVisibleOptions();
|
||||
}
|
||||
return frame.isVisible(visibleSelector, convertViaJson(options, Frame.IsVisibleOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locator last() {
|
||||
return new LoccatorImpl(frame, selector + " >> _nth=last");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locator locator(String selector) {
|
||||
return new LoccatorImpl(frame, this.selector + " >> " + selector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locator nth(int index) {
|
||||
return new LoccatorImpl(frame, selector + " >> _nth=" + index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void press(String key, PressOptions options) {
|
||||
if (options == null) {
|
||||
options = new PressOptions();
|
||||
}
|
||||
frame.press(visibleSelector, key, convertViaJson(options, Frame.PressOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] screenshot(ScreenshotOptions options) {
|
||||
return withElement((h, o) -> h.screenshot(o), convertViaJson(options, ElementHandle.ScreenshotOptions.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrollIntoViewIfNeeded(ScrollIntoViewIfNeededOptions options) {
|
||||
withElement((h, o) -> {
|
||||
h.scrollIntoViewIfNeeded(o);
|
||||
return null;
|
||||
}, convertViaJson(options, ElementHandle.ScrollIntoViewIfNeededOptions.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> selectOption(String values, SelectOptionOptions options) {
|
||||
if (options == null) {
|
||||
options = new SelectOptionOptions();
|
||||
}
|
||||
return frame.selectOption(visibleSelector, values, convertViaJson(options, Frame.SelectOptionOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> selectOption(ElementHandle values, SelectOptionOptions options) {
|
||||
if (options == null) {
|
||||
options = new SelectOptionOptions();
|
||||
}
|
||||
return frame.selectOption(visibleSelector, values, convertViaJson(options, Frame.SelectOptionOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> selectOption(String[] values, SelectOptionOptions options) {
|
||||
if (options == null) {
|
||||
options = new SelectOptionOptions();
|
||||
}
|
||||
return frame.selectOption(visibleSelector, values, convertViaJson(options, Frame.SelectOptionOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> selectOption(SelectOption values, SelectOptionOptions options) {
|
||||
if (options == null) {
|
||||
options = new SelectOptionOptions();
|
||||
}
|
||||
return frame.selectOption(visibleSelector, values, convertViaJson(options, Frame.SelectOptionOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> selectOption(ElementHandle[] values, SelectOptionOptions options) {
|
||||
if (options == null) {
|
||||
options = new SelectOptionOptions();
|
||||
}
|
||||
return frame.selectOption(visibleSelector, values, convertViaJson(options, Frame.SelectOptionOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> selectOption(SelectOption[] values, SelectOptionOptions options) {
|
||||
if (options == null) {
|
||||
options = new SelectOptionOptions();
|
||||
}
|
||||
return frame.selectOption(visibleSelector, values, convertViaJson(options, Frame.SelectOptionOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectText(SelectTextOptions options) {
|
||||
withElement((h, o) -> {
|
||||
h.selectText(o);
|
||||
return null;
|
||||
}, convertViaJson(options, ElementHandle.SelectTextOptions.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInputFiles(Path files, SetInputFilesOptions options) {
|
||||
if (options == null) {
|
||||
options = new SetInputFilesOptions();
|
||||
}
|
||||
frame.setInputFiles(visibleSelector, files, convertViaJson(options, Frame.SetInputFilesOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInputFiles(Path[] files, SetInputFilesOptions options) {
|
||||
if (options == null) {
|
||||
options = new SetInputFilesOptions();
|
||||
}
|
||||
frame.setInputFiles(visibleSelector, files, convertViaJson(options, Frame.SetInputFilesOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInputFiles(FilePayload files, SetInputFilesOptions options) {
|
||||
if (options == null) {
|
||||
options = new SetInputFilesOptions();
|
||||
}
|
||||
frame.setInputFiles(visibleSelector, files, convertViaJson(options, Frame.SetInputFilesOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInputFiles(FilePayload[] files, SetInputFilesOptions options) {
|
||||
if (options == null) {
|
||||
options = new SetInputFilesOptions();
|
||||
}
|
||||
frame.setInputFiles(visibleSelector, files, convertViaJson(options, Frame.SetInputFilesOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tap(TapOptions options) {
|
||||
if (options == null) {
|
||||
options = new TapOptions();
|
||||
}
|
||||
frame.tap(visibleSelector, convertViaJson(options, Frame.TapOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String textContent(TextContentOptions options) {
|
||||
if (options == null) {
|
||||
options = new TextContentOptions();
|
||||
}
|
||||
return frame.textContent(visibleSelector, convertViaJson(options, Frame.TextContentOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void type(String text, TypeOptions options) {
|
||||
if (options == null) {
|
||||
options = new TypeOptions();
|
||||
}
|
||||
frame.type(visibleSelector, text, convertViaJson(options, Frame.TypeOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uncheck(UncheckOptions options) {
|
||||
if (options == null) {
|
||||
options = new UncheckOptions();
|
||||
}
|
||||
frame.uncheck(visibleSelector, convertViaJson(options, Frame.UncheckOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Loccator@" + selector;
|
||||
}
|
||||
}
|
||||
@ -548,8 +548,9 @@ public class PageImpl extends ChannelOwner implements Page {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElementHandle querySelector(String selector) {
|
||||
return withLogging("Page.querySelector", () -> mainFrame.querySelectorImpl(selector));
|
||||
public ElementHandle querySelector(String selector, QuerySelectorOptions options) {
|
||||
return withLogging("Page.querySelector", () -> mainFrame.querySelectorImpl(
|
||||
selector, convertViaJson(options, Frame.QuerySelectorOptions.class)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -558,8 +559,9 @@ public class PageImpl extends ChannelOwner implements Page {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evalOnSelector(String selector, String pageFunction, Object arg) {
|
||||
return withLogging("Page.evalOnSelector", () -> mainFrame.evalOnSelectorImpl(selector, pageFunction, arg));
|
||||
public Object evalOnSelector(String selector, String pageFunction, Object arg, EvalOnSelectorOptions options) {
|
||||
return withLogging("Page.evalOnSelector", () -> mainFrame.evalOnSelectorImpl(
|
||||
selector, pageFunction, arg, convertViaJson(options, Frame.EvalOnSelectorOptions.class)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -865,6 +867,11 @@ public class PageImpl extends ChannelOwner implements Page {
|
||||
return keyboard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locator locator(String selector) {
|
||||
return mainFrame.locator(selector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Frame mainFrame() {
|
||||
return mainFrame;
|
||||
|
||||
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.microsoft.playwright;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestLocatorClick extends TestBase {
|
||||
|
||||
@Test
|
||||
void shouldWork() {
|
||||
page.navigate(server.PREFIX + "/input/button.html");
|
||||
Locator button = page.locator("button");
|
||||
button.click();
|
||||
assertEquals("Clicked", page.evaluate("() => window['result']"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldWorkWithNodeRemoved() {
|
||||
page.navigate(server.PREFIX + "/input/button.html");
|
||||
page.evaluate("() => delete window['Node']");
|
||||
Locator button = page.locator("button");
|
||||
button.click();
|
||||
assertEquals("Clicked", page.evaluate("() => window['result']"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldDoubleClickTheButton() {
|
||||
page.navigate(server.PREFIX + "/input/button.html");
|
||||
page.evaluate("() => {\n" +
|
||||
" window['double'] = false;\n" +
|
||||
" const button = document.querySelector('button');\n" +
|
||||
" button.addEventListener('dblclick', event => {\n" +
|
||||
" window['double'] = true;\n" +
|
||||
" });\n" +
|
||||
"}");
|
||||
Locator button = page.locator("button");
|
||||
button.dblclick();
|
||||
assertEquals(true, page.evaluate("double"));
|
||||
assertEquals("Clicked", page.evaluate("result"));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package com.microsoft.playwright;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class TestLocatorElementHandle extends TestBase {
|
||||
@Test
|
||||
void shouldQueryExistingElement() {
|
||||
page.navigate(server.PREFIX + "/playground.html");
|
||||
page.setContent("<html><body><div class='second'><div class='inner'>A</div></div></body></html>");
|
||||
Locator html = page.locator("html");
|
||||
Locator second = html.locator(".second");
|
||||
Locator inner = second.locator(".inner");
|
||||
Object content = page.evaluate("e => e.textContent", inner.elementHandle());
|
||||
assertEquals("A", content);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldQueryExistingElements() {
|
||||
page.setContent("<html><body><div>A</div><br/><div>B</div></body></html>");
|
||||
Locator html = page.locator("html");
|
||||
List<ElementHandle> elements = html.locator("div").elementHandles();
|
||||
assertEquals(2, elements.size());
|
||||
List<Object> texts = elements.stream().map(element -> page.evaluate("e => e.textContent", element))
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(asList("A", "B"), texts);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnEmptyArrayForNonExistingElements() {
|
||||
page.setContent("<html><body><span>A</span><br/><span>B</span></body></html>");
|
||||
Locator html = page.locator("html");
|
||||
List<ElementHandle> elements = html.locator("div").elementHandles();
|
||||
assertEquals(0, elements.size());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void xpathShouldQueryExistingElement() {
|
||||
page.navigate(server.PREFIX + "/playground.html");
|
||||
page.setContent("<html><body><div class='second'><div class='inner'>A</div></div></body></html>");
|
||||
Locator html = page.locator("html");
|
||||
Locator second = html.locator("xpath=./body/div[contains(@class, 'second')]");
|
||||
Locator inner = second.locator("xpath=./div[contains(@class, 'inner')]");
|
||||
Object content = page.evaluate("e => e.textContent", inner.elementHandle());
|
||||
assertEquals("A", content);
|
||||
}
|
||||
|
||||
@Test
|
||||
void xpathShouldReturnNullForNonExistingElement() {
|
||||
page.setContent("<html><body><div class='second'><div class='inner'>B</div></div></body></html>");
|
||||
Locator html = page.locator("html");
|
||||
List<ElementHandle> second = html.locator("xpath=/div[contains(@class, 'third')]").elementHandles();
|
||||
assertEquals(asList(), second);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package com.microsoft.playwright;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class TestLocatorEvaluate extends TestBase {
|
||||
@Test
|
||||
void shouldWork() {
|
||||
page.setContent("<html><body><div class='tweet'><div class='like'>100</div><div class='retweets'>10</div></div></body></html>");
|
||||
Locator tweet = page.locator(".tweet .like");
|
||||
Object content = tweet.evaluate("node => node.innerText");
|
||||
assertEquals("100", content);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldRetrieveContentFromSubtree() {
|
||||
String htmlContent = "<div class='a'>not-a-child-div</div><div id='myId'><div class='a'>a-child-div</div></div>";
|
||||
page.setContent(htmlContent);
|
||||
Locator locator = page.locator("#myId .a");
|
||||
Object content = locator.evaluate("node => node.innerText");
|
||||
assertEquals("a-child-div", content);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldWorkForAll() {
|
||||
page.setContent("<html><body><div class='tweet'><div class='like'>100</div><div class='like'>10</div></div></body></html>");
|
||||
Locator tweet = page.locator(".tweet .like");
|
||||
Object content = tweet.evaluateAll("nodes => nodes.map(n => n.innerText)");
|
||||
assertEquals(asList("100", "10"), content);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldRetrieveContentFromSubtreeForAll() {
|
||||
String htmlContent = "<div class='a'>not-a-child-div</div><div id='myId'><div class='a'>a1-child-div</div><div class='a'>a2-child-div</div></div>";
|
||||
page.setContent(htmlContent);
|
||||
Locator element = page.locator("#myId .a");
|
||||
Object content = element.evaluateAll("nodes => nodes.map(n => n.innerText)");
|
||||
assertEquals(asList("a1-child-div", "a2-child-div"), content);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldNotThrowInCaseOfMissingSelectorForAll() {
|
||||
String htmlContent = "<div class='a'>not-a-child-div</div><div id='myId'></div>";
|
||||
page.setContent(htmlContent);
|
||||
Locator element = page.locator("#myId .a");
|
||||
Object nodesLength = element.evaluateAll("nodes => nodes.length");
|
||||
assertEquals(0, nodesLength);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
package com.microsoft.playwright;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class TestPageStrict extends TestBase {
|
||||
@Test
|
||||
void shouldFailPageTextContentInStrictMode() {
|
||||
page.setContent("<span>span1</span><div><span>target</span></div>");
|
||||
try {
|
||||
page.textContent("span", new Page.TextContentOptions().setStrict(true));
|
||||
fail("did not throw");
|
||||
} catch (PlaywrightException e) {
|
||||
assertTrue(e.getMessage().contains("strict mode violation"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldFailPageGetAttributeInStrictMode() {
|
||||
page.setContent("<span>span1</span><div><span>target</span></div>");
|
||||
try {
|
||||
page.getAttribute("span", "id", new Page.GetAttributeOptions().setStrict(true));
|
||||
fail("did not throw");
|
||||
} catch (PlaywrightException e) {
|
||||
assertTrue(e.getMessage().contains("strict mode violation"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldFailPageFillInStrictMode() {
|
||||
page.setContent("<input></input><div><input></input></div>");
|
||||
try {
|
||||
page.fill("input", "text", new Page.FillOptions().setStrict(true));
|
||||
fail("did not throw");
|
||||
} catch (PlaywrightException e) {
|
||||
assertTrue(e.getMessage().contains("strict mode violation"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void shouldFailPageInStrictMode() {
|
||||
page.setContent("<span>span1</span><div><span>target</span></div>");
|
||||
try {
|
||||
ElementHandle error = page.querySelector("span", new Page.QuerySelectorOptions().setStrict(true));
|
||||
fail("did not throw");
|
||||
} catch (PlaywrightException e) {
|
||||
assertTrue(e.getMessage().contains("strict mode violation"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldFailPageWaitForSelectorInStrictMode() {
|
||||
page.setContent("<span>span1</span><div><span>target</span></div>");
|
||||
try {
|
||||
page.waitForSelector("span", new Page.WaitForSelectorOptions().setStrict(true));
|
||||
fail("did not throw");
|
||||
} catch (PlaywrightException e) {
|
||||
assertTrue(e.getMessage().contains("strict mode violation"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldFailPageDispatchEventInStrictMode() {
|
||||
page.setContent("<span></span><div><span></span></div>");
|
||||
try {
|
||||
page.dispatchEvent("span", "click", new HashMap<>(), new Page.DispatchEventOptions().setStrict(true));
|
||||
fail("did not throw");
|
||||
} catch (PlaywrightException e) {
|
||||
assertTrue(e.getMessage().contains("strict mode violation"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1 +1 @@
|
||||
1.13.0-1626733671000
|
||||
1.14.0-next-1627483012000
|
||||
|
||||
@ -249,10 +249,12 @@ class TypeRef extends Element {
|
||||
customTypeNames.put("BrowserContext.addCookies.cookies", "Cookie");
|
||||
customTypeNames.put("BrowserContext.cookies", "Cookie");
|
||||
|
||||
customTypeNames.put("Locator.selectOption.values", "SelectOption");
|
||||
customTypeNames.put("ElementHandle.selectOption.values", "SelectOption");
|
||||
customTypeNames.put("Frame.selectOption.values", "SelectOption");
|
||||
customTypeNames.put("Page.selectOption.values", "SelectOption");
|
||||
|
||||
customTypeNames.put("Locator.setInputFiles.files", "FilePayload");
|
||||
customTypeNames.put("ElementHandle.setInputFiles.files", "FilePayload");
|
||||
customTypeNames.put("FileChooser.setFiles.files", "FilePayload");
|
||||
customTypeNames.put("Frame.setInputFiles.files", "FilePayload");
|
||||
@ -866,7 +868,7 @@ class Interface extends TypeDefinition {
|
||||
if ("Playwright".equals(jsonName)) {
|
||||
output.add("import com.microsoft.playwright.impl.PlaywrightImpl;");
|
||||
}
|
||||
if (asList("Page", "Request", "Response", "FileChooser", "Frame", "ElementHandle", "Browser", "BrowserContext", "BrowserType", "Mouse", "Keyboard").contains(jsonName)) {
|
||||
if (asList("Page", "Request", "Response", "FileChooser", "Frame", "ElementHandle", "Locator", "Browser", "BrowserContext", "BrowserType", "Mouse", "Keyboard").contains(jsonName)) {
|
||||
output.add("import com.microsoft.playwright.options.*;");
|
||||
}
|
||||
if (jsonName.equals("Route")) {
|
||||
@ -875,7 +877,7 @@ class Interface extends TypeDefinition {
|
||||
if ("Download".equals(jsonName)) {
|
||||
output.add("import java.io.InputStream;");
|
||||
}
|
||||
if (asList("Page", "Frame", "ElementHandle", "FileChooser", "Browser", "BrowserContext", "BrowserType", "Download", "Route", "Selectors", "Tracing", "Video").contains(jsonName)) {
|
||||
if (asList("Page", "Frame", "ElementHandle", "Locator", "FileChooser", "Browser", "BrowserContext", "BrowserType", "Download", "Route", "Selectors", "Tracing", "Video").contains(jsonName)) {
|
||||
output.add("import java.nio.file.Path;");
|
||||
}
|
||||
output.add("import java.util.*;");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user