playwright-ruby-client 0.3.0 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -5
- data/docs/api_coverage.md +14 -25
- data/lib/playwright/channel.rb +19 -9
- data/lib/playwright/channel_owners/artifact.rb +30 -0
- data/lib/playwright/channel_owners/browser.rb +21 -0
- data/lib/playwright/channel_owners/browser_context.rb +5 -0
- data/lib/playwright/channel_owners/browser_type.rb +28 -0
- data/lib/playwright/channel_owners/element_handle.rb +1 -1
- data/lib/playwright/channel_owners/frame.rb +25 -2
- data/lib/playwright/channel_owners/js_handle.rb +2 -2
- data/lib/playwright/channel_owners/page.rb +78 -15
- data/lib/playwright/channel_owners/playwright.rb +22 -29
- data/lib/playwright/channel_owners/stream.rb +15 -0
- data/lib/playwright/connection.rb +11 -32
- data/lib/playwright/download.rb +27 -0
- data/lib/playwright/errors.rb +6 -0
- data/lib/playwright/events.rb +2 -5
- data/lib/playwright/keyboard_impl.rb +1 -1
- data/lib/playwright/mouse_impl.rb +41 -0
- data/lib/playwright/route_handler_entry.rb +1 -9
- data/lib/playwright/transport.rb +27 -6
- data/lib/playwright/url_matcher.rb +1 -1
- data/lib/playwright/utils.rb +8 -0
- data/lib/playwright/version.rb +1 -1
- data/lib/playwright/video.rb +51 -0
- data/lib/playwright/wait_helper.rb +2 -2
- data/lib/playwright.rb +47 -9
- data/lib/playwright_api/accessibility.rb +39 -1
- data/lib/playwright_api/android.rb +10 -10
- data/lib/playwright_api/android_device.rb +10 -9
- data/lib/playwright_api/browser.rb +83 -8
- data/lib/playwright_api/browser_context.rb +163 -15
- data/lib/playwright_api/browser_type.rb +35 -4
- data/lib/playwright_api/console_message.rb +6 -6
- data/lib/playwright_api/dialog.rb +28 -8
- data/lib/playwright_api/element_handle.rb +111 -37
- data/lib/playwright_api/file_chooser.rb +5 -0
- data/lib/playwright_api/frame.rb +228 -37
- data/lib/playwright_api/js_handle.rb +26 -3
- data/lib/playwright_api/keyboard.rb +48 -1
- data/lib/playwright_api/mouse.rb +26 -5
- data/lib/playwright_api/page.rb +456 -48
- data/lib/playwright_api/playwright.rb +26 -9
- data/lib/playwright_api/request.rb +34 -6
- data/lib/playwright_api/response.rb +8 -8
- data/lib/playwright_api/route.rb +30 -6
- data/lib/playwright_api/selectors.rb +32 -6
- data/lib/playwright_api/touchscreen.rb +1 -1
- data/lib/playwright_api/worker.rb +25 -1
- data/playwright.gemspec +4 -2
- metadata +37 -14
- data/lib/playwright/channel_owners/chromium_browser.rb +0 -8
- data/lib/playwright/channel_owners/chromium_browser_context.rb +0 -8
- data/lib/playwright/channel_owners/download.rb +0 -27
- data/lib/playwright/channel_owners/firefox_browser.rb +0 -8
- data/lib/playwright/channel_owners/webkit_browser.rb +0 -8
- data/lib/playwright_api/binding_call.rb +0 -32
- data/lib/playwright_api/chromium_browser_context.rb +0 -59
- data/lib/playwright_api/download.rb +0 -95
- data/lib/playwright_api/video.rb +0 -24
data/lib/playwright_api/page.rb
CHANGED
@@ -21,6 +21,24 @@ module Playwright
|
|
21
21
|
# })();
|
22
22
|
# ```
|
23
23
|
#
|
24
|
+
# ```java
|
25
|
+
# import com.microsoft.playwright.*;
|
26
|
+
#
|
27
|
+
# public class Example {
|
28
|
+
# public static void main(String[] args) {
|
29
|
+
# try (Playwright playwright = Playwright.create()) {
|
30
|
+
# BrowserType webkit = playwright.webkit();
|
31
|
+
# Browser browser = webkit.launch();
|
32
|
+
# BrowserContext context = browser.newContext();
|
33
|
+
# Page page = context.newPage();
|
34
|
+
# page.navigate("https://example.com");
|
35
|
+
# page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("screenshot.png")));
|
36
|
+
# browser.close();
|
37
|
+
# }
|
38
|
+
# }
|
39
|
+
# }
|
40
|
+
# ```
|
41
|
+
#
|
24
42
|
# ```python async
|
25
43
|
# import asyncio
|
26
44
|
# from playwright.async_api import async_playwright
|
@@ -67,6 +85,10 @@ module Playwright
|
|
67
85
|
# page.once('load', () => console.log('Page loaded!'));
|
68
86
|
# ```
|
69
87
|
#
|
88
|
+
# ```java
|
89
|
+
# page.onLoad(p -> System.out.println("Page loaded!"));
|
90
|
+
# ```
|
91
|
+
#
|
70
92
|
# ```py
|
71
93
|
# page.once("load", lambda: print("page loaded!"))
|
72
94
|
# ```
|
@@ -83,6 +105,15 @@ module Playwright
|
|
83
105
|
# page.removeListener('request', logRequest);
|
84
106
|
# ```
|
85
107
|
#
|
108
|
+
# ```java
|
109
|
+
# Consumer<Request> logRequest = interceptedRequest -> {
|
110
|
+
# System.out.println("A request was made: " + interceptedRequest.url());
|
111
|
+
# };
|
112
|
+
# page.onRequest(logRequest);
|
113
|
+
# // Sometime later...
|
114
|
+
# page.offRequest(logRequest);
|
115
|
+
# ```
|
116
|
+
#
|
86
117
|
# ```py
|
87
118
|
# def log_request(intercepted_request):
|
88
119
|
# print("a request was made:", intercepted_request.url)
|
@@ -130,6 +161,11 @@ module Playwright
|
|
130
161
|
# await page.addInitScript({ path: './preload.js' });
|
131
162
|
# ```
|
132
163
|
#
|
164
|
+
# ```java
|
165
|
+
# // In your playwright script, assuming the preload.js file is in same directory
|
166
|
+
# page.addInitScript(Paths.get("./preload.js"));
|
167
|
+
# ```
|
168
|
+
#
|
133
169
|
# ```python async
|
134
170
|
# # in your playwright script, assuming the preload.js file is in same directory
|
135
171
|
# await page.add_init_script(path="./preload.js")
|
@@ -168,34 +204,39 @@ module Playwright
|
|
168
204
|
end
|
169
205
|
|
170
206
|
# This method checks an element matching `selector` by performing the following steps:
|
171
|
-
# 1. Find an element
|
172
|
-
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method
|
207
|
+
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
208
|
+
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already
|
173
209
|
# checked, this method returns immediately.
|
174
210
|
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
175
211
|
# element is detached during the checks, the whole action is retried.
|
176
212
|
# 1. Scroll the element into view if needed.
|
177
213
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
178
214
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
179
|
-
# 1. Ensure that the element is now checked. If not, this method
|
215
|
+
# 1. Ensure that the element is now checked. If not, this method throws.
|
180
216
|
#
|
181
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
182
|
-
#
|
217
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
218
|
+
# zero timeout disables this.
|
183
219
|
#
|
184
220
|
# Shortcut for main frame's [`method: Frame.check`].
|
185
|
-
def check(
|
186
|
-
|
221
|
+
def check(
|
222
|
+
selector,
|
223
|
+
force: nil,
|
224
|
+
noWaitAfter: nil,
|
225
|
+
position: nil,
|
226
|
+
timeout: nil)
|
227
|
+
wrap_impl(@impl.check(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
|
187
228
|
end
|
188
229
|
|
189
230
|
# This method clicks an element matching `selector` by performing the following steps:
|
190
|
-
# 1. Find an element
|
231
|
+
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
191
232
|
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
192
233
|
# element is detached during the checks, the whole action is retried.
|
193
234
|
# 1. Scroll the element into view if needed.
|
194
235
|
# 1. Use [`property: Page.mouse`] to click in the center of the element, or the specified `position`.
|
195
236
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
196
237
|
#
|
197
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
198
|
-
#
|
238
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
239
|
+
# zero timeout disables this.
|
199
240
|
#
|
200
241
|
# Shortcut for main frame's [`method: Frame.click`].
|
201
242
|
def click(
|
@@ -233,16 +274,16 @@ module Playwright
|
|
233
274
|
end
|
234
275
|
|
235
276
|
# This method double clicks an element matching `selector` by performing the following steps:
|
236
|
-
# 1. Find an element
|
277
|
+
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
237
278
|
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
238
279
|
# element is detached during the checks, the whole action is retried.
|
239
280
|
# 1. Scroll the element into view if needed.
|
240
281
|
# 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`.
|
241
282
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the
|
242
|
-
# first click of the `dblclick()` triggers a navigation event, this method will
|
283
|
+
# first click of the `dblclick()` triggers a navigation event, this method will throw.
|
243
284
|
#
|
244
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
245
|
-
#
|
285
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
286
|
+
# zero timeout disables this.
|
246
287
|
#
|
247
288
|
# > NOTE: `page.dblclick()` dispatches two `click` events and a single `dblclick` event.
|
248
289
|
#
|
@@ -259,8 +300,8 @@ module Playwright
|
|
259
300
|
wrap_impl(@impl.dblclick(unwrap_impl(selector), button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
|
260
301
|
end
|
261
302
|
|
262
|
-
# The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the
|
263
|
-
# is dispatched. This is
|
303
|
+
# The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
|
304
|
+
# `click` is dispatched. This is equivalent to calling
|
264
305
|
# [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
|
265
306
|
#
|
266
307
|
#
|
@@ -268,6 +309,10 @@ module Playwright
|
|
268
309
|
# await page.dispatchEvent('button#submit', 'click');
|
269
310
|
# ```
|
270
311
|
#
|
312
|
+
# ```java
|
313
|
+
# page.dispatchEvent("button#submit", "click");
|
314
|
+
# ```
|
315
|
+
#
|
271
316
|
# ```python async
|
272
317
|
# await page.dispatch_event("button#submit", "click")
|
273
318
|
# ```
|
@@ -297,6 +342,14 @@ module Playwright
|
|
297
342
|
# await page.dispatchEvent('#source', 'dragstart', { dataTransfer });
|
298
343
|
# ```
|
299
344
|
#
|
345
|
+
# ```java
|
346
|
+
# // Note you can only create DataTransfer in Chromium and Firefox
|
347
|
+
# JSHandle dataTransfer = page.evaluateHandle("() => new DataTransfer()");
|
348
|
+
# Map<String, Object> arg = new HashMap<>();
|
349
|
+
# arg.put("dataTransfer", dataTransfer);
|
350
|
+
# page.dispatchEvent("#source", "dragstart", arg);
|
351
|
+
# ```
|
352
|
+
#
|
300
353
|
# ```python async
|
301
354
|
# # note you can only create data_transfer in chromium and firefox
|
302
355
|
# data_transfer = await page.evaluate_handle("new DataTransfer()")
|
@@ -312,7 +365,6 @@ module Playwright
|
|
312
365
|
wrap_impl(@impl.dispatch_event(unwrap_impl(selector), unwrap_impl(type), eventInit: unwrap_impl(eventInit), timeout: unwrap_impl(timeout)))
|
313
366
|
end
|
314
367
|
|
315
|
-
#
|
316
368
|
#
|
317
369
|
# ```js
|
318
370
|
# await page.evaluate(() => matchMedia('screen').matches);
|
@@ -333,6 +385,25 @@ module Playwright
|
|
333
385
|
# // → false
|
334
386
|
# ```
|
335
387
|
#
|
388
|
+
# ```java
|
389
|
+
# page.evaluate("() => matchMedia('screen').matches");
|
390
|
+
# // → true
|
391
|
+
# page.evaluate("() => matchMedia('print').matches");
|
392
|
+
# // → false
|
393
|
+
#
|
394
|
+
# page.emulateMedia(new Page.EmulateMediaOptions().setMedia(Media.PRINT));
|
395
|
+
# page.evaluate("() => matchMedia('screen').matches");
|
396
|
+
# // → false
|
397
|
+
# page.evaluate("() => matchMedia('print').matches");
|
398
|
+
# // → true
|
399
|
+
#
|
400
|
+
# page.emulateMedia(new Page.EmulateMediaOptions());
|
401
|
+
# page.evaluate("() => matchMedia('screen').matches");
|
402
|
+
# // → true
|
403
|
+
# page.evaluate("() => matchMedia('print').matches");
|
404
|
+
# // → false
|
405
|
+
# ```
|
406
|
+
#
|
336
407
|
# ```python async
|
337
408
|
# await page.evaluate("matchMedia('screen').matches")
|
338
409
|
# # → True
|
@@ -382,6 +453,16 @@ module Playwright
|
|
382
453
|
# // → false
|
383
454
|
# ```
|
384
455
|
#
|
456
|
+
# ```java
|
457
|
+
# page.emulateMedia(new Page.EmulateMediaOptions().setColorScheme(ColorScheme.DARK));
|
458
|
+
# page.evaluate("() => matchMedia('(prefers-color-scheme: dark)').matches");
|
459
|
+
# // → true
|
460
|
+
# page.evaluate("() => matchMedia('(prefers-color-scheme: light)').matches");
|
461
|
+
# // → false
|
462
|
+
# page.evaluate("() => matchMedia('(prefers-color-scheme: no-preference)').matches");
|
463
|
+
# // → false
|
464
|
+
# ```
|
465
|
+
#
|
385
466
|
# ```python async
|
386
467
|
# await page.emulate_media(color_scheme="dark")
|
387
468
|
# await page.evaluate("matchMedia('(prefers-color-scheme: dark)').matches")
|
@@ -419,6 +500,12 @@ module Playwright
|
|
419
500
|
# const html = await page.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
|
420
501
|
# ```
|
421
502
|
#
|
503
|
+
# ```java
|
504
|
+
# String searchValue = (String) page.evalOnSelector("#search", "el => el.value");
|
505
|
+
# String preloadHref = (String) page.evalOnSelector("link[rel=preload]", "el => el.href");
|
506
|
+
# String html = (String) page.evalOnSelector(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello");
|
507
|
+
# ```
|
508
|
+
#
|
422
509
|
# ```python async
|
423
510
|
# search_value = await page.eval_on_selector("#search", "el => el.value")
|
424
511
|
# preload_href = await page.eval_on_selector("link[rel=preload]", "el => el.href")
|
@@ -449,6 +536,10 @@ module Playwright
|
|
449
536
|
# const divCounts = await page.$$eval('div', (divs, min) => divs.length >= min, 10);
|
450
537
|
# ```
|
451
538
|
#
|
539
|
+
# ```java
|
540
|
+
# boolean divCounts = (boolean) page.evalOnSelectorAll("div", "(divs, min) => divs.length >= min", 10);
|
541
|
+
# ```
|
542
|
+
#
|
452
543
|
# ```python async
|
453
544
|
# div_counts = await page.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
454
545
|
# ```
|
@@ -479,6 +570,13 @@ module Playwright
|
|
479
570
|
# console.log(result); // prints "56"
|
480
571
|
# ```
|
481
572
|
#
|
573
|
+
# ```java
|
574
|
+
# Object result = page.evaluate("([x, y]) => {\n" +
|
575
|
+
# " return Promise.resolve(x * y);\n" +
|
576
|
+
# "}", Arrays.asList(7, 8));
|
577
|
+
# System.out.println(result); // prints "56"
|
578
|
+
# ```
|
579
|
+
#
|
482
580
|
# ```python async
|
483
581
|
# result = await page.evaluate("([x, y]) => Promise.resolve(x * y)", [7, 8])
|
484
582
|
# print(result) # prints "56"
|
@@ -498,6 +596,10 @@ module Playwright
|
|
498
596
|
# console.log(await page.evaluate(`1 + ${x}`)); // prints "11"
|
499
597
|
# ```
|
500
598
|
#
|
599
|
+
# ```java
|
600
|
+
# System.out.println(page.evaluate("1 + 2")); // prints "3"
|
601
|
+
# ```
|
602
|
+
#
|
501
603
|
# ```python async
|
502
604
|
# print(await page.evaluate("1 + 2")) # prints "3"
|
503
605
|
# x = 10
|
@@ -519,6 +621,12 @@ module Playwright
|
|
519
621
|
# await bodyHandle.dispose();
|
520
622
|
# ```
|
521
623
|
#
|
624
|
+
# ```java
|
625
|
+
# ElementHandle bodyHandle = page.querySelector("body");
|
626
|
+
# String html = (String) page.evaluate("([body, suffix]) => body.innerHTML + suffix", Arrays.asList(bodyHandle, "hello"));
|
627
|
+
# bodyHandle.dispose();
|
628
|
+
# ```
|
629
|
+
#
|
522
630
|
# ```python async
|
523
631
|
# body_handle = await page.query_selector("body")
|
524
632
|
# html = await page.evaluate("([body, suffix]) => body.innerHTML + suffix", [body_handle, "hello"])
|
@@ -550,6 +658,11 @@ module Playwright
|
|
550
658
|
# aWindowHandle; // Handle for the window object.
|
551
659
|
# ```
|
552
660
|
#
|
661
|
+
# ```java
|
662
|
+
# // Handle for the window object.
|
663
|
+
# JSHandle aWindowHandle = page.evaluateHandle("() => Promise.resolve(window)");
|
664
|
+
# ```
|
665
|
+
#
|
553
666
|
# ```python async
|
554
667
|
# a_window_handle = await page.evaluate_handle("Promise.resolve(window)")
|
555
668
|
# a_window_handle # handle for the window object.
|
@@ -567,6 +680,10 @@ module Playwright
|
|
567
680
|
# const aHandle = await page.evaluateHandle('document'); // Handle for the 'document'
|
568
681
|
# ```
|
569
682
|
#
|
683
|
+
# ```java
|
684
|
+
# JSHandle aHandle = page.evaluateHandle("document"); // Handle for the "document".
|
685
|
+
# ```
|
686
|
+
#
|
570
687
|
# ```python async
|
571
688
|
# a_handle = await page.evaluate_handle("document") # handle for the "document"
|
572
689
|
# ```
|
@@ -585,6 +702,13 @@ module Playwright
|
|
585
702
|
# await resultHandle.dispose();
|
586
703
|
# ```
|
587
704
|
#
|
705
|
+
# ```java
|
706
|
+
# JSHandle aHandle = page.evaluateHandle("() => document.body");
|
707
|
+
# JSHandle resultHandle = page.evaluateHandle("([body, suffix]) => body.innerHTML + suffix", Arrays.asList(aHandle, "hello"));
|
708
|
+
# System.out.println(resultHandle.jsonValue());
|
709
|
+
# resultHandle.dispose();
|
710
|
+
# ```
|
711
|
+
#
|
588
712
|
# ```python async
|
589
713
|
# a_handle = await page.evaluate_handle("document.body")
|
590
714
|
# result_handle = await page.evaluate_handle("body => body.innerHTML", a_handle)
|
@@ -637,6 +761,30 @@ module Playwright
|
|
637
761
|
# })();
|
638
762
|
# ```
|
639
763
|
#
|
764
|
+
# ```java
|
765
|
+
# import com.microsoft.playwright.*;
|
766
|
+
#
|
767
|
+
# public class Example {
|
768
|
+
# public static void main(String[] args) {
|
769
|
+
# try (Playwright playwright = Playwright.create()) {
|
770
|
+
# BrowserType webkit = playwright.webkit();
|
771
|
+
# Browser browser = webkit.launch({ headless: false });
|
772
|
+
# BrowserContext context = browser.newContext();
|
773
|
+
# Page page = context.newPage();
|
774
|
+
# page.exposeBinding("pageURL", (source, args) -> source.page().url());
|
775
|
+
# page.setContent("<script>\n" +
|
776
|
+
# " async function onClick() {\n" +
|
777
|
+
# " document.querySelector('div').textContent = await window.pageURL();\n" +
|
778
|
+
# " }\n" +
|
779
|
+
# "</script>\n" +
|
780
|
+
# "<button onclick=\"onClick()\">Click me</button>\n" +
|
781
|
+
# "<div></div>");
|
782
|
+
# page.click("button");
|
783
|
+
# }
|
784
|
+
# }
|
785
|
+
# }
|
786
|
+
# ```
|
787
|
+
#
|
640
788
|
# ```python async
|
641
789
|
# import asyncio
|
642
790
|
# from playwright.async_api import async_playwright
|
@@ -704,6 +852,20 @@ module Playwright
|
|
704
852
|
# `);
|
705
853
|
# ```
|
706
854
|
#
|
855
|
+
# ```java
|
856
|
+
# page.exposeBinding("clicked", (source, args) -> {
|
857
|
+
# ElementHandle element = (ElementHandle) args[0];
|
858
|
+
# System.out.println(element.textContent());
|
859
|
+
# return null;
|
860
|
+
# }, new Page.ExposeBindingOptions().setHandle(true));
|
861
|
+
# page.setContent("" +
|
862
|
+
# "<script>\n" +
|
863
|
+
# " document.addEventListener('click', event => window.clicked(event.target));\n" +
|
864
|
+
# "</script>\n" +
|
865
|
+
# "<div>Click me</div>\n" +
|
866
|
+
# "<div>Or click me</div>\n");
|
867
|
+
# ```
|
868
|
+
#
|
707
869
|
# ```python async
|
708
870
|
# async def print(source, element):
|
709
871
|
# print(await element.text_content())
|
@@ -768,6 +930,44 @@ module Playwright
|
|
768
930
|
# })();
|
769
931
|
# ```
|
770
932
|
#
|
933
|
+
# ```java
|
934
|
+
# import com.microsoft.playwright.*;
|
935
|
+
#
|
936
|
+
# import java.nio.charset.StandardCharsets;
|
937
|
+
# import java.security.MessageDigest;
|
938
|
+
# import java.security.NoSuchAlgorithmException;
|
939
|
+
# import java.util.Base64;
|
940
|
+
#
|
941
|
+
# public class Example {
|
942
|
+
# public static void main(String[] args) {
|
943
|
+
# try (Playwright playwright = Playwright.create()) {
|
944
|
+
# BrowserType webkit = playwright.webkit();
|
945
|
+
# Browser browser = webkit.launch({ headless: false });
|
946
|
+
# Page page = browser.newPage();
|
947
|
+
# page.exposeFunction("sha1", args -> {
|
948
|
+
# String text = (String) args[0];
|
949
|
+
# MessageDigest crypto;
|
950
|
+
# try {
|
951
|
+
# crypto = MessageDigest.getInstance("SHA-1");
|
952
|
+
# } catch (NoSuchAlgorithmException e) {
|
953
|
+
# return null;
|
954
|
+
# }
|
955
|
+
# byte[] token = crypto.digest(text.getBytes(StandardCharsets.UTF_8));
|
956
|
+
# return Base64.getEncoder().encodeToString(token);
|
957
|
+
# });
|
958
|
+
# page.setContent("<script>\n" +
|
959
|
+
# " async function onClick() {\n" +
|
960
|
+
# " document.querySelector('div').textContent = await window.sha1('PLAYWRIGHT');\n" +
|
961
|
+
# " }\n" +
|
962
|
+
# "</script>\n" +
|
963
|
+
# "<button onclick=\"onClick()\">Click me</button>\n" +
|
964
|
+
# "<div></div>\n");
|
965
|
+
# page.click("button");
|
966
|
+
# }
|
967
|
+
# }
|
968
|
+
# }
|
969
|
+
# ```
|
970
|
+
#
|
771
971
|
# ```python async
|
772
972
|
# import asyncio
|
773
973
|
# import hashlib
|
@@ -862,6 +1062,10 @@ module Playwright
|
|
862
1062
|
# const frame = page.frame('frame-name');
|
863
1063
|
# ```
|
864
1064
|
#
|
1065
|
+
# ```java
|
1066
|
+
# Frame frame = page.frame("frame-name");
|
1067
|
+
# ```
|
1068
|
+
#
|
865
1069
|
# ```py
|
866
1070
|
# frame = page.frame(name="frame-name")
|
867
1071
|
# ```
|
@@ -871,6 +1075,10 @@ module Playwright
|
|
871
1075
|
# const frame = page.frame({ url: /.*domain.*/ });
|
872
1076
|
# ```
|
873
1077
|
#
|
1078
|
+
# ```java
|
1079
|
+
# Frame frame = page.frameByUrl(Pattern.compile(".*domain.*");
|
1080
|
+
# ```
|
1081
|
+
#
|
874
1082
|
# ```py
|
875
1083
|
# frame = page.frame(url=r".*domain.*")
|
876
1084
|
# ```
|
@@ -929,15 +1137,15 @@ module Playwright
|
|
929
1137
|
end
|
930
1138
|
|
931
1139
|
# This method hovers over an element matching `selector` by performing the following steps:
|
932
|
-
# 1. Find an element
|
1140
|
+
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
933
1141
|
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
934
1142
|
# element is detached during the checks, the whole action is retried.
|
935
1143
|
# 1. Scroll the element into view if needed.
|
936
1144
|
# 1. Use [`property: Page.mouse`] to hover over the center of the element, or the specified `position`.
|
937
1145
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
938
1146
|
#
|
939
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
940
|
-
#
|
1147
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
1148
|
+
# zero timeout disables this.
|
941
1149
|
#
|
942
1150
|
# Shortcut for main frame's [`method: Frame.hover`].
|
943
1151
|
def hover(
|
@@ -1036,6 +1244,12 @@ module Playwright
|
|
1036
1244
|
# await page.pdf({path: 'page.pdf'});
|
1037
1245
|
# ```
|
1038
1246
|
#
|
1247
|
+
# ```java
|
1248
|
+
# // Generates a PDF with "screen" media type.
|
1249
|
+
# page.emulateMedia(new Page.EmulateMediaOptions().setMedia(Media.SCREEN));
|
1250
|
+
# page.pdf(new Page.PdfOptions().setPath(Paths.get("page.pdf")));
|
1251
|
+
# ```
|
1252
|
+
#
|
1039
1253
|
# ```python async
|
1040
1254
|
# # generates a pdf with "screen" media type.
|
1041
1255
|
# await page.emulate_media(media="screen")
|
@@ -1109,7 +1323,7 @@ module Playwright
|
|
1109
1323
|
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
|
1110
1324
|
# texts.
|
1111
1325
|
#
|
1112
|
-
# Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When
|
1326
|
+
# Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
|
1113
1327
|
# modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
1114
1328
|
#
|
1115
1329
|
#
|
@@ -1125,6 +1339,17 @@ module Playwright
|
|
1125
1339
|
# await browser.close();
|
1126
1340
|
# ```
|
1127
1341
|
#
|
1342
|
+
# ```java
|
1343
|
+
# Page page = browser.newPage();
|
1344
|
+
# page.navigate("https://keycode.info");
|
1345
|
+
# page.press("body", "A");
|
1346
|
+
# page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("A.png")));
|
1347
|
+
# page.press("body", "ArrowLeft");
|
1348
|
+
# page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("ArrowLeft.png" )));
|
1349
|
+
# page.press("body", "Shift+O");
|
1350
|
+
# page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("O.png" )));
|
1351
|
+
# ```
|
1352
|
+
#
|
1128
1353
|
# ```python async
|
1129
1354
|
# page = await browser.new_page()
|
1130
1355
|
# await page.goto("https://keycode.info")
|
@@ -1185,7 +1410,7 @@ module Playwright
|
|
1185
1410
|
#
|
1186
1411
|
# > NOTE: The handler will only be called for the first url if the response is a redirect.
|
1187
1412
|
#
|
1188
|
-
# An example of a
|
1413
|
+
# An example of a naive handler that aborts all image requests:
|
1189
1414
|
#
|
1190
1415
|
#
|
1191
1416
|
# ```js
|
@@ -1195,6 +1420,13 @@ module Playwright
|
|
1195
1420
|
# await browser.close();
|
1196
1421
|
# ```
|
1197
1422
|
#
|
1423
|
+
# ```java
|
1424
|
+
# Page page = browser.newPage();
|
1425
|
+
# page.route("**/*.{png,jpg,jpeg}", route -> route.abort());
|
1426
|
+
# page.navigate("https://example.com");
|
1427
|
+
# browser.close();
|
1428
|
+
# ```
|
1429
|
+
#
|
1198
1430
|
# ```python async
|
1199
1431
|
# page = await browser.new_page()
|
1200
1432
|
# await page.route("**/*.{png,jpg,jpeg}", lambda route: route.abort())
|
@@ -1219,6 +1451,13 @@ module Playwright
|
|
1219
1451
|
# await browser.close();
|
1220
1452
|
# ```
|
1221
1453
|
#
|
1454
|
+
# ```java
|
1455
|
+
# Page page = browser.newPage();
|
1456
|
+
# page.route(Pattern.compile("(\\.png$)|(\\.jpg$)"),route -> route.abort());
|
1457
|
+
# page.navigate("https://example.com");
|
1458
|
+
# browser.close();
|
1459
|
+
# ```
|
1460
|
+
#
|
1222
1461
|
# ```python async
|
1223
1462
|
# page = await browser.new_page()
|
1224
1463
|
# await page.route(re.compile(r"(\.png$)|(\.jpg$)"), lambda route: route.abort())
|
@@ -1236,15 +1475,14 @@ module Playwright
|
|
1236
1475
|
# Page routes take precedence over browser context routes (set up with [`method: BrowserContext.route`]) when request
|
1237
1476
|
# matches both handlers.
|
1238
1477
|
#
|
1478
|
+
# To remove a route with its handler you can use [`method: Page.unroute`].
|
1479
|
+
#
|
1239
1480
|
# > NOTE: Enabling routing disables http cache.
|
1240
1481
|
def route(url, handler)
|
1241
1482
|
wrap_impl(@impl.route(unwrap_impl(url), unwrap_impl(handler)))
|
1242
1483
|
end
|
1243
1484
|
|
1244
1485
|
# Returns the buffer with the captured screenshot.
|
1245
|
-
#
|
1246
|
-
# > NOTE: Screenshots take at least 1/6 second on Chromium OS X and Chromium Windows. See https://crbug.com/741689 for
|
1247
|
-
# discussion.
|
1248
1486
|
def screenshot(
|
1249
1487
|
clip: nil,
|
1250
1488
|
fullPage: nil,
|
@@ -1276,6 +1514,15 @@ module Playwright
|
|
1276
1514
|
#
|
1277
1515
|
# ```
|
1278
1516
|
#
|
1517
|
+
# ```java
|
1518
|
+
# // single selection matching the value
|
1519
|
+
# page.selectOption("select#colors", "blue");
|
1520
|
+
# // single selection matching both the value and the label
|
1521
|
+
# page.selectOption("select#colors", new SelectOption().setLabel("Blue"));
|
1522
|
+
# // multiple selection
|
1523
|
+
# page.selectOption("select#colors", new String[] {"red", "green", "blue"});
|
1524
|
+
# ```
|
1525
|
+
#
|
1279
1526
|
# ```python async
|
1280
1527
|
# # single selection matching the value
|
1281
1528
|
# await page.select_option("select#colors", "blue")
|
@@ -1318,6 +1565,7 @@ module Playwright
|
|
1318
1565
|
# - [`method: Page.reload`]
|
1319
1566
|
# - [`method: Page.setContent`]
|
1320
1567
|
# - [`method: Page.waitForNavigation`]
|
1568
|
+
# - [`method: Page.waitForURL`]
|
1321
1569
|
#
|
1322
1570
|
# > NOTE: [`method: Page.setDefaultNavigationTimeout`] takes priority over [`method: Page.setDefaultTimeout`],
|
1323
1571
|
# [`method: BrowserContext.setDefaultTimeout`] and [`method: BrowserContext.setDefaultNavigationTimeout`].
|
@@ -1367,6 +1615,12 @@ module Playwright
|
|
1367
1615
|
# await page.goto('https://example.com');
|
1368
1616
|
# ```
|
1369
1617
|
#
|
1618
|
+
# ```java
|
1619
|
+
# Page page = browser.newPage();
|
1620
|
+
# page.setViewportSize(640, 480);
|
1621
|
+
# page.navigate("https://example.com");
|
1622
|
+
# ```
|
1623
|
+
#
|
1370
1624
|
# ```python async
|
1371
1625
|
# page = await browser.new_page()
|
1372
1626
|
# await page.set_viewport_size({"width": 640, "height": 480})
|
@@ -1384,15 +1638,15 @@ module Playwright
|
|
1384
1638
|
alias_method :viewport_size=, :set_viewport_size
|
1385
1639
|
|
1386
1640
|
# This method taps an element matching `selector` by performing the following steps:
|
1387
|
-
# 1. Find an element
|
1641
|
+
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
1388
1642
|
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
1389
1643
|
# element is detached during the checks, the whole action is retried.
|
1390
1644
|
# 1. Scroll the element into view if needed.
|
1391
1645
|
# 1. Use [`property: Page.touchscreen`] to tap the center of the element, or the specified `position`.
|
1392
1646
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
1393
1647
|
#
|
1394
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
1395
|
-
#
|
1648
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
1649
|
+
# zero timeout disables this.
|
1396
1650
|
#
|
1397
1651
|
# > NOTE: [`method: Page.tap`] requires that the `hasTouch` option of the browser context be set to true.
|
1398
1652
|
#
|
@@ -1428,6 +1682,13 @@ module Playwright
|
|
1428
1682
|
# await page.type('#mytextarea', 'World', {delay: 100}); // Types slower, like a user
|
1429
1683
|
# ```
|
1430
1684
|
#
|
1685
|
+
# ```java
|
1686
|
+
# // Types instantly
|
1687
|
+
# page.type("#mytextarea", "Hello");
|
1688
|
+
# // Types slower, like a user
|
1689
|
+
# page.type("#mytextarea", "World", new Page.TypeOptions().setDelay(100));
|
1690
|
+
# ```
|
1691
|
+
#
|
1431
1692
|
# ```python async
|
1432
1693
|
# await page.type("#mytextarea", "hello") # types instantly
|
1433
1694
|
# await page.type("#mytextarea", "world", delay=100) # types slower, like a user
|
@@ -1449,22 +1710,27 @@ module Playwright
|
|
1449
1710
|
end
|
1450
1711
|
|
1451
1712
|
# This method unchecks an element matching `selector` by performing the following steps:
|
1452
|
-
# 1. Find an element
|
1453
|
-
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method
|
1713
|
+
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
1714
|
+
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already
|
1454
1715
|
# unchecked, this method returns immediately.
|
1455
1716
|
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
1456
1717
|
# element is detached during the checks, the whole action is retried.
|
1457
1718
|
# 1. Scroll the element into view if needed.
|
1458
1719
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
1459
1720
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
1460
|
-
# 1. Ensure that the element is now unchecked. If not, this method
|
1721
|
+
# 1. Ensure that the element is now unchecked. If not, this method throws.
|
1461
1722
|
#
|
1462
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
1463
|
-
#
|
1723
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
1724
|
+
# zero timeout disables this.
|
1464
1725
|
#
|
1465
1726
|
# Shortcut for main frame's [`method: Frame.uncheck`].
|
1466
|
-
def uncheck(
|
1467
|
-
|
1727
|
+
def uncheck(
|
1728
|
+
selector,
|
1729
|
+
force: nil,
|
1730
|
+
noWaitAfter: nil,
|
1731
|
+
position: nil,
|
1732
|
+
timeout: nil)
|
1733
|
+
wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
|
1468
1734
|
end
|
1469
1735
|
|
1470
1736
|
# Removes a route created with [`method: Page.route`]. When `handler` is not specified, removes all routes for the `url`.
|
@@ -1479,14 +1745,14 @@ module Playwright
|
|
1479
1745
|
|
1480
1746
|
# Video object associated with this page.
|
1481
1747
|
def video
|
1482
|
-
|
1748
|
+
wrap_impl(@impl.video)
|
1483
1749
|
end
|
1484
1750
|
|
1485
1751
|
def viewport_size
|
1486
1752
|
wrap_impl(@impl.viewport_size)
|
1487
1753
|
end
|
1488
1754
|
|
1489
|
-
# Performs action and waits for a
|
1755
|
+
# Performs action and waits for a `ConsoleMessage` to be logged by in the page. If predicate is provided, it passes
|
1490
1756
|
# `ConsoleMessage` value into the `predicate` function and waits for `predicate(message)` to return a truthy value. Will
|
1491
1757
|
# throw an error if the page is closed before the console event is fired.
|
1492
1758
|
def expect_console_message(predicate: nil, timeout: nil, &block)
|
@@ -1551,6 +1817,23 @@ module Playwright
|
|
1551
1817
|
# })();
|
1552
1818
|
# ```
|
1553
1819
|
#
|
1820
|
+
# ```java
|
1821
|
+
# import com.microsoft.playwright.*;
|
1822
|
+
#
|
1823
|
+
# public class Example {
|
1824
|
+
# public static void main(String[] args) {
|
1825
|
+
# try (Playwright playwright = Playwright.create()) {
|
1826
|
+
# BrowserType webkit = playwright.webkit();
|
1827
|
+
# Browser browser = webkit.launch();
|
1828
|
+
# Page page = browser.newPage();
|
1829
|
+
# page.setViewportSize(50, 50);
|
1830
|
+
# page.waitForFunction("() => window.innerWidth < 100");
|
1831
|
+
# browser.close();
|
1832
|
+
# }
|
1833
|
+
# }
|
1834
|
+
# }
|
1835
|
+
# ```
|
1836
|
+
#
|
1554
1837
|
# ```python async
|
1555
1838
|
# import asyncio
|
1556
1839
|
# from playwright.async_api import async_playwright
|
@@ -1592,6 +1875,11 @@ module Playwright
|
|
1592
1875
|
# await page.waitForFunction(selector => !!document.querySelector(selector), selector);
|
1593
1876
|
# ```
|
1594
1877
|
#
|
1878
|
+
# ```java
|
1879
|
+
# String selector = ".foo";
|
1880
|
+
# page.waitForFunction("selector => !!document.querySelector(selector)", selector);
|
1881
|
+
# ```
|
1882
|
+
#
|
1595
1883
|
# ```python async
|
1596
1884
|
# selector = ".foo"
|
1597
1885
|
# await page.wait_for_function("selector => !!document.querySelector(selector)", selector)
|
@@ -1618,6 +1906,11 @@ module Playwright
|
|
1618
1906
|
# await page.waitForLoadState(); // The promise resolves after 'load' event.
|
1619
1907
|
# ```
|
1620
1908
|
#
|
1909
|
+
# ```java
|
1910
|
+
# page.click("button"); // Click triggers navigation.
|
1911
|
+
# page.waitForLoadState(); // The promise resolves after "load" event.
|
1912
|
+
# ```
|
1913
|
+
#
|
1621
1914
|
# ```python async
|
1622
1915
|
# await page.click("button") # click triggers navigation.
|
1623
1916
|
# await page.wait_for_load_state() # the promise resolves after "load" event.
|
@@ -1638,6 +1931,14 @@ module Playwright
|
|
1638
1931
|
# console.log(await popup.title()); // Popup is ready to use.
|
1639
1932
|
# ```
|
1640
1933
|
#
|
1934
|
+
# ```java
|
1935
|
+
# Page popup = page.waitForPopup(() -> {
|
1936
|
+
# page.click("button"); // Click triggers a popup.
|
1937
|
+
# });
|
1938
|
+
# popup.waitForLoadState(LoadState.DOMCONTENTLOADED);
|
1939
|
+
# System.out.println(popup.title()); // Popup is ready to use.
|
1940
|
+
# ```
|
1941
|
+
#
|
1641
1942
|
# ```python async
|
1642
1943
|
# async with page.expect_popup() as page_info:
|
1643
1944
|
# await page.click("button") # click triggers a popup.
|
@@ -1677,6 +1978,13 @@ module Playwright
|
|
1677
1978
|
# ]);
|
1678
1979
|
# ```
|
1679
1980
|
#
|
1981
|
+
# ```java
|
1982
|
+
# // The method returns after navigation has finished
|
1983
|
+
# Response response = page.waitForNavigation(() -> {
|
1984
|
+
# page.click("a.delayed-navigation"); // Clicking the link will indirectly cause a navigation
|
1985
|
+
# });
|
1986
|
+
# ```
|
1987
|
+
#
|
1680
1988
|
# ```python async
|
1681
1989
|
# async with page.expect_navigation():
|
1682
1990
|
# await page.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
|
@@ -1713,6 +2021,13 @@ module Playwright
|
|
1713
2021
|
# return firstRequest.url();
|
1714
2022
|
# ```
|
1715
2023
|
#
|
2024
|
+
# ```java
|
2025
|
+
# Request firstRequest = page.waitForRequest("http://example.com/resource");
|
2026
|
+
# Object finalRequest = page.waitForRequest(
|
2027
|
+
# request -> "http://example.com".equals(request.url()) && "GET".equals(request.method()), () -> {});
|
2028
|
+
# return firstRequest.url();
|
2029
|
+
# ```
|
2030
|
+
#
|
1716
2031
|
# ```python async
|
1717
2032
|
# async with page.expect_request("http://example.com/resource") as first:
|
1718
2033
|
# await page.click('button')
|
@@ -1750,16 +2065,36 @@ module Playwright
|
|
1750
2065
|
# return finalResponse.ok();
|
1751
2066
|
# ```
|
1752
2067
|
#
|
2068
|
+
# ```java
|
2069
|
+
# Response firstResponse = page.waitForResponse("https://example.com/resource", () -> {});
|
2070
|
+
# Response finalResponse = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200, () -> {});
|
2071
|
+
# return finalResponse.ok();
|
2072
|
+
# ```
|
2073
|
+
#
|
1753
2074
|
# ```python async
|
1754
|
-
#
|
1755
|
-
#
|
1756
|
-
#
|
2075
|
+
# async with page.expect_response("https://example.com/resource") as response_info:
|
2076
|
+
# await page.click("input")
|
2077
|
+
# response = response_info.value
|
2078
|
+
# return response.ok
|
2079
|
+
#
|
2080
|
+
# # or with a lambda
|
2081
|
+
# async with page.expect_response(lambda response: response.url == "https://example.com" and response.status === 200) as response_info:
|
2082
|
+
# await page.click("input")
|
2083
|
+
# response = response_info.value
|
2084
|
+
# return response.ok
|
1757
2085
|
# ```
|
1758
2086
|
#
|
1759
2087
|
# ```python sync
|
1760
|
-
#
|
1761
|
-
#
|
1762
|
-
#
|
2088
|
+
# with page.expect_response("https://example.com/resource") as response_info:
|
2089
|
+
# page.click("input")
|
2090
|
+
# response = response_info.value
|
2091
|
+
# return response.ok
|
2092
|
+
#
|
2093
|
+
# # or with a lambda
|
2094
|
+
# with page.expect_response(lambda response: response.url == "https://example.com" and response.status === 200) as response_info:
|
2095
|
+
# page.click("input")
|
2096
|
+
# response = response_info.value
|
2097
|
+
# return response.ok
|
1763
2098
|
# ```
|
1764
2099
|
def expect_response(urlOrPredicate, timeout: nil)
|
1765
2100
|
wrap_impl(@impl.expect_response(unwrap_impl(urlOrPredicate), timeout: unwrap_impl(timeout)))
|
@@ -1790,6 +2125,26 @@ module Playwright
|
|
1790
2125
|
# })();
|
1791
2126
|
# ```
|
1792
2127
|
#
|
2128
|
+
# ```java
|
2129
|
+
# import com.microsoft.playwright.*;
|
2130
|
+
#
|
2131
|
+
# public class Example {
|
2132
|
+
# public static void main(String[] args) {
|
2133
|
+
# try (Playwright playwright = Playwright.create()) {
|
2134
|
+
# BrowserType chromium = playwright.chromium();
|
2135
|
+
# Browser browser = chromium.launch();
|
2136
|
+
# Page page = browser.newPage();
|
2137
|
+
# for (String currentURL : Arrays.asList("https://google.com", "https://bbc.com")) {
|
2138
|
+
# page.navigate(currentURL);
|
2139
|
+
# ElementHandle element = page.waitForSelector("img");
|
2140
|
+
# System.out.println("Loaded image: " + element.getAttribute("src"));
|
2141
|
+
# }
|
2142
|
+
# browser.close();
|
2143
|
+
# }
|
2144
|
+
# }
|
2145
|
+
# }
|
2146
|
+
# ```
|
2147
|
+
#
|
1793
2148
|
# ```python async
|
1794
2149
|
# import asyncio
|
1795
2150
|
# from playwright.async_api import async_playwright
|
@@ -1841,6 +2196,11 @@ module Playwright
|
|
1841
2196
|
# await page.waitForTimeout(1000);
|
1842
2197
|
# ```
|
1843
2198
|
#
|
2199
|
+
# ```java
|
2200
|
+
# // wait for 1 second
|
2201
|
+
# page.waitForTimeout(1000);
|
2202
|
+
# ```
|
2203
|
+
#
|
1844
2204
|
# ```python async
|
1845
2205
|
# # wait for 1 second
|
1846
2206
|
# await page.wait_for_timeout(1000)
|
@@ -1856,6 +2216,34 @@ module Playwright
|
|
1856
2216
|
raise NotImplementedError.new('wait_for_timeout is not implemented yet.')
|
1857
2217
|
end
|
1858
2218
|
|
2219
|
+
# Waits for the main frame to navigate to the given URL.
|
2220
|
+
#
|
2221
|
+
#
|
2222
|
+
# ```js
|
2223
|
+
# await page.click('a.delayed-navigation'); // Clicking the link will indirectly cause a navigation
|
2224
|
+
# await page.waitForURL('**/target.html');
|
2225
|
+
# ```
|
2226
|
+
#
|
2227
|
+
# ```java
|
2228
|
+
# page.click("a.delayed-navigation"); // Clicking the link will indirectly cause a navigation
|
2229
|
+
# page.waitForURL("**/target.html");
|
2230
|
+
# ```
|
2231
|
+
#
|
2232
|
+
# ```python async
|
2233
|
+
# await page.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
|
2234
|
+
# await page.wait_for_url("**/target.html")
|
2235
|
+
# ```
|
2236
|
+
#
|
2237
|
+
# ```python sync
|
2238
|
+
# page.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
|
2239
|
+
# page.wait_for_url("**/target.html")
|
2240
|
+
# ```
|
2241
|
+
#
|
2242
|
+
# Shortcut for main frame's [`method: Frame.waitForURL`].
|
2243
|
+
def wait_for_url(url, timeout: nil, waitUntil: nil)
|
2244
|
+
wrap_impl(@impl.wait_for_url(unwrap_impl(url), timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
|
2245
|
+
end
|
2246
|
+
|
1859
2247
|
# Performs action and waits for a new `Worker`. If predicate is provided, it passes `Worker` value into the `predicate`
|
1860
2248
|
# function and waits for `predicate(worker)` to return a truthy value. Will throw an error if the page is closed before
|
1861
2249
|
# the worker event is fired.
|
@@ -1881,14 +2269,28 @@ module Playwright
|
|
1881
2269
|
end
|
1882
2270
|
|
1883
2271
|
# @nodoc
|
1884
|
-
def
|
1885
|
-
wrap_impl(@impl.
|
2272
|
+
def start_js_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
|
2273
|
+
wrap_impl(@impl.start_js_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
|
1886
2274
|
end
|
1887
2275
|
|
1888
|
-
# -- inherited from EventEmitter --
|
1889
2276
|
# @nodoc
|
1890
|
-
def
|
1891
|
-
|
2277
|
+
def stop_js_coverage
|
2278
|
+
wrap_impl(@impl.stop_js_coverage)
|
2279
|
+
end
|
2280
|
+
|
2281
|
+
# @nodoc
|
2282
|
+
def start_css_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
|
2283
|
+
wrap_impl(@impl.start_css_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
|
2284
|
+
end
|
2285
|
+
|
2286
|
+
# @nodoc
|
2287
|
+
def stop_css_coverage
|
2288
|
+
wrap_impl(@impl.stop_css_coverage)
|
2289
|
+
end
|
2290
|
+
|
2291
|
+
# @nodoc
|
2292
|
+
def owned_context=(req)
|
2293
|
+
wrap_impl(@impl.owned_context=(unwrap_impl(req)))
|
1892
2294
|
end
|
1893
2295
|
|
1894
2296
|
# -- inherited from EventEmitter --
|
@@ -1903,6 +2305,12 @@ module Playwright
|
|
1903
2305
|
event_emitter_proxy.on(event, callback)
|
1904
2306
|
end
|
1905
2307
|
|
2308
|
+
# -- inherited from EventEmitter --
|
2309
|
+
# @nodoc
|
2310
|
+
def off(event, callback)
|
2311
|
+
event_emitter_proxy.off(event, callback)
|
2312
|
+
end
|
2313
|
+
|
1906
2314
|
private def event_emitter_proxy
|
1907
2315
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
1908
2316
|
end
|