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/frame.rb
CHANGED
@@ -31,6 +31,29 @@ module Playwright
|
|
31
31
|
# })();
|
32
32
|
# ```
|
33
33
|
#
|
34
|
+
# ```java
|
35
|
+
# import com.microsoft.playwright.*;
|
36
|
+
#
|
37
|
+
# public class Example {
|
38
|
+
# public static void main(String[] args) {
|
39
|
+
# try (Playwright playwright = Playwright.create()) {
|
40
|
+
# BrowserType firefox = playwright.firefox();
|
41
|
+
# Browser browser = firefox.launch();
|
42
|
+
# Page page = browser.newPage();
|
43
|
+
# page.navigate("https://www.google.com/chrome/browser/canary.html");
|
44
|
+
# dumpFrameTree(page.mainFrame(), "");
|
45
|
+
# browser.close();
|
46
|
+
# }
|
47
|
+
# }
|
48
|
+
# static void dumpFrameTree(Frame frame, String indent) {
|
49
|
+
# System.out.println(indent + frame.url());
|
50
|
+
# for (Frame child : frame.childFrames()) {
|
51
|
+
# dumpFrameTree(child, indent + " ");
|
52
|
+
# }
|
53
|
+
# }
|
54
|
+
# }
|
55
|
+
# ```
|
56
|
+
#
|
34
57
|
# ```python async
|
35
58
|
# import asyncio
|
36
59
|
# from playwright.async_api import async_playwright
|
@@ -91,20 +114,25 @@ module Playwright
|
|
91
114
|
end
|
92
115
|
|
93
116
|
# This method checks an element matching `selector` by performing the following steps:
|
94
|
-
# 1. Find an element
|
95
|
-
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method
|
117
|
+
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
118
|
+
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already
|
96
119
|
# checked, this method returns immediately.
|
97
120
|
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
98
121
|
# element is detached during the checks, the whole action is retried.
|
99
122
|
# 1. Scroll the element into view if needed.
|
100
123
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
101
124
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
102
|
-
# 1. Ensure that the element is now checked. If not, this method
|
125
|
+
# 1. Ensure that the element is now checked. If not, this method throws.
|
103
126
|
#
|
104
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
105
|
-
#
|
106
|
-
def check(
|
107
|
-
|
127
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
128
|
+
# zero timeout disables this.
|
129
|
+
def check(
|
130
|
+
selector,
|
131
|
+
force: nil,
|
132
|
+
noWaitAfter: nil,
|
133
|
+
position: nil,
|
134
|
+
timeout: nil)
|
135
|
+
wrap_impl(@impl.check(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
|
108
136
|
end
|
109
137
|
|
110
138
|
def child_frames
|
@@ -112,15 +140,15 @@ module Playwright
|
|
112
140
|
end
|
113
141
|
|
114
142
|
# This method clicks an element matching `selector` by performing the following steps:
|
115
|
-
# 1. Find an element
|
143
|
+
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
116
144
|
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
117
145
|
# element is detached during the checks, the whole action is retried.
|
118
146
|
# 1. Scroll the element into view if needed.
|
119
147
|
# 1. Use [`property: Page.mouse`] to click in the center of the element, or the specified `position`.
|
120
148
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
121
149
|
#
|
122
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
123
|
-
#
|
150
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
151
|
+
# zero timeout disables this.
|
124
152
|
def click(
|
125
153
|
selector,
|
126
154
|
button: nil,
|
@@ -140,16 +168,16 @@ module Playwright
|
|
140
168
|
end
|
141
169
|
|
142
170
|
# This method double clicks an element matching `selector` by performing the following steps:
|
143
|
-
# 1. Find an element
|
171
|
+
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
144
172
|
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
145
173
|
# element is detached during the checks, the whole action is retried.
|
146
174
|
# 1. Scroll the element into view if needed.
|
147
175
|
# 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`.
|
148
176
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the
|
149
|
-
# first click of the `dblclick()` triggers a navigation event, this method will
|
177
|
+
# first click of the `dblclick()` triggers a navigation event, this method will throw.
|
150
178
|
#
|
151
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
152
|
-
#
|
179
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
180
|
+
# zero timeout disables this.
|
153
181
|
#
|
154
182
|
# > NOTE: `frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
|
155
183
|
def dblclick(
|
@@ -164,8 +192,8 @@ module Playwright
|
|
164
192
|
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)))
|
165
193
|
end
|
166
194
|
|
167
|
-
# The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the
|
168
|
-
# is dispatched. This is
|
195
|
+
# The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
|
196
|
+
# `click` is dispatched. This is equivalent to calling
|
169
197
|
# [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
|
170
198
|
#
|
171
199
|
#
|
@@ -173,6 +201,10 @@ module Playwright
|
|
173
201
|
# await frame.dispatchEvent('button#submit', 'click');
|
174
202
|
# ```
|
175
203
|
#
|
204
|
+
# ```java
|
205
|
+
# frame.dispatchEvent("button#submit", "click");
|
206
|
+
# ```
|
207
|
+
#
|
176
208
|
# ```python async
|
177
209
|
# await frame.dispatch_event("button#submit", "click")
|
178
210
|
# ```
|
@@ -202,6 +234,14 @@ module Playwright
|
|
202
234
|
# await frame.dispatchEvent('#source', 'dragstart', { dataTransfer });
|
203
235
|
# ```
|
204
236
|
#
|
237
|
+
# ```java
|
238
|
+
# // Note you can only create DataTransfer in Chromium and Firefox
|
239
|
+
# JSHandle dataTransfer = frame.evaluateHandle("() => new DataTransfer()");
|
240
|
+
# Map<String, Object> arg = new HashMap<>();
|
241
|
+
# arg.put("dataTransfer", dataTransfer);
|
242
|
+
# frame.dispatchEvent("#source", "dragstart", arg);
|
243
|
+
# ```
|
244
|
+
#
|
205
245
|
# ```python async
|
206
246
|
# # note you can only create data_transfer in chromium and firefox
|
207
247
|
# data_transfer = await frame.evaluate_handle("new DataTransfer()")
|
@@ -235,6 +275,12 @@ module Playwright
|
|
235
275
|
# const html = await frame.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
|
236
276
|
# ```
|
237
277
|
#
|
278
|
+
# ```java
|
279
|
+
# String searchValue = (String) frame.evalOnSelector("#search", "el => el.value");
|
280
|
+
# String preloadHref = (String) frame.evalOnSelector("link[rel=preload]", "el => el.href");
|
281
|
+
# String html = (String) frame.evalOnSelector(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello");
|
282
|
+
# ```
|
283
|
+
#
|
238
284
|
# ```python async
|
239
285
|
# search_value = await frame.eval_on_selector("#search", "el => el.value")
|
240
286
|
# preload_href = await frame.eval_on_selector("link[rel=preload]", "el => el.href")
|
@@ -265,6 +311,10 @@ module Playwright
|
|
265
311
|
# const divsCounts = await frame.$$eval('div', (divs, min) => divs.length >= min, 10);
|
266
312
|
# ```
|
267
313
|
#
|
314
|
+
# ```java
|
315
|
+
# boolean divsCounts = (boolean) page.evalOnSelectorAll("div", "(divs, min) => divs.length >= min", 10);
|
316
|
+
# ```
|
317
|
+
#
|
268
318
|
# ```python async
|
269
319
|
# divs_counts = await frame.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
270
320
|
# ```
|
@@ -293,6 +343,13 @@ module Playwright
|
|
293
343
|
# console.log(result); // prints "56"
|
294
344
|
# ```
|
295
345
|
#
|
346
|
+
# ```java
|
347
|
+
# Object result = frame.evaluate("([x, y]) => {\n" +
|
348
|
+
# " return Promise.resolve(x * y);\n" +
|
349
|
+
# "}", Arrays.asList(7, 8));
|
350
|
+
# System.out.println(result); // prints "56"
|
351
|
+
# ```
|
352
|
+
#
|
296
353
|
# ```python async
|
297
354
|
# result = await frame.evaluate("([x, y]) => Promise.resolve(x * y)", [7, 8])
|
298
355
|
# print(result) # prints "56"
|
@@ -310,6 +367,10 @@ module Playwright
|
|
310
367
|
# console.log(await frame.evaluate('1 + 2')); // prints "3"
|
311
368
|
# ```
|
312
369
|
#
|
370
|
+
# ```java
|
371
|
+
# System.out.println(frame.evaluate("1 + 2")); // prints "3"
|
372
|
+
# ```
|
373
|
+
#
|
313
374
|
# ```python async
|
314
375
|
# print(await frame.evaluate("1 + 2")) # prints "3"
|
315
376
|
# x = 10
|
@@ -331,6 +392,12 @@ module Playwright
|
|
331
392
|
# await bodyHandle.dispose();
|
332
393
|
# ```
|
333
394
|
#
|
395
|
+
# ```java
|
396
|
+
# ElementHandle bodyHandle = frame.querySelector("body");
|
397
|
+
# String html = (String) frame.evaluate("([body, suffix]) => body.innerHTML + suffix", Arrays.asList(bodyHandle, "hello"));
|
398
|
+
# bodyHandle.dispose();
|
399
|
+
# ```
|
400
|
+
#
|
334
401
|
# ```python async
|
335
402
|
# body_handle = await frame.query_selector("body")
|
336
403
|
# html = await frame.evaluate("([body, suffix]) => body.innerHTML + suffix", [body_handle, "hello"])
|
@@ -349,7 +416,7 @@ module Playwright
|
|
349
416
|
# Returns the return value of `expression` as a `JSHandle`.
|
350
417
|
#
|
351
418
|
# The only difference between [`method: Frame.evaluate`] and [`method: Frame.evaluateHandle`] is that
|
352
|
-
# [method: Frame.evaluateHandle`] returns `JSHandle`.
|
419
|
+
# [`method: Frame.evaluateHandle`] returns `JSHandle`.
|
353
420
|
#
|
354
421
|
# If the function, passed to the [`method: Frame.evaluateHandle`], returns a [Promise], then
|
355
422
|
# [`method: Frame.evaluateHandle`] would wait for the promise to resolve and return its value.
|
@@ -360,6 +427,11 @@ module Playwright
|
|
360
427
|
# aWindowHandle; // Handle for the window object.
|
361
428
|
# ```
|
362
429
|
#
|
430
|
+
# ```java
|
431
|
+
# // Handle for the window object.
|
432
|
+
# JSHandle aWindowHandle = frame.evaluateHandle("() => Promise.resolve(window)");
|
433
|
+
# ```
|
434
|
+
#
|
363
435
|
# ```python async
|
364
436
|
# a_window_handle = await frame.evaluate_handle("Promise.resolve(window)")
|
365
437
|
# a_window_handle # handle for the window object.
|
@@ -377,6 +449,10 @@ module Playwright
|
|
377
449
|
# const aHandle = await frame.evaluateHandle('document'); // Handle for the 'document'.
|
378
450
|
# ```
|
379
451
|
#
|
452
|
+
# ```java
|
453
|
+
# JSHandle aHandle = frame.evaluateHandle("document"); // Handle for the "document".
|
454
|
+
# ```
|
455
|
+
#
|
380
456
|
# ```python async
|
381
457
|
# a_handle = await page.evaluate_handle("document") # handle for the "document"
|
382
458
|
# ```
|
@@ -395,6 +471,13 @@ module Playwright
|
|
395
471
|
# await resultHandle.dispose();
|
396
472
|
# ```
|
397
473
|
#
|
474
|
+
# ```java
|
475
|
+
# JSHandle aHandle = frame.evaluateHandle("() => document.body");
|
476
|
+
# JSHandle resultHandle = frame.evaluateHandle("([body, suffix]) => body.innerHTML + suffix", Arrays.asList(aHandle, "hello"));
|
477
|
+
# System.out.println(resultHandle.jsonValue());
|
478
|
+
# resultHandle.dispose();
|
479
|
+
# ```
|
480
|
+
#
|
398
481
|
# ```python async
|
399
482
|
# a_handle = await page.evaluate_handle("document.body")
|
400
483
|
# result_handle = await page.evaluate_handle("body => body.innerHTML", a_handle)
|
@@ -443,6 +526,12 @@ module Playwright
|
|
443
526
|
# console.log(frame === contentFrame); // -> true
|
444
527
|
# ```
|
445
528
|
#
|
529
|
+
# ```java
|
530
|
+
# ElementHandle frameElement = frame.frameElement();
|
531
|
+
# Frame contentFrame = frameElement.contentFrame();
|
532
|
+
# System.out.println(frame == contentFrame); // -> true
|
533
|
+
# ```
|
534
|
+
#
|
446
535
|
# ```python async
|
447
536
|
# frame_element = await frame.frame_element()
|
448
537
|
# content_frame = await frame_element.content_frame()
|
@@ -486,15 +575,15 @@ module Playwright
|
|
486
575
|
end
|
487
576
|
|
488
577
|
# This method hovers over an element matching `selector` by performing the following steps:
|
489
|
-
# 1. Find an element
|
578
|
+
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
490
579
|
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
491
580
|
# element is detached during the checks, the whole action is retried.
|
492
581
|
# 1. Scroll the element into view if needed.
|
493
582
|
# 1. Use [`property: Page.mouse`] to hover over the center of the element, or the specified `position`.
|
494
583
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
495
584
|
#
|
496
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
497
|
-
#
|
585
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
586
|
+
# zero timeout disables this.
|
498
587
|
def hover(
|
499
588
|
selector,
|
500
589
|
force: nil,
|
@@ -584,7 +673,7 @@ module Playwright
|
|
584
673
|
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
|
585
674
|
# texts.
|
586
675
|
#
|
587
|
-
# Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When
|
676
|
+
# Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
|
588
677
|
# modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
589
678
|
def press(
|
590
679
|
selector,
|
@@ -630,6 +719,15 @@ module Playwright
|
|
630
719
|
# frame.selectOption('select#colors', 'red', 'green', 'blue');
|
631
720
|
# ```
|
632
721
|
#
|
722
|
+
# ```java
|
723
|
+
# // single selection matching the value
|
724
|
+
# frame.selectOption("select#colors", "blue");
|
725
|
+
# // single selection matching both the value and the label
|
726
|
+
# frame.selectOption("select#colors", new SelectOption().setLabel("Blue"));
|
727
|
+
# // multiple selection
|
728
|
+
# frame.selectOption("select#colors", new String[] {"red", "green", "blue"});
|
729
|
+
# ```
|
730
|
+
#
|
633
731
|
# ```python async
|
634
732
|
# # single selection matching the value
|
635
733
|
# await frame.select_option("select#colors", "blue")
|
@@ -673,15 +771,15 @@ module Playwright
|
|
673
771
|
end
|
674
772
|
|
675
773
|
# This method taps an element matching `selector` by performing the following steps:
|
676
|
-
# 1. Find an element
|
774
|
+
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
677
775
|
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
678
776
|
# element is detached during the checks, the whole action is retried.
|
679
777
|
# 1. Scroll the element into view if needed.
|
680
778
|
# 1. Use [`property: Page.touchscreen`] to tap the center of the element, or the specified `position`.
|
681
779
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
682
780
|
#
|
683
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
684
|
-
#
|
781
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
782
|
+
# zero timeout disables this.
|
685
783
|
#
|
686
784
|
# > NOTE: `frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
|
687
785
|
def tap_point(
|
@@ -715,6 +813,13 @@ module Playwright
|
|
715
813
|
# await frame.type('#mytextarea', 'World', {delay: 100}); // Types slower, like a user
|
716
814
|
# ```
|
717
815
|
#
|
816
|
+
# ```java
|
817
|
+
# // Types instantly
|
818
|
+
# frame.type("#mytextarea", "Hello");
|
819
|
+
# // Types slower, like a user
|
820
|
+
# frame.type("#mytextarea", "World", new Frame.TypeOptions().setDelay(100));
|
821
|
+
# ```
|
822
|
+
#
|
718
823
|
# ```python async
|
719
824
|
# await frame.type("#mytextarea", "hello") # types instantly
|
720
825
|
# await frame.type("#mytextarea", "world", delay=100) # types slower, like a user
|
@@ -734,20 +839,25 @@ module Playwright
|
|
734
839
|
end
|
735
840
|
|
736
841
|
# This method checks an element matching `selector` by performing the following steps:
|
737
|
-
# 1. Find an element
|
738
|
-
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method
|
842
|
+
# 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
|
843
|
+
# 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already
|
739
844
|
# unchecked, this method returns immediately.
|
740
845
|
# 1. Wait for [actionability](./actionability.md) checks on the matched element, unless `force` option is set. If the
|
741
846
|
# element is detached during the checks, the whole action is retried.
|
742
847
|
# 1. Scroll the element into view if needed.
|
743
848
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
744
849
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
745
|
-
# 1. Ensure that the element is now unchecked. If not, this method
|
850
|
+
# 1. Ensure that the element is now unchecked. If not, this method throws.
|
746
851
|
#
|
747
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
748
|
-
#
|
749
|
-
def uncheck(
|
750
|
-
|
852
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
|
853
|
+
# zero timeout disables this.
|
854
|
+
def uncheck(
|
855
|
+
selector,
|
856
|
+
force: nil,
|
857
|
+
noWaitAfter: nil,
|
858
|
+
position: nil,
|
859
|
+
timeout: nil)
|
860
|
+
wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
|
751
861
|
end
|
752
862
|
|
753
863
|
# Returns frame's url.
|
@@ -773,6 +883,23 @@ module Playwright
|
|
773
883
|
# })();
|
774
884
|
# ```
|
775
885
|
#
|
886
|
+
# ```java
|
887
|
+
# import com.microsoft.playwright.*;
|
888
|
+
#
|
889
|
+
# public class Example {
|
890
|
+
# public static void main(String[] args) {
|
891
|
+
# try (Playwright playwright = Playwright.create()) {
|
892
|
+
# BrowserType firefox = playwright.firefox();
|
893
|
+
# Browser browser = firefox.launch();
|
894
|
+
# Page page = browser.newPage();
|
895
|
+
# page.setViewportSize(50, 50);
|
896
|
+
# page.mainFrame().waitForFunction("window.innerWidth < 100");
|
897
|
+
# browser.close();
|
898
|
+
# }
|
899
|
+
# }
|
900
|
+
# }
|
901
|
+
# ```
|
902
|
+
#
|
776
903
|
# ```python async
|
777
904
|
# import asyncio
|
778
905
|
# from playwright.async_api import async_playwright
|
@@ -814,6 +941,11 @@ module Playwright
|
|
814
941
|
# await frame.waitForFunction(selector => !!document.querySelector(selector), selector);
|
815
942
|
# ```
|
816
943
|
#
|
944
|
+
# ```java
|
945
|
+
# String selector = ".foo";
|
946
|
+
# frame.waitForFunction("selector => !!document.querySelector(selector)", selector);
|
947
|
+
# ```
|
948
|
+
#
|
817
949
|
# ```python async
|
818
950
|
# selector = ".foo"
|
819
951
|
# await frame.wait_for_function("selector => !!document.querySelector(selector)", selector)
|
@@ -838,6 +970,11 @@ module Playwright
|
|
838
970
|
# await frame.waitForLoadState(); // Waits for 'load' state by default.
|
839
971
|
# ```
|
840
972
|
#
|
973
|
+
# ```java
|
974
|
+
# frame.click("button"); // Click triggers navigation.
|
975
|
+
# frame.waitForLoadState(); // Waits for "load" state by default.
|
976
|
+
# ```
|
977
|
+
#
|
841
978
|
# ```python async
|
842
979
|
# await frame.click("button") # click triggers navigation.
|
843
980
|
# await frame.wait_for_load_state() # the promise resolves after "load" event.
|
@@ -866,6 +1003,14 @@ module Playwright
|
|
866
1003
|
# ]);
|
867
1004
|
# ```
|
868
1005
|
#
|
1006
|
+
# ```java
|
1007
|
+
# // The method returns after navigation has finished
|
1008
|
+
# Response response = frame.waitForNavigation(() -> {
|
1009
|
+
# // Clicking the link will indirectly cause a navigation
|
1010
|
+
# frame.click("a.delayed-navigation");
|
1011
|
+
# });
|
1012
|
+
# ```
|
1013
|
+
#
|
869
1014
|
# ```python async
|
870
1015
|
# async with frame.expect_navigation():
|
871
1016
|
# await frame.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
|
@@ -909,6 +1054,26 @@ module Playwright
|
|
909
1054
|
# })();
|
910
1055
|
# ```
|
911
1056
|
#
|
1057
|
+
# ```java
|
1058
|
+
# import com.microsoft.playwright.*;
|
1059
|
+
#
|
1060
|
+
# public class Example {
|
1061
|
+
# public static void main(String[] args) {
|
1062
|
+
# try (Playwright playwright = Playwright.create()) {
|
1063
|
+
# BrowserType chromium = playwright.chromium();
|
1064
|
+
# Browser browser = chromium.launch();
|
1065
|
+
# Page page = browser.newPage();
|
1066
|
+
# for (String currentURL : Arrays.asList("https://google.com", "https://bbc.com")) {
|
1067
|
+
# page.navigate(currentURL);
|
1068
|
+
# ElementHandle element = page.mainFrame().waitForSelector("img");
|
1069
|
+
# System.out.println("Loaded image: " + element.getAttribute("src"));
|
1070
|
+
# }
|
1071
|
+
# browser.close();
|
1072
|
+
# }
|
1073
|
+
# }
|
1074
|
+
# }
|
1075
|
+
# ```
|
1076
|
+
#
|
912
1077
|
# ```python async
|
913
1078
|
# import asyncio
|
914
1079
|
# from playwright.async_api import async_playwright
|
@@ -957,15 +1122,35 @@ module Playwright
|
|
957
1122
|
raise NotImplementedError.new('wait_for_timeout is not implemented yet.')
|
958
1123
|
end
|
959
1124
|
|
960
|
-
#
|
961
|
-
|
962
|
-
|
1125
|
+
# Waits for the frame to navigate to the given URL.
|
1126
|
+
#
|
1127
|
+
#
|
1128
|
+
# ```js
|
1129
|
+
# await frame.click('a.delayed-navigation'); // Clicking the link will indirectly cause a navigation
|
1130
|
+
# await frame.waitForURL('**/target.html');
|
1131
|
+
# ```
|
1132
|
+
#
|
1133
|
+
# ```java
|
1134
|
+
# frame.click("a.delayed-navigation"); // Clicking the link will indirectly cause a navigation
|
1135
|
+
# frame.waitForURL("**/target.html");
|
1136
|
+
# ```
|
1137
|
+
#
|
1138
|
+
# ```python async
|
1139
|
+
# await frame.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
|
1140
|
+
# await frame.wait_for_url("**/target.html")
|
1141
|
+
# ```
|
1142
|
+
#
|
1143
|
+
# ```python sync
|
1144
|
+
# frame.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
|
1145
|
+
# frame.wait_for_url("**/target.html")
|
1146
|
+
# ```
|
1147
|
+
def wait_for_url(url, timeout: nil, waitUntil: nil)
|
1148
|
+
wrap_impl(@impl.wait_for_url(unwrap_impl(url), timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
|
963
1149
|
end
|
964
1150
|
|
965
|
-
# -- inherited from EventEmitter --
|
966
1151
|
# @nodoc
|
967
|
-
def
|
968
|
-
|
1152
|
+
def detached=(req)
|
1153
|
+
wrap_impl(@impl.detached=(unwrap_impl(req)))
|
969
1154
|
end
|
970
1155
|
|
971
1156
|
# -- inherited from EventEmitter --
|
@@ -980,6 +1165,12 @@ module Playwright
|
|
980
1165
|
event_emitter_proxy.on(event, callback)
|
981
1166
|
end
|
982
1167
|
|
1168
|
+
# -- inherited from EventEmitter --
|
1169
|
+
# @nodoc
|
1170
|
+
def off(event, callback)
|
1171
|
+
event_emitter_proxy.off(event, callback)
|
1172
|
+
end
|
1173
|
+
|
983
1174
|
private def event_emitter_proxy
|
984
1175
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
985
1176
|
end
|
@@ -8,6 +8,11 @@ module Playwright
|
|
8
8
|
# // ...
|
9
9
|
# ```
|
10
10
|
#
|
11
|
+
# ```java
|
12
|
+
# JSHandle windowHandle = page.evaluateHandle("() => window");
|
13
|
+
# // ...
|
14
|
+
# ```
|
15
|
+
#
|
11
16
|
# ```python async
|
12
17
|
# window_handle = await page.evaluate_handle("window")
|
13
18
|
# # ...
|
@@ -50,6 +55,11 @@ module Playwright
|
|
50
55
|
# expect(await tweetHandle.evaluate(node => node.innerText)).toBe('10 retweets');
|
51
56
|
# ```
|
52
57
|
#
|
58
|
+
# ```java
|
59
|
+
# ElementHandle tweetHandle = page.querySelector(".tweet .retweets");
|
60
|
+
# assertEquals("10 retweets", tweetHandle.evaluate("node => node.innerText"));
|
61
|
+
# ```
|
62
|
+
#
|
53
63
|
# ```python async
|
54
64
|
# tweet_handle = await page.query_selector(".tweet .retweets")
|
55
65
|
# assert await tweet_handle.evaluate("node => node.innerText") == "10 retweets"
|
@@ -89,6 +99,14 @@ module Playwright
|
|
89
99
|
# await handle.dispose();
|
90
100
|
# ```
|
91
101
|
#
|
102
|
+
# ```java
|
103
|
+
# JSHandle handle = page.evaluateHandle("() => ({window, document}"););
|
104
|
+
# Map<String, JSHandle> properties = handle.getProperties();
|
105
|
+
# JSHandle windowHandle = properties.get("window");
|
106
|
+
# JSHandle documentHandle = properties.get("document");
|
107
|
+
# handle.dispose();
|
108
|
+
# ```
|
109
|
+
#
|
92
110
|
# ```python async
|
93
111
|
# handle = await page.evaluate_handle("{window, document}")
|
94
112
|
# properties = await handle.get_properties()
|
@@ -122,10 +140,9 @@ module Playwright
|
|
122
140
|
wrap_impl(@impl.json_value)
|
123
141
|
end
|
124
142
|
|
125
|
-
# -- inherited from EventEmitter --
|
126
143
|
# @nodoc
|
127
|
-
def
|
128
|
-
|
144
|
+
def to_s
|
145
|
+
wrap_impl(@impl.to_s)
|
129
146
|
end
|
130
147
|
|
131
148
|
# -- inherited from EventEmitter --
|
@@ -140,6 +157,12 @@ module Playwright
|
|
140
157
|
event_emitter_proxy.on(event, callback)
|
141
158
|
end
|
142
159
|
|
160
|
+
# -- inherited from EventEmitter --
|
161
|
+
# @nodoc
|
162
|
+
def off(event, callback)
|
163
|
+
event_emitter_proxy.off(event, callback)
|
164
|
+
end
|
165
|
+
|
143
166
|
private def event_emitter_proxy
|
144
167
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
145
168
|
end
|
@@ -21,6 +21,17 @@ module Playwright
|
|
21
21
|
# // Result text will end up saying 'Hello!'
|
22
22
|
# ```
|
23
23
|
#
|
24
|
+
# ```java
|
25
|
+
# page.keyboard().type("Hello World!");
|
26
|
+
# page.keyboard().press("ArrowLeft");
|
27
|
+
# page.keyboard().down("Shift");
|
28
|
+
# for (int i = 0; i < " World".length(); i++)
|
29
|
+
# page.keyboard().press("ArrowLeft");
|
30
|
+
# page.keyboard().up("Shift");
|
31
|
+
# page.keyboard().press("Backspace");
|
32
|
+
# // Result text will end up saying "Hello!"
|
33
|
+
# ```
|
34
|
+
#
|
24
35
|
# ```python async
|
25
36
|
# await page.keyboard.type("Hello World!")
|
26
37
|
# await page.keyboard.press("ArrowLeft")
|
@@ -52,6 +63,12 @@ module Playwright
|
|
52
63
|
# await page.keyboard.press('Shift+A');
|
53
64
|
# ```
|
54
65
|
#
|
66
|
+
# ```java
|
67
|
+
# page.keyboard().press("Shift+KeyA");
|
68
|
+
# // or
|
69
|
+
# page.keyboard().press("Shift+A");
|
70
|
+
# ```
|
71
|
+
#
|
55
72
|
# ```python async
|
56
73
|
# await page.keyboard.press("Shift+KeyA")
|
57
74
|
# # or
|
@@ -74,6 +91,13 @@ module Playwright
|
|
74
91
|
# await page.keyboard.press('Meta+A');
|
75
92
|
# ```
|
76
93
|
#
|
94
|
+
# ```java
|
95
|
+
# // on Windows and Linux
|
96
|
+
# page.keyboard().press("Control+A");
|
97
|
+
# // on macOS
|
98
|
+
# page.keyboard().press("Meta+A");
|
99
|
+
# ```
|
100
|
+
#
|
77
101
|
# ```python async
|
78
102
|
# # on windows and linux
|
79
103
|
# await page.keyboard.press("Control+A")
|
@@ -124,6 +148,10 @@ module Playwright
|
|
124
148
|
# page.keyboard.insertText('嗨');
|
125
149
|
# ```
|
126
150
|
#
|
151
|
+
# ```java
|
152
|
+
# page.keyboard().insertText("嗨");
|
153
|
+
# ```
|
154
|
+
#
|
127
155
|
# ```python async
|
128
156
|
# await page.keyboard.insert_text("嗨")
|
129
157
|
# ```
|
@@ -151,7 +179,7 @@ module Playwright
|
|
151
179
|
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
|
152
180
|
# texts.
|
153
181
|
#
|
154
|
-
# Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When
|
182
|
+
# Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
|
155
183
|
# modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
156
184
|
#
|
157
185
|
#
|
@@ -167,6 +195,18 @@ module Playwright
|
|
167
195
|
# await browser.close();
|
168
196
|
# ```
|
169
197
|
#
|
198
|
+
# ```java
|
199
|
+
# Page page = browser.newPage();
|
200
|
+
# page.navigate("https://keycode.info");
|
201
|
+
# page.keyboard().press("A");
|
202
|
+
# page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("A.png"));
|
203
|
+
# page.keyboard().press("ArrowLeft");
|
204
|
+
# page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("ArrowLeft.png")));
|
205
|
+
# page.keyboard().press("Shift+O");
|
206
|
+
# page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("O.png")));
|
207
|
+
# browser.close();
|
208
|
+
# ```
|
209
|
+
#
|
170
210
|
# ```python async
|
171
211
|
# page = await browser.new_page()
|
172
212
|
# await page.goto("https://keycode.info")
|
@@ -206,6 +246,13 @@ module Playwright
|
|
206
246
|
# await page.keyboard.type('World', {delay: 100}); // Types slower, like a user
|
207
247
|
# ```
|
208
248
|
#
|
249
|
+
# ```java
|
250
|
+
# // Types instantly
|
251
|
+
# page.keyboard().type("Hello");
|
252
|
+
# // Types slower, like a user
|
253
|
+
# page.keyboard().type("World", new Keyboard.TypeOptions().setDelay(100));
|
254
|
+
# ```
|
255
|
+
#
|
209
256
|
# ```python async
|
210
257
|
# await page.keyboard.type("Hello") # types instantly
|
211
258
|
# await page.keyboard.type("World", delay=100) # types slower, like a user
|