1
0
mirror of synced 2026-05-23 11:13:15 +00:00

Compare commits

...

8 Commits

Author SHA1 Message Date
Yury Semikhatsky 8ed802234d chore: mark 1.41.0 (#1453) 2024-01-17 15:57:30 -08:00
Yury Semikhatsky eefb9b68ff chore(1.41): Revert "feat(junit-playwright) (#1412)" (#1452)
Revert "feat(junit-playwright) (#1412)"

This reverts commit f28ca44fa0.
2024-01-17 15:37:59 -08:00
Yury Semikhatsky bc2857053c chore: roll driver 1.41.0 (#1450) 2024-01-17 11:26:02 -08:00
Yury Semikhatsky 7e6f98c903 chore: roll driver to 1.41 beta (#1449) 2024-01-17 08:55:22 -08:00
Yury Semikhatsky e889b20fda chore: roll driver to 1.41.0-alpha (#1443) 2023-12-18 16:01:35 -08:00
uchagani f28ca44fa0 feat(junit-playwright) (#1412) 2023-12-04 17:32:59 -08:00
Yury Semikhatsky d73f953e68 chore: mark 1.41 dev version (#1428) 2023-11-20 11:03:13 -08:00
Yury Semikhatsky cc28516281 chore: mark version 1.40.0 (#1427) 2023-11-20 10:57:07 -08:00
37 changed files with 390 additions and 119 deletions
+2 -2
View File
@@ -11,9 +11,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom
| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->120.0.6099.28<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Chromium <!-- GEN:chromium-version -->121.0.6167.57<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit <!-- GEN:webkit-version -->17.4<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->119.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Firefox <!-- GEN:firefox-version -->121.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
Headless execution is supported for all the browsers on all platforms. Check out [system requirements](https://playwright.dev/java/docs/intro#system-requirements) for details.
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.40.0-SNAPSHOT</version>
<version>1.41.0</version>
</parent>
<artifactId>driver-bundle</artifactId>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.40.0-SNAPSHOT</version>
<version>1.41.0</version>
</parent>
<artifactId>driver</artifactId>
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>org.example</groupId>
<artifactId>examples</artifactId>
<version>1.40.0-SNAPSHOT</version>
<version>1.41.0</version>
<name>Playwright Client Examples</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.40.0-SNAPSHOT</version>
<version>1.41.0</version>
</parent>
<artifactId>playwright</artifactId>
@@ -1260,6 +1260,13 @@ public interface BrowserContext extends AutoCloseable {
* @since v1.12
*/
Tracing tracing();
/**
* Removes all routes created with {@link BrowserContext#route BrowserContext.route()} and {@link
* BrowserContext#routeFromHAR BrowserContext.routeFromHAR()}.
*
* @since v1.41
*/
void unrouteAll();
/**
* Removes a route created with {@link BrowserContext#route BrowserContext.route()}. When {@code handler} is not specified,
* removes all routes for the {@code url}.
@@ -165,8 +165,10 @@ public interface BrowserType {
}
class LaunchOptions {
/**
* Additional arguments to pass to the browser instance. The list of Chromium flags can be found <a
* href="http://peter.sh/experiments/chromium-command-line-switches/">here</a>.
* <strong>NOTE:</strong> Use custom browser args at your own risk, as some of them may break Playwright functionality.
*
* <p> Additional arguments to pass to the browser instance. The list of Chromium flags can be found <a
* href="https://peter.sh/experiments/chromium-command-line-switches/">here</a>.
*/
public List<String> args;
/**
@@ -253,8 +255,10 @@ public interface BrowserType {
public Path tracesDir;
/**
* Additional arguments to pass to the browser instance. The list of Chromium flags can be found <a
* href="http://peter.sh/experiments/chromium-command-line-switches/">here</a>.
* <strong>NOTE:</strong> Use custom browser args at your own risk, as some of them may break Playwright functionality.
*
* <p> Additional arguments to pass to the browser instance. The list of Chromium flags can be found <a
* href="https://peter.sh/experiments/chromium-command-line-switches/">here</a>.
*/
public LaunchOptions setArgs(List<String> args) {
this.args = args;
@@ -416,8 +420,10 @@ public interface BrowserType {
*/
public Boolean acceptDownloads;
/**
* Additional arguments to pass to the browser instance. The list of Chromium flags can be found <a
* href="http://peter.sh/experiments/chromium-command-line-switches/">here</a>.
* <strong>NOTE:</strong> Use custom browser args at your own risk, as some of them may break Playwright functionality.
*
* <p> Additional arguments to pass to the browser instance. The list of Chromium flags can be found <a
* href="https://peter.sh/experiments/chromium-command-line-switches/">here</a>.
*/
public List<String> args;
/**
@@ -675,8 +681,10 @@ public interface BrowserType {
return this;
}
/**
* Additional arguments to pass to the browser instance. The list of Chromium flags can be found <a
* href="http://peter.sh/experiments/chromium-command-line-switches/">here</a>.
* <strong>NOTE:</strong> Use custom browser args at your own risk, as some of them may break Playwright functionality.
*
* <p> Additional arguments to pass to the browser instance. The list of Chromium flags can be found <a
* href="https://peter.sh/experiments/chromium-command-line-switches/">here</a>.
*/
public LaunchPersistentContextOptions setArgs(List<String> args) {
this.args = args;
@@ -634,6 +634,12 @@ public interface ElementHandle extends JSHandle {
* <p> Defaults to {@code "device"}.
*/
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. This stylesheet pierces the Shadow DOM
* and applies to the inner frames.
*/
public String style;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
@@ -719,6 +725,15 @@ public interface ElementHandle extends JSHandle {
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. This stylesheet pierces the Shadow DOM
* and applies to the inner frames.
*/
public ScreenshotOptions setStyle(String style) {
this.style = style;
return this;
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
@@ -2531,8 +2546,7 @@ public interface ElementHandle extends JSHandle {
* <li> {@code "visible"} Wait until the element is <a
* href="https://playwright.dev/java/docs/actionability#visible">visible</a>.</li>
* <li> {@code "hidden"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability#visible">not
* visible</a> or <a href="https://playwright.dev/java/docs/actionability#attached">not attached</a>. Note that waiting for
* hidden does not throw when the element detaches.</li>
* visible</a> or not attached. Note that waiting for hidden does not throw when the element detaches.</li>
* <li> {@code "stable"} Wait until the element is both <a
* href="https://playwright.dev/java/docs/actionability#visible">visible</a> and <a
* href="https://playwright.dev/java/docs/actionability#stable">stable</a>.</li>
@@ -2562,8 +2576,7 @@ public interface ElementHandle extends JSHandle {
* <li> {@code "visible"} Wait until the element is <a
* href="https://playwright.dev/java/docs/actionability#visible">visible</a>.</li>
* <li> {@code "hidden"} Wait until the element is <a href="https://playwright.dev/java/docs/actionability#visible">not
* visible</a> or <a href="https://playwright.dev/java/docs/actionability#attached">not attached</a>. Note that waiting for
* hidden does not throw when the element detaches.</li>
* visible</a> or not attached. Note that waiting for hidden does not throw when the element detaches.</li>
* <li> {@code "stable"} Wait until the element is both <a
* href="https://playwright.dev/java/docs/actionability#visible">visible</a> and <a
* href="https://playwright.dev/java/docs/actionability#stable">stable</a>.</li>
@@ -1470,8 +1470,14 @@ public interface Frame {
}
class LocatorOptions {
/**
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
* For example, {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
* Narrows down the results of the method to those which contain elements matching this relative locator. For example,
* {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
*
* <p> Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not the
* document root. For example, you can find {@code content} that has {@code div} in {@code
* <article><content><div>Playwright</div></content></article>}. However, looking for {@code content} that has {@code
* article div} will fail, because the inner locator must be relative and should not use any elements outside the {@code
* content}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
@@ -1497,8 +1503,14 @@ public interface Frame {
public Object hasText;
/**
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
* For example, {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
* Narrows down the results of the method to those which contain elements matching this relative locator. For example,
* {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
*
* <p> Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not the
* document root. For example, you can find {@code content} that has {@code div} in {@code
* <article><content><div>Playwright</div></content></article>}. However, looking for {@code content} that has {@code
* article div} will fail, because the inner locator must be relative and should not use any elements outside the {@code
* content}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
@@ -285,8 +285,14 @@ public interface FrameLocator {
}
class LocatorOptions {
/**
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
* For example, {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
* Narrows down the results of the method to those which contain elements matching this relative locator. For example,
* {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
*
* <p> Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not the
* document root. For example, you can find {@code content} that has {@code div} in {@code
* <article><content><div>Playwright</div></content></article>}. However, looking for {@code content} that has {@code
* article div} will fail, because the inner locator must be relative and should not use any elements outside the {@code
* content}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
@@ -312,8 +318,14 @@ public interface FrameLocator {
public Object hasText;
/**
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
* For example, {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
* Narrows down the results of the method to those which contain elements matching this relative locator. For example,
* {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
*
* <p> Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not the
* document root. For example, you can find {@code content} that has {@code div} in {@code
* <article><content><div>Playwright</div></content></article>}. However, looking for {@code content} that has {@code
* article div} will fail, because the inner locator must be relative and should not use any elements outside the {@code
* content}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
@@ -656,8 +656,14 @@ public interface Locator {
}
class FilterOptions {
/**
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
* For example, {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
* Narrows down the results of the method to those which contain elements matching this relative locator. For example,
* {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
*
* <p> Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not the
* document root. For example, you can find {@code content} that has {@code div} in {@code
* <article><content><div>Playwright</div></content></article>}. However, looking for {@code content} that has {@code
* article div} will fail, because the inner locator must be relative and should not use any elements outside the {@code
* content}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
@@ -683,8 +689,14 @@ public interface Locator {
public Object hasText;
/**
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
* For example, {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
* Narrows down the results of the method to those which contain elements matching this relative locator. For example,
* {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
*
* <p> Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not the
* document root. For example, you can find {@code content} that has {@code div} in {@code
* <article><content><div>Playwright</div></content></article>}. However, looking for {@code content} that has {@code
* article div} will fail, because the inner locator must be relative and should not use any elements outside the {@code
* content}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
@@ -1262,8 +1274,14 @@ public interface Locator {
}
class LocatorOptions {
/**
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
* For example, {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
* Narrows down the results of the method to those which contain elements matching this relative locator. For example,
* {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
*
* <p> Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not the
* document root. For example, you can find {@code content} that has {@code div} in {@code
* <article><content><div>Playwright</div></content></article>}. However, looking for {@code content} that has {@code
* article div} will fail, because the inner locator must be relative and should not use any elements outside the {@code
* content}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
@@ -1289,8 +1307,14 @@ public interface Locator {
public Object hasText;
/**
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
* For example, {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
* Narrows down the results of the method to those which contain elements matching this relative locator. For example,
* {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
*
* <p> Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not the
* document root. For example, you can find {@code content} that has {@code div} in {@code
* <article><content><div>Playwright</div></content></article>}. However, looking for {@code content} that has {@code
* article div} will fail, because the inner locator must be relative and should not use any elements outside the {@code
* content}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
@@ -1483,6 +1507,12 @@ public interface Locator {
* <p> Defaults to {@code "device"}.
*/
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. This stylesheet pierces the Shadow DOM
* and applies to the inner frames.
*/
public String style;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
@@ -1568,6 +1598,15 @@ public interface Locator {
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. This stylesheet pierces the Shadow DOM
* and applies to the inner frames.
*/
public ScreenshotOptions setStyle(String style) {
this.style = style;
return this;
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
@@ -1924,8 +1924,14 @@ public interface Page extends AutoCloseable {
}
class LocatorOptions {
/**
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
* For example, {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
* Narrows down the results of the method to those which contain elements matching this relative locator. For example,
* {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
*
* <p> Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not the
* document root. For example, you can find {@code content} that has {@code div} in {@code
* <article><content><div>Playwright</div></content></article>}. However, looking for {@code content} that has {@code
* article div} will fail, because the inner locator must be relative and should not use any elements outside the {@code
* content}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
@@ -1951,8 +1957,14 @@ public interface Page extends AutoCloseable {
public Object hasText;
/**
* Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer one.
* For example, {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
* Narrows down the results of the method to those which contain elements matching this relative locator. For example,
* {@code article} that has {@code text=Playwright} matches {@code <article><div>Playwright</div></article>}.
*
* <p> Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not the
* document root. For example, you can find {@code content} that has {@code div} in {@code
* <article><content><div>Playwright</div></content></article>}. However, looking for {@code content} that has {@code
* article div} will fail, because the inner locator must be relative and should not use any elements outside the {@code
* content}.
*
* <p> Note that outer and inner locators must belong to the same frame. Inner locator must not contain {@code FrameLocator}s.
*/
@@ -2450,6 +2462,12 @@ public interface Page extends AutoCloseable {
* <p> Defaults to {@code "device"}.
*/
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. This stylesheet pierces the Shadow DOM
* and applies to the inner frames.
*/
public String style;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
@@ -2556,6 +2574,15 @@ public interface Page extends AutoCloseable {
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. This stylesheet pierces the Shadow DOM
* and applies to the inner frames.
*/
public ScreenshotOptions setStyle(String style) {
this.style = style;
return this;
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
@@ -7030,6 +7057,12 @@ public interface Page extends AutoCloseable {
* @since v1.8
*/
void uncheck(String selector, UncheckOptions options);
/**
* Removes all routes created with {@link Page#route Page.route()} and {@link Page#routeFromHAR Page.routeFromHAR()}.
*
* @since v1.41
*/
void unrouteAll();
/**
* Removes a route created with {@link Page#route Page.route()}. When {@code handler} is not specified, removes all routes
* for the {@code url}.
@@ -38,8 +38,9 @@ import java.nio.file.Path;
public interface Tracing {
class StartOptions {
/**
* If specified, the trace is going to be saved into the file with the given name inside the {@code tracesDir} folder
* specified in {@link BrowserType#launch BrowserType.launch()}.
* If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the {@code
* tracesDir} folder specified in {@link BrowserType#launch BrowserType.launch()}. To specify the final trace zip file
* name, you need to pass {@code path} option to {@link Tracing#stop Tracing.stop()} instead.
*/
public String name;
/**
@@ -66,8 +67,9 @@ public interface Tracing {
public String title;
/**
* If specified, the trace is going to be saved into the file with the given name inside the {@code tracesDir} folder
* specified in {@link BrowserType#launch BrowserType.launch()}.
* If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the {@code
* tracesDir} folder specified in {@link BrowserType#launch BrowserType.launch()}. To specify the final trace zip file
* name, you need to pass {@code path} option to {@link Tracing#stop Tracing.stop()} instead.
*/
public StartOptions setName(String name) {
this.name = name;
@@ -110,8 +112,9 @@ public interface Tracing {
}
class StartChunkOptions {
/**
* If specified, the trace is going to be saved into the file with the given name inside the {@code tracesDir} folder
* specified in {@link BrowserType#launch BrowserType.launch()}.
* If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the {@code
* tracesDir} folder specified in {@link BrowserType#launch BrowserType.launch()}. To specify the final trace zip file
* name, you need to pass {@code path} option to {@link Tracing#stopChunk Tracing.stopChunk()} instead.
*/
public String name;
/**
@@ -120,8 +123,9 @@ public interface Tracing {
public String title;
/**
* If specified, the trace is going to be saved into the file with the given name inside the {@code tracesDir} folder
* specified in {@link BrowserType#launch BrowserType.launch()}.
* If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the {@code
* tracesDir} folder specified in {@link BrowserType#launch BrowserType.launch()}. To specify the final trace zip file
* name, you need to pass {@code path} option to {@link Tracing#stopChunk Tracing.stopChunk()} instead.
*/
public StartChunkOptions setName(String name) {
this.name = name;
@@ -427,8 +427,8 @@ public interface LocatorAssertions {
*/
LocatorAssertions not();
/**
* Ensures that {@code Locator} points to an <a href="https://playwright.dev/java/docs/actionability#attached">attached</a>
* DOM node.
* Ensures that {@code Locator} points to an element that is <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected">connected</a> to a Document or a ShadowRoot.
*
* <p> **Usage**
* <pre>{@code
@@ -441,8 +441,8 @@ public interface LocatorAssertions {
isAttached(null);
}
/**
* Ensures that {@code Locator} points to an <a href="https://playwright.dev/java/docs/actionability#attached">attached</a>
* DOM node.
* Ensures that {@code Locator} points to an element that is <a
* href="https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected">connected</a> to a Document or a ShadowRoot.
*
* <p> **Usage**
* <pre>{@code
@@ -671,8 +671,8 @@ public interface LocatorAssertions {
*/
void isInViewport(IsInViewportOptions options);
/**
* Ensures that {@code Locator} points to an <a href="https://playwright.dev/java/docs/actionability#attached">attached</a>
* and <a href="https://playwright.dev/java/docs/actionability#visible">visible</a> DOM node.
* Ensures that {@code Locator} points to an attached and <a
* href="https://playwright.dev/java/docs/actionability#visible">visible</a> DOM node.
*
* <p> To check that at least one element from the list is visible, use {@link Locator#first Locator.first()}.
*
@@ -698,8 +698,8 @@ public interface LocatorAssertions {
isVisible(null);
}
/**
* Ensures that {@code Locator} points to an <a href="https://playwright.dev/java/docs/actionability#attached">attached</a>
* and <a href="https://playwright.dev/java/docs/actionability#visible">visible</a> DOM node.
* Ensures that {@code Locator} points to an attached and <a
* href="https://playwright.dev/java/docs/actionability#visible">visible</a> DOM node.
*
* <p> To check that at least one element from the list is visible, use {@link Locator#first Locator.first()}.
*
@@ -723,8 +723,8 @@ public interface LocatorAssertions {
*/
void isVisible(IsVisibleOptions options);
/**
* Ensures the {@code Locator} points to an element that contains the given text. You can use regular expressions for the
* value as well.
* Ensures the {@code Locator} points to an element that contains the given text. All nested elements will be considered
* when computing the text content of the element. You can use regular expressions for the value as well.
*
* <p> **Details**
*
@@ -768,8 +768,8 @@ public interface LocatorAssertions {
containsText(expected, null);
}
/**
* Ensures the {@code Locator} points to an element that contains the given text. You can use regular expressions for the
* value as well.
* Ensures the {@code Locator} points to an element that contains the given text. All nested elements will be considered
* when computing the text content of the element. You can use regular expressions for the value as well.
*
* <p> **Details**
*
@@ -811,8 +811,8 @@ public interface LocatorAssertions {
*/
void containsText(String expected, ContainsTextOptions options);
/**
* Ensures the {@code Locator} points to an element that contains the given text. You can use regular expressions for the
* value as well.
* Ensures the {@code Locator} points to an element that contains the given text. All nested elements will be considered
* when computing the text content of the element. You can use regular expressions for the value as well.
*
* <p> **Details**
*
@@ -856,8 +856,8 @@ public interface LocatorAssertions {
containsText(expected, null);
}
/**
* Ensures the {@code Locator} points to an element that contains the given text. You can use regular expressions for the
* value as well.
* Ensures the {@code Locator} points to an element that contains the given text. All nested elements will be considered
* when computing the text content of the element. You can use regular expressions for the value as well.
*
* <p> **Details**
*
@@ -899,8 +899,8 @@ public interface LocatorAssertions {
*/
void containsText(Pattern expected, ContainsTextOptions options);
/**
* Ensures the {@code Locator} points to an element that contains the given text. You can use regular expressions for the
* value as well.
* Ensures the {@code Locator} points to an element that contains the given text. All nested elements will be considered
* when computing the text content of the element. You can use regular expressions for the value as well.
*
* <p> **Details**
*
@@ -944,8 +944,8 @@ public interface LocatorAssertions {
containsText(expected, null);
}
/**
* Ensures the {@code Locator} points to an element that contains the given text. You can use regular expressions for the
* value as well.
* Ensures the {@code Locator} points to an element that contains the given text. All nested elements will be considered
* when computing the text content of the element. You can use regular expressions for the value as well.
*
* <p> **Details**
*
@@ -987,8 +987,8 @@ public interface LocatorAssertions {
*/
void containsText(String[] expected, ContainsTextOptions options);
/**
* Ensures the {@code Locator} points to an element that contains the given text. You can use regular expressions for the
* value as well.
* Ensures the {@code Locator} points to an element that contains the given text. All nested elements will be considered
* when computing the text content of the element. You can use regular expressions for the value as well.
*
* <p> **Details**
*
@@ -1032,8 +1032,8 @@ public interface LocatorAssertions {
containsText(expected, null);
}
/**
* Ensures the {@code Locator} points to an element that contains the given text. You can use regular expressions for the
* value as well.
* Ensures the {@code Locator} points to an element that contains the given text. All nested elements will be considered
* when computing the text content of the element. You can use regular expressions for the value as well.
*
* <p> **Details**
*
@@ -1455,8 +1455,8 @@ public interface LocatorAssertions {
*/
void hasJSProperty(String name, Object value, HasJSPropertyOptions options);
/**
* Ensures the {@code Locator} points to an element with the given text. You can use regular expressions for the value as
* well.
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
* computing the text content of the element. You can use regular expressions for the value as well.
*
* <p> **Details**
*
@@ -1500,8 +1500,8 @@ public interface LocatorAssertions {
hasText(expected, null);
}
/**
* Ensures the {@code Locator} points to an element with the given text. You can use regular expressions for the value as
* well.
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
* computing the text content of the element. You can use regular expressions for the value as well.
*
* <p> **Details**
*
@@ -1543,8 +1543,8 @@ public interface LocatorAssertions {
*/
void hasText(String expected, HasTextOptions options);
/**
* Ensures the {@code Locator} points to an element with the given text. You can use regular expressions for the value as
* well.
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
* computing the text content of the element. You can use regular expressions for the value as well.
*
* <p> **Details**
*
@@ -1588,8 +1588,8 @@ public interface LocatorAssertions {
hasText(expected, null);
}
/**
* Ensures the {@code Locator} points to an element with the given text. You can use regular expressions for the value as
* well.
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
* computing the text content of the element. You can use regular expressions for the value as well.
*
* <p> **Details**
*
@@ -1631,8 +1631,8 @@ public interface LocatorAssertions {
*/
void hasText(Pattern expected, HasTextOptions options);
/**
* Ensures the {@code Locator} points to an element with the given text. You can use regular expressions for the value as
* well.
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
* computing the text content of the element. You can use regular expressions for the value as well.
*
* <p> **Details**
*
@@ -1676,8 +1676,8 @@ public interface LocatorAssertions {
hasText(expected, null);
}
/**
* Ensures the {@code Locator} points to an element with the given text. You can use regular expressions for the value as
* well.
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
* computing the text content of the element. You can use regular expressions for the value as well.
*
* <p> **Details**
*
@@ -1719,8 +1719,8 @@ public interface LocatorAssertions {
*/
void hasText(String[] expected, HasTextOptions options);
/**
* Ensures the {@code Locator} points to an element with the given text. You can use regular expressions for the value as
* well.
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
* computing the text content of the element. You can use regular expressions for the value as well.
*
* <p> **Details**
*
@@ -1764,8 +1764,8 @@ public interface LocatorAssertions {
hasText(expected, null);
}
/**
* Ensures the {@code Locator} points to an element with the given text. You can use regular expressions for the value as
* well.
* Ensures the {@code Locator} points to an element with the given text. All nested elements will be considered when
* computing the text content of the element. You can use regular expressions for the value as well.
*
* <p> **Details**
*
@@ -568,6 +568,14 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
return tracing;
}
@Override
public void unrouteAll() {
withLogging("BrowserContext.unrouteAll", () -> {
routes.removeAll();
updateInterceptionPatterns();
});
}
@Override
public void unroute(String url, Consumer<Route> handler) {
unroute(new UrlMatcher(this.baseUrl, url), handler);
@@ -1226,6 +1226,14 @@ public class PageImpl extends ChannelOwner implements Page {
() -> mainFrame.uncheckImpl(selector, convertType(options, Frame.UncheckOptions.class)));
}
@Override
public void unrouteAll() {
withLogging("Page.unrouteAll", () -> {
routes.removeAll();
updateInterceptionPatterns();
});
}
@Override
public void unroute(String url, Consumer<Route> handler) {
unroute(new UrlMatcher(browserContext.baseUrl, url), handler);
@@ -66,8 +66,8 @@ class Router {
.collect(Collectors.toList());
}
int size() {
return routes.size();
void removeAll() {
routes.clear();
}
enum HandleResult { NoMatchingHandler, Handled, Fallback, PendingHandler }
@@ -42,6 +42,19 @@ public interface FormData {
}
/**
* Sets a field on the form. File values can be passed either as {@code Path} or as {@code FilePayload}.
* <pre>{@code
* import com.microsoft.playwright.options.FormData;
* ...
* FormData form = FormData.create()
* // Only name and value are set.
* .set("firstName", "John")
* // Name and value are set, filename and Content-Type are inferred from the file path.
* .set("profilePicture1", Paths.get("john.jpg"))
* // Name, value, filename and Content-Type are set.
* .set("profilePicture2", new FilePayload("john.jpg", "image/jpeg", Files.readAllBytes(Paths.get("john.jpg"))));
* .set("age", 30);
* page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
* }</pre>
*
* @param name Field name.
* @param value Field value.
@@ -50,6 +63,19 @@ public interface FormData {
FormData set(String name, String value);
/**
* Sets a field on the form. File values can be passed either as {@code Path} or as {@code FilePayload}.
* <pre>{@code
* import com.microsoft.playwright.options.FormData;
* ...
* FormData form = FormData.create()
* // Only name and value are set.
* .set("firstName", "John")
* // Name and value are set, filename and Content-Type are inferred from the file path.
* .set("profilePicture1", Paths.get("john.jpg"))
* // Name, value, filename and Content-Type are set.
* .set("profilePicture2", new FilePayload("john.jpg", "image/jpeg", Files.readAllBytes(Paths.get("john.jpg"))));
* .set("age", 30);
* page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
* }</pre>
*
* @param name Field name.
* @param value Field value.
@@ -58,6 +84,19 @@ public interface FormData {
FormData set(String name, boolean value);
/**
* Sets a field on the form. File values can be passed either as {@code Path} or as {@code FilePayload}.
* <pre>{@code
* import com.microsoft.playwright.options.FormData;
* ...
* FormData form = FormData.create()
* // Only name and value are set.
* .set("firstName", "John")
* // Name and value are set, filename and Content-Type are inferred from the file path.
* .set("profilePicture1", Paths.get("john.jpg"))
* // Name, value, filename and Content-Type are set.
* .set("profilePicture2", new FilePayload("john.jpg", "image/jpeg", Files.readAllBytes(Paths.get("john.jpg"))));
* .set("age", 30);
* page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
* }</pre>
*
* @param name Field name.
* @param value Field value.
@@ -66,6 +105,19 @@ public interface FormData {
FormData set(String name, int value);
/**
* Sets a field on the form. File values can be passed either as {@code Path} or as {@code FilePayload}.
* <pre>{@code
* import com.microsoft.playwright.options.FormData;
* ...
* FormData form = FormData.create()
* // Only name and value are set.
* .set("firstName", "John")
* // Name and value are set, filename and Content-Type are inferred from the file path.
* .set("profilePicture1", Paths.get("john.jpg"))
* // Name, value, filename and Content-Type are set.
* .set("profilePicture2", new FilePayload("john.jpg", "image/jpeg", Files.readAllBytes(Paths.get("john.jpg"))));
* .set("age", 30);
* page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
* }</pre>
*
* @param name Field name.
* @param value Field value.
@@ -74,6 +126,19 @@ public interface FormData {
FormData set(String name, Path value);
/**
* Sets a field on the form. File values can be passed either as {@code Path} or as {@code FilePayload}.
* <pre>{@code
* import com.microsoft.playwright.options.FormData;
* ...
* FormData form = FormData.create()
* // Only name and value are set.
* .set("firstName", "John")
* // Name and value are set, filename and Content-Type are inferred from the file path.
* .set("profilePicture1", Paths.get("john.jpg"))
* // Name, value, filename and Content-Type are set.
* .set("profilePicture2", new FilePayload("john.jpg", "image/jpeg", Files.readAllBytes(Paths.get("john.jpg"))));
* .set("age", 30);
* page.request().post("http://localhost/submit", RequestOptions.create().setForm(form));
* }</pre>
*
* @param name Field name.
* @param value Field value.
@@ -236,8 +236,17 @@ public class TestBrowserContextBasic extends TestBase {
void shouldWorkWithOfflineOption() {
BrowserContext context = browser.newContext(new Browser.NewContextOptions().setOffline(true));
Page page = context.newPage();
assertThrows(PlaywrightException.class, () -> page.navigate(server.EMPTY_PAGE));
if (isFirefox()) {
// Firefox navigates to an error page, and this navigation might conflict with the
// next navigation we do in test.
// So we need to wait for the navigation explicitly.
boolean[] frameNavigated = { false };
page.onFrameNavigated(frame -> frameNavigated[0] = true);
assertThrows(PlaywrightException.class, () -> page.navigate(server.EMPTY_PAGE));
page.waitForCondition(() -> frameNavigated[0], new Page.WaitForConditionOptions().setTimeout(10_000));
} else {
assertThrows(PlaywrightException.class, () -> page.navigate(server.EMPTY_PAGE));
}
context.setOffline(false);
Response response = page.navigate(server.EMPTY_PAGE);
assertEquals(200, response.status());
@@ -374,17 +374,9 @@ public class TestPageKeyboard extends TestBase {
JSHandle lastEvent = captureLastKeyDown();
page.keyboard().press("Meta");
LinkedHashMap eventData = (LinkedHashMap) lastEvent.jsonValue();
if (isFirefox() && !isMac) {
assertEquals("OS", eventData.get("key"));
} else {
assertEquals("Meta", eventData.get("key"));
}
assertEquals("Meta", eventData.get("key"));
assertEquals("MetaLeft", eventData.get("code"));
if (isFirefox() && !isMac) {
assertFalse((Boolean) eventData.get("metaKey"), eventData.toString());
} else {
assertTrue((Boolean) eventData.get("metaKey"), eventData.toString());
}
assertTrue((Boolean) eventData.get("metaKey"), eventData.toString());
}
@Test
@@ -134,15 +134,4 @@ public class TestPageNetworkRequest extends TestBase {
assertTrue(request[0].isNavigationRequest());
assertTrue(error[0].getMessage().contains("Frame for this navigation request is not available"), error[0].getMessage());
}
@Test
void shouldThrowIfRequestWasGCed() {
List<Request> requests = new ArrayList<>();
page.onRequest(req -> requests.add(req));
for (int i = 0; i < 1001; i++) {
page.navigate(server.EMPTY_PAGE);
}
PlaywrightException e = assertThrows(PlaywrightException.class, () -> requests.get(0).response());
assertEquals("The object has been collected to prevent unbounded heap growth.", e.getMessage());
}
}
@@ -28,7 +28,10 @@ import org.opentest4j.AssertionFailedError;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
@@ -249,4 +252,40 @@ public class TestPageScreenshot extends TestBase {
assertThrows(AssertionError.class, () -> assertArrayEquals(screenshot1, screenshot2));
}
@Test
@DisabledIf(value="com.microsoft.playwright.TestBase#isWebKit", disabledReason="array lengths differ")
void shouldHideElementsBasedOnAttr() throws IOException {
page.setViewportSize(500, 500);
page.navigate(server.PREFIX + "/grid.html");
page.locator("div").nth(5).evaluate("element => {\n" +
" element.setAttribute('data-test-screenshot', 'hide');\n" +
"}");
byte[] actual = page.screenshot(new Page.ScreenshotOptions().setStyle("[data-test-screenshot=\"hide\"] {\n" +
" visibility: hidden;\n" +
" }"));
assertArrayEquals(expectedScreenshot("hide-should-work"), actual, "Screenshots should match");
Object visibility = page.locator("div").nth(5).evaluate("element => element.style.visibility");
assertEquals("", visibility);
}
@Test
@DisabledIf(value="com.microsoft.playwright.TestBase#isWebKit", disabledReason="array lengths differ")
void shouldRemoveElementsBasedOnAttr() throws IOException {
page.setViewportSize(500, 500);
page.navigate(server.PREFIX + "/grid.html");
page.locator("div").nth(5).evaluate("element => {\n" +
" element.setAttribute('data-test-screenshot', 'remove');\n" +
" }");
byte[] actual = page.screenshot(new Page.ScreenshotOptions().setStyle("[data-test-screenshot=\"remove\"] {\n" +
" display: none;\n" +
" }"));
assertArrayEquals(expectedScreenshot("remove-should-work"), actual, "Screenshots should match");
Object display = page.locator("div").nth(5).evaluate("element => element.style.display");
assertEquals("", display);
}
private byte[] expectedScreenshot(String name) throws IOException {
Path path = Paths.get("src/test/resources/expectations");
return Files.readAllBytes(path.resolve(name + "-" + browserType.name() + ".png"));
}
}
@@ -0,0 +1,33 @@
package com.microsoft.playwright;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class TestUnrouteBehavior extends TestBase {
@Test
void contextUnrouteAllRemovesAllHandlers() {
context.route("**/*", route -> {
route.abort();
});
context.route("**/empty.html", route -> {
route.abort();
});
context.unrouteAll();
page.navigate(server.EMPTY_PAGE);
}
@Test
void pageUnrouteAllRemovesAllRoutes() {
page.route("**/*", route -> {
route.abort();
});
page.route("**/empty.html", route -> {
route.abort();
});
page.unrouteAll();
Response response = page.navigate(server.EMPTY_PAGE);
assertTrue(response.ok());
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.40.0-SNAPSHOT</version>
<version>1.41.0</version>
<packaging>pom</packaging>
<name>Playwright Parent Project</name>
<description>Java library to automate Chromium, Firefox and WebKit with a single API.
+1 -1
View File
@@ -1 +1 @@
1.40.0
1.41.0
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>com.microsoft.playwright</groupId>
<artifactId>api-generator</artifactId>
<version>1.40.0-SNAPSHOT</version>
<version>1.41.0</version>
<name>Playwright - API Generator</name>
<description>
This is an internal module used to generate Java API from the upstream Playwright
+1 -1
View File
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.playwright</groupId>
<artifactId>test-cli-fatjar</artifactId>
<version>1.40.0-SNAPSHOT</version>
<version>1.41.0</version>
<name>Test Playwright Command Line FatJar</name>
<properties>
<compiler.version>1.8</compiler.version>
+1 -1
View File
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.playwright</groupId>
<artifactId>test-cli-version</artifactId>
<version>1.40.0-SNAPSHOT</version>
<version>1.41.0</version>
<name>Test Playwright Command Line Version</name>
<properties>
<compiler.version>1.8</compiler.version>
+1 -1
View File
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.playwright</groupId>
<artifactId>test-local-installation</artifactId>
<version>1.40.0-SNAPSHOT</version>
<version>1.41.0</version>
<name>Test local installation</name>
<description>Runs Playwright test suite (copied from playwright module) against locally cached Playwright</description>
<properties>
+1 -1
View File
@@ -9,7 +9,7 @@
</parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>test-spring-boot-starter</artifactId>
<version>1.40.0-SNAPSHOT</version>
<version>1.41.0</version>
<name>Test Playwright With Spring Boot</name>
<properties>
<spring.version>2.4.3</spring.version>
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>com.microsoft.playwright</groupId>
<artifactId>update-version</artifactId>
<version>1.40.0-SNAPSHOT</version>
<version>1.41.0</version>
<name>Playwright - Update Version in Documentation</name>
<description>
This is an internal module used to update versions in the documentation based on