playwright-ruby-client 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/api_coverage.md +42 -45
- data/lib/playwright.rb +1 -0
- data/lib/playwright/channel_owners/browser_context.rb +9 -1
- data/lib/playwright/channel_owners/frame.rb +7 -0
- data/lib/playwright/channel_owners/page.rb +250 -0
- data/lib/playwright/channel_owners/request.rb +8 -0
- data/lib/playwright/event_emitter.rb +4 -1
- data/lib/playwright/http_headers.rb +20 -0
- data/lib/playwright/utils.rb +1 -1
- data/lib/playwright/version.rb +1 -1
- data/lib/playwright_api/android.rb +4 -4
- data/lib/playwright_api/android_device.rb +5 -5
- data/lib/playwright_api/android_input.rb +4 -4
- data/lib/playwright_api/browser.rb +5 -3
- data/lib/playwright_api/browser_context.rb +3 -29
- data/lib/playwright_api/browser_type.rb +3 -3
- data/lib/playwright_api/chromium_browser_context.rb +0 -2
- data/lib/playwright_api/dialog.rb +5 -1
- data/lib/playwright_api/element_handle.rb +89 -88
- data/lib/playwright_api/file_chooser.rb +13 -5
- data/lib/playwright_api/frame.rb +99 -100
- data/lib/playwright_api/js_handle.rb +11 -12
- data/lib/playwright_api/page.rb +140 -149
- data/lib/playwright_api/playwright.rb +10 -5
- data/lib/playwright_api/request.rb +5 -8
- data/lib/playwright_api/response.rb +0 -7
- data/lib/playwright_api/route.rb +1 -0
- data/lib/playwright_api/selectors.rb +2 -2
- data/lib/playwright_api/web_socket.rb +0 -6
- data/lib/playwright_api/worker.rb +13 -13
- metadata +3 -2
@@ -3,17 +3,25 @@ module Playwright
|
|
3
3
|
#
|
4
4
|
#
|
5
5
|
# ```js
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
6
|
+
# const [fileChooser] = await Promise.all([
|
7
|
+
# page.waitForEvent('filechooser'),
|
8
|
+
# page.click('upload')
|
9
|
+
# ]);
|
10
|
+
# await fileChooser.setFiles('myfile.pdf');
|
9
11
|
# ```
|
10
12
|
#
|
11
13
|
# ```python async
|
12
|
-
# page.
|
14
|
+
# async with page.expect_file_chooser() as fc_info:
|
15
|
+
# await page.click("upload")
|
16
|
+
# file_chooser = await fc_info.value
|
17
|
+
# await file_chooser.set_files("myfile.pdf")
|
13
18
|
# ```
|
14
19
|
#
|
15
20
|
# ```python sync
|
16
|
-
# page.
|
21
|
+
# with page.expect_file_chooser() as fc_info:
|
22
|
+
# page.click("upload")
|
23
|
+
# file_chooser = fc_info.value
|
24
|
+
# file_chooser.set_files("myfile.pdf")
|
17
25
|
# ```
|
18
26
|
class FileChooser < PlaywrightApi
|
19
27
|
|
data/lib/playwright_api/frame.rb
CHANGED
@@ -75,82 +75,6 @@ module Playwright
|
|
75
75
|
# ```
|
76
76
|
class Frame < PlaywrightApi
|
77
77
|
|
78
|
-
# Returns the ElementHandle pointing to the frame element.
|
79
|
-
#
|
80
|
-
# The method finds an element matching the specified selector within the frame. See
|
81
|
-
# [Working with selectors](./selectors.md#working-with-selectors) for more details. If no elements match the selector,
|
82
|
-
# returns `null`.
|
83
|
-
def query_selector(selector)
|
84
|
-
wrap_impl(@impl.query_selector(unwrap_impl(selector)))
|
85
|
-
end
|
86
|
-
|
87
|
-
# Returns the ElementHandles pointing to the frame elements.
|
88
|
-
#
|
89
|
-
# The method finds all elements matching the specified selector within the frame. See
|
90
|
-
# [Working with selectors](./selectors.md#working-with-selectors) for more details. If no elements match the selector,
|
91
|
-
# returns empty array.
|
92
|
-
def query_selector_all(selector)
|
93
|
-
wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
|
94
|
-
end
|
95
|
-
|
96
|
-
# Returns the return value of `pageFunction`
|
97
|
-
#
|
98
|
-
# The method finds an element matching the specified selector within the frame and passes it as a first argument to
|
99
|
-
# `pageFunction`. See [Working with selectors](./selectors.md#working-with-selectors) for more details. If no elements
|
100
|
-
# match the selector, the method throws an error.
|
101
|
-
#
|
102
|
-
# If `pageFunction` returns a [Promise], then `frame.$eval` would wait for the promise to resolve and return its value.
|
103
|
-
#
|
104
|
-
# Examples:
|
105
|
-
#
|
106
|
-
#
|
107
|
-
# ```js
|
108
|
-
# const searchValue = await frame.$eval('#search', el => el.value);
|
109
|
-
# const preloadHref = await frame.$eval('link[rel=preload]', el => el.href);
|
110
|
-
# const html = await frame.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
|
111
|
-
# ```
|
112
|
-
#
|
113
|
-
# ```python async
|
114
|
-
# search_value = await frame.eval_on_selector("#search", "el => el.value")
|
115
|
-
# preload_href = await frame.eval_on_selector("link[rel=preload]", "el => el.href")
|
116
|
-
# html = await frame.eval_on_selector(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello")
|
117
|
-
# ```
|
118
|
-
#
|
119
|
-
# ```python sync
|
120
|
-
# search_value = frame.eval_on_selector("#search", "el => el.value")
|
121
|
-
# preload_href = frame.eval_on_selector("link[rel=preload]", "el => el.href")
|
122
|
-
# html = frame.eval_on_selector(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello")
|
123
|
-
# ```
|
124
|
-
def eval_on_selector(selector, pageFunction, arg: nil)
|
125
|
-
wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(pageFunction), arg: unwrap_impl(arg)))
|
126
|
-
end
|
127
|
-
|
128
|
-
# Returns the return value of `pageFunction`
|
129
|
-
#
|
130
|
-
# The method finds all elements matching the specified selector within the frame and passes an array of matched elements
|
131
|
-
# as a first argument to `pageFunction`. See [Working with selectors](./selectors.md#working-with-selectors) for more
|
132
|
-
# details.
|
133
|
-
#
|
134
|
-
# If `pageFunction` returns a [Promise], then `frame.$$eval` would wait for the promise to resolve and return its value.
|
135
|
-
#
|
136
|
-
# Examples:
|
137
|
-
#
|
138
|
-
#
|
139
|
-
# ```js
|
140
|
-
# const divsCounts = await frame.$$eval('div', (divs, min) => divs.length >= min, 10);
|
141
|
-
# ```
|
142
|
-
#
|
143
|
-
# ```python async
|
144
|
-
# divs_counts = await frame.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
145
|
-
# ```
|
146
|
-
#
|
147
|
-
# ```python sync
|
148
|
-
# divs_counts = frame.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
149
|
-
# ```
|
150
|
-
def eval_on_selector_all(selector, pageFunction, arg: nil)
|
151
|
-
wrap_impl(@impl.eval_on_selector_all(unwrap_impl(selector), unwrap_impl(pageFunction), arg: unwrap_impl(arg)))
|
152
|
-
end
|
153
|
-
|
154
78
|
# Returns the added tag when the script's onload fires or when the script content was injected into frame.
|
155
79
|
#
|
156
80
|
# Adds a `<script>` tag into the page with the desired url or content.
|
@@ -293,14 +217,73 @@ module Playwright
|
|
293
217
|
wrap_impl(@impl.dispatch_event(unwrap_impl(selector), unwrap_impl(type), eventInit: unwrap_impl(eventInit), timeout: unwrap_impl(timeout)))
|
294
218
|
end
|
295
219
|
|
296
|
-
# Returns the return value of `
|
220
|
+
# Returns the return value of `expression`.
|
221
|
+
#
|
222
|
+
# The method finds an element matching the specified selector within the frame and passes it as a first argument to
|
223
|
+
# `expression`. See [Working with selectors](./selectors.md) for more details. If no elements match the selector, the
|
224
|
+
# method throws an error.
|
225
|
+
#
|
226
|
+
# If `expression` returns a [Promise], then [`method: Frame.evalOnSelector`] would wait for the promise to resolve and
|
227
|
+
# return its value.
|
228
|
+
#
|
229
|
+
# Examples:
|
230
|
+
#
|
231
|
+
#
|
232
|
+
# ```js
|
233
|
+
# const searchValue = await frame.$eval('#search', el => el.value);
|
234
|
+
# const preloadHref = await frame.$eval('link[rel=preload]', el => el.href);
|
235
|
+
# const html = await frame.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
|
236
|
+
# ```
|
237
|
+
#
|
238
|
+
# ```python async
|
239
|
+
# search_value = await frame.eval_on_selector("#search", "el => el.value")
|
240
|
+
# preload_href = await frame.eval_on_selector("link[rel=preload]", "el => el.href")
|
241
|
+
# html = await frame.eval_on_selector(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello")
|
242
|
+
# ```
|
243
|
+
#
|
244
|
+
# ```python sync
|
245
|
+
# search_value = frame.eval_on_selector("#search", "el => el.value")
|
246
|
+
# preload_href = frame.eval_on_selector("link[rel=preload]", "el => el.href")
|
247
|
+
# html = frame.eval_on_selector(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello")
|
248
|
+
# ```
|
249
|
+
def eval_on_selector(selector, expression, arg: nil)
|
250
|
+
wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
|
251
|
+
end
|
252
|
+
|
253
|
+
# Returns the return value of `expression`.
|
254
|
+
#
|
255
|
+
# The method finds all elements matching the specified selector within the frame and passes an array of matched elements
|
256
|
+
# as a first argument to `expression`. See [Working with selectors](./selectors.md) for more details.
|
257
|
+
#
|
258
|
+
# If `expression` returns a [Promise], then [`method: Frame.evalOnSelectorAll`] would wait for the promise to resolve and
|
259
|
+
# return its value.
|
260
|
+
#
|
261
|
+
# Examples:
|
262
|
+
#
|
263
|
+
#
|
264
|
+
# ```js
|
265
|
+
# const divsCounts = await frame.$$eval('div', (divs, min) => divs.length >= min, 10);
|
266
|
+
# ```
|
267
|
+
#
|
268
|
+
# ```python async
|
269
|
+
# divs_counts = await frame.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
270
|
+
# ```
|
271
|
+
#
|
272
|
+
# ```python sync
|
273
|
+
# divs_counts = frame.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
274
|
+
# ```
|
275
|
+
def eval_on_selector_all(selector, expression, arg: nil)
|
276
|
+
wrap_impl(@impl.eval_on_selector_all(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
|
277
|
+
end
|
278
|
+
|
279
|
+
# Returns the return value of `expression`.
|
297
280
|
#
|
298
281
|
# If the function passed to the [`method: Frame.evaluate`] returns a [Promise], then [`method: Frame.evaluate`] would wait
|
299
282
|
# for the promise to resolve and return its value.
|
300
283
|
#
|
301
|
-
# If the function passed to the [`method: Frame.evaluate`] returns a non-[Serializable] value,
|
302
|
-
#
|
303
|
-
#
|
284
|
+
# If the function passed to the [`method: Frame.evaluate`] returns a non-[Serializable] value, then
|
285
|
+
# [`method: Frame.evaluate`] returns `undefined`. Playwright also supports transferring some additional values that are
|
286
|
+
# not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
|
304
287
|
#
|
305
288
|
#
|
306
289
|
# ```js
|
@@ -359,17 +342,17 @@ module Playwright
|
|
359
342
|
# html = frame.evaluate("([body, suffix]) => body.innerHTML + suffix", [body_handle, "hello"])
|
360
343
|
# body_handle.dispose()
|
361
344
|
# ```
|
362
|
-
def evaluate(
|
363
|
-
wrap_impl(@impl.evaluate(unwrap_impl(
|
345
|
+
def evaluate(expression, arg: nil)
|
346
|
+
wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
364
347
|
end
|
365
348
|
|
366
|
-
# Returns the return value of `
|
349
|
+
# Returns the return value of `expression` as a `JSHandle`.
|
367
350
|
#
|
368
|
-
# The only difference between [`method: Frame.evaluate`] and [`method: Frame.evaluateHandle`] is
|
369
|
-
#
|
351
|
+
# The only difference between [`method: Frame.evaluate`] and [`method: Frame.evaluateHandle`] is that
|
352
|
+
# [method: Frame.evaluateHandle`] returns `JSHandle`.
|
370
353
|
#
|
371
|
-
# If the function, passed to the [`method: Frame.evaluateHandle`], returns a [Promise],
|
372
|
-
#
|
354
|
+
# If the function, passed to the [`method: Frame.evaluateHandle`], returns a [Promise], then
|
355
|
+
# [`method: Frame.evaluateHandle`] would wait for the promise to resolve and return its value.
|
373
356
|
#
|
374
357
|
#
|
375
358
|
# ```js
|
@@ -378,7 +361,6 @@ module Playwright
|
|
378
361
|
# ```
|
379
362
|
#
|
380
363
|
# ```python async
|
381
|
-
# # FIXME
|
382
364
|
# a_window_handle = await frame.evaluate_handle("Promise.resolve(window)")
|
383
365
|
# a_window_handle # handle for the window object.
|
384
366
|
# ```
|
@@ -426,14 +408,15 @@ module Playwright
|
|
426
408
|
# print(result_handle.json_value())
|
427
409
|
# result_handle.dispose()
|
428
410
|
# ```
|
429
|
-
def evaluate_handle(
|
430
|
-
wrap_impl(@impl.evaluate_handle(unwrap_impl(
|
411
|
+
def evaluate_handle(expression, arg: nil)
|
412
|
+
wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
431
413
|
end
|
432
414
|
|
433
415
|
# This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the
|
434
|
-
# element, fills it and triggers an `input` event after filling. If the element
|
435
|
-
#
|
436
|
-
#
|
416
|
+
# element, fills it and triggers an `input` event after filling. If the element is inside the `<label>` element that has
|
417
|
+
# associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), that control will be
|
418
|
+
# filled instead. If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this
|
419
|
+
# method throws an error. Note that you can pass an empty string to clear the input field.
|
437
420
|
#
|
438
421
|
# To send fine-grained keyboard events, use [`method: Frame.type`].
|
439
422
|
def fill(selector, value, noWaitAfter: nil, timeout: nil)
|
@@ -610,6 +593,22 @@ module Playwright
|
|
610
593
|
wrap_impl(@impl.press(unwrap_impl(selector), unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
611
594
|
end
|
612
595
|
|
596
|
+
# Returns the ElementHandle pointing to the frame element.
|
597
|
+
#
|
598
|
+
# The method finds an element matching the specified selector within the frame. See
|
599
|
+
# [Working with selectors](./selectors.md) for more details. If no elements match the selector, returns `null`.
|
600
|
+
def query_selector(selector)
|
601
|
+
wrap_impl(@impl.query_selector(unwrap_impl(selector)))
|
602
|
+
end
|
603
|
+
|
604
|
+
# Returns the ElementHandles pointing to the frame elements.
|
605
|
+
#
|
606
|
+
# The method finds all elements matching the specified selector within the frame. See
|
607
|
+
# [Working with selectors](./selectors.md) for more details. If no elements match the selector, returns empty array.
|
608
|
+
def query_selector_all(selector)
|
609
|
+
wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
|
610
|
+
end
|
611
|
+
|
613
612
|
# Returns the array of option values that have been successfully selected.
|
614
613
|
#
|
615
614
|
# Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
|
@@ -747,9 +746,9 @@ module Playwright
|
|
747
746
|
wrap_impl(@impl.url)
|
748
747
|
end
|
749
748
|
|
750
|
-
# Returns when the `
|
749
|
+
# Returns when the `expression` returns a truthy value, returns that value.
|
751
750
|
#
|
752
|
-
# The `waitForFunction` can be used to observe viewport size change:
|
751
|
+
# The [`method: Frame.waitForFunction`] can be used to observe viewport size change:
|
753
752
|
#
|
754
753
|
#
|
755
754
|
# ```js
|
@@ -773,7 +772,7 @@ module Playwright
|
|
773
772
|
# webkit = playwright.webkit
|
774
773
|
# browser = await webkit.launch()
|
775
774
|
# page = await browser.new_page()
|
776
|
-
# await page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);"
|
775
|
+
# await page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);")
|
777
776
|
# await page.main_frame.wait_for_function("() => window.x > 0")
|
778
777
|
# await browser.close()
|
779
778
|
#
|
@@ -790,7 +789,7 @@ module Playwright
|
|
790
789
|
# webkit = playwright.webkit
|
791
790
|
# browser = webkit.launch()
|
792
791
|
# page = browser.new_page()
|
793
|
-
# page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);"
|
792
|
+
# page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);")
|
794
793
|
# page.main_frame.wait_for_function("() => window.x > 0")
|
795
794
|
# browser.close()
|
796
795
|
#
|
@@ -815,8 +814,8 @@ module Playwright
|
|
815
814
|
# selector = ".foo"
|
816
815
|
# frame.wait_for_function("selector => !!document.querySelector(selector)", selector)
|
817
816
|
# ```
|
818
|
-
def wait_for_function(
|
819
|
-
wrap_impl(@impl.wait_for_function(unwrap_impl(
|
817
|
+
def wait_for_function(expression, arg: nil, polling: nil, timeout: nil)
|
818
|
+
wrap_impl(@impl.wait_for_function(unwrap_impl(expression), arg: unwrap_impl(arg), polling: unwrap_impl(polling), timeout: unwrap_impl(timeout)))
|
820
819
|
end
|
821
820
|
|
822
821
|
# Waits for the required load state to be reached.
|
@@ -938,7 +937,7 @@ module Playwright
|
|
938
937
|
# run(playwright)
|
939
938
|
# ```
|
940
939
|
def wait_for_selector(selector, state: nil, timeout: nil)
|
941
|
-
|
940
|
+
wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
|
942
941
|
end
|
943
942
|
|
944
943
|
# Waits for the given `timeout` in milliseconds.
|
@@ -22,7 +22,7 @@ module Playwright
|
|
22
22
|
# [`method: JSHandle.dispose`]. JSHandles are auto-disposed when their origin frame gets navigated or the parent context
|
23
23
|
# gets destroyed.
|
24
24
|
#
|
25
|
-
# JSHandle instances can be used as an argument in [`method: Page
|
25
|
+
# JSHandle instances can be used as an argument in [`method: Page.evalOnSelector`], [`method: Page.evaluate`] and
|
26
26
|
# [`method: Page.evaluateHandle`] methods.
|
27
27
|
class JSHandle < PlaywrightApi
|
28
28
|
|
@@ -36,12 +36,11 @@ module Playwright
|
|
36
36
|
wrap_impl(@impl.dispose)
|
37
37
|
end
|
38
38
|
|
39
|
-
# Returns the return value of `
|
39
|
+
# Returns the return value of `expression`.
|
40
40
|
#
|
41
|
-
# This method passes this handle as the first argument to `
|
41
|
+
# This method passes this handle as the first argument to `expression`.
|
42
42
|
#
|
43
|
-
# If `
|
44
|
-
# value.
|
43
|
+
# If `expression` returns a [Promise], then `handle.evaluate` would wait for the promise to resolve and return its value.
|
45
44
|
#
|
46
45
|
# Examples:
|
47
46
|
#
|
@@ -60,23 +59,23 @@ module Playwright
|
|
60
59
|
# tweet_handle = page.query_selector(".tweet .retweets")
|
61
60
|
# assert tweet_handle.evaluate("node => node.innerText") == "10 retweets"
|
62
61
|
# ```
|
63
|
-
def evaluate(
|
64
|
-
wrap_impl(@impl.evaluate(unwrap_impl(
|
62
|
+
def evaluate(expression, arg: nil)
|
63
|
+
wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
65
64
|
end
|
66
65
|
|
67
|
-
# Returns the return value of `
|
66
|
+
# Returns the return value of `expression` as a `JSHandle`.
|
68
67
|
#
|
69
|
-
# This method passes this handle as the first argument to `
|
68
|
+
# This method passes this handle as the first argument to `expression`.
|
70
69
|
#
|
71
70
|
# The only difference between `jsHandle.evaluate` and `jsHandle.evaluateHandle` is that `jsHandle.evaluateHandle` returns
|
72
|
-
#
|
71
|
+
# `JSHandle`.
|
73
72
|
#
|
74
73
|
# If the function passed to the `jsHandle.evaluateHandle` returns a [Promise], then `jsHandle.evaluateHandle` would wait
|
75
74
|
# for the promise to resolve and return its value.
|
76
75
|
#
|
77
76
|
# See [`method: Page.evaluateHandle`] for more details.
|
78
|
-
def evaluate_handle(
|
79
|
-
wrap_impl(@impl.evaluate_handle(unwrap_impl(
|
77
|
+
def evaluate_handle(expression, arg: nil)
|
78
|
+
wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
80
79
|
end
|
81
80
|
|
82
81
|
# The method returns a map with **own property names** as keys and JSHandle instances for the property values.
|
data/lib/playwright_api/page.rb
CHANGED
@@ -2,8 +2,8 @@ module Playwright
|
|
2
2
|
# - extends: [EventEmitter]
|
3
3
|
#
|
4
4
|
# Page provides methods to interact with a single tab in a `Browser`, or an
|
5
|
-
# [extension background page](https://developer.chrome.com/extensions/background_pages) in Chromium. One
|
6
|
-
# instance might have multiple
|
5
|
+
# [extension background page](https://developer.chrome.com/extensions/background_pages) in Chromium. One `Browser`
|
6
|
+
# instance might have multiple `Page` instances.
|
7
7
|
#
|
8
8
|
# This example creates a page, navigates it to a URL, and then saves a screenshot:
|
9
9
|
#
|
@@ -114,78 +114,6 @@ module Playwright
|
|
114
114
|
wrap_impl(@impl.touchscreen)
|
115
115
|
end
|
116
116
|
|
117
|
-
# The method finds an element matching the specified selector within the page. If no elements match the selector, the
|
118
|
-
# return value resolves to `null`.
|
119
|
-
#
|
120
|
-
# Shortcut for main frame's [`method: Frame.$`].
|
121
|
-
def query_selector(selector)
|
122
|
-
wrap_impl(@impl.query_selector(unwrap_impl(selector)))
|
123
|
-
end
|
124
|
-
|
125
|
-
# The method finds all elements matching the specified selector within the page. If no elements match the selector, the
|
126
|
-
# return value resolves to `[]`.
|
127
|
-
#
|
128
|
-
# Shortcut for main frame's [`method: Frame.$$`].
|
129
|
-
def query_selector_all(selector)
|
130
|
-
wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
|
131
|
-
end
|
132
|
-
|
133
|
-
# The method finds an element matching the specified selector within the page and passes it as a first argument to
|
134
|
-
# `pageFunction`. If no elements match the selector, the method throws an error. Returns the value of `pageFunction`.
|
135
|
-
#
|
136
|
-
# If `pageFunction` returns a [Promise], then [`method: Page.$eval`] would wait for the promise to resolve and return its
|
137
|
-
# value.
|
138
|
-
#
|
139
|
-
# Examples:
|
140
|
-
#
|
141
|
-
#
|
142
|
-
# ```js
|
143
|
-
# const searchValue = await page.$eval('#search', el => el.value);
|
144
|
-
# const preloadHref = await page.$eval('link[rel=preload]', el => el.href);
|
145
|
-
# const html = await page.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
|
146
|
-
# ```
|
147
|
-
#
|
148
|
-
# ```python async
|
149
|
-
# search_value = await page.eval_on_selector("#search", "el => el.value")
|
150
|
-
# preload_href = await page.eval_on_selector("link[rel=preload]", "el => el.href")
|
151
|
-
# html = await page.eval_on_selector(".main-container", "(e, suffix) => e.outer_html + suffix", "hello")
|
152
|
-
# ```
|
153
|
-
#
|
154
|
-
# ```python sync
|
155
|
-
# search_value = page.eval_on_selector("#search", "el => el.value")
|
156
|
-
# preload_href = page.eval_on_selector("link[rel=preload]", "el => el.href")
|
157
|
-
# html = page.eval_on_selector(".main-container", "(e, suffix) => e.outer_html + suffix", "hello")
|
158
|
-
# ```
|
159
|
-
#
|
160
|
-
# Shortcut for main frame's [`method: Frame.$eval`].
|
161
|
-
def eval_on_selector(selector, pageFunction, arg: nil)
|
162
|
-
wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(pageFunction), arg: unwrap_impl(arg)))
|
163
|
-
end
|
164
|
-
|
165
|
-
# The method finds all elements matching the specified selector within the page and passes an array of matched elements as
|
166
|
-
# a first argument to `pageFunction`. Returns the result of `pageFunction` invocation.
|
167
|
-
#
|
168
|
-
# If `pageFunction` returns a [Promise], then [`method: Page.$$eval`] would wait for the promise to resolve and return its
|
169
|
-
# value.
|
170
|
-
#
|
171
|
-
# Examples:
|
172
|
-
#
|
173
|
-
#
|
174
|
-
# ```js
|
175
|
-
# const divCounts = await page.$$eval('div', (divs, min) => divs.length >= min, 10);
|
176
|
-
# ```
|
177
|
-
#
|
178
|
-
# ```python async
|
179
|
-
# div_counts = await page.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
180
|
-
# ```
|
181
|
-
#
|
182
|
-
# ```python sync
|
183
|
-
# div_counts = page.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
184
|
-
# ```
|
185
|
-
def eval_on_selector_all(selector, pageFunction, arg: nil)
|
186
|
-
wrap_impl(@impl.eval_on_selector_all(unwrap_impl(selector), unwrap_impl(pageFunction), arg: unwrap_impl(arg)))
|
187
|
-
end
|
188
|
-
|
189
117
|
# Adds a script which would be evaluated in one of the following scenarios:
|
190
118
|
# - Whenever the page is navigated.
|
191
119
|
# - Whenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly
|
@@ -221,7 +149,7 @@ module Playwright
|
|
221
149
|
# > NOTE: The order of evaluation of multiple scripts installed via [`method: BrowserContext.addInitScript`] and
|
222
150
|
# [`method: Page.addInitScript`] is not defined.
|
223
151
|
def add_init_script(script, arg: nil)
|
224
|
-
|
152
|
+
wrap_impl(@impl.add_init_script(unwrap_impl(script), arg: unwrap_impl(arg)))
|
225
153
|
end
|
226
154
|
|
227
155
|
# Adds a `<script>` tag into the page with the desired url or content. Returns the added tag when the script's onload
|
@@ -242,7 +170,7 @@ module Playwright
|
|
242
170
|
|
243
171
|
# Brings page to front (activates tab).
|
244
172
|
def bring_to_front
|
245
|
-
|
173
|
+
wrap_impl(@impl.bring_to_front)
|
246
174
|
end
|
247
175
|
|
248
176
|
# This method checks an element matching `selector` by performing the following steps:
|
@@ -261,7 +189,7 @@ module Playwright
|
|
261
189
|
#
|
262
190
|
# Shortcut for main frame's [`method: Frame.check`].
|
263
191
|
def check(selector, force: nil, noWaitAfter: nil, timeout: nil)
|
264
|
-
|
192
|
+
wrap_impl(@impl.check(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
265
193
|
end
|
266
194
|
|
267
195
|
# This method clicks an element matching `selector` by performing the following steps:
|
@@ -387,7 +315,7 @@ module Playwright
|
|
387
315
|
# page.dispatch_event("#source", "dragstart", { "dataTransfer": data_transfer })
|
388
316
|
# ```
|
389
317
|
def dispatch_event(selector, type, eventInit: nil, timeout: nil)
|
390
|
-
|
318
|
+
wrap_impl(@impl.dispatch_event(unwrap_impl(selector), unwrap_impl(type), eventInit: unwrap_impl(eventInit), timeout: unwrap_impl(timeout)))
|
391
319
|
end
|
392
320
|
|
393
321
|
#
|
@@ -478,20 +406,76 @@ module Playwright
|
|
478
406
|
# # → False
|
479
407
|
# page.evaluate("matchMedia('(prefers-color-scheme: no-preference)').matches")
|
480
408
|
# ```
|
481
|
-
def emulate_media(
|
482
|
-
|
409
|
+
def emulate_media(colorScheme: nil, media: nil)
|
410
|
+
wrap_impl(@impl.emulate_media(colorScheme: unwrap_impl(colorScheme), media: unwrap_impl(media)))
|
411
|
+
end
|
412
|
+
|
413
|
+
# The method finds an element matching the specified selector within the page and passes it as a first argument to
|
414
|
+
# `expression`. If no elements match the selector, the method throws an error. Returns the value of `expression`.
|
415
|
+
#
|
416
|
+
# If `expression` returns a [Promise], then [`method: Page.evalOnSelector`] would wait for the promise to resolve and
|
417
|
+
# return its value.
|
418
|
+
#
|
419
|
+
# Examples:
|
420
|
+
#
|
421
|
+
#
|
422
|
+
# ```js
|
423
|
+
# const searchValue = await page.$eval('#search', el => el.value);
|
424
|
+
# const preloadHref = await page.$eval('link[rel=preload]', el => el.href);
|
425
|
+
# const html = await page.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
|
426
|
+
# ```
|
427
|
+
#
|
428
|
+
# ```python async
|
429
|
+
# search_value = await page.eval_on_selector("#search", "el => el.value")
|
430
|
+
# preload_href = await page.eval_on_selector("link[rel=preload]", "el => el.href")
|
431
|
+
# html = await page.eval_on_selector(".main-container", "(e, suffix) => e.outer_html + suffix", "hello")
|
432
|
+
# ```
|
433
|
+
#
|
434
|
+
# ```python sync
|
435
|
+
# search_value = page.eval_on_selector("#search", "el => el.value")
|
436
|
+
# preload_href = page.eval_on_selector("link[rel=preload]", "el => el.href")
|
437
|
+
# html = page.eval_on_selector(".main-container", "(e, suffix) => e.outer_html + suffix", "hello")
|
438
|
+
# ```
|
439
|
+
#
|
440
|
+
# Shortcut for main frame's [`method: Frame.evalOnSelector`].
|
441
|
+
def eval_on_selector(selector, expression, arg: nil)
|
442
|
+
wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
|
443
|
+
end
|
444
|
+
|
445
|
+
# The method finds all elements matching the specified selector within the page and passes an array of matched elements as
|
446
|
+
# a first argument to `expression`. Returns the result of `expression` invocation.
|
447
|
+
#
|
448
|
+
# If `expression` returns a [Promise], then [`method: Page.evalOnSelectorAll`] would wait for the promise to resolve and
|
449
|
+
# return its value.
|
450
|
+
#
|
451
|
+
# Examples:
|
452
|
+
#
|
453
|
+
#
|
454
|
+
# ```js
|
455
|
+
# const divCounts = await page.$$eval('div', (divs, min) => divs.length >= min, 10);
|
456
|
+
# ```
|
457
|
+
#
|
458
|
+
# ```python async
|
459
|
+
# div_counts = await page.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
460
|
+
# ```
|
461
|
+
#
|
462
|
+
# ```python sync
|
463
|
+
# div_counts = page.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
|
464
|
+
# ```
|
465
|
+
def eval_on_selector_all(selector, expression, arg: nil)
|
466
|
+
wrap_impl(@impl.eval_on_selector_all(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
|
483
467
|
end
|
484
468
|
|
485
|
-
# Returns the value of the `
|
469
|
+
# Returns the value of the `expression` invocation.
|
486
470
|
#
|
487
471
|
# If the function passed to the [`method: Page.evaluate`] returns a [Promise], then [`method: Page.evaluate`] would wait
|
488
472
|
# for the promise to resolve and return its value.
|
489
473
|
#
|
490
|
-
# If the function passed to the [`method: Page.evaluate`] returns a non-[Serializable] value,
|
491
|
-
#
|
492
|
-
#
|
474
|
+
# If the function passed to the [`method: Page.evaluate`] returns a non-[Serializable] value, then
|
475
|
+
# [`method: Page.evaluate`] resolves to `undefined`. Playwright also supports transferring some additional values that are
|
476
|
+
# not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
|
493
477
|
#
|
494
|
-
# Passing argument to `
|
478
|
+
# Passing argument to `expression`:
|
495
479
|
#
|
496
480
|
#
|
497
481
|
# ```js
|
@@ -554,14 +538,14 @@ module Playwright
|
|
554
538
|
# ```
|
555
539
|
#
|
556
540
|
# Shortcut for main frame's [`method: Frame.evaluate`].
|
557
|
-
def evaluate(
|
558
|
-
wrap_impl(@impl.evaluate(unwrap_impl(
|
541
|
+
def evaluate(expression, arg: nil)
|
542
|
+
wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
559
543
|
end
|
560
544
|
|
561
|
-
# Returns the value of the `
|
545
|
+
# Returns the value of the `expression` invocation as a `JSHandle`.
|
562
546
|
#
|
563
547
|
# The only difference between [`method: Page.evaluate`] and [`method: Page.evaluateHandle`] is that
|
564
|
-
# [`method: Page.evaluateHandle`] returns
|
548
|
+
# [`method: Page.evaluateHandle`] returns `JSHandle`.
|
565
549
|
#
|
566
550
|
# If the function passed to the [`method: Page.evaluateHandle`] returns a [Promise], then [`method: Page.evaluateHandle`]
|
567
551
|
# would wait for the promise to resolve and return its value.
|
@@ -573,7 +557,6 @@ module Playwright
|
|
573
557
|
# ```
|
574
558
|
#
|
575
559
|
# ```python async
|
576
|
-
# # FIXME
|
577
560
|
# a_window_handle = await page.evaluate_handle("Promise.resolve(window)")
|
578
561
|
# a_window_handle # handle for the window object.
|
579
562
|
# ```
|
@@ -621,8 +604,8 @@ module Playwright
|
|
621
604
|
# print(result_handle.json_value())
|
622
605
|
# result_handle.dispose()
|
623
606
|
# ```
|
624
|
-
def evaluate_handle(
|
625
|
-
wrap_impl(@impl.evaluate_handle(unwrap_impl(
|
607
|
+
def evaluate_handle(expression, arg: nil)
|
608
|
+
wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
626
609
|
end
|
627
610
|
|
628
611
|
# The method adds a function called `name` on the `window` object of every frame in this page. When called, the function
|
@@ -755,7 +738,7 @@ module Playwright
|
|
755
738
|
# """)
|
756
739
|
# ```
|
757
740
|
def expose_binding(name, callback, handle: nil)
|
758
|
-
|
741
|
+
wrap_impl(@impl.expose_binding(unwrap_impl(name), unwrap_impl(callback), handle: unwrap_impl(handle)))
|
759
742
|
end
|
760
743
|
|
761
744
|
# The method adds a function called `name` on the `window` object of every frame in the page. When called, the function
|
@@ -854,13 +837,14 @@ module Playwright
|
|
854
837
|
# run(playwright)
|
855
838
|
# ```
|
856
839
|
def expose_function(name, callback)
|
857
|
-
|
840
|
+
wrap_impl(@impl.expose_function(unwrap_impl(name), unwrap_impl(callback)))
|
858
841
|
end
|
859
842
|
|
860
843
|
# This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the
|
861
|
-
# element, fills it and triggers an `input` event after filling. If the element
|
862
|
-
#
|
863
|
-
#
|
844
|
+
# element, fills it and triggers an `input` event after filling. If the element is inside the `<label>` element that has
|
845
|
+
# associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), that control will be
|
846
|
+
# filled instead. If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this
|
847
|
+
# method throws an error. Note that you can pass an empty string to clear the input field.
|
864
848
|
#
|
865
849
|
# To send fine-grained keyboard events, use [`method: Page.type`].
|
866
850
|
#
|
@@ -907,7 +891,7 @@ module Playwright
|
|
907
891
|
|
908
892
|
# Returns element attribute value.
|
909
893
|
def get_attribute(selector, name, timeout: nil)
|
910
|
-
|
894
|
+
wrap_impl(@impl.get_attribute(unwrap_impl(selector), unwrap_impl(name), timeout: unwrap_impl(timeout)))
|
911
895
|
end
|
912
896
|
|
913
897
|
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
@@ -915,7 +899,7 @@ module Playwright
|
|
915
899
|
#
|
916
900
|
# Navigate to the previous page in history.
|
917
901
|
def go_back(timeout: nil, waitUntil: nil)
|
918
|
-
|
902
|
+
wrap_impl(@impl.go_back(timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
|
919
903
|
end
|
920
904
|
|
921
905
|
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
@@ -923,7 +907,7 @@ module Playwright
|
|
923
907
|
#
|
924
908
|
# Navigate to the next page in history.
|
925
909
|
def go_forward(timeout: nil, waitUntil: nil)
|
926
|
-
|
910
|
+
wrap_impl(@impl.go_forward(timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
|
927
911
|
end
|
928
912
|
|
929
913
|
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
@@ -968,22 +952,22 @@ module Playwright
|
|
968
952
|
modifiers: nil,
|
969
953
|
position: nil,
|
970
954
|
timeout: nil)
|
971
|
-
|
955
|
+
wrap_impl(@impl.hover(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
|
972
956
|
end
|
973
957
|
|
974
958
|
# Returns `element.innerHTML`.
|
975
959
|
def inner_html(selector, timeout: nil)
|
976
|
-
|
960
|
+
wrap_impl(@impl.inner_html(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
977
961
|
end
|
978
962
|
|
979
963
|
# Returns `element.innerText`.
|
980
964
|
def inner_text(selector, timeout: nil)
|
981
|
-
|
965
|
+
wrap_impl(@impl.inner_text(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
982
966
|
end
|
983
967
|
|
984
968
|
# Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
|
985
969
|
def checked?(selector, timeout: nil)
|
986
|
-
|
970
|
+
wrap_impl(@impl.checked?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
987
971
|
end
|
988
972
|
|
989
973
|
# Indicates that the page has been closed.
|
@@ -993,27 +977,27 @@ module Playwright
|
|
993
977
|
|
994
978
|
# Returns whether the element is disabled, the opposite of [enabled](./actionability.md#enabled).
|
995
979
|
def disabled?(selector, timeout: nil)
|
996
|
-
|
980
|
+
wrap_impl(@impl.disabled?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
997
981
|
end
|
998
982
|
|
999
983
|
# Returns whether the element is [editable](./actionability.md#editable).
|
1000
984
|
def editable?(selector, timeout: nil)
|
1001
|
-
|
985
|
+
wrap_impl(@impl.editable?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
1002
986
|
end
|
1003
987
|
|
1004
988
|
# Returns whether the element is [enabled](./actionability.md#enabled).
|
1005
989
|
def enabled?(selector, timeout: nil)
|
1006
|
-
|
990
|
+
wrap_impl(@impl.enabled?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
1007
991
|
end
|
1008
992
|
|
1009
993
|
# Returns whether the element is hidden, the opposite of [visible](./actionability.md#visible).
|
1010
994
|
def hidden?(selector, timeout: nil)
|
1011
|
-
|
995
|
+
wrap_impl(@impl.hidden?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
1012
996
|
end
|
1013
997
|
|
1014
998
|
# Returns whether the element is [visible](./actionability.md#visible).
|
1015
999
|
def visible?(selector, timeout: nil)
|
1016
|
-
|
1000
|
+
wrap_impl(@impl.visible?(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
1017
1001
|
end
|
1018
1002
|
|
1019
1003
|
# The page's main frame. Page is guaranteed to have a main frame which persists during navigations.
|
@@ -1026,6 +1010,18 @@ module Playwright
|
|
1026
1010
|
wrap_impl(@impl.opener)
|
1027
1011
|
end
|
1028
1012
|
|
1013
|
+
# Pauses script execution. Playwright will stop executing the script and wait for the user to either press 'Resume' button
|
1014
|
+
# in the page overlay or to call `playwright.resume()` in the DevTools console.
|
1015
|
+
#
|
1016
|
+
# User can inspect selectors or perform manual steps while paused. Resume will continue running the original script from
|
1017
|
+
# the place it was paused.
|
1018
|
+
#
|
1019
|
+
# > NOTE: This method requires Playwright to be started in a headed mode, with a falsy [`options: headless`] value in the
|
1020
|
+
# [`method: BrowserType.launch`].
|
1021
|
+
def pause
|
1022
|
+
raise NotImplementedError.new('pause is not implemented yet.')
|
1023
|
+
end
|
1024
|
+
|
1029
1025
|
# Returns the PDF buffer.
|
1030
1026
|
#
|
1031
1027
|
# > NOTE: Generating a pdf is currently only supported in Chromium headless.
|
@@ -1098,7 +1094,7 @@ module Playwright
|
|
1098
1094
|
printBackground: nil,
|
1099
1095
|
scale: nil,
|
1100
1096
|
width: nil)
|
1101
|
-
|
1097
|
+
wrap_impl(@impl.pdf(displayHeaderFooter: unwrap_impl(displayHeaderFooter), footerTemplate: unwrap_impl(footerTemplate), format: unwrap_impl(format), headerTemplate: unwrap_impl(headerTemplate), height: unwrap_impl(height), landscape: unwrap_impl(landscape), margin: unwrap_impl(margin), pageRanges: unwrap_impl(pageRanges), path: unwrap_impl(path), preferCSSPageSize: unwrap_impl(preferCSSPageSize), printBackground: unwrap_impl(printBackground), scale: unwrap_impl(scale), width: unwrap_impl(width)))
|
1102
1098
|
end
|
1103
1099
|
|
1104
1100
|
# Focuses the element, and then uses [`method: Keyboard.down`] and [`method: Keyboard.up`].
|
@@ -1165,6 +1161,22 @@ module Playwright
|
|
1165
1161
|
wrap_impl(@impl.press(unwrap_impl(selector), unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
1166
1162
|
end
|
1167
1163
|
|
1164
|
+
# The method finds an element matching the specified selector within the page. If no elements match the selector, the
|
1165
|
+
# return value resolves to `null`.
|
1166
|
+
#
|
1167
|
+
# Shortcut for main frame's [`method: Frame.querySelector`].
|
1168
|
+
def query_selector(selector)
|
1169
|
+
wrap_impl(@impl.query_selector(unwrap_impl(selector)))
|
1170
|
+
end
|
1171
|
+
|
1172
|
+
# The method finds all elements matching the specified selector within the page. If no elements match the selector, the
|
1173
|
+
# return value resolves to `[]`.
|
1174
|
+
#
|
1175
|
+
# Shortcut for main frame's [`method: Frame.querySelectorAll`].
|
1176
|
+
def query_selector_all(selector)
|
1177
|
+
wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
|
1178
|
+
end
|
1179
|
+
|
1168
1180
|
# Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
|
1169
1181
|
# last redirect.
|
1170
1182
|
def reload(timeout: nil, waitUntil: nil)
|
@@ -1288,7 +1300,7 @@ module Playwright
|
|
1288
1300
|
#
|
1289
1301
|
# Shortcut for main frame's [`method: Frame.selectOption`]
|
1290
1302
|
def select_option(selector, values, noWaitAfter: nil, timeout: nil)
|
1291
|
-
|
1303
|
+
wrap_impl(@impl.select_option(unwrap_impl(selector), unwrap_impl(values), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
1292
1304
|
end
|
1293
1305
|
|
1294
1306
|
def set_content(html, timeout: nil, waitUntil: nil)
|
@@ -1323,7 +1335,7 @@ module Playwright
|
|
1323
1335
|
#
|
1324
1336
|
# > NOTE: [`method: Page.setExtraHTTPHeaders`] does not guarantee the order of headers in the outgoing requests.
|
1325
1337
|
def set_extra_http_headers(headers)
|
1326
|
-
|
1338
|
+
wrap_impl(@impl.set_extra_http_headers(unwrap_impl(headers)))
|
1327
1339
|
end
|
1328
1340
|
alias_method :extra_http_headers=, :set_extra_http_headers
|
1329
1341
|
|
@@ -1333,7 +1345,7 @@ module Playwright
|
|
1333
1345
|
# Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
1334
1346
|
# are resolved relative to the the current working directory. For empty array, clears the selected files.
|
1335
1347
|
def set_input_files(selector, files, noWaitAfter: nil, timeout: nil)
|
1336
|
-
|
1348
|
+
wrap_impl(@impl.set_input_files(unwrap_impl(selector), unwrap_impl(files), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
1337
1349
|
end
|
1338
1350
|
|
1339
1351
|
# In the case of multiple pages in a single browser, each page can have its own viewport size. However,
|
@@ -1389,12 +1401,12 @@ module Playwright
|
|
1389
1401
|
noWaitAfter: nil,
|
1390
1402
|
position: nil,
|
1391
1403
|
timeout: nil)
|
1392
|
-
|
1404
|
+
wrap_impl(@impl.tap_point(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
|
1393
1405
|
end
|
1394
1406
|
|
1395
1407
|
# Returns `element.textContent`.
|
1396
1408
|
def text_content(selector, timeout: nil)
|
1397
|
-
|
1409
|
+
wrap_impl(@impl.text_content(unwrap_impl(selector), timeout: unwrap_impl(timeout)))
|
1398
1410
|
end
|
1399
1411
|
|
1400
1412
|
# Returns the page's title. Shortcut for main frame's [`method: Frame.title`].
|
@@ -1449,7 +1461,7 @@ module Playwright
|
|
1449
1461
|
#
|
1450
1462
|
# Shortcut for main frame's [`method: Frame.uncheck`].
|
1451
1463
|
def uncheck(selector, force: nil, noWaitAfter: nil, timeout: nil)
|
1452
|
-
|
1464
|
+
wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
1453
1465
|
end
|
1454
1466
|
|
1455
1467
|
# Removes a route created with [`method: Page.route`]. When `handler` is not specified, removes all routes for the `url`.
|
@@ -1471,35 +1483,9 @@ module Playwright
|
|
1471
1483
|
wrap_impl(@impl.viewport_size)
|
1472
1484
|
end
|
1473
1485
|
|
1474
|
-
#
|
1475
|
-
# value. Will throw an error if the page is closed before the event is fired. Returns the event data value.
|
1476
|
-
#
|
1477
|
-
#
|
1478
|
-
# ```js
|
1479
|
-
# const [frame, _] = await Promise.all([
|
1480
|
-
# page.waitForEvent('framenavigated'),
|
1481
|
-
# page.click('button')
|
1482
|
-
# ]);
|
1483
|
-
# ```
|
1484
|
-
#
|
1485
|
-
# ```python async
|
1486
|
-
# async with page.expect_event("framenavigated") as event_info:
|
1487
|
-
# await page.click("button")
|
1488
|
-
# frame = await event_info.value
|
1489
|
-
# ```
|
1490
|
-
#
|
1491
|
-
# ```python sync
|
1492
|
-
# with page.expect_event("framenavigated") as event_info:
|
1493
|
-
# page.click("button")
|
1494
|
-
# frame = event_info.value
|
1495
|
-
# ```
|
1496
|
-
def expect_event(event, optionsOrPredicate: nil, &block)
|
1497
|
-
wrap_impl(@impl.expect_event(unwrap_impl(event), optionsOrPredicate: unwrap_impl(optionsOrPredicate), &wrap_block_call(block)))
|
1498
|
-
end
|
1499
|
-
|
1500
|
-
# Returns when the `pageFunction` returns a truthy value. It resolves to a JSHandle of the truthy value.
|
1486
|
+
# Returns when the `expression` returns a truthy value. It resolves to a JSHandle of the truthy value.
|
1501
1487
|
#
|
1502
|
-
# The `waitForFunction` can be used to observe viewport size change:
|
1488
|
+
# The [`method: Page.waitForFunction`] can be used to observe viewport size change:
|
1503
1489
|
#
|
1504
1490
|
#
|
1505
1491
|
# ```js
|
@@ -1523,7 +1509,7 @@ module Playwright
|
|
1523
1509
|
# webkit = playwright.webkit
|
1524
1510
|
# browser = await webkit.launch()
|
1525
1511
|
# page = await browser.new_page()
|
1526
|
-
# await page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);"
|
1512
|
+
# await page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);")
|
1527
1513
|
# await page.wait_for_function("() => window.x > 0")
|
1528
1514
|
# await browser.close()
|
1529
1515
|
#
|
@@ -1540,7 +1526,7 @@ module Playwright
|
|
1540
1526
|
# webkit = playwright.webkit
|
1541
1527
|
# browser = webkit.launch()
|
1542
1528
|
# page = browser.new_page()
|
1543
|
-
# page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);"
|
1529
|
+
# page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);")
|
1544
1530
|
# page.wait_for_function("() => window.x > 0")
|
1545
1531
|
# browser.close()
|
1546
1532
|
#
|
@@ -1567,8 +1553,8 @@ module Playwright
|
|
1567
1553
|
# ```
|
1568
1554
|
#
|
1569
1555
|
# Shortcut for main frame's [`method: Frame.waitForFunction`].
|
1570
|
-
def wait_for_function(
|
1571
|
-
wrap_impl(@impl.wait_for_function(unwrap_impl(
|
1556
|
+
def wait_for_function(expression, arg: nil, polling: nil, timeout: nil)
|
1557
|
+
wrap_impl(@impl.wait_for_function(unwrap_impl(expression), arg: unwrap_impl(arg), polling: unwrap_impl(polling), timeout: unwrap_impl(timeout)))
|
1572
1558
|
end
|
1573
1559
|
|
1574
1560
|
# Returns when the required load state has been reached.
|
@@ -1784,7 +1770,7 @@ module Playwright
|
|
1784
1770
|
# run(playwright)
|
1785
1771
|
# ```
|
1786
1772
|
def wait_for_selector(selector, state: nil, timeout: nil)
|
1787
|
-
|
1773
|
+
wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
|
1788
1774
|
end
|
1789
1775
|
|
1790
1776
|
# Waits for the given `timeout` in milliseconds.
|
@@ -1826,6 +1812,11 @@ module Playwright
|
|
1826
1812
|
wrap_impl(@impl.after_initialize)
|
1827
1813
|
end
|
1828
1814
|
|
1815
|
+
# @nodoc
|
1816
|
+
def expect_event(event, optionsOrPredicate: nil, &block)
|
1817
|
+
wrap_impl(@impl.expect_event(unwrap_impl(event), optionsOrPredicate: unwrap_impl(optionsOrPredicate), &wrap_block_call(block)))
|
1818
|
+
end
|
1819
|
+
|
1829
1820
|
# @nodoc
|
1830
1821
|
def owned_context=(req)
|
1831
1822
|
wrap_impl(@impl.owned_context=(unwrap_impl(req)))
|