playwright-ruby-client 0.0.8 → 1.58.1.alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/AGENTS.md +4 -0
- data/CLAUDE/api_generation.md +28 -0
- data/CLAUDE/ci_expectations.md +23 -0
- data/CLAUDE/gem_release_flow.md +39 -0
- data/CLAUDE/past_upgrade_pr_patterns.md +42 -0
- data/CLAUDE/playwright_upgrade_workflow.md +35 -0
- data/CLAUDE/rspec_debugging.md +30 -0
- data/CLAUDE/unimplemented_examples.md +18 -0
- data/CLAUDE.md +32 -0
- data/CONTRIBUTING.md +5 -0
- data/README.md +60 -16
- data/documentation/README.md +33 -0
- data/documentation/babel.config.js +3 -0
- data/documentation/docs/api/api_request.md +7 -0
- data/documentation/docs/api/api_request_context.md +298 -0
- data/documentation/docs/api/api_response.md +114 -0
- data/documentation/docs/api/browser.md +237 -0
- data/documentation/docs/api/browser_context.md +503 -0
- data/documentation/docs/api/browser_type.md +184 -0
- data/documentation/docs/api/cdp_session.md +44 -0
- data/documentation/docs/api/clock.md +154 -0
- data/documentation/docs/api/console_message.md +85 -0
- data/documentation/docs/api/dialog.md +84 -0
- data/documentation/docs/api/download.md +111 -0
- data/documentation/docs/api/element_handle.md +694 -0
- data/documentation/docs/api/experimental/_category_.yml +3 -0
- data/documentation/docs/api/experimental/android.md +42 -0
- data/documentation/docs/api/experimental/android_device.md +109 -0
- data/documentation/docs/api/experimental/android_input.md +43 -0
- data/documentation/docs/api/experimental/android_socket.md +7 -0
- data/documentation/docs/api/experimental/android_web_view.md +7 -0
- data/documentation/docs/api/file_chooser.md +53 -0
- data/documentation/docs/api/frame.md +1218 -0
- data/documentation/docs/api/frame_locator.md +348 -0
- data/documentation/docs/api/js_handle.md +121 -0
- data/documentation/docs/api/keyboard.md +170 -0
- data/documentation/docs/api/locator.md +1495 -0
- data/documentation/docs/api/locator_assertions.md +827 -0
- data/documentation/docs/api/mouse.md +86 -0
- data/documentation/docs/api/page.md +1946 -0
- data/documentation/docs/api/page_assertions.md +65 -0
- data/documentation/docs/api/playwright.md +66 -0
- data/documentation/docs/api/request.md +255 -0
- data/documentation/docs/api/response.md +176 -0
- data/documentation/docs/api/route.md +205 -0
- data/documentation/docs/api/selectors.md +63 -0
- data/documentation/docs/api/touchscreen.md +22 -0
- data/documentation/docs/api/tracing.md +129 -0
- data/documentation/docs/api/web_socket.md +51 -0
- data/documentation/docs/api/worker.md +83 -0
- data/documentation/docs/article/api_coverage.mdx +11 -0
- data/documentation/docs/article/getting_started.md +161 -0
- data/documentation/docs/article/guides/_category_.yml +3 -0
- data/documentation/docs/article/guides/download_playwright_driver.md +55 -0
- data/documentation/docs/article/guides/inspector.md +31 -0
- data/documentation/docs/article/guides/launch_browser.md +121 -0
- data/documentation/docs/article/guides/playwright_on_alpine_linux.md +112 -0
- data/documentation/docs/article/guides/rails_integration.md +278 -0
- data/documentation/docs/article/guides/rails_integration_with_null_driver.md +145 -0
- data/documentation/docs/article/guides/recording_video.md +79 -0
- data/documentation/docs/article/guides/rspec_integration.md +59 -0
- data/documentation/docs/article/guides/semi_automation.md +71 -0
- data/documentation/docs/article/guides/use_storage_state.md +78 -0
- data/documentation/docs/include/api_coverage.md +671 -0
- data/documentation/docusaurus.config.js +114 -0
- data/documentation/package.json +39 -0
- data/documentation/sidebars.js +15 -0
- data/documentation/src/components/HomepageFeatures.js +61 -0
- data/documentation/src/components/HomepageFeatures.module.css +13 -0
- data/documentation/src/css/custom.css +44 -0
- data/documentation/src/pages/index.js +49 -0
- data/documentation/src/pages/index.module.css +41 -0
- data/documentation/src/pages/markdown-page.md +7 -0
- data/documentation/static/.nojekyll +0 -0
- data/documentation/static/img/playwright-logo.svg +9 -0
- data/documentation/static/img/playwright-ruby-client.png +0 -0
- data/documentation/static/img/undraw_dropdown_menu.svg +1 -0
- data/documentation/static/img/undraw_web_development.svg +1 -0
- data/documentation/static/img/undraw_windows.svg +1 -0
- data/documentation/yarn.lock +9005 -0
- data/lib/playwright/{input_types/android_input.rb → android_input_impl.rb} +5 -1
- data/lib/playwright/api_implementation.rb +18 -0
- data/lib/playwright/api_response_impl.rb +77 -0
- data/lib/playwright/channel.rb +62 -1
- data/lib/playwright/channel_owner.rb +70 -7
- data/lib/playwright/channel_owners/android.rb +16 -3
- data/lib/playwright/channel_owners/android_device.rb +22 -66
- data/lib/playwright/channel_owners/api_request_context.rb +247 -0
- data/lib/playwright/channel_owners/artifact.rb +40 -0
- data/lib/playwright/channel_owners/binding_call.rb +70 -0
- data/lib/playwright/channel_owners/browser.rb +114 -22
- data/lib/playwright/channel_owners/browser_context.rb +589 -15
- data/lib/playwright/channel_owners/browser_type.rb +90 -1
- data/lib/playwright/channel_owners/cdp_session.rb +19 -0
- data/lib/playwright/channel_owners/dialog.rb +32 -0
- data/lib/playwright/channel_owners/element_handle.rb +107 -43
- data/lib/playwright/channel_owners/fetch_request.rb +8 -0
- data/lib/playwright/channel_owners/frame.rb +334 -104
- data/lib/playwright/channel_owners/js_handle.rb +9 -13
- data/lib/playwright/channel_owners/local_utils.rb +82 -0
- data/lib/playwright/channel_owners/page.rb +778 -95
- data/lib/playwright/channel_owners/playwright.rb +25 -30
- data/lib/playwright/channel_owners/request.rb +120 -18
- data/lib/playwright/channel_owners/response.rb +113 -0
- data/lib/playwright/channel_owners/route.rb +181 -0
- data/lib/playwright/channel_owners/stream.rb +30 -0
- data/lib/playwright/channel_owners/tracing.rb +117 -0
- data/lib/playwright/channel_owners/web_socket.rb +96 -0
- data/lib/playwright/channel_owners/worker.rb +46 -0
- data/lib/playwright/channel_owners/writable_stream.rb +14 -0
- data/lib/playwright/clock_impl.rb +67 -0
- data/lib/playwright/connection.rb +111 -63
- data/lib/playwright/console_message_impl.rb +29 -0
- data/lib/playwright/download_impl.rb +32 -0
- data/lib/playwright/errors.rb +42 -5
- data/lib/playwright/event_emitter.rb +17 -3
- data/lib/playwright/event_emitter_proxy.rb +49 -0
- data/lib/playwright/events.rb +10 -5
- data/lib/playwright/file_chooser_impl.rb +24 -0
- data/lib/playwright/frame_locator_impl.rb +66 -0
- data/lib/playwright/har_router.rb +89 -0
- data/lib/playwright/http_headers.rb +14 -0
- data/lib/playwright/input_files.rb +102 -15
- data/lib/playwright/javascript/expression.rb +7 -11
- data/lib/playwright/javascript/regex.rb +23 -0
- data/lib/playwright/javascript/source_url.rb +16 -0
- data/lib/playwright/javascript/value_parser.rb +108 -19
- data/lib/playwright/javascript/value_serializer.rb +47 -8
- data/lib/playwright/javascript/visitor_info.rb +26 -0
- data/lib/playwright/javascript.rb +2 -10
- data/lib/playwright/{input_types/keyboard.rb → keyboard_impl.rb} +6 -2
- data/lib/playwright/locator_assertions_impl.rb +571 -0
- data/lib/playwright/locator_impl.rb +544 -0
- data/lib/playwright/locator_utils.rb +136 -0
- data/lib/playwright/mouse_impl.rb +57 -0
- data/lib/playwright/page_assertions_impl.rb +154 -0
- data/lib/playwright/playwright_api.rb +102 -30
- data/lib/playwright/raw_headers.rb +61 -0
- data/lib/playwright/route_handler.rb +78 -0
- data/lib/playwright/select_option_values.rb +34 -13
- data/lib/playwright/selectors_impl.rb +45 -0
- data/lib/playwright/test.rb +102 -0
- data/lib/playwright/timeout_settings.rb +9 -4
- data/lib/playwright/touchscreen_impl.rb +14 -0
- data/lib/playwright/transport.rb +61 -10
- data/lib/playwright/url_matcher.rb +24 -2
- data/lib/playwright/utils.rb +48 -13
- data/lib/playwright/version.rb +2 -1
- data/lib/playwright/video.rb +54 -0
- data/lib/playwright/waiter.rb +166 -0
- data/lib/playwright/web_socket_client.rb +167 -0
- data/lib/playwright/web_socket_transport.rb +116 -0
- data/lib/playwright.rb +188 -11
- data/lib/playwright_api/android.rb +46 -11
- data/lib/playwright_api/android_device.rb +182 -31
- data/lib/playwright_api/android_input.rb +22 -13
- data/lib/playwright_api/android_socket.rb +18 -0
- data/lib/playwright_api/android_web_view.rb +24 -0
- data/lib/playwright_api/api_request.rb +26 -0
- data/lib/playwright_api/api_request_context.rb +311 -0
- data/lib/playwright_api/api_response.rb +92 -0
- data/lib/playwright_api/browser.rb +116 -103
- data/lib/playwright_api/browser_context.rb +290 -389
- data/lib/playwright_api/browser_type.rb +96 -118
- data/lib/playwright_api/cdp_session.rb +36 -39
- data/lib/playwright_api/clock.rb +121 -0
- data/lib/playwright_api/console_message.rb +35 -19
- data/lib/playwright_api/dialog.rb +53 -50
- data/lib/playwright_api/download.rb +49 -43
- data/lib/playwright_api/element_handle.rb +354 -402
- data/lib/playwright_api/file_chooser.rb +15 -18
- data/lib/playwright_api/frame.rb +703 -603
- data/lib/playwright_api/frame_locator.rb +285 -0
- data/lib/playwright_api/js_handle.rb +50 -76
- data/lib/playwright_api/keyboard.rb +67 -146
- data/lib/playwright_api/locator.rb +1304 -0
- data/lib/playwright_api/locator_assertions.rb +704 -0
- data/lib/playwright_api/mouse.rb +23 -29
- data/lib/playwright_api/page.rb +1196 -1176
- data/lib/playwright_api/page_assertions.rb +60 -0
- data/lib/playwright_api/playwright.rb +54 -122
- data/lib/playwright_api/request.rb +112 -74
- data/lib/playwright_api/response.rb +92 -20
- data/lib/playwright_api/route.rb +152 -62
- data/lib/playwright_api/selectors.rb +47 -61
- data/lib/playwright_api/touchscreen.rb +8 -2
- data/lib/playwright_api/tracing.rb +128 -0
- data/lib/playwright_api/web_socket.rb +43 -5
- data/lib/playwright_api/worker.rb +74 -34
- data/playwright.gemspec +14 -9
- data/sig/playwright.rbs +658 -0
- metadata +216 -50
- data/docs/api_coverage.md +0 -354
- 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/console_message.rb +0 -21
- data/lib/playwright/channel_owners/firefox_browser.rb +0 -8
- data/lib/playwright/channel_owners/selectors.rb +0 -4
- data/lib/playwright/channel_owners/webkit_browser.rb +0 -8
- data/lib/playwright/input_type.rb +0 -19
- data/lib/playwright/input_types/mouse.rb +0 -4
- data/lib/playwright/input_types/touchscreen.rb +0 -4
- data/lib/playwright/javascript/function.rb +0 -67
- data/lib/playwright/wait_helper.rb +0 -73
- data/lib/playwright_api/accessibility.rb +0 -93
- data/lib/playwright_api/binding_call.rb +0 -23
- data/lib/playwright_api/chromium_browser_context.rb +0 -57
- data/lib/playwright_api/video.rb +0 -24
|
@@ -2,171 +2,56 @@ require_relative './js_handle.rb'
|
|
|
2
2
|
|
|
3
3
|
module Playwright
|
|
4
4
|
# - extends: `JSHandle`
|
|
5
|
-
#
|
|
6
|
-
# ElementHandle represents an in-page DOM element. ElementHandles can be created with the [`method: Page.$`] method.
|
|
7
|
-
#
|
|
8
5
|
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
# const browser = await chromium.launch();
|
|
14
|
-
# const page = await browser.newPage();
|
|
15
|
-
# await page.goto('https://example.com');
|
|
16
|
-
# const hrefElement = await page.$('a');
|
|
17
|
-
# await hrefElement.click();
|
|
18
|
-
# // ...
|
|
19
|
-
# })();
|
|
20
|
-
# ```
|
|
21
|
-
#
|
|
22
|
-
# ```python async
|
|
23
|
-
# import asyncio
|
|
24
|
-
# from playwright.async_api import async_playwright
|
|
25
|
-
#
|
|
26
|
-
# async def run(playwright):
|
|
27
|
-
# chromium = playwright.chromium
|
|
28
|
-
# browser = await chromium.launch()
|
|
29
|
-
# page = await browser.new_page()
|
|
30
|
-
# await page.goto("https://example.com")
|
|
31
|
-
# href_element = await page.query_selector("a")
|
|
32
|
-
# await href_element.click()
|
|
33
|
-
# # ...
|
|
34
|
-
#
|
|
35
|
-
# async def main():
|
|
36
|
-
# async with async_playwright() as playwright:
|
|
37
|
-
# await run(playwright)
|
|
38
|
-
# asyncio.run(main())
|
|
39
|
-
# ```
|
|
40
|
-
#
|
|
6
|
+
# ElementHandle represents an in-page DOM element. ElementHandles can be created with the [`method: Page.querySelector`] method.
|
|
7
|
+
#
|
|
8
|
+
# **NOTE**: The use of ElementHandle is discouraged, use `Locator` objects and web-first assertions instead.
|
|
9
|
+
#
|
|
41
10
|
# ```python sync
|
|
42
|
-
#
|
|
43
|
-
#
|
|
44
|
-
# def run(playwright):
|
|
45
|
-
# chromium = playwright.chromium
|
|
46
|
-
# browser = chromium.launch()
|
|
47
|
-
# page = browser.new_page()
|
|
48
|
-
# page.goto("https://example.com")
|
|
49
|
-
# href_element = page.query_selector("a")
|
|
50
|
-
# href_element.click()
|
|
51
|
-
# # ...
|
|
52
|
-
#
|
|
53
|
-
# with sync_playwright() as playwright:
|
|
54
|
-
# run(playwright)
|
|
11
|
+
# href_element = page.query_selector("a")
|
|
12
|
+
# href_element.click()
|
|
55
13
|
# ```
|
|
56
|
-
#
|
|
14
|
+
#
|
|
57
15
|
# ElementHandle prevents DOM element from garbage collection unless the handle is disposed with
|
|
58
16
|
# [`method: JSHandle.dispose`]. ElementHandles are auto-disposed when their origin frame gets navigated.
|
|
59
|
-
#
|
|
60
|
-
# ElementHandle instances can be used as an argument in [`method: Page
|
|
17
|
+
#
|
|
18
|
+
# ElementHandle instances can be used as an argument in [`method: Page.evalOnSelector`] and [`method: Page.evaluate`] methods.
|
|
19
|
+
#
|
|
20
|
+
# The difference between the `Locator` and ElementHandle is that the ElementHandle points to a particular element, while `Locator` captures the logic of how to retrieve an element.
|
|
21
|
+
#
|
|
22
|
+
# In the example below, handle points to a particular DOM element on page. If that element changes text or is used by React to render an entirely different component, handle is still pointing to that very DOM element. This can lead to unexpected behaviors.
|
|
23
|
+
#
|
|
24
|
+
# ```python sync
|
|
25
|
+
# handle = page.query_selector("text=Submit")
|
|
26
|
+
# handle.hover()
|
|
27
|
+
# handle.click()
|
|
28
|
+
# ```
|
|
29
|
+
#
|
|
30
|
+
# With the locator, every time the `element` is used, up-to-date DOM element is located in the page using the selector. So in the snippet below, underlying DOM element is going to be located twice.
|
|
31
|
+
#
|
|
32
|
+
# ```python sync
|
|
33
|
+
# locator = page.get_by_text("Submit")
|
|
34
|
+
# locator.hover()
|
|
35
|
+
# locator.click()
|
|
36
|
+
# ```
|
|
61
37
|
class ElementHandle < JSHandle
|
|
62
38
|
|
|
63
|
-
# The method finds an element matching the specified selector in the `ElementHandle`'s subtree. See
|
|
64
|
-
# [Working with selectors](./selectors.md#working-with-selectors) for more details. If no elements match the selector,
|
|
65
|
-
# returns `null`.
|
|
66
|
-
def query_selector(selector)
|
|
67
|
-
wrap_impl(@impl.query_selector(unwrap_impl(selector)))
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# The method finds all elements matching the specified selector in the `ElementHandle`s subtree. See
|
|
71
|
-
# [Working with selectors](./selectors.md#working-with-selectors) for more details. If no elements match the selector,
|
|
72
|
-
# returns empty array.
|
|
73
|
-
def query_selector_all(selector)
|
|
74
|
-
wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
# Returns the return value of `pageFunction`
|
|
78
|
-
#
|
|
79
|
-
# The method finds an element matching the specified selector in the `ElementHandle`s subtree and passes it as a first
|
|
80
|
-
# argument to `pageFunction`. See [Working with selectors](./selectors.md#working-with-selectors) for more details. If no
|
|
81
|
-
# elements match the selector, the method throws an error.
|
|
82
|
-
#
|
|
83
|
-
# If `pageFunction` returns a [Promise], then `frame.$eval` would wait for the promise to resolve and return its value.
|
|
84
|
-
#
|
|
85
|
-
# Examples:
|
|
86
|
-
#
|
|
87
|
-
#
|
|
88
|
-
# ```js
|
|
89
|
-
# const tweetHandle = await page.$('.tweet');
|
|
90
|
-
# expect(await tweetHandle.$eval('.like', node => node.innerText)).toBe('100');
|
|
91
|
-
# expect(await tweetHandle.$eval('.retweets', node => node.innerText)).toBe('10');
|
|
92
|
-
# ```
|
|
93
|
-
#
|
|
94
|
-
# ```python async
|
|
95
|
-
# tweet_handle = await page.query_selector(".tweet")
|
|
96
|
-
# assert await tweet_handle.eval_on_selector(".like", "node => node.innerText") == "100"
|
|
97
|
-
# assert await tweet_handle.eval_on_selector(".retweets", "node => node.innerText") = "10"
|
|
98
|
-
# ```
|
|
99
|
-
#
|
|
100
|
-
# ```python sync
|
|
101
|
-
# tweet_handle = page.query_selector(".tweet")
|
|
102
|
-
# assert tweet_handle.eval_on_selector(".like", "node => node.innerText") == "100"
|
|
103
|
-
# assert tweet_handle.eval_on_selector(".retweets", "node => node.innerText") = "10"
|
|
104
|
-
# ```
|
|
105
|
-
def eval_on_selector(selector, pageFunction, arg: nil)
|
|
106
|
-
wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(pageFunction), arg: unwrap_impl(arg)))
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
# Returns the return value of `pageFunction`
|
|
110
|
-
#
|
|
111
|
-
# The method finds all elements matching the specified selector in the `ElementHandle`'s subtree and passes an array of
|
|
112
|
-
# matched elements as a first argument to `pageFunction`. See
|
|
113
|
-
# [Working with selectors](./selectors.md#working-with-selectors) for more details.
|
|
114
|
-
#
|
|
115
|
-
# If `pageFunction` returns a [Promise], then `frame.$$eval` would wait for the promise to resolve and return its value.
|
|
116
|
-
#
|
|
117
|
-
# Examples:
|
|
118
|
-
#
|
|
119
|
-
# ```html
|
|
120
|
-
# <div class="feed">
|
|
121
|
-
# <div class="tweet">Hello!</div>
|
|
122
|
-
# <div class="tweet">Hi!</div>
|
|
123
|
-
# </div>
|
|
124
|
-
# ```
|
|
125
|
-
#
|
|
126
39
|
#
|
|
127
|
-
# ```js
|
|
128
|
-
# const feedHandle = await page.$('.feed');
|
|
129
|
-
# expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!']);
|
|
130
|
-
# ```
|
|
131
|
-
#
|
|
132
|
-
# ```python async
|
|
133
|
-
# # FIXME
|
|
134
|
-
# feed_handle = await page.query_selector(".feed")
|
|
135
|
-
# assert await feed_handle.eval_on_selector_all(".tweet", "nodes => nodes.map(n => n.innerText)") == ["hello!", "hi!"]
|
|
136
|
-
# ```
|
|
137
|
-
#
|
|
138
|
-
# ```python sync
|
|
139
|
-
# feed_handle = page.query_selector(".feed")
|
|
140
|
-
# assert feed_handle.eval_on_selector_all(".tweet", "nodes => nodes.map(n => n.innerText)") == ["hello!", "hi!"]
|
|
141
|
-
# ```
|
|
142
|
-
def eval_on_selector_all(selector, pageFunction, arg: nil)
|
|
143
|
-
wrap_impl(@impl.eval_on_selector_all(unwrap_impl(selector), unwrap_impl(pageFunction), arg: unwrap_impl(arg)))
|
|
144
|
-
end
|
|
145
|
-
|
|
146
40
|
# This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
|
|
147
41
|
# calculated relative to the main frame viewport - which is usually the same as the browser window.
|
|
148
|
-
#
|
|
149
|
-
# Scrolling affects the returned
|
|
42
|
+
#
|
|
43
|
+
# Scrolling affects the returned bounding box, similarly to
|
|
150
44
|
# [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That
|
|
151
45
|
# means `x` and/or `y` may be negative.
|
|
152
|
-
#
|
|
46
|
+
#
|
|
153
47
|
# Elements from child frames return the bounding box relative to the main frame, unlike the
|
|
154
48
|
# [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect).
|
|
155
|
-
#
|
|
49
|
+
#
|
|
156
50
|
# Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following
|
|
157
51
|
# snippet should click the center of the element.
|
|
158
|
-
#
|
|
159
52
|
#
|
|
160
|
-
#
|
|
161
|
-
#
|
|
162
|
-
# await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
|
|
163
|
-
# ```
|
|
164
|
-
#
|
|
165
|
-
# ```python async
|
|
166
|
-
# box = await element_handle.bounding_box()
|
|
167
|
-
# await page.mouse.click(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2)
|
|
168
|
-
# ```
|
|
169
|
-
#
|
|
53
|
+
# **Usage**
|
|
54
|
+
#
|
|
170
55
|
# ```python sync
|
|
171
56
|
# box = element_handle.bounding_box()
|
|
172
57
|
# page.mouse.click(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2)
|
|
@@ -175,33 +60,38 @@ module Playwright
|
|
|
175
60
|
wrap_impl(@impl.bounding_box)
|
|
176
61
|
end
|
|
177
62
|
|
|
63
|
+
#
|
|
178
64
|
# This method checks the element by performing the following steps:
|
|
179
|
-
# 1. Ensure that element is a checkbox or a radio input. If not, this method
|
|
180
|
-
#
|
|
181
|
-
# 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set.
|
|
65
|
+
# 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked, this method returns immediately.
|
|
66
|
+
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
|
182
67
|
# 1. Scroll the element into view if needed.
|
|
183
68
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
|
184
|
-
# 1.
|
|
185
|
-
#
|
|
186
|
-
#
|
|
187
|
-
#
|
|
188
|
-
#
|
|
189
|
-
#
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
69
|
+
# 1. Ensure that the element is now checked. If not, this method throws.
|
|
70
|
+
#
|
|
71
|
+
# If the element is detached from the DOM at any moment during the action, this method throws.
|
|
72
|
+
#
|
|
73
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
74
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
|
75
|
+
def check(
|
|
76
|
+
force: nil,
|
|
77
|
+
noWaitAfter: nil,
|
|
78
|
+
position: nil,
|
|
79
|
+
timeout: nil,
|
|
80
|
+
trial: nil)
|
|
81
|
+
wrap_impl(@impl.check(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
|
193
82
|
end
|
|
194
83
|
|
|
84
|
+
#
|
|
195
85
|
# This method clicks the element by performing the following steps:
|
|
196
|
-
# 1. Wait for [actionability](
|
|
86
|
+
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
|
197
87
|
# 1. Scroll the element into view if needed.
|
|
198
88
|
# 1. Use [`property: Page.mouse`] to click in the center of the element, or the specified `position`.
|
|
199
89
|
# 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
|
200
|
-
#
|
|
201
|
-
# If the element is detached from the DOM at any moment during the action, this method
|
|
202
|
-
#
|
|
203
|
-
# When all steps combined have not finished during the specified `timeout`, this method
|
|
204
|
-
# Passing zero timeout disables this.
|
|
90
|
+
#
|
|
91
|
+
# If the element is detached from the DOM at any moment during the action, this method throws.
|
|
92
|
+
#
|
|
93
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
94
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
|
205
95
|
def click(
|
|
206
96
|
button: nil,
|
|
207
97
|
clickCount: nil,
|
|
@@ -210,28 +100,30 @@ module Playwright
|
|
|
210
100
|
modifiers: nil,
|
|
211
101
|
noWaitAfter: nil,
|
|
212
102
|
position: nil,
|
|
213
|
-
|
|
214
|
-
|
|
103
|
+
steps: nil,
|
|
104
|
+
timeout: nil,
|
|
105
|
+
trial: nil)
|
|
106
|
+
wrap_impl(@impl.click(button: unwrap_impl(button), clickCount: unwrap_impl(clickCount), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), steps: unwrap_impl(steps), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
|
215
107
|
end
|
|
216
108
|
|
|
109
|
+
#
|
|
217
110
|
# Returns the content frame for element handles referencing iframe nodes, or `null` otherwise
|
|
218
111
|
def content_frame
|
|
219
112
|
wrap_impl(@impl.content_frame)
|
|
220
113
|
end
|
|
221
114
|
|
|
115
|
+
#
|
|
222
116
|
# This method double clicks the element by performing the following steps:
|
|
223
|
-
# 1. Wait for [actionability](
|
|
117
|
+
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
|
224
118
|
# 1. Scroll the element into view if needed.
|
|
225
119
|
# 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`.
|
|
226
|
-
#
|
|
227
|
-
#
|
|
228
|
-
#
|
|
229
|
-
#
|
|
230
|
-
#
|
|
231
|
-
#
|
|
232
|
-
#
|
|
233
|
-
#
|
|
234
|
-
# > NOTE: `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event.
|
|
120
|
+
#
|
|
121
|
+
# If the element is detached from the DOM at any moment during the action, this method throws.
|
|
122
|
+
#
|
|
123
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
124
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
|
125
|
+
#
|
|
126
|
+
# **NOTE**: `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event.
|
|
235
127
|
def dblclick(
|
|
236
128
|
button: nil,
|
|
237
129
|
delay: nil,
|
|
@@ -239,54 +131,42 @@ module Playwright
|
|
|
239
131
|
modifiers: nil,
|
|
240
132
|
noWaitAfter: nil,
|
|
241
133
|
position: nil,
|
|
242
|
-
|
|
243
|
-
|
|
134
|
+
steps: nil,
|
|
135
|
+
timeout: nil,
|
|
136
|
+
trial: nil)
|
|
137
|
+
wrap_impl(@impl.dblclick(button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), steps: unwrap_impl(steps), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
|
244
138
|
end
|
|
245
139
|
|
|
246
|
-
#
|
|
247
|
-
#
|
|
140
|
+
#
|
|
141
|
+
# The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element, `click`
|
|
142
|
+
# is dispatched. This is equivalent to calling
|
|
248
143
|
# [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
|
|
249
|
-
#
|
|
250
144
|
#
|
|
251
|
-
#
|
|
252
|
-
#
|
|
253
|
-
# ```
|
|
254
|
-
#
|
|
255
|
-
# ```python async
|
|
256
|
-
# await element_handle.dispatch_event("click")
|
|
257
|
-
# ```
|
|
258
|
-
#
|
|
145
|
+
# **Usage**
|
|
146
|
+
#
|
|
259
147
|
# ```python sync
|
|
260
148
|
# element_handle.dispatch_event("click")
|
|
261
149
|
# ```
|
|
262
|
-
#
|
|
263
|
-
# Under the hood, it creates an instance of an event based on the given `type`, initializes it with
|
|
264
|
-
# and dispatches it on the element. Events are `composed`, `cancelable` and bubble by
|
|
265
|
-
#
|
|
266
|
-
#
|
|
150
|
+
#
|
|
151
|
+
# Under the hood, it creates an instance of an event based on the given `type`, initializes it with
|
|
152
|
+
# `eventInit` properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by
|
|
153
|
+
# default.
|
|
154
|
+
#
|
|
155
|
+
# Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial
|
|
156
|
+
# properties:
|
|
157
|
+
# - [DeviceMotionEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent/DeviceMotionEvent)
|
|
158
|
+
# - [DeviceOrientationEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent/DeviceOrientationEvent)
|
|
267
159
|
# - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
|
|
160
|
+
# - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
|
|
268
161
|
# - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
|
|
269
162
|
# - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
|
|
270
163
|
# - [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
|
|
271
164
|
# - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
|
|
272
165
|
# - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
|
|
273
|
-
# - [
|
|
274
|
-
#
|
|
166
|
+
# - [WheelEvent](https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/WheelEvent)
|
|
167
|
+
#
|
|
275
168
|
# You can also specify `JSHandle` as the property value if you want live objects to be passed into the event:
|
|
276
|
-
#
|
|
277
169
|
#
|
|
278
|
-
# ```js
|
|
279
|
-
# // Note you can only create DataTransfer in Chromium and Firefox
|
|
280
|
-
# const dataTransfer = await page.evaluateHandle(() => new DataTransfer());
|
|
281
|
-
# await elementHandle.dispatchEvent('dragstart', { dataTransfer });
|
|
282
|
-
# ```
|
|
283
|
-
#
|
|
284
|
-
# ```python async
|
|
285
|
-
# # note you can only create data_transfer in chromium and firefox
|
|
286
|
-
# data_transfer = await page.evaluate_handle("new DataTransfer()")
|
|
287
|
-
# await element_handle.dispatch_event("#source", "dragstart", {"dataTransfer": data_transfer})
|
|
288
|
-
# ```
|
|
289
|
-
#
|
|
290
170
|
# ```python sync
|
|
291
171
|
# # note you can only create data_transfer in chromium and firefox
|
|
292
172
|
# data_transfer = page.evaluate_handle("new DataTransfer()")
|
|
@@ -296,352 +176,424 @@ module Playwright
|
|
|
296
176
|
wrap_impl(@impl.dispatch_event(unwrap_impl(type), eventInit: unwrap_impl(eventInit)))
|
|
297
177
|
end
|
|
298
178
|
|
|
299
|
-
#
|
|
300
|
-
#
|
|
301
|
-
#
|
|
302
|
-
|
|
303
|
-
|
|
179
|
+
#
|
|
180
|
+
# Returns the return value of `expression`.
|
|
181
|
+
#
|
|
182
|
+
# The method finds an element matching the specified selector in the `ElementHandle`s subtree and passes it as a first
|
|
183
|
+
# argument to `expression`. If no elements match the selector, the method throws an error.
|
|
184
|
+
#
|
|
185
|
+
# If `expression` returns a [Promise], then [`method: ElementHandle.evalOnSelector`] would wait for the promise to resolve and return its
|
|
186
|
+
# value.
|
|
187
|
+
#
|
|
188
|
+
# **Usage**
|
|
189
|
+
#
|
|
190
|
+
# ```python sync
|
|
191
|
+
# tweet_handle = page.query_selector(".tweet")
|
|
192
|
+
# assert tweet_handle.eval_on_selector(".like", "node => node.innerText") == "100"
|
|
193
|
+
# assert tweet_handle.eval_on_selector(".retweets", "node => node.innerText") == "10"
|
|
194
|
+
# ```
|
|
195
|
+
def eval_on_selector(selector, expression, arg: nil)
|
|
196
|
+
wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
#
|
|
200
|
+
# Returns the return value of `expression`.
|
|
201
|
+
#
|
|
202
|
+
# The method finds all elements matching the specified selector in the `ElementHandle`'s subtree and passes an array of
|
|
203
|
+
# matched elements as a first argument to `expression`.
|
|
204
|
+
#
|
|
205
|
+
# If `expression` returns a [Promise], then [`method: ElementHandle.evalOnSelectorAll`] would wait for the promise to resolve and return its
|
|
206
|
+
# value.
|
|
207
|
+
#
|
|
208
|
+
# **Usage**
|
|
209
|
+
#
|
|
210
|
+
# ```html
|
|
211
|
+
# <div class="feed">
|
|
212
|
+
# <div class="tweet">Hello!</div>
|
|
213
|
+
# <div class="tweet">Hi!</div>
|
|
214
|
+
# </div>
|
|
215
|
+
# ```
|
|
216
|
+
#
|
|
217
|
+
# ```python sync
|
|
218
|
+
# feed_handle = page.query_selector(".feed")
|
|
219
|
+
# assert feed_handle.eval_on_selector_all(".tweet", "nodes => nodes.map(n => n.innerText)") == ["hello!", "hi!"]
|
|
220
|
+
# ```
|
|
221
|
+
def eval_on_selector_all(selector, expression, arg: nil)
|
|
222
|
+
wrap_impl(@impl.eval_on_selector_all(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
|
|
304
223
|
end
|
|
305
224
|
|
|
225
|
+
#
|
|
226
|
+
# This method waits for [actionability](../actionability.md) checks, focuses the element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input field.
|
|
227
|
+
#
|
|
228
|
+
# If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled instead.
|
|
229
|
+
#
|
|
230
|
+
# To send fine-grained keyboard events, use [`method: Locator.pressSequentially`].
|
|
231
|
+
def fill(value, force: nil, noWaitAfter: nil, timeout: nil)
|
|
232
|
+
wrap_impl(@impl.fill(unwrap_impl(value), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
#
|
|
306
236
|
# Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus) on the element.
|
|
307
237
|
def focus
|
|
308
238
|
wrap_impl(@impl.focus)
|
|
309
239
|
end
|
|
310
240
|
|
|
241
|
+
#
|
|
311
242
|
# Returns element attribute value.
|
|
312
243
|
def get_attribute(name)
|
|
313
244
|
wrap_impl(@impl.get_attribute(unwrap_impl(name)))
|
|
314
245
|
end
|
|
315
246
|
alias_method :[], :get_attribute
|
|
316
247
|
|
|
248
|
+
#
|
|
317
249
|
# This method hovers over the element by performing the following steps:
|
|
318
|
-
# 1. Wait for [actionability](
|
|
250
|
+
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
|
319
251
|
# 1. Scroll the element into view if needed.
|
|
320
252
|
# 1. Use [`property: Page.mouse`] to hover over the center of the element, or the specified `position`.
|
|
321
|
-
#
|
|
322
|
-
#
|
|
323
|
-
#
|
|
324
|
-
#
|
|
325
|
-
#
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
253
|
+
#
|
|
254
|
+
# If the element is detached from the DOM at any moment during the action, this method throws.
|
|
255
|
+
#
|
|
256
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
257
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
|
258
|
+
def hover(
|
|
259
|
+
force: nil,
|
|
260
|
+
modifiers: nil,
|
|
261
|
+
noWaitAfter: nil,
|
|
262
|
+
position: nil,
|
|
263
|
+
timeout: nil,
|
|
264
|
+
trial: nil)
|
|
265
|
+
wrap_impl(@impl.hover(force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
|
329
266
|
end
|
|
330
267
|
|
|
268
|
+
#
|
|
331
269
|
# Returns the `element.innerHTML`.
|
|
332
270
|
def inner_html
|
|
333
271
|
wrap_impl(@impl.inner_html)
|
|
334
272
|
end
|
|
335
273
|
|
|
274
|
+
#
|
|
336
275
|
# Returns the `element.innerText`.
|
|
337
276
|
def inner_text
|
|
338
277
|
wrap_impl(@impl.inner_text)
|
|
339
278
|
end
|
|
340
279
|
|
|
280
|
+
#
|
|
281
|
+
# Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.
|
|
282
|
+
#
|
|
283
|
+
# Throws for non-input elements. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.
|
|
284
|
+
def input_value(timeout: nil)
|
|
285
|
+
wrap_impl(@impl.input_value(timeout: unwrap_impl(timeout)))
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
#
|
|
341
289
|
# Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
|
|
342
290
|
def checked?
|
|
343
291
|
wrap_impl(@impl.checked?)
|
|
344
292
|
end
|
|
345
293
|
|
|
346
|
-
#
|
|
294
|
+
#
|
|
295
|
+
# Returns whether the element is disabled, the opposite of [enabled](../actionability.md#enabled).
|
|
347
296
|
def disabled?
|
|
348
297
|
wrap_impl(@impl.disabled?)
|
|
349
298
|
end
|
|
350
299
|
|
|
351
|
-
#
|
|
300
|
+
#
|
|
301
|
+
# Returns whether the element is [editable](../actionability.md#editable).
|
|
352
302
|
def editable?
|
|
353
303
|
wrap_impl(@impl.editable?)
|
|
354
304
|
end
|
|
355
305
|
|
|
356
|
-
#
|
|
306
|
+
#
|
|
307
|
+
# Returns whether the element is [enabled](../actionability.md#enabled).
|
|
357
308
|
def enabled?
|
|
358
309
|
wrap_impl(@impl.enabled?)
|
|
359
310
|
end
|
|
360
311
|
|
|
361
|
-
#
|
|
312
|
+
#
|
|
313
|
+
# Returns whether the element is hidden, the opposite of [visible](../actionability.md#visible).
|
|
362
314
|
def hidden?
|
|
363
315
|
wrap_impl(@impl.hidden?)
|
|
364
316
|
end
|
|
365
317
|
|
|
366
|
-
#
|
|
318
|
+
#
|
|
319
|
+
# Returns whether the element is [visible](../actionability.md#visible).
|
|
367
320
|
def visible?
|
|
368
321
|
wrap_impl(@impl.visible?)
|
|
369
322
|
end
|
|
370
323
|
|
|
324
|
+
#
|
|
371
325
|
# Returns the frame containing the given element.
|
|
372
326
|
def owner_frame
|
|
373
327
|
wrap_impl(@impl.owner_frame)
|
|
374
328
|
end
|
|
375
329
|
|
|
330
|
+
#
|
|
376
331
|
# Focuses the element, and then uses [`method: Keyboard.down`] and [`method: Keyboard.up`].
|
|
377
|
-
#
|
|
378
|
-
# `key` can specify the intended
|
|
379
|
-
# value or a single character to
|
|
332
|
+
#
|
|
333
|
+
# `key` can specify the intended
|
|
334
|
+
# [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
|
|
335
|
+
# generate the text for. A superset of the `key` values can be found
|
|
380
336
|
# [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
|
|
381
|
-
#
|
|
337
|
+
#
|
|
382
338
|
# `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
|
|
383
339
|
# `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
|
|
384
|
-
#
|
|
385
|
-
# Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
|
|
386
|
-
#
|
|
340
|
+
#
|
|
341
|
+
# Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`, `ControlOrMeta`.
|
|
342
|
+
#
|
|
387
343
|
# Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
|
|
388
|
-
#
|
|
389
|
-
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
|
|
390
|
-
# texts.
|
|
391
|
-
#
|
|
392
|
-
# Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When
|
|
344
|
+
#
|
|
345
|
+
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
|
|
346
|
+
# respective texts.
|
|
347
|
+
#
|
|
348
|
+
# Shortcuts such as `key: "Control+o"`, `key: "Control++` or `key: "Control+Shift+T"` are supported as well. When specified with the
|
|
393
349
|
# modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
|
394
350
|
def press(key, delay: nil, noWaitAfter: nil, timeout: nil)
|
|
395
351
|
wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
|
396
352
|
end
|
|
397
353
|
|
|
398
|
-
#
|
|
399
|
-
#
|
|
400
|
-
#
|
|
354
|
+
#
|
|
355
|
+
# The method finds an element matching the specified selector in the `ElementHandle`'s subtree. If no elements match the selector,
|
|
356
|
+
# returns `null`.
|
|
357
|
+
def query_selector(selector)
|
|
358
|
+
wrap_impl(@impl.query_selector(unwrap_impl(selector)))
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
#
|
|
362
|
+
# The method finds all elements matching the specified selector in the `ElementHandle`s subtree. If no elements match the selector,
|
|
363
|
+
# returns empty array.
|
|
364
|
+
def query_selector_all(selector)
|
|
365
|
+
wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
#
|
|
369
|
+
# This method captures a screenshot of the page, clipped to the size and position of this particular element. If the element is covered by other elements, it will not be actually visible on the screenshot. If the element is a scrollable container, only the currently scrolled content will be visible on the screenshot.
|
|
370
|
+
#
|
|
371
|
+
# This method waits for the [actionability](../actionability.md) checks, then scrolls element into view before taking a
|
|
401
372
|
# screenshot. If the element is detached from DOM, the method throws an error.
|
|
373
|
+
#
|
|
374
|
+
# Returns the buffer with the captured screenshot.
|
|
402
375
|
def screenshot(
|
|
376
|
+
animations: nil,
|
|
377
|
+
caret: nil,
|
|
378
|
+
mask: nil,
|
|
379
|
+
maskColor: nil,
|
|
403
380
|
omitBackground: nil,
|
|
404
381
|
path: nil,
|
|
405
382
|
quality: nil,
|
|
383
|
+
scale: nil,
|
|
384
|
+
style: nil,
|
|
406
385
|
timeout: nil,
|
|
407
386
|
type: nil)
|
|
408
|
-
wrap_impl(@impl.screenshot(omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
|
|
387
|
+
wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), caret: unwrap_impl(caret), mask: unwrap_impl(mask), maskColor: unwrap_impl(maskColor), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), scale: unwrap_impl(scale), style: unwrap_impl(style), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
|
|
409
388
|
end
|
|
410
389
|
|
|
411
|
-
#
|
|
390
|
+
#
|
|
391
|
+
# This method waits for [actionability](../actionability.md) checks, then tries to scroll element into view, unless it is
|
|
412
392
|
# completely visible as defined by
|
|
413
393
|
# [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)'s `ratio`.
|
|
414
|
-
#
|
|
394
|
+
#
|
|
415
395
|
# Throws when `elementHandle` does not point to an element
|
|
416
396
|
# [connected](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected) to a Document or a ShadowRoot.
|
|
397
|
+
#
|
|
398
|
+
# See [scrolling](../input.md#scrolling) for alternative ways to scroll.
|
|
417
399
|
def scroll_into_view_if_needed(timeout: nil)
|
|
418
400
|
wrap_impl(@impl.scroll_into_view_if_needed(timeout: unwrap_impl(timeout)))
|
|
419
401
|
end
|
|
420
402
|
|
|
403
|
+
#
|
|
404
|
+
# This method waits for [actionability](../actionability.md) checks, waits until all specified options are present in the `<select>` element and selects these options.
|
|
405
|
+
#
|
|
406
|
+
# If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
|
|
407
|
+
#
|
|
421
408
|
# Returns the array of option values that have been successfully selected.
|
|
422
|
-
#
|
|
423
|
-
# Triggers a `change` and `input` event once all the provided options have been selected.
|
|
424
|
-
#
|
|
425
|
-
#
|
|
426
|
-
#
|
|
427
|
-
#
|
|
428
|
-
#
|
|
429
|
-
# ```js
|
|
430
|
-
# // single selection matching the value
|
|
431
|
-
# handle.selectOption('blue');
|
|
432
|
-
#
|
|
433
|
-
# // single selection matching the label
|
|
434
|
-
# handle.selectOption({ label: 'Blue' });
|
|
435
|
-
#
|
|
436
|
-
# // multiple selection
|
|
437
|
-
# handle.selectOption(['red', 'green', 'blue']);
|
|
438
|
-
# ```
|
|
439
|
-
#
|
|
440
|
-
# ```python async
|
|
441
|
-
# # single selection matching the value
|
|
442
|
-
# await handle.select_option("blue")
|
|
443
|
-
# # single selection matching the label
|
|
444
|
-
# await handle.select_option(label="blue")
|
|
445
|
-
# # multiple selection
|
|
446
|
-
# await handle.select_option(value=["red", "green", "blue"])
|
|
447
|
-
# ```
|
|
448
|
-
#
|
|
409
|
+
#
|
|
410
|
+
# Triggers a `change` and `input` event once all the provided options have been selected.
|
|
411
|
+
#
|
|
412
|
+
# **Usage**
|
|
413
|
+
#
|
|
449
414
|
# ```python sync
|
|
450
|
-
# #
|
|
415
|
+
# # Single selection matching the value or label
|
|
451
416
|
# handle.select_option("blue")
|
|
452
417
|
# # single selection matching both the label
|
|
453
418
|
# handle.select_option(label="blue")
|
|
454
419
|
# # multiple selection
|
|
455
420
|
# handle.select_option(value=["red", "green", "blue"])
|
|
456
421
|
# ```
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
# # multiple selection for blue, red and second option
|
|
467
|
-
# handle.select_option(value="blue", { index: 2 }, "red")
|
|
468
|
-
# ```
|
|
469
|
-
def select_option(values, noWaitAfter: nil, timeout: nil)
|
|
470
|
-
wrap_impl(@impl.select_option(unwrap_impl(values), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
|
422
|
+
def select_option(
|
|
423
|
+
element: nil,
|
|
424
|
+
index: nil,
|
|
425
|
+
value: nil,
|
|
426
|
+
label: nil,
|
|
427
|
+
force: nil,
|
|
428
|
+
noWaitAfter: nil,
|
|
429
|
+
timeout: nil)
|
|
430
|
+
wrap_impl(@impl.select_option(element: unwrap_impl(element), index: unwrap_impl(index), value: unwrap_impl(value), label: unwrap_impl(label), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
|
471
431
|
end
|
|
472
432
|
|
|
473
|
-
#
|
|
433
|
+
#
|
|
434
|
+
# This method waits for [actionability](../actionability.md) checks, then focuses the element and selects all its text
|
|
474
435
|
# content.
|
|
475
|
-
|
|
476
|
-
|
|
436
|
+
#
|
|
437
|
+
# If the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), focuses and selects text in the control instead.
|
|
438
|
+
def select_text(force: nil, timeout: nil)
|
|
439
|
+
wrap_impl(@impl.select_text(force: unwrap_impl(force), timeout: unwrap_impl(timeout)))
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
#
|
|
443
|
+
# This method checks or unchecks an element by performing the following steps:
|
|
444
|
+
# 1. Ensure that element is a checkbox or a radio input. If not, this method throws.
|
|
445
|
+
# 1. If the element already has the right checked state, this method returns immediately.
|
|
446
|
+
# 1. Wait for [actionability](../actionability.md) checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
|
|
447
|
+
# 1. Scroll the element into view if needed.
|
|
448
|
+
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
|
449
|
+
# 1. Ensure that the element is now checked or unchecked. If not, this method throws.
|
|
450
|
+
#
|
|
451
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
452
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
|
453
|
+
def set_checked(
|
|
454
|
+
checked,
|
|
455
|
+
force: nil,
|
|
456
|
+
noWaitAfter: nil,
|
|
457
|
+
position: nil,
|
|
458
|
+
timeout: nil,
|
|
459
|
+
trial: nil)
|
|
460
|
+
wrap_impl(@impl.set_checked(unwrap_impl(checked), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
|
477
461
|
end
|
|
462
|
+
alias_method :checked=, :set_checked
|
|
478
463
|
|
|
479
|
-
#
|
|
480
|
-
# [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
|
|
481
|
-
#
|
|
464
|
+
#
|
|
482
465
|
# Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
|
|
483
|
-
# are resolved relative to the
|
|
466
|
+
# are resolved relative to the current working directory. For empty array, clears the selected files.
|
|
467
|
+
# For inputs with a `[webkitdirectory]` attribute, only a single directory path is supported.
|
|
468
|
+
#
|
|
469
|
+
# This method expects `ElementHandle` to point to an
|
|
470
|
+
# [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.
|
|
484
471
|
def set_input_files(files, noWaitAfter: nil, timeout: nil)
|
|
485
472
|
wrap_impl(@impl.set_input_files(unwrap_impl(files), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
|
486
473
|
end
|
|
487
474
|
alias_method :input_files=, :set_input_files
|
|
488
475
|
|
|
476
|
+
#
|
|
489
477
|
# This method taps the element by performing the following steps:
|
|
490
|
-
# 1. Wait for [actionability](
|
|
478
|
+
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
|
491
479
|
# 1. Scroll the element into view if needed.
|
|
492
480
|
# 1. Use [`property: Page.touchscreen`] to tap the center of the element, or the specified `position`.
|
|
493
|
-
#
|
|
494
|
-
#
|
|
495
|
-
#
|
|
496
|
-
#
|
|
497
|
-
#
|
|
498
|
-
#
|
|
499
|
-
#
|
|
500
|
-
# > NOTE: `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true.
|
|
481
|
+
#
|
|
482
|
+
# If the element is detached from the DOM at any moment during the action, this method throws.
|
|
483
|
+
#
|
|
484
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
485
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
|
486
|
+
#
|
|
487
|
+
# **NOTE**: `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true.
|
|
501
488
|
def tap_point(
|
|
502
489
|
force: nil,
|
|
503
490
|
modifiers: nil,
|
|
504
491
|
noWaitAfter: nil,
|
|
505
492
|
position: nil,
|
|
506
|
-
timeout: nil
|
|
507
|
-
|
|
493
|
+
timeout: nil,
|
|
494
|
+
trial: nil)
|
|
495
|
+
wrap_impl(@impl.tap_point(force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
|
508
496
|
end
|
|
509
497
|
|
|
498
|
+
#
|
|
510
499
|
# Returns the `node.textContent`.
|
|
511
500
|
def text_content
|
|
512
501
|
wrap_impl(@impl.text_content)
|
|
513
502
|
end
|
|
514
503
|
|
|
504
|
+
#
|
|
515
505
|
# Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
|
|
516
|
-
#
|
|
506
|
+
#
|
|
517
507
|
# To press a special key, like `Control` or `ArrowDown`, use [`method: ElementHandle.press`].
|
|
518
|
-
#
|
|
519
508
|
#
|
|
520
|
-
#
|
|
521
|
-
#
|
|
522
|
-
#
|
|
523
|
-
# ```
|
|
524
|
-
#
|
|
525
|
-
# ```python async
|
|
526
|
-
# await element_handle.type("hello") # types instantly
|
|
527
|
-
# await element_handle.type("world", delay=100) # types slower, like a user
|
|
528
|
-
# ```
|
|
529
|
-
#
|
|
530
|
-
# ```python sync
|
|
531
|
-
# element_handle.type("hello") # types instantly
|
|
532
|
-
# element_handle.type("world", delay=100) # types slower, like a user
|
|
533
|
-
# ```
|
|
534
|
-
#
|
|
535
|
-
# An example of typing into a text field and then submitting the form:
|
|
536
|
-
#
|
|
537
|
-
#
|
|
538
|
-
# ```js
|
|
539
|
-
# const elementHandle = await page.$('input');
|
|
540
|
-
# await elementHandle.type('some text');
|
|
541
|
-
# await elementHandle.press('Enter');
|
|
542
|
-
# ```
|
|
543
|
-
#
|
|
544
|
-
# ```python async
|
|
545
|
-
# element_handle = await page.query_selector("input")
|
|
546
|
-
# await element_handle.type("some text")
|
|
547
|
-
# await element_handle.press("Enter")
|
|
548
|
-
# ```
|
|
549
|
-
#
|
|
550
|
-
# ```python sync
|
|
551
|
-
# element_handle = page.query_selector("input")
|
|
552
|
-
# element_handle.type("some text")
|
|
553
|
-
# element_handle.press("Enter")
|
|
554
|
-
# ```
|
|
509
|
+
# **Usage**
|
|
510
|
+
#
|
|
511
|
+
# @deprecated In most cases, you should use [`method: Locator.fill`] instead. You only need to press keys one by one if there is special keyboard handling on the page - in this case use [`method: Locator.pressSequentially`].
|
|
555
512
|
def type(text, delay: nil, noWaitAfter: nil, timeout: nil)
|
|
556
513
|
wrap_impl(@impl.type(unwrap_impl(text), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
|
557
514
|
end
|
|
558
515
|
|
|
516
|
+
#
|
|
559
517
|
# This method checks the element by performing the following steps:
|
|
560
|
-
# 1. Ensure that element is a checkbox or a radio input. If not, this method
|
|
561
|
-
#
|
|
562
|
-
# 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set.
|
|
518
|
+
# 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already unchecked, this method returns immediately.
|
|
519
|
+
# 1. Wait for [actionability](../actionability.md) checks on the element, unless `force` option is set.
|
|
563
520
|
# 1. Scroll the element into view if needed.
|
|
564
521
|
# 1. Use [`property: Page.mouse`] to click in the center of the element.
|
|
565
|
-
# 1.
|
|
566
|
-
#
|
|
567
|
-
#
|
|
568
|
-
#
|
|
569
|
-
#
|
|
570
|
-
#
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
522
|
+
# 1. Ensure that the element is now unchecked. If not, this method throws.
|
|
523
|
+
#
|
|
524
|
+
# If the element is detached from the DOM at any moment during the action, this method throws.
|
|
525
|
+
#
|
|
526
|
+
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
|
527
|
+
# `TimeoutError`. Passing zero timeout disables this.
|
|
528
|
+
def uncheck(
|
|
529
|
+
force: nil,
|
|
530
|
+
noWaitAfter: nil,
|
|
531
|
+
position: nil,
|
|
532
|
+
timeout: nil,
|
|
533
|
+
trial: nil)
|
|
534
|
+
wrap_impl(@impl.uncheck(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
|
574
535
|
end
|
|
575
536
|
|
|
537
|
+
#
|
|
576
538
|
# Returns when the element satisfies the `state`.
|
|
577
|
-
#
|
|
578
|
-
# Depending on the `state` parameter, this method waits for one of the [actionability](
|
|
579
|
-
# This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
|
|
580
|
-
# - `"visible"` Wait until the element is [visible](
|
|
581
|
-
# - `"hidden"` Wait until the element is [not visible](
|
|
582
|
-
#
|
|
583
|
-
# - `"
|
|
584
|
-
#
|
|
585
|
-
# - `"
|
|
586
|
-
#
|
|
587
|
-
# - `"editable"` Wait until the element is [editable](./actionability.md#editable).
|
|
588
|
-
#
|
|
539
|
+
#
|
|
540
|
+
# Depending on the `state` parameter, this method waits for one of the [actionability](../actionability.md) checks
|
|
541
|
+
# to pass. This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
|
|
542
|
+
# - `"visible"` Wait until the element is [visible](../actionability.md#visible).
|
|
543
|
+
# - `"hidden"` Wait until the element is [not visible](../actionability.md#visible) or not attached. Note that waiting for hidden does not throw when the element detaches.
|
|
544
|
+
# - `"stable"` Wait until the element is both [visible](../actionability.md#visible) and [stable](../actionability.md#stable).
|
|
545
|
+
# - `"enabled"` Wait until the element is [enabled](../actionability.md#enabled).
|
|
546
|
+
# - `"disabled"` Wait until the element is [not enabled](../actionability.md#enabled).
|
|
547
|
+
# - `"editable"` Wait until the element is [editable](../actionability.md#editable).
|
|
548
|
+
#
|
|
589
549
|
# If the element does not satisfy the condition for the `timeout` milliseconds, this method will throw.
|
|
590
550
|
def wait_for_element_state(state, timeout: nil)
|
|
591
551
|
wrap_impl(@impl.wait_for_element_state(unwrap_impl(state), timeout: unwrap_impl(timeout)))
|
|
592
552
|
end
|
|
593
553
|
|
|
594
|
-
#
|
|
595
|
-
# `
|
|
596
|
-
#
|
|
597
|
-
#
|
|
598
|
-
#
|
|
599
|
-
#
|
|
600
|
-
#
|
|
601
|
-
#
|
|
602
|
-
#
|
|
603
|
-
#
|
|
604
|
-
#
|
|
605
|
-
# const div = await page.$('div');
|
|
606
|
-
# // Waiting for the 'span' selector relative to the div.
|
|
607
|
-
# const span = await div.waitForSelector('span', { state: 'attached' });
|
|
608
|
-
# ```
|
|
609
|
-
#
|
|
610
|
-
# ```python async
|
|
611
|
-
# await page.set_content("<div><span></span></div>")
|
|
612
|
-
# div = await page.query_selector("div")
|
|
613
|
-
# # waiting for the "span" selector relative to the div.
|
|
614
|
-
# span = await div.wait_for_selector("span", state="attached")
|
|
615
|
-
# ```
|
|
616
|
-
#
|
|
554
|
+
#
|
|
555
|
+
# Returns element specified by selector when it satisfies `state` option. Returns `null` if waiting for `hidden`
|
|
556
|
+
# or `detached`.
|
|
557
|
+
#
|
|
558
|
+
# Wait for the `selector` relative to the element handle to satisfy `state` option (either
|
|
559
|
+
# appear/disappear from dom, or become visible/hidden). If at the moment of calling the method `selector` already
|
|
560
|
+
# satisfies the condition, the method will return immediately. If the selector doesn't satisfy the condition for the
|
|
561
|
+
# `timeout` milliseconds, the function will throw.
|
|
562
|
+
#
|
|
563
|
+
# **Usage**
|
|
564
|
+
#
|
|
617
565
|
# ```python sync
|
|
618
566
|
# page.set_content("<div><span></span></div>")
|
|
619
567
|
# div = page.query_selector("div")
|
|
620
568
|
# # waiting for the "span" selector relative to the div.
|
|
621
569
|
# span = div.wait_for_selector("span", state="attached")
|
|
622
570
|
# ```
|
|
623
|
-
#
|
|
624
|
-
#
|
|
625
|
-
def wait_for_selector(selector, state: nil, timeout: nil)
|
|
626
|
-
wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
|
|
571
|
+
#
|
|
572
|
+
# **NOTE**: This method does not work across navigations, use [`method: Page.waitForSelector`] instead.
|
|
573
|
+
def wait_for_selector(selector, state: nil, strict: nil, timeout: nil)
|
|
574
|
+
wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
|
627
575
|
end
|
|
628
576
|
|
|
629
577
|
# -- inherited from EventEmitter --
|
|
630
578
|
# @nodoc
|
|
631
|
-
def
|
|
632
|
-
|
|
579
|
+
def once(event, callback)
|
|
580
|
+
event_emitter_proxy.once(event, callback)
|
|
633
581
|
end
|
|
634
582
|
|
|
635
583
|
# -- inherited from EventEmitter --
|
|
636
584
|
# @nodoc
|
|
637
|
-
def
|
|
638
|
-
|
|
585
|
+
def on(event, callback)
|
|
586
|
+
event_emitter_proxy.on(event, callback)
|
|
639
587
|
end
|
|
640
588
|
|
|
641
589
|
# -- inherited from EventEmitter --
|
|
642
590
|
# @nodoc
|
|
643
|
-
def
|
|
644
|
-
|
|
591
|
+
def off(event, callback)
|
|
592
|
+
event_emitter_proxy.off(event, callback)
|
|
593
|
+
end
|
|
594
|
+
|
|
595
|
+
private def event_emitter_proxy
|
|
596
|
+
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
|
645
597
|
end
|
|
646
598
|
end
|
|
647
599
|
end
|