Skip to content

Commit 8ce193d

Browse files
authored
chore: roll to 1.21 beta driver (microsoft#888)
1 parent 7eddd2d commit 8ce193d

25 files changed

Lines changed: 1142 additions & 1090 deletions

.github/workflows/verify_api.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v2
23-
- uses: microsoft/[email protected]
24-
- name: Cache Maven packages
25-
uses: actions/cache@v2
26-
with:
27-
path: ~/.m2
28-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
29-
restore-keys: ${{ runner.os }}-m2
23+
- uses: microsoft/playwright-github-action@v1
3024
- name: Download drivers
3125
run: scripts/download_driver_for_all_platforms.sh
3226
- name: Regenerate APIs

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom
1111

1212
| | Linux | macOS | Windows |
1313
| :--- | :---: | :---: | :---: |
14-
| Chromium <!-- GEN:chromium-version -->101.0.4929.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
14+
| Chromium <!-- GEN:chromium-version -->101.0.4951.15<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
1515
| WebKit <!-- GEN:webkit-version -->15.4<!-- GEN:stop --> ||||
16-
| Firefox <!-- GEN:firefox-version -->97.0.1<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
16+
| Firefox <!-- GEN:firefox-version -->98.0.2<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
1717

1818
Headless execution is supported for all the browsers on all platforms. Check out [system requirements](https://playwright.dev/java/docs/next/intro/#system-requirements) for details.
1919

driver/src/main/java/com/microsoft/playwright/impl/DriverLogging.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class DriverLogging {
3131
"yyyy-MM-dd'T'HH:mm:ss.SSSXXX").withZone(ZoneId.of("UTC"));
3232

3333
static void logWithTimestamp(String message) {
34+
if (!isEnabled) {
35+
return;
36+
}
3437
// This matches log format produced by the server.
3538
String timestamp = ZonedDateTime.now().format(timestampFormat);
3639
System.err.println(timestamp + " " + message);

playwright/src/main/java/com/microsoft/playwright/APIRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
import java.util.*;
2222

2323
/**
24-
* Exposes API that can be used for the Web API testing. Each Playwright browser context has a APIRequestContext instance
25-
* attached which shares cookies with the page context. Its also possible to create a new APIRequestContext instance
26-
* manually. For more information see <a href="https://playwright.dev/java/docs/class-apirequestcontext">here</a>.
24+
* Exposes API that can be used for the Web API testing. This class is used for creating {@code APIRequestContext} instance which
25+
* in turn can be used for sending web requests. An instance of this class can be obtained via {@link Playwright#request
26+
* Playwright.request()}. For more information see {@code APIRequestContext}.
2727
*/
2828
public interface APIRequest {
2929
class NewContextOptions {

playwright/src/main/java/com/microsoft/playwright/APIRequestContext.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,24 @@
2121

2222
/**
2323
* This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
24-
* environment or the service to your e2e test. When used on {@code Page} or a {@code BrowserContext}, this API will automatically use
25-
* the cookies from the corresponding {@code BrowserContext}. This means that if you log in using this API, your e2e test will be
26-
* logged in and vice versa.
24+
* environment or the service to your e2e test.
25+
*
26+
* <p> Each Playwright browser context has associated with it {@code APIRequestContext} instance which shares cookie storage with the
27+
* browser context and can be accessed via {@link BrowserContext#request BrowserContext.request()} or {@link Page#request
28+
* Page.request()}. It is also possible to create a new APIRequestContext instance manually by calling {@link
29+
* APIRequest#newContext APIRequest.newContext()}.
30+
*
31+
* <p> **Cookie management**
32+
*
33+
* <p> {@code APIRequestContext} retuned by {@link BrowserContext#request BrowserContext.request()} and {@link Page#request
34+
* Page.request()} shares cookie storage with the corresponding {@code BrowserContext}. Each API request will have {@code Cookie}
35+
* header populated with the values from the browser context. If the API response contains {@code Set-Cookie} header it will
36+
* automatically update {@code BrowserContext} cookies and requests made from the page will pick them up. This means that if you
37+
* log in using this API, your e2e test will be logged in and vice versa.
38+
*
39+
* <p> If you want API requests to not interfere with the browser cookies you shoud create a new {@code APIRequestContext} by calling
40+
* {@link APIRequest#newContext APIRequest.newContext()}. Such {@code APIRequestContext} object will have its own isolated cookie
41+
* storage.
2742
*/
2843
public interface APIRequestContext {
2944
class StorageStateOptions {

playwright/src/main/java/com/microsoft/playwright/BrowserContext.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,6 @@ default void exposeBinding(String name, BindingCallback callback) {
497497
* <li> {@code "midi"}</li>
498498
* <li> {@code "midi-sysex"} (system-exclusive midi)</li>
499499
* <li> {@code "notifications"}</li>
500-
* <li> {@code "push"}</li>
501500
* <li> {@code "camera"}</li>
502501
* <li> {@code "microphone"}</li>
503502
* <li> {@code "background-sync"}</li>
@@ -524,7 +523,6 @@ default void grantPermissions(List<String> permissions) {
524523
* <li> {@code "midi"}</li>
525524
* <li> {@code "midi-sysex"} (system-exclusive midi)</li>
526525
* <li> {@code "notifications"}</li>
527-
* <li> {@code "push"}</li>
528526
* <li> {@code "camera"}</li>
529527
* <li> {@code "microphone"}</li>
530528
* <li> {@code "background-sync"}</li>

playwright/src/main/java/com/microsoft/playwright/BrowserType.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ class ConnectOptions {
5252
*/
5353
public Double slowMo;
5454
/**
55-
* Maximum time in milliseconds to wait for the connection to be established. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to
56-
* disable timeout.
55+
* Maximum time in milliseconds to wait for the connection to be established. Defaults to {@code 0} (no timeout).
5756
*/
5857
public Double timeout;
5958

@@ -73,8 +72,7 @@ public ConnectOptions setSlowMo(double slowMo) {
7372
return this;
7473
}
7574
/**
76-
* Maximum time in milliseconds to wait for the connection to be established. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to
77-
* disable timeout.
75+
* Maximum time in milliseconds to wait for the connection to be established. Defaults to {@code 0} (no timeout).
7876
*/
7977
public ConnectOptions setTimeout(double timeout) {
8078
this.timeout = timeout;
@@ -130,7 +128,7 @@ class LaunchOptions {
130128
/**
131129
* Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
132130
* "msedge-beta", "msedge-dev", "msedge-canary". Read more about using <a
133-
* href="https://playwright.dev/java/docs/browsers#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
131+
* href="../browsers.md#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
134132
*/
135133
public Object channel;
136134
/**
@@ -222,7 +220,7 @@ public LaunchOptions setArgs(List<String> args) {
222220
/**
223221
* Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
224222
* "msedge-beta", "msedge-dev", "msedge-canary". Read more about using <a
225-
* href="https://playwright.dev/java/docs/browsers#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
223+
* href="../browsers.md#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
226224
*/
227225
public LaunchOptions setChannel(BrowserChannel channel) {
228226
this.channel = channel;
@@ -231,7 +229,7 @@ public LaunchOptions setChannel(BrowserChannel channel) {
231229
/**
232230
* Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
233231
* "msedge-beta", "msedge-dev", "msedge-canary". Read more about using <a
234-
* href="https://playwright.dev/java/docs/browsers#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
232+
* href="../browsers.md#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
235233
*/
236234
public LaunchOptions setChannel(String channel) {
237235
this.channel = channel;
@@ -399,7 +397,7 @@ class LaunchPersistentContextOptions {
399397
/**
400398
* Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
401399
* "msedge-beta", "msedge-dev", "msedge-canary". Read more about using <a
402-
* href="https://playwright.dev/java/docs/browsers#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
400+
* href="../browsers.md#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
403401
*/
404402
public Object channel;
405403
/**
@@ -625,7 +623,7 @@ public LaunchPersistentContextOptions setBypassCSP(boolean bypassCSP) {
625623
/**
626624
* Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
627625
* "msedge-beta", "msedge-dev", "msedge-canary". Read more about using <a
628-
* href="https://playwright.dev/java/docs/browsers#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
626+
* href="../browsers.md#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
629627
*/
630628
public LaunchPersistentContextOptions setChannel(BrowserChannel channel) {
631629
this.channel = channel;
@@ -634,7 +632,7 @@ public LaunchPersistentContextOptions setChannel(BrowserChannel channel) {
634632
/**
635633
* Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
636634
* "msedge-beta", "msedge-dev", "msedge-canary". Read more about using <a
637-
* href="https://playwright.dev/java/docs/browsers#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
635+
* href="../browsers.md#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
638636
*/
639637
public LaunchPersistentContextOptions setChannel(String channel) {
640638
this.channel = channel;
@@ -971,21 +969,21 @@ public LaunchPersistentContextOptions setViewportSize(ViewportSize viewportSize)
971969
}
972970
}
973971
/**
974-
* This methods attaches Playwright to an existing browser instance.
972+
* This method attaches Playwright to an existing browser instance.
975973
*
976974
* @param wsEndpoint A browser websocket endpoint to connect to.
977975
*/
978976
default Browser connect(String wsEndpoint) {
979977
return connect(wsEndpoint, null);
980978
}
981979
/**
982-
* This methods attaches Playwright to an existing browser instance.
980+
* This method attaches Playwright to an existing browser instance.
983981
*
984982
* @param wsEndpoint A browser websocket endpoint to connect to.
985983
*/
986984
Browser connect(String wsEndpoint, ConnectOptions options);
987985
/**
988-
* This methods attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
986+
* This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
989987
*
990988
* <p> The default browser context is accessible via {@link Browser#contexts Browser.contexts()}.
991989
*
@@ -998,7 +996,7 @@ default Browser connectOverCDP(String endpointURL) {
998996
return connectOverCDP(endpointURL, null);
999997
}
1000998
/**
1001-
* This methods attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
999+
* This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
10021000
*
10031001
* <p> The default browser context is accessible via {@link Browser#contexts Browser.contexts()}.
10041002
*

playwright/src/main/java/com/microsoft/playwright/ConsoleMessage.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,28 @@
1919
import java.util.*;
2020

2121
/**
22-
* {@code ConsoleMessage} objects are dispatched by page via the {@link Page#onConsoleMessage Page.onConsoleMessage()} event.
22+
* {@code ConsoleMessage} objects are dispatched by page via the {@link Page#onConsoleMessage Page.onConsoleMessage()} event. For
23+
* each console messages logged in the page there will be corresponding event in the Playwright context.
24+
* <pre>{@code
25+
* // Listen for all System.out.printlns
26+
* page.onConsoleMessage(msg -> System.out.println(msg.text()));
27+
*
28+
* // Listen for all console events and handle errors
29+
* page.onConsoleMessage(msg -> {
30+
* if ("error".equals(msg.type()))
31+
* System.out.println("Error text: " + msg.text());
32+
* });
33+
*
34+
* // Get the next System.out.println
35+
* ConsoleMessage msg = page.waitForConsoleMessage(() -> {
36+
* // Issue console.log inside the page
37+
* page.evaluate("console.log('hello', 42, { foo: 'bar' });");
38+
* });
39+
*
40+
* // Deconstruct console.log arguments
41+
* msg.args().get(0).jsonValue() // hello
42+
* msg.args().get(1).jsonValue() // 42
43+
* }</pre>
2344
*/
2445
public interface ConsoleMessage {
2546
/**

0 commit comments

Comments
 (0)