Skip to content

Commit edf0e45

Browse files
authored
feat: roll to 1.23.0-beta-1655926399000 (#956)
1 parent c8eb4f9 commit edf0e45

34 files changed

+1117
-113
lines changed

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 -->102.0.5005.40<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
14+
| Chromium <!-- GEN:chromium-version -->103.0.5060.53<!-- 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 -->99.0.1<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
16+
| Firefox <!-- GEN:firefox-version -->100.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

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

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.nio.file.Path;
2121
import java.util.*;
2222
import java.util.function.Consumer;
23+
import java.util.regex.Pattern;
2324

2425
/**
2526
* A Browser is created via {@link BrowserType#launch BrowserType.launch()}. An example of using a {@code Browser} to create a
@@ -153,6 +154,7 @@ class NewContextOptions {
153154
* BrowserContext.close()} for the HAR to be saved.
154155
*/
155156
public Path recordHarPath;
157+
public Object recordHarUrlFilter;
156158
/**
157159
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
158160
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
@@ -174,6 +176,15 @@ class NewContextOptions {
174176
* is set.
175177
*/
176178
public ScreenSize screenSize;
179+
/**
180+
* Whether to allow sites to register Service workers. Defaults to {@code "allow"}.
181+
* <ul>
182+
* <li> {@code "allow"}: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API">Service Workers</a> can be
183+
* registered.</li>
184+
* <li> {@code "block"}: Playwright will block all registration of Service Workers.</li>
185+
* </ul>
186+
*/
187+
public ServiceWorkerPolicy serviceWorkers;
177188
/**
178189
* Populates context with given storage state. This option can be used to initialize context with logged-in information
179190
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}.
@@ -186,7 +197,7 @@ class NewContextOptions {
186197
*/
187198
public Path storageStatePath;
188199
/**
189-
* It specified, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors
200+
* If specified, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors
190201
* that imply single target DOM element will throw when more than one element matches the selector. See {@code Locator} to learn
191202
* more about the strict mode.
192203
*/
@@ -379,6 +390,14 @@ public NewContextOptions setRecordHarPath(Path recordHarPath) {
379390
this.recordHarPath = recordHarPath;
380391
return this;
381392
}
393+
public NewContextOptions setRecordHarUrlFilter(String recordHarUrlFilter) {
394+
this.recordHarUrlFilter = recordHarUrlFilter;
395+
return this;
396+
}
397+
public NewContextOptions setRecordHarUrlFilter(Pattern recordHarUrlFilter) {
398+
this.recordHarUrlFilter = recordHarUrlFilter;
399+
return this;
400+
}
382401
/**
383402
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
384403
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
@@ -427,6 +446,18 @@ public NewContextOptions setScreenSize(ScreenSize screenSize) {
427446
this.screenSize = screenSize;
428447
return this;
429448
}
449+
/**
450+
* Whether to allow sites to register Service workers. Defaults to {@code "allow"}.
451+
* <ul>
452+
* <li> {@code "allow"}: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API">Service Workers</a> can be
453+
* registered.</li>
454+
* <li> {@code "block"}: Playwright will block all registration of Service Workers.</li>
455+
* </ul>
456+
*/
457+
public NewContextOptions setServiceWorkers(ServiceWorkerPolicy serviceWorkers) {
458+
this.serviceWorkers = serviceWorkers;
459+
return this;
460+
}
430461
/**
431462
* Populates context with given storage state. This option can be used to initialize context with logged-in information
432463
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}.
@@ -445,7 +476,7 @@ public NewContextOptions setStorageStatePath(Path storageStatePath) {
445476
return this;
446477
}
447478
/**
448-
* It specified, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors
479+
* If specified, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors
449480
* that imply single target DOM element will throw when more than one element matches the selector. See {@code Locator} to learn
450481
* more about the strict mode.
451482
*/
@@ -581,6 +612,7 @@ class NewPageOptions {
581612
* BrowserContext.close()} for the HAR to be saved.
582613
*/
583614
public Path recordHarPath;
615+
public Object recordHarUrlFilter;
584616
/**
585617
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
586618
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
@@ -602,6 +634,15 @@ class NewPageOptions {
602634
* is set.
603635
*/
604636
public ScreenSize screenSize;
637+
/**
638+
* Whether to allow sites to register Service workers. Defaults to {@code "allow"}.
639+
* <ul>
640+
* <li> {@code "allow"}: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API">Service Workers</a> can be
641+
* registered.</li>
642+
* <li> {@code "block"}: Playwright will block all registration of Service Workers.</li>
643+
* </ul>
644+
*/
645+
public ServiceWorkerPolicy serviceWorkers;
605646
/**
606647
* Populates context with given storage state. This option can be used to initialize context with logged-in information
607648
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}.
@@ -614,7 +655,7 @@ class NewPageOptions {
614655
*/
615656
public Path storageStatePath;
616657
/**
617-
* It specified, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors
658+
* If specified, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors
618659
* that imply single target DOM element will throw when more than one element matches the selector. See {@code Locator} to learn
619660
* more about the strict mode.
620661
*/
@@ -807,6 +848,14 @@ public NewPageOptions setRecordHarPath(Path recordHarPath) {
807848
this.recordHarPath = recordHarPath;
808849
return this;
809850
}
851+
public NewPageOptions setRecordHarUrlFilter(String recordHarUrlFilter) {
852+
this.recordHarUrlFilter = recordHarUrlFilter;
853+
return this;
854+
}
855+
public NewPageOptions setRecordHarUrlFilter(Pattern recordHarUrlFilter) {
856+
this.recordHarUrlFilter = recordHarUrlFilter;
857+
return this;
858+
}
810859
/**
811860
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure
812861
* to call {@link BrowserContext#close BrowserContext.close()} for videos to be saved.
@@ -855,6 +904,18 @@ public NewPageOptions setScreenSize(ScreenSize screenSize) {
855904
this.screenSize = screenSize;
856905
return this;
857906
}
907+
/**
908+
* Whether to allow sites to register Service workers. Defaults to {@code "allow"}.
909+
* <ul>
910+
* <li> {@code "allow"}: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API">Service Workers</a> can be
911+
* registered.</li>
912+
* <li> {@code "block"}: Playwright will block all registration of Service Workers.</li>
913+
* </ul>
914+
*/
915+
public NewPageOptions setServiceWorkers(ServiceWorkerPolicy serviceWorkers) {
916+
this.serviceWorkers = serviceWorkers;
917+
return this;
918+
}
858919
/**
859920
* Populates context with given storage state. This option can be used to initialize context with logged-in information
860921
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}.
@@ -873,7 +934,7 @@ public NewPageOptions setStorageStatePath(Path storageStatePath) {
873934
return this;
874935
}
875936
/**
876-
* It specified, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors
937+
* If specified, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors
877938
* that imply single target DOM element will throw when more than one element matches the selector. See {@code Locator} to learn
878939
* more about the strict mode.
879940
*/
@@ -947,6 +1008,10 @@ public StartTracingOptions setScreenshots(boolean screenshots) {
9471008
return this;
9481009
}
9491010
}
1011+
/**
1012+
* Get the browser type (chromium, firefox or webkit) that the browser belongs to.
1013+
*/
1014+
BrowserType browserType();
9501015
/**
9511016
* In case this browser is obtained using {@link BrowserType#launch BrowserType.launch()}, closes the browser and all of
9521017
* its pages (if any were opened).

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

Lines changed: 91 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,59 @@ public RouteOptions setTimes(int times) {
174174
return this;
175175
}
176176
}
177+
class RouteFromHAROptions {
178+
/**
179+
* <ul>
180+
* <li> If set to 'abort' any request not found in the HAR file will be aborted.</li>
181+
* <li> If set to 'fallback' falls through to the next route handler in the handler chain.</li>
182+
* </ul>
183+
*
184+
* <p> Defaults to abort.
185+
*/
186+
public HarNotFound notFound;
187+
/**
188+
* A glob pattern, regular expression or predicate to match the request URL. Only requests with URL matching the pattern
189+
* will be surved from the HAR file. If not specified, all requests are served from the HAR file.
190+
*/
191+
public Object url;
192+
193+
/**
194+
* <ul>
195+
* <li> If set to 'abort' any request not found in the HAR file will be aborted.</li>
196+
* <li> If set to 'fallback' falls through to the next route handler in the handler chain.</li>
197+
* </ul>
198+
*
199+
* <p> Defaults to abort.
200+
*/
201+
public RouteFromHAROptions setNotFound(HarNotFound notFound) {
202+
this.notFound = notFound;
203+
return this;
204+
}
205+
/**
206+
* A glob pattern, regular expression or predicate to match the request URL. Only requests with URL matching the pattern
207+
* will be surved from the HAR file. If not specified, all requests are served from the HAR file.
208+
*/
209+
public RouteFromHAROptions setUrl(String url) {
210+
this.url = url;
211+
return this;
212+
}
213+
/**
214+
* A glob pattern, regular expression or predicate to match the request URL. Only requests with URL matching the pattern
215+
* will be surved from the HAR file. If not specified, all requests are served from the HAR file.
216+
*/
217+
public RouteFromHAROptions setUrl(Pattern url) {
218+
this.url = url;
219+
return this;
220+
}
221+
/**
222+
* A glob pattern, regular expression or predicate to match the request URL. Only requests with URL matching the pattern
223+
* will be surved from the HAR file. If not specified, all requests are served from the HAR file.
224+
*/
225+
public RouteFromHAROptions setUrl(Predicate<String> url) {
226+
this.url = url;
227+
return this;
228+
}
229+
}
177230
class StorageStateOptions {
178231
/**
179232
* The file path to save the storage state to. If {@code path} is a relative path, then it is resolved relative to current
@@ -553,9 +606,9 @@ default void grantPermissions(List<String> permissions) {
553606
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
554607
* is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
555608
*
556-
* <p> <strong>NOTE:</strong> {@link Page#route Page.route()} will not intercept requests intercepted by Service Worker. See <a
609+
* <p> <strong>NOTE:</strong> {@link BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <a
557610
* href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers when
558-
* using request interception. Via {@code await context.addInitScript(() => delete window.navigator.serviceWorker);}
611+
* using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
559612
*
560613
* <p> An example of a naive handler that aborts all image requests:
561614
* <pre>{@code
@@ -605,9 +658,9 @@ default void route(String url, Consumer<Route> handler) {
605658
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
606659
* is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
607660
*
608-
* <p> <strong>NOTE:</strong> {@link Page#route Page.route()} will not intercept requests intercepted by Service Worker. See <a
661+
* <p> <strong>NOTE:</strong> {@link BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <a
609662
* href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers when
610-
* using request interception. Via {@code await context.addInitScript(() => delete window.navigator.serviceWorker);}
663+
* using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
611664
*
612665
* <p> An example of a naive handler that aborts all image requests:
613666
* <pre>{@code
@@ -655,9 +708,9 @@ default void route(String url, Consumer<Route> handler) {
655708
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
656709
* is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
657710
*
658-
* <p> <strong>NOTE:</strong> {@link Page#route Page.route()} will not intercept requests intercepted by Service Worker. See <a
711+
* <p> <strong>NOTE:</strong> {@link BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <a
659712
* href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers when
660-
* using request interception. Via {@code await context.addInitScript(() => delete window.navigator.serviceWorker);}
713+
* using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
661714
*
662715
* <p> An example of a naive handler that aborts all image requests:
663716
* <pre>{@code
@@ -707,9 +760,9 @@ default void route(Pattern url, Consumer<Route> handler) {
707760
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
708761
* is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
709762
*
710-
* <p> <strong>NOTE:</strong> {@link Page#route Page.route()} will not intercept requests intercepted by Service Worker. See <a
763+
* <p> <strong>NOTE:</strong> {@link BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <a
711764
* href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers when
712-
* using request interception. Via {@code await context.addInitScript(() => delete window.navigator.serviceWorker);}
765+
* using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
713766
*
714767
* <p> An example of a naive handler that aborts all image requests:
715768
* <pre>{@code
@@ -757,9 +810,9 @@ default void route(Pattern url, Consumer<Route> handler) {
757810
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
758811
* is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
759812
*
760-
* <p> <strong>NOTE:</strong> {@link Page#route Page.route()} will not intercept requests intercepted by Service Worker. See <a
813+
* <p> <strong>NOTE:</strong> {@link BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <a
761814
* href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers when
762-
* using request interception. Via {@code await context.addInitScript(() => delete window.navigator.serviceWorker);}
815+
* using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
763816
*
764817
* <p> An example of a naive handler that aborts all image requests:
765818
* <pre>{@code
@@ -809,9 +862,9 @@ default void route(Predicate<String> url, Consumer<Route> handler) {
809862
* Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
810863
* is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
811864
*
812-
* <p> <strong>NOTE:</strong> {@link Page#route Page.route()} will not intercept requests intercepted by Service Worker. See <a
865+
* <p> <strong>NOTE:</strong> {@link BrowserContext#route BrowserContext.route()} will not intercept requests intercepted by Service Worker. See <a
813866
* href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers when
814-
* using request interception. Via {@code await context.addInitScript(() => delete window.navigator.serviceWorker);}
867+
* using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
815868
*
816869
* <p> An example of a naive handler that aborts all image requests:
817870
* <pre>{@code
@@ -855,6 +908,32 @@ default void route(Predicate<String> url, Consumer<Route> handler) {
855908
* @param handler handler function to route the request.
856909
*/
857910
void route(Predicate<String> url, Consumer<Route> handler, RouteOptions options);
911+
/**
912+
* If specified the network requests that are made in the context will be served from the HAR file. Read more about <a
913+
* href="https://playwright.dev/java/docs/network#replaying-from-har">Replaying from HAR</a>.
914+
*
915+
* <p> Playwright will not serve requests intercepted by Service Worker from the HAR file. See <a
916+
* href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers when
917+
* using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
918+
*
919+
* @param har Path to a <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> file with prerecorded network data. If {@code path}
920+
* is a relative path, then it is resolved relative to the current working directory.
921+
*/
922+
default void routeFromHAR(Path har) {
923+
routeFromHAR(har, null);
924+
}
925+
/**
926+
* If specified the network requests that are made in the context will be served from the HAR file. Read more about <a
927+
* href="https://playwright.dev/java/docs/network#replaying-from-har">Replaying from HAR</a>.
928+
*
929+
* <p> Playwright will not serve requests intercepted by Service Worker from the HAR file. See <a
930+
* href="https://github.com/microsoft/playwright/issues/1090">this</a> issue. We recommend disabling Service Workers when
931+
* using request interception by setting {@code Browser.newContext.serviceWorkers} to {@code "block"}.
932+
*
933+
* @param har Path to a <a href="http://www.softwareishard.com/blog/har-12-spec">HAR</a> file with prerecorded network data. If {@code path}
934+
* is a relative path, then it is resolved relative to the current working directory.
935+
*/
936+
void routeFromHAR(Path har, RouteFromHAROptions options);
858937
/**
859938
* This setting will change the default maximum navigation time for the following methods and related shortcuts:
860939
* <ul>

0 commit comments

Comments
 (0)