diff --git a/playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java b/playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java index 6b79120b8..a8210ffad 100644 --- a/playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java +++ b/playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java @@ -16,11 +16,14 @@ package com.microsoft.playwright.assertions; -import org.jspecify.annotations.Nullable; import java.util.*; import java.util.regex.Pattern; +import com.microsoft.playwright.Locator; import com.microsoft.playwright.options.AriaRole; import com.microsoft.playwright.options.PseudoElement; +import com.microsoft.playwright.options.ScreenshotAnimations; +import com.microsoft.playwright.options.ScreenshotCaret; +import com.microsoft.playwright.options.ScreenshotScale; /** * The {@code LocatorAssertions} class provides assertion methods that can be used to make assertions about the {@code @@ -42,11 +45,11 @@ */ public interface LocatorAssertions { class IsAttachedOptions { - public @Nullable Boolean attached; + public Boolean attached; /** * Time to retry the assertion for in milliseconds. Defaults to {@code 5000}. */ - public @Nullable Double timeout; + public Double timeout; public IsAttachedOptions setAttached(boolean attached) { this.attached = attached; @@ -60,21 +63,183 @@ public IsAttachedOptions setTimeout(double timeout) { return this; } } + class HasScreenshotOptions { + /** + * When set to {@code "disabled"}, stops CSS animations, CSS transitions and Web Animations. Animations get different + * treatment depending on their duration: + *
Defaults to {@code "disabled"}.
+ */
+ public ScreenshotAnimations animations;
+ /**
+ * When set to {@code "hide"}, screenshot will hide text caret. When set to {@code "initial"}, text caret behavior will not
+ * be changed. Defaults to {@code "hide"}.
+ */
+ public ScreenshotCaret caret;
+ /**
+ * Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box
+ * {@code #FF00FF} (customized by {@code maskColor}) that completely covers its bounding box.
+ */
+ public List Defaults to {@code "css"}.
+ */
+ public ScreenshotScale scale;
+ /**
+ * Text of the stylesheet to apply while making the screenshot. This is where you can hide dynamic elements, make elements
+ * invisible or change their properties to help you creating repeatable screenshots.
+ */
+ public String style;
+ /**
+ * An acceptable perceived color difference between the same pixel in compared images, between zero (strict) and one
+ * (lax), default is {@code 0.2}.
+ */
+ public Double threshold;
+ /**
+ * Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
+ */
+ public Double timeout;
+
+ /**
+ * When set to {@code "disabled"}, stops CSS animations, CSS transitions and Web Animations. Animations get different
+ * treatment depending on their duration:
+ * Defaults to {@code "disabled"}.
+ */
+ public HasScreenshotOptions setAnimations(ScreenshotAnimations animations) {
+ this.animations = animations;
+ return this;
+ }
+ /**
+ * When set to {@code "hide"}, screenshot will hide text caret. When set to {@code "initial"}, text caret behavior will not
+ * be changed. Defaults to {@code "hide"}.
+ */
+ public HasScreenshotOptions setCaret(ScreenshotCaret caret) {
+ this.caret = caret;
+ return this;
+ }
+ /**
+ * Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box
+ * {@code #FF00FF} (customized by {@code maskColor}) that completely covers its bounding box.
+ */
+ public HasScreenshotOptions setMask(List Defaults to {@code "css"}.
+ */
+ public HasScreenshotOptions setScale(ScreenshotScale scale) {
+ this.scale = scale;
+ return this;
+ }
+ /**
+ * Text of the stylesheet to apply while making the screenshot. This is where you can hide dynamic elements, make elements
+ * invisible or change their properties to help you creating repeatable screenshots.
+ */
+ public HasScreenshotOptions setStyle(String style) {
+ this.style = style;
+ return this;
+ }
+ /**
+ * An acceptable perceived color difference between the same pixel in compared images, between zero (strict) and one
+ * (lax), default is {@code 0.2}.
+ */
+ public HasScreenshotOptions setThreshold(double threshold) {
+ this.threshold = threshold;
+ return this;
+ }
+ /**
+ * Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
+ */
+ public HasScreenshotOptions setTimeout(double timeout) {
+ this.timeout = timeout;
+ return this;
+ }
+ }
class IsCheckedOptions {
/**
* Provides state to assert for. Asserts for input to be checked by default. This option can't be used when {@code
* indeterminate} is set to true.
*/
- public @Nullable Boolean checked;
+ public Boolean checked;
/**
* Asserts that the element is in the indeterminate (mixed) state. Only supported for checkboxes and radio buttons. This
* option can't be true when {@code checked} is provided.
*/
- public @Nullable Boolean indeterminate;
+ public Boolean indeterminate;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Provides state to assert for. Asserts for input to be checked by default. This option can't be used when {@code
@@ -104,7 +269,7 @@ class IsDisabledOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
@@ -115,11 +280,11 @@ public IsDisabledOptions setTimeout(double timeout) {
}
}
class IsEditableOptions {
- public @Nullable Boolean editable;
+ public Boolean editable;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
public IsEditableOptions setEditable(boolean editable) {
this.editable = editable;
@@ -137,7 +302,7 @@ class IsEmptyOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
@@ -148,11 +313,11 @@ public IsEmptyOptions setTimeout(double timeout) {
}
}
class IsEnabledOptions {
- public @Nullable Boolean enabled;
+ public Boolean enabled;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
public IsEnabledOptions setEnabled(boolean enabled) {
this.enabled = enabled;
@@ -170,7 +335,7 @@ class IsFocusedOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
@@ -184,7 +349,7 @@ class IsHiddenOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
@@ -199,11 +364,11 @@ class IsInViewportOptions {
* The minimal ratio of the element to intersect viewport. If equals to {@code 0}, then element should intersect viewport
* at any positive ratio. Defaults to {@code 0}.
*/
- public @Nullable Double ratio;
+ public Double ratio;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* The minimal ratio of the element to intersect viewport. If equals to {@code 0}, then element should intersect viewport
@@ -225,8 +390,8 @@ class IsVisibleOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
- public @Nullable Boolean visible;
+ public Double timeout;
+ public Boolean visible;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
@@ -244,7 +409,7 @@ class ContainsClassOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
@@ -259,15 +424,15 @@ class ContainsTextOptions {
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
* expression flag if specified.
*/
- public @Nullable Boolean ignoreCase;
+ public Boolean ignoreCase;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Whether to use {@code element.innerText} instead of {@code element.textContent} when retrieving DOM node text.
*/
- public @Nullable Boolean useInnerText;
+ public Boolean useInnerText;
/**
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
@@ -297,11 +462,11 @@ class HasAccessibleDescriptionOptions {
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
* expression flag if specified.
*/
- public @Nullable Boolean ignoreCase;
+ public Boolean ignoreCase;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
@@ -324,11 +489,11 @@ class HasAccessibleErrorMessageOptions {
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
* expression flag if specified.
*/
- public @Nullable Boolean ignoreCase;
+ public Boolean ignoreCase;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
@@ -351,11 +516,11 @@ class HasAccessibleNameOptions {
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
* expression flag if specified.
*/
- public @Nullable Boolean ignoreCase;
+ public Boolean ignoreCase;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
@@ -378,11 +543,11 @@ class HasAttributeOptions {
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
* expression flag if specified.
*/
- public @Nullable Boolean ignoreCase;
+ public Boolean ignoreCase;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
@@ -404,7 +569,7 @@ class HasClassOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
@@ -418,7 +583,7 @@ class HasCountOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
@@ -432,11 +597,11 @@ class HasCSSOptions {
/**
* Pseudo-element to read computed styles from.
*/
- public @Nullable PseudoElement pseudo;
+ public PseudoElement pseudo;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Pseudo-element to read computed styles from.
@@ -457,7 +622,7 @@ class HasIdOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
@@ -471,7 +636,7 @@ class HasJSPropertyOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
@@ -485,7 +650,7 @@ class HasRoleOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
@@ -500,15 +665,15 @@ class HasTextOptions {
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
* expression flag if specified.
*/
- public @Nullable Boolean ignoreCase;
+ public Boolean ignoreCase;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Whether to use {@code element.innerText} instead of {@code element.textContent} when retrieving DOM node text.
*/
- public @Nullable Boolean useInnerText;
+ public Boolean useInnerText;
/**
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
@@ -537,7 +702,7 @@ class HasValueOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
@@ -551,7 +716,7 @@ class HasValuesOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
@@ -565,7 +730,7 @@ class MatchesAriaSnapshotOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
@@ -613,7 +778,7 @@ default void isAttached() {
*
* @since v1.33
*/
- void isAttached(@Nullable IsAttachedOptions options);
+ void isAttached(IsAttachedOptions options);
/**
* Ensures the {@code Locator} points to a checked input.
*
@@ -637,7 +802,7 @@ default void isChecked() {
*
* @since v1.20
*/
- void isChecked(@Nullable IsCheckedOptions options);
+ void isChecked(IsCheckedOptions options);
/**
* Ensures the {@code Locator} points to a disabled element. Element is disabled if it has "disabled" attribute or is
* disabled via non-visible one.
@@ -793,7 +958,7 @@ default void isHidden() {
*
* @since v1.20
*/
- void isHidden(@Nullable IsHiddenOptions options);
+ void isHidden(IsHiddenOptions options);
/**
* Ensures the {@code Locator} points to an element that intersects viewport, according to the intersection observer API.
@@ -831,7 +996,7 @@ default void isInViewport() {
*
* @since v1.31
*/
- void isInViewport(@Nullable IsInViewportOptions options);
+ void isInViewport(IsInViewportOptions options);
/**
* Ensures that {@code Locator} points to an attached and visible DOM node.
@@ -885,7 +1050,7 @@ default void isVisible() {
*
* @since v1.20
*/
- void isVisible(@Nullable IsVisibleOptions options);
+ void isVisible(IsVisibleOptions options);
/**
* Ensures the {@code Locator} points to an element with given CSS classes. All classes from the asserted value, separated
* by spaces, must be present in the expected) {
* @param expected A string containing expected class names, separated by spaces, or a list of such strings to assert multiple elements.
* @since v1.52
*/
- void containsClass(List Usage
+ * Note that screenshot assertions only work with the Playwright driver's screenshot comparison support; there is no
+ * test-runner-managed snapshot directory or configuration as in {@code @playwright/test}. By default, baseline images
+ * are stored under {@code src/test/resources/__screenshots__/ Defaults to {@code "disabled"}.
+ */
+ public ScreenshotAnimations animations;
+ /**
+ * When set to {@code "hide"}, screenshot will hide text caret. When set to {@code "initial"}, text caret behavior will not
+ * be changed. Defaults to {@code "hide"}.
+ */
+ public ScreenshotCaret caret;
+ /**
+ * An object which specifies clipping of the resulting image.
+ */
+ public Clip clip;
+ /**
+ * When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to
+ * {@code false}.
+ */
+ public Boolean fullPage;
+ /**
+ * Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box
+ * {@code #FF00FF} (customized by {@code maskColor}) that completely covers its bounding box.
+ */
+ public List Defaults to {@code "css"}.
+ */
+ public ScreenshotScale scale;
+ /**
+ * Text of the stylesheet to apply while making the screenshot. This is where you can hide dynamic elements, make elements
+ * invisible or change their properties to help you creating repeatable screenshots.
+ */
+ public String style;
+ /**
+ * An acceptable perceived color difference between the same pixel in compared images, between zero (strict) and one
+ * (lax), default is {@code 0.2}.
+ */
+ public Double threshold;
+ /**
+ * Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
+ */
+ public Double timeout;
+
+ /**
+ * When set to {@code "disabled"}, stops CSS animations, CSS transitions and Web Animations. Animations get different
+ * treatment depending on their duration:
+ * Defaults to {@code "disabled"}.
+ */
+ public HasScreenshotOptions setAnimations(ScreenshotAnimations animations) {
+ this.animations = animations;
+ return this;
+ }
+ /**
+ * When set to {@code "hide"}, screenshot will hide text caret. When set to {@code "initial"}, text caret behavior will not
+ * be changed. Defaults to {@code "hide"}.
+ */
+ public HasScreenshotOptions setCaret(ScreenshotCaret caret) {
+ this.caret = caret;
+ return this;
+ }
+ /**
+ * An object which specifies clipping of the resulting image.
+ */
+ public HasScreenshotOptions setClip(Clip clip) {
+ this.clip = clip;
+ return this;
+ }
+ /**
+ * When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to
+ * {@code false}.
+ */
+ public HasScreenshotOptions setFullPage(boolean fullPage) {
+ this.fullPage = fullPage;
+ return this;
+ }
+ /**
+ * Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box
+ * {@code #FF00FF} (customized by {@code maskColor}) that completely covers its bounding box.
+ */
+ public HasScreenshotOptions setMask(List Defaults to {@code "css"}.
+ */
+ public HasScreenshotOptions setScale(ScreenshotScale scale) {
+ this.scale = scale;
+ return this;
+ }
+ /**
+ * Text of the stylesheet to apply while making the screenshot. This is where you can hide dynamic elements, make elements
+ * invisible or change their properties to help you creating repeatable screenshots.
+ */
+ public HasScreenshotOptions setStyle(String style) {
+ this.style = style;
+ return this;
+ }
+ /**
+ * An acceptable perceived color difference between the same pixel in compared images, between zero (strict) and one
+ * (lax), default is {@code 0.2}.
+ */
+ public HasScreenshotOptions setThreshold(double threshold) {
+ this.threshold = threshold;
+ return this;
+ }
+ /**
+ * Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
+ */
+ public HasScreenshotOptions setTimeout(double timeout) {
+ this.timeout = timeout;
+ return this;
+ }
+ }
class HasTitleOptions {
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
@@ -71,11 +262,11 @@ class HasURLOptions {
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
* expression parameter if specified. A provided predicate ignores this flag.
*/
- public @Nullable Boolean ignoreCase;
+ public Boolean ignoreCase;
/**
* Time to retry the assertion for in milliseconds. Defaults to {@code 5000}.
*/
- public @Nullable Double timeout;
+ public Double timeout;
/**
* Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular
@@ -139,7 +330,63 @@ default void matchesAriaSnapshot(String expected) {
*
* @since v1.60
*/
- void matchesAriaSnapshot(String expected, @Nullable MatchesAriaSnapshotOptions options);
+ void matchesAriaSnapshot(String expected, MatchesAriaSnapshotOptions options);
+ /**
+ * This function will wait until two consecutive page screenshots yield the same result, and then compare the last
+ * screenshot with the expectation.
+ *
+ * Usage
+ * Note that screenshot assertions only work with the Playwright driver's screenshot comparison support; there is no
+ * test-runner-managed snapshot directory or configuration as in {@code @playwright/test}. By default, baseline images
+ * are stored under {@code src/test/resources/__screenshots__/ Usage
+ * Usage
+ *
+ *
+ *
+ * {@code
+ * Locator locator = page.getByRole(AriaRole.BUTTON);
+ * assertThat(locator).hasScreenshot("image.png");
+ * }
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * {@code
+ * assertThat(page).hasScreenshot("image.png");
+ * }
+ *
+ * {@code
+ * assertThat(page).hasScreenshot("image.png");
+ * }
+ *
+ * @param name Snapshot name. Must have a {@code .png} extension.
+ * @since v1.23
+ */
+ void hasScreenshot(String name, HasScreenshotOptions options);
+ /**
+ * This function will wait until two consecutive page screenshots yield the same result, and then compare the last
+ * screenshot with the expectation.
+ *
+ * {@code
+ * assertThat(page).hasScreenshot(new String[] {"folder", "image.png"});
+ * }
+ *
+ * @param nameSegments Snapshot name segments that will be joined to form the file path. The last segment must have a {@code .png} extension.
+ * @since v1.23
+ */
+ default void hasScreenshot(String[] nameSegments) {
+ hasScreenshot(nameSegments, null);
+ }
+ /**
+ * This function will wait until two consecutive page screenshots yield the same result, and then compare the last
+ * screenshot with the expectation.
+ *
+ * @param nameSegments Snapshot name segments that will be joined to form the file path. The last segment must have a {@code .png} extension.
+ * @since v1.23
+ */
+ void hasScreenshot(String[] nameSegments, HasScreenshotOptions options);
/**
* Ensures the page has the given title.
*
@@ -165,7 +412,7 @@ default void hasTitle(String titleOrRegExp) {
* @param titleOrRegExp Expected title or RegExp.
* @since v1.20
*/
- void hasTitle(String titleOrRegExp, @Nullable HasTitleOptions options);
+ void hasTitle(String titleOrRegExp, HasTitleOptions options);
/**
* Ensures the page has the given title.
*
@@ -191,7 +438,7 @@ default void hasTitle(Pattern titleOrRegExp) {
* @param titleOrRegExp Expected title or RegExp.
* @since v1.20
*/
- void hasTitle(Pattern titleOrRegExp, @Nullable HasTitleOptions options);
+ void hasTitle(Pattern titleOrRegExp, HasTitleOptions options);
/**
* Ensures the page is navigated to the given URL.
*
@@ -217,7 +464,7 @@ default void hasURL(String urlOrRegExp) {
* @param urlOrRegExp Expected URL string or RegExp.
* @since v1.20
*/
- void hasURL(String urlOrRegExp, @Nullable HasURLOptions options);
+ void hasURL(String urlOrRegExp, HasURLOptions options);
/**
* Ensures the page is navigated to the given URL.
*
@@ -243,6 +490,6 @@ default void hasURL(Pattern urlOrRegExp) {
* @param urlOrRegExp Expected URL string or RegExp.
* @since v1.20
*/
- void hasURL(Pattern urlOrRegExp, @Nullable HasURLOptions options);
+ void hasURL(Pattern urlOrRegExp, HasURLOptions options);
}
diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/LocatorAssertionsImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/LocatorAssertionsImpl.java
index 088910c98..9d8a4761d 100644
--- a/playwright/src/main/java/com/microsoft/playwright/impl/LocatorAssertionsImpl.java
+++ b/playwright/src/main/java/com/microsoft/playwright/impl/LocatorAssertionsImpl.java
@@ -385,6 +385,21 @@ public void matchesAriaSnapshot(String expected, MatchesAriaSnapshotOptions snap
expectImpl("to.match.aria", options, expected,"Locator expected to match Aria snapshot", "Assert \"matchesAriaSnapshot\"");
}
+ @Override
+ public void hasScreenshot(String name, HasScreenshotOptions options) {
+ hasScreenshotImpl(name, options);
+ }
+
+ @Override
+ public void hasScreenshot(String[] nameSegments, HasScreenshotOptions options) {
+ hasScreenshotImpl(nameSegments, options);
+ }
+
+ private void hasScreenshotImpl(Object nameOrNames, HasScreenshotOptions options) {
+ ScreenshotAssertionsOptions screenshotOptions = convertType(options, ScreenshotAssertionsOptions.class);
+ new ScreenshotAssertionsHelper(actualLocator.frame.page, actualLocator, isNot).assertScreenshot(nameOrNames, screenshotOptions, "Assert \"hasScreenshot\"");
+ }
+
@Override
public void isChecked(IsCheckedOptions options) {
if (options == null) {
diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/PageAssertionsImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/PageAssertionsImpl.java
index 2cdd63d17..5f3f51cd0 100644
--- a/playwright/src/main/java/com/microsoft/playwright/impl/PageAssertionsImpl.java
+++ b/playwright/src/main/java/com/microsoft/playwright/impl/PageAssertionsImpl.java
@@ -83,6 +83,21 @@ public void matchesAriaSnapshot(String expected, MatchesAriaSnapshotOptions snap
expectImpl("to.match.aria", options, expected, "Page expected to match Aria snapshot", "Assert \"matchesAriaSnapshot\"");
}
+ @Override
+ public void hasScreenshot(String name, HasScreenshotOptions options) {
+ hasScreenshotImpl(name, options);
+ }
+
+ @Override
+ public void hasScreenshot(String[] nameSegments, HasScreenshotOptions options) {
+ hasScreenshotImpl(nameSegments, options);
+ }
+
+ private void hasScreenshotImpl(Object nameOrNames, HasScreenshotOptions options) {
+ ScreenshotAssertionsOptions screenshotOptions = convertType(options, ScreenshotAssertionsOptions.class);
+ new ScreenshotAssertionsHelper(actualPage, null, isNot).assertScreenshot(nameOrNames, screenshotOptions, "Assert \"hasScreenshot\"");
+ }
+
@Override
public PageAssertions not() {
return new PageAssertionsImpl(actualPage, !isNot);
diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java
index 88aaf4c32..bbb71b6c3 100644
--- a/playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java
+++ b/playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java
@@ -88,7 +88,6 @@ private static final Map