playwright-ruby-client 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +49 -0
- data/Rakefile +3 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/lib/playwright.rb +39 -0
- data/lib/playwright/channel.rb +28 -0
- data/lib/playwright/channel_owner.rb +80 -0
- data/lib/playwright/channel_owners/android.rb +3 -0
- data/lib/playwright/channel_owners/binding_call.rb +4 -0
- data/lib/playwright/channel_owners/browser.rb +80 -0
- data/lib/playwright/channel_owners/browser_context.rb +13 -0
- data/lib/playwright/channel_owners/browser_type.rb +26 -0
- data/lib/playwright/channel_owners/chromium_browser.rb +8 -0
- data/lib/playwright/channel_owners/chromium_browser_context.rb +8 -0
- data/lib/playwright/channel_owners/electron.rb +3 -0
- data/lib/playwright/channel_owners/firefox_browser.rb +8 -0
- data/lib/playwright/channel_owners/frame.rb +44 -0
- data/lib/playwright/channel_owners/page.rb +53 -0
- data/lib/playwright/channel_owners/playwright.rb +57 -0
- data/lib/playwright/channel_owners/request.rb +5 -0
- data/lib/playwright/channel_owners/response.rb +5 -0
- data/lib/playwright/channel_owners/selectors.rb +4 -0
- data/lib/playwright/channel_owners/webkit_browser.rb +8 -0
- data/lib/playwright/connection.rb +238 -0
- data/lib/playwright/errors.rb +35 -0
- data/lib/playwright/event_emitter.rb +62 -0
- data/lib/playwright/events.rb +86 -0
- data/lib/playwright/playwright_api.rb +75 -0
- data/lib/playwright/transport.rb +86 -0
- data/lib/playwright/version.rb +5 -0
- data/lib/playwright_api/accessibility.rb +39 -0
- data/lib/playwright_api/binding_call.rb +5 -0
- data/lib/playwright_api/browser.rb +123 -0
- data/lib/playwright_api/browser_context.rb +285 -0
- data/lib/playwright_api/browser_type.rb +144 -0
- data/lib/playwright_api/cdp_session.rb +34 -0
- data/lib/playwright_api/chromium_browser_context.rb +26 -0
- data/lib/playwright_api/console_message.rb +22 -0
- data/lib/playwright_api/dialog.rb +46 -0
- data/lib/playwright_api/download.rb +54 -0
- data/lib/playwright_api/element_handle.rb +361 -0
- data/lib/playwright_api/file_chooser.rb +31 -0
- data/lib/playwright_api/frame.rb +526 -0
- data/lib/playwright_api/js_handle.rb +69 -0
- data/lib/playwright_api/keyboard.rb +101 -0
- data/lib/playwright_api/mouse.rb +47 -0
- data/lib/playwright_api/page.rb +986 -0
- data/lib/playwright_api/playwright.rb +35 -0
- data/lib/playwright_api/request.rb +119 -0
- data/lib/playwright_api/response.rb +61 -0
- data/lib/playwright_api/route.rb +53 -0
- data/lib/playwright_api/selectors.rb +51 -0
- data/lib/playwright_api/touchscreen.rb +10 -0
- data/lib/playwright_api/video.rb +14 -0
- data/lib/playwright_api/web_socket.rb +21 -0
- data/lib/playwright_api/worker.rb +34 -0
- data/playwright.gemspec +35 -0
- metadata +216 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative './browser_context.rb'
|
2
|
+
|
3
|
+
module Playwright
|
4
|
+
# Chromium-specific features including background pages, service worker support, etc.
|
5
|
+
#
|
6
|
+
# ```js
|
7
|
+
# const backgroundPage = await context.waitForEvent('backgroundpage');
|
8
|
+
# ```
|
9
|
+
class ChromiumBrowserContext < BrowserContext
|
10
|
+
|
11
|
+
# All existing background pages in the context.
|
12
|
+
def background_pages
|
13
|
+
raise NotImplementedError.new('background_pages is not implemented yet.')
|
14
|
+
end
|
15
|
+
|
16
|
+
# Returns the newly created session.
|
17
|
+
def new_cdp_session(page)
|
18
|
+
raise NotImplementedError.new('new_cdp_session is not implemented yet.')
|
19
|
+
end
|
20
|
+
|
21
|
+
# All existing service workers in the context.
|
22
|
+
def service_workers
|
23
|
+
raise NotImplementedError.new('service_workers is not implemented yet.')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Playwright
|
2
|
+
# ConsoleMessage objects are dispatched by page via the page.on('console') event.
|
3
|
+
class ConsoleMessage < PlaywrightApi
|
4
|
+
|
5
|
+
def args
|
6
|
+
raise NotImplementedError.new('args is not implemented yet.')
|
7
|
+
end
|
8
|
+
|
9
|
+
def location
|
10
|
+
raise NotImplementedError.new('location is not implemented yet.')
|
11
|
+
end
|
12
|
+
|
13
|
+
def text
|
14
|
+
raise NotImplementedError.new('text is not implemented yet.')
|
15
|
+
end
|
16
|
+
|
17
|
+
# One of the following values: `'log'`, `'debug'`, `'info'`, `'error'`, `'warning'`, `'dir'`, `'dirxml'`, `'table'`, `'trace'`, `'clear'`, `'startGroup'`, `'startGroupCollapsed'`, `'endGroup'`, `'assert'`, `'profile'`, `'profileEnd'`, `'count'`, `'timeEnd'`.
|
18
|
+
def type_text
|
19
|
+
raise NotImplementedError.new('type_text is not implemented yet.')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Playwright
|
2
|
+
# Dialog objects are dispatched by page via the page.on('dialog') event.
|
3
|
+
# An example of using `Dialog` class:
|
4
|
+
#
|
5
|
+
# ```js
|
6
|
+
# const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
|
7
|
+
#
|
8
|
+
# (async () => {
|
9
|
+
# const browser = await chromium.launch();
|
10
|
+
# const page = await browser.newPage();
|
11
|
+
# page.on('dialog', async dialog => {
|
12
|
+
# console.log(dialog.message());
|
13
|
+
# await dialog.dismiss();
|
14
|
+
# await browser.close();
|
15
|
+
# });
|
16
|
+
# page.evaluate(() => alert('1'));
|
17
|
+
# })();
|
18
|
+
# ```
|
19
|
+
class Dialog < PlaywrightApi
|
20
|
+
|
21
|
+
# Returns when the dialog has been accepted.
|
22
|
+
def accept(promptText: nil)
|
23
|
+
raise NotImplementedError.new('accept is not implemented yet.')
|
24
|
+
end
|
25
|
+
|
26
|
+
# If dialog is prompt, returns default prompt value. Otherwise, returns empty string.
|
27
|
+
def default_value
|
28
|
+
raise NotImplementedError.new('default_value is not implemented yet.')
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns when the dialog has been dismissed.
|
32
|
+
def dismiss
|
33
|
+
raise NotImplementedError.new('dismiss is not implemented yet.')
|
34
|
+
end
|
35
|
+
|
36
|
+
# A message displayed in the dialog.
|
37
|
+
def message
|
38
|
+
raise NotImplementedError.new('message is not implemented yet.')
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns dialog's type, can be one of `alert`, `beforeunload`, `confirm` or `prompt`.
|
42
|
+
def type_text
|
43
|
+
raise NotImplementedError.new('type_text is not implemented yet.')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Playwright
|
2
|
+
# Download objects are dispatched by page via the page.on('download') event.
|
3
|
+
# All the downloaded files belonging to the browser context are deleted when the browser context is closed. All downloaded files are deleted when the browser closes.
|
4
|
+
# Download event is emitted once the download starts. Download path becomes available once download completes:
|
5
|
+
#
|
6
|
+
# ```js
|
7
|
+
# const [ download ] = await Promise.all([
|
8
|
+
# page.waitForEvent('download'), // wait for download to start
|
9
|
+
# page.click('a')
|
10
|
+
# ]);
|
11
|
+
# // wait for download to complete
|
12
|
+
# const path = await download.path();
|
13
|
+
# ...
|
14
|
+
# ```
|
15
|
+
#
|
16
|
+
# **NOTE** Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual download is not performed and user has no access to the downloaded files.
|
17
|
+
class Download < PlaywrightApi
|
18
|
+
|
19
|
+
# Returns readable stream for current download or `null` if download failed.
|
20
|
+
def create_read_stream
|
21
|
+
raise NotImplementedError.new('create_read_stream is not implemented yet.')
|
22
|
+
end
|
23
|
+
|
24
|
+
# Deletes the downloaded file.
|
25
|
+
def delete
|
26
|
+
raise NotImplementedError.new('delete is not implemented yet.')
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns download error if any.
|
30
|
+
def failure
|
31
|
+
raise NotImplementedError.new('failure is not implemented yet.')
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns path to the downloaded file in case of successful download.
|
35
|
+
def path
|
36
|
+
raise NotImplementedError.new('path is not implemented yet.')
|
37
|
+
end
|
38
|
+
|
39
|
+
# Saves the download to a user-specified path.
|
40
|
+
def save_as(path)
|
41
|
+
raise NotImplementedError.new('save_as is not implemented yet.')
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns suggested filename for this download. It is typically computed by the browser from the `Content-Disposition` response header or the `download` attribute. See the spec on whatwg. Different browsers can use different logic for computing it.
|
45
|
+
def suggested_filename
|
46
|
+
raise NotImplementedError.new('suggested_filename is not implemented yet.')
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns downloaded url.
|
50
|
+
def url
|
51
|
+
raise NotImplementedError.new('url is not implemented yet.')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,361 @@
|
|
1
|
+
require_relative './js_handle.rb'
|
2
|
+
|
3
|
+
module Playwright
|
4
|
+
# ElementHandle represents an in-page DOM element. ElementHandles can be created with the `page.$(selector)` method.
|
5
|
+
#
|
6
|
+
# ```js
|
7
|
+
# const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
|
8
|
+
#
|
9
|
+
# (async () => {
|
10
|
+
# const browser = await chromium.launch();
|
11
|
+
# const page = await browser.newPage();
|
12
|
+
# await page.goto('https://example.com');
|
13
|
+
# const hrefElement = await page.$('a');
|
14
|
+
# await hrefElement.click();
|
15
|
+
# // ...
|
16
|
+
# })();
|
17
|
+
# ```
|
18
|
+
# ElementHandle prevents DOM element from garbage collection unless the handle is disposed with `jsHandle.dispose()`. ElementHandles are auto-disposed when their origin frame gets navigated.
|
19
|
+
# ElementHandle instances can be used as an argument in `page.$eval(selector, pageFunction[, arg])` and `page.evaluate(pageFunction[, arg])` methods.
|
20
|
+
class ElementHandle < JSHandle
|
21
|
+
|
22
|
+
# The method finds an element matching the specified selector in the `ElementHandle`'s subtree. See Working with selectors for more details. If no elements match the selector, returns `null`.
|
23
|
+
def S(selector)
|
24
|
+
raise NotImplementedError.new('S is not implemented yet.')
|
25
|
+
end
|
26
|
+
|
27
|
+
# The method finds all elements matching the specified selector in the `ElementHandle`s subtree. See Working with selectors for more details. If no elements match the selector, returns empty array.
|
28
|
+
def SS(selector)
|
29
|
+
raise NotImplementedError.new('SS is not implemented yet.')
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns the return value of `pageFunction`
|
33
|
+
# The method finds an element matching the specified selector in the `ElementHandle`s subtree and passes it as a first argument to `pageFunction`. See Working with selectors for more details. If no elements match the selector, the method throws an error.
|
34
|
+
# If `pageFunction` returns a Promise, then `frame.$eval` would wait for the promise to resolve and return its value.
|
35
|
+
# Examples:
|
36
|
+
#
|
37
|
+
# ```js
|
38
|
+
# const tweetHandle = await page.$('.tweet');
|
39
|
+
# expect(await tweetHandle.$eval('.like', node => node.innerText)).toBe('100');
|
40
|
+
# expect(await tweetHandle.$eval('.retweets', node => node.innerText)).toBe('10');
|
41
|
+
# ```
|
42
|
+
def Seval(selector, pageFunction, arg: nil)
|
43
|
+
raise NotImplementedError.new('Seval is not implemented yet.')
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns the return value of `pageFunction`
|
47
|
+
# The method finds all elements matching the specified selector in the `ElementHandle`'s subtree and passes an array of matched elements as a first argument to `pageFunction`. See Working with selectors for more details.
|
48
|
+
# If `pageFunction` returns a Promise, then `frame.$$eval` would wait for the promise to resolve and return its value.
|
49
|
+
# Examples:
|
50
|
+
# ```html
|
51
|
+
# <div class="feed">
|
52
|
+
# <div class="tweet">Hello!</div>
|
53
|
+
# <div class="tweet">Hi!</div>
|
54
|
+
# </div>
|
55
|
+
# ```
|
56
|
+
#
|
57
|
+
# ```js
|
58
|
+
# const feedHandle = await page.$('.feed');
|
59
|
+
# expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!']);
|
60
|
+
# ```
|
61
|
+
def SSeval(selector, pageFunction, arg: nil)
|
62
|
+
raise NotImplementedError.new('SSeval is not implemented yet.')
|
63
|
+
end
|
64
|
+
|
65
|
+
# This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is calculated relative to the main frame viewport - which is usually the same as the browser window.
|
66
|
+
# Scrolling affects the returned bonding box, similarly to Element.getBoundingClientRect. That means `x` and/or `y` may be negative.
|
67
|
+
# Elements from child frames return the bounding box relative to the main frame, unlike the Element.getBoundingClientRect.
|
68
|
+
# Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following snippet should click the center of the element.
|
69
|
+
#
|
70
|
+
# ```js
|
71
|
+
# const box = await elementHandle.boundingBox();
|
72
|
+
# await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
|
73
|
+
# ```
|
74
|
+
def bounding_box
|
75
|
+
raise NotImplementedError.new('bounding_box is not implemented yet.')
|
76
|
+
end
|
77
|
+
|
78
|
+
# This method checks the element by performing the following steps:
|
79
|
+
#
|
80
|
+
# Ensure that element is a checkbox or a radio input. If not, this method rejects. If the element is already checked, this method returns immediately.
|
81
|
+
# Wait for actionability checks on the element, unless `force` option is set.
|
82
|
+
# Scroll the element into view if needed.
|
83
|
+
# Use page.mouse to click in the center of the element.
|
84
|
+
# Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
85
|
+
# Ensure that the element is now checked. If not, this method rejects.
|
86
|
+
#
|
87
|
+
# If the element is detached from the DOM at any moment during the action, this method rejects.
|
88
|
+
# When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
|
89
|
+
def check(force: nil, noWaitAfter: nil, timeout: nil)
|
90
|
+
raise NotImplementedError.new('check is not implemented yet.')
|
91
|
+
end
|
92
|
+
|
93
|
+
# This method clicks the element by performing the following steps:
|
94
|
+
#
|
95
|
+
# Wait for actionability checks on the element, unless `force` option is set.
|
96
|
+
# Scroll the element into view if needed.
|
97
|
+
# Use page.mouse to click in the center of the element, or the specified `position`.
|
98
|
+
# Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
99
|
+
#
|
100
|
+
# If the element is detached from the DOM at any moment during the action, this method rejects.
|
101
|
+
# When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
|
102
|
+
def click(
|
103
|
+
button: nil,
|
104
|
+
clickCount: nil,
|
105
|
+
delay: nil,
|
106
|
+
position: nil,
|
107
|
+
modifiers: nil,
|
108
|
+
force: nil,
|
109
|
+
noWaitAfter: nil,
|
110
|
+
timeout: nil)
|
111
|
+
raise NotImplementedError.new('click is not implemented yet.')
|
112
|
+
end
|
113
|
+
|
114
|
+
# Returns the content frame for element handles referencing iframe nodes, or `null` otherwise
|
115
|
+
def content_frame
|
116
|
+
raise NotImplementedError.new('content_frame is not implemented yet.')
|
117
|
+
end
|
118
|
+
|
119
|
+
# This method double clicks the element by performing the following steps:
|
120
|
+
#
|
121
|
+
# Wait for actionability checks on the element, unless `force` option is set.
|
122
|
+
# Scroll the element into view if needed.
|
123
|
+
# Use page.mouse to double click in the center of the element, or the specified `position`.
|
124
|
+
# Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the first click of the `dblclick()` triggers a navigation event, this method will reject.
|
125
|
+
#
|
126
|
+
# If the element is detached from the DOM at any moment during the action, this method rejects.
|
127
|
+
# When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
|
128
|
+
#
|
129
|
+
# **NOTE** `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event.
|
130
|
+
def dblclick(
|
131
|
+
button: nil,
|
132
|
+
delay: nil,
|
133
|
+
position: nil,
|
134
|
+
modifiers: nil,
|
135
|
+
force: nil,
|
136
|
+
noWaitAfter: nil,
|
137
|
+
timeout: nil)
|
138
|
+
raise NotImplementedError.new('dblclick is not implemented yet.')
|
139
|
+
end
|
140
|
+
|
141
|
+
# The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the elment, `click` is dispatched. This is equivalend to calling element.click().
|
142
|
+
#
|
143
|
+
# ```js
|
144
|
+
# await elementHandle.dispatchEvent('click');
|
145
|
+
# ```
|
146
|
+
# Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
|
147
|
+
# Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
|
148
|
+
#
|
149
|
+
# DragEvent
|
150
|
+
# FocusEvent
|
151
|
+
# KeyboardEvent
|
152
|
+
# MouseEvent
|
153
|
+
# PointerEvent
|
154
|
+
# TouchEvent
|
155
|
+
# Event
|
156
|
+
#
|
157
|
+
# You can also specify `JSHandle` as the property value if you want live objects to be passed into the event:
|
158
|
+
#
|
159
|
+
# ```js
|
160
|
+
# // Note you can only create DataTransfer in Chromium and Firefox
|
161
|
+
# const dataTransfer = await page.evaluateHandle(() => new DataTransfer());
|
162
|
+
# await elementHandle.dispatchEvent('dragstart', { dataTransfer });
|
163
|
+
# ```
|
164
|
+
def dispatch_event(type, eventInit: nil)
|
165
|
+
raise NotImplementedError.new('dispatch_event is not implemented yet.')
|
166
|
+
end
|
167
|
+
|
168
|
+
# This method waits for actionability checks, focuses the element, fills it and triggers an `input` event after filling. If the element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. Note that you can pass an empty string to clear the input field.
|
169
|
+
def fill(value, noWaitAfter: nil, timeout: nil)
|
170
|
+
raise NotImplementedError.new('fill is not implemented yet.')
|
171
|
+
end
|
172
|
+
|
173
|
+
# Calls focus on the element.
|
174
|
+
def focus
|
175
|
+
raise NotImplementedError.new('focus is not implemented yet.')
|
176
|
+
end
|
177
|
+
|
178
|
+
# Returns element attribute value.
|
179
|
+
def get_attribute(name)
|
180
|
+
raise NotImplementedError.new('get_attribute is not implemented yet.')
|
181
|
+
end
|
182
|
+
|
183
|
+
# This method hovers over the element by performing the following steps:
|
184
|
+
#
|
185
|
+
# Wait for actionability checks on the element, unless `force` option is set.
|
186
|
+
# Scroll the element into view if needed.
|
187
|
+
# Use page.mouse to hover over the center of the element, or the specified `position`.
|
188
|
+
# Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
189
|
+
#
|
190
|
+
# If the element is detached from the DOM at any moment during the action, this method rejects.
|
191
|
+
# When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
|
192
|
+
def hover(position: nil, modifiers: nil, force: nil, timeout: nil)
|
193
|
+
raise NotImplementedError.new('hover is not implemented yet.')
|
194
|
+
end
|
195
|
+
|
196
|
+
# Returns the `element.innerHTML`.
|
197
|
+
def inner_html
|
198
|
+
raise NotImplementedError.new('inner_html is not implemented yet.')
|
199
|
+
end
|
200
|
+
|
201
|
+
# Returns the `element.innerText`.
|
202
|
+
def inner_text
|
203
|
+
raise NotImplementedError.new('inner_text is not implemented yet.')
|
204
|
+
end
|
205
|
+
|
206
|
+
# Returns the frame containing the given element.
|
207
|
+
def owner_frame
|
208
|
+
raise NotImplementedError.new('owner_frame is not implemented yet.')
|
209
|
+
end
|
210
|
+
|
211
|
+
# Focuses the element, and then uses `keyboard.down(key)` and `keyboard.up(key)`.
|
212
|
+
# `key` can specify the intended keyboardEvent.key value or a single character to generate the text for. A superset of the `key` values can be found here. Examples of the keys are:
|
213
|
+
# `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
|
214
|
+
# Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
|
215
|
+
# Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
|
216
|
+
# If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.
|
217
|
+
# Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When speficied with the modifier, modifier is pressed and being held while the subsequent key is being pressed.
|
218
|
+
def press(key, delay: nil, noWaitAfter: nil, timeout: nil)
|
219
|
+
raise NotImplementedError.new('press is not implemented yet.')
|
220
|
+
end
|
221
|
+
|
222
|
+
# Returns the buffer with the captured screenshot.
|
223
|
+
# This method waits for the actionability checks, then scrolls element into view before taking a screenshot. If the element is detached from DOM, the method throws an error.
|
224
|
+
def screenshot(
|
225
|
+
path: nil,
|
226
|
+
type: nil,
|
227
|
+
quality: nil,
|
228
|
+
omitBackground: nil,
|
229
|
+
timeout: nil)
|
230
|
+
raise NotImplementedError.new('screenshot is not implemented yet.')
|
231
|
+
end
|
232
|
+
|
233
|
+
# This method waits for actionability checks, then tries to scroll element into view, unless it is completely visible as defined by IntersectionObserver's `ratio`.
|
234
|
+
# Throws when `elementHandle` does not point to an element connected to a Document or a ShadowRoot.
|
235
|
+
def scroll_into_view_if_needed(timeout: nil)
|
236
|
+
raise NotImplementedError.new('scroll_into_view_if_needed is not implemented yet.')
|
237
|
+
end
|
238
|
+
|
239
|
+
# Returns the array of option values that have been successfully selected.
|
240
|
+
# Triggers a `change` and `input` event once all the provided options have been selected. If element is not a `<select>` element, the method throws an error.
|
241
|
+
#
|
242
|
+
# ```js
|
243
|
+
# // single selection matching the value
|
244
|
+
# handle.selectOption('blue');
|
245
|
+
#
|
246
|
+
# // single selection matching both the value and the label
|
247
|
+
# handle.selectOption({ label: 'Blue' });
|
248
|
+
#
|
249
|
+
# // multiple selection
|
250
|
+
# handle.selectOption('red', 'green', 'blue');
|
251
|
+
#
|
252
|
+
# // multiple selection for blue, red and second option
|
253
|
+
# handle.selectOption({ value: 'blue' }, { index: 2 }, 'red');
|
254
|
+
# ```
|
255
|
+
def select_option(values, noWaitAfter: nil, timeout: nil)
|
256
|
+
raise NotImplementedError.new('select_option is not implemented yet.')
|
257
|
+
end
|
258
|
+
|
259
|
+
# This method waits for actionability checks, then focuses the element and selects all its text content.
|
260
|
+
def select_text(timeout: nil)
|
261
|
+
raise NotImplementedError.new('select_text is not implemented yet.')
|
262
|
+
end
|
263
|
+
|
264
|
+
# This method expects `elementHandle` to point to an input element.
|
265
|
+
# Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they are resolved relative to the the current working directory. For empty array, clears the selected files.
|
266
|
+
def set_input_files(files, noWaitAfter: nil, timeout: nil)
|
267
|
+
raise NotImplementedError.new('set_input_files is not implemented yet.')
|
268
|
+
end
|
269
|
+
|
270
|
+
# This method taps the element by performing the following steps:
|
271
|
+
#
|
272
|
+
# Wait for actionability checks on the element, unless `force` option is set.
|
273
|
+
# Scroll the element into view if needed.
|
274
|
+
# Use page.touchscreen to tap in the center of the element, or the specified `position`.
|
275
|
+
# Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
276
|
+
#
|
277
|
+
# If the element is detached from the DOM at any moment during the action, this method rejects.
|
278
|
+
# When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
|
279
|
+
#
|
280
|
+
# **NOTE** `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true.
|
281
|
+
def tap_point(
|
282
|
+
position: nil,
|
283
|
+
modifiers: nil,
|
284
|
+
force: nil,
|
285
|
+
noWaitAfter: nil,
|
286
|
+
timeout: nil)
|
287
|
+
raise NotImplementedError.new('tap_point is not implemented yet.')
|
288
|
+
end
|
289
|
+
|
290
|
+
# Returns the `node.textContent`.
|
291
|
+
def text_content
|
292
|
+
raise NotImplementedError.new('text_content is not implemented yet.')
|
293
|
+
end
|
294
|
+
|
295
|
+
def to_string
|
296
|
+
raise NotImplementedError.new('to_string is not implemented yet.')
|
297
|
+
end
|
298
|
+
|
299
|
+
# Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
|
300
|
+
# To press a special key, like `Control` or `ArrowDown`, use `elementHandle.press(key[, options])`.
|
301
|
+
#
|
302
|
+
# ```js
|
303
|
+
# await elementHandle.type('Hello'); // Types instantly
|
304
|
+
# await elementHandle.type('World', {delay: 100}); // Types slower, like a user
|
305
|
+
# ```
|
306
|
+
# An example of typing into a text field and then submitting the form:
|
307
|
+
#
|
308
|
+
# ```js
|
309
|
+
# const elementHandle = await page.$('input');
|
310
|
+
# await elementHandle.type('some text');
|
311
|
+
# await elementHandle.press('Enter');
|
312
|
+
# ```
|
313
|
+
def type_text(text, delay: nil, noWaitAfter: nil, timeout: nil)
|
314
|
+
raise NotImplementedError.new('type_text is not implemented yet.')
|
315
|
+
end
|
316
|
+
|
317
|
+
# This method checks the element by performing the following steps:
|
318
|
+
#
|
319
|
+
# Ensure that element is a checkbox or a radio input. If not, this method rejects. If the element is already unchecked, this method returns immediately.
|
320
|
+
# Wait for actionability checks on the element, unless `force` option is set.
|
321
|
+
# Scroll the element into view if needed.
|
322
|
+
# Use page.mouse to click in the center of the element.
|
323
|
+
# Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
|
324
|
+
# Ensure that the element is now unchecked. If not, this method rejects.
|
325
|
+
#
|
326
|
+
# If the element is detached from the DOM at any moment during the action, this method rejects.
|
327
|
+
# When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
|
328
|
+
def uncheck(force: nil, noWaitAfter: nil, timeout: nil)
|
329
|
+
raise NotImplementedError.new('uncheck is not implemented yet.')
|
330
|
+
end
|
331
|
+
|
332
|
+
# Returns the element satisfies the `state`.
|
333
|
+
# Depending on the `state` parameter, this method waits for one of the actionability checks to pass. This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
|
334
|
+
#
|
335
|
+
# `"visible"` Wait until the element is visible.
|
336
|
+
# `"hidden"` Wait until the element is not visible or not attached. Note that waiting for hidden does not throw when the element detaches.
|
337
|
+
# `"stable"` Wait until the element is both visible and stable.
|
338
|
+
# `"enabled"` Wait until the element is enabled.
|
339
|
+
# `"disabled"` Wait until the element is not enabled.
|
340
|
+
#
|
341
|
+
# If the element does not satisfy the condition for the `timeout` milliseconds, this method will throw.
|
342
|
+
def wait_for_element_state(state, timeout: nil)
|
343
|
+
raise NotImplementedError.new('wait_for_element_state is not implemented yet.')
|
344
|
+
end
|
345
|
+
|
346
|
+
# Returns element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or `detached`.
|
347
|
+
# Wait for the `selector` relative to the element handle to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
|
348
|
+
#
|
349
|
+
# ```js
|
350
|
+
# await page.setContent(`<div><span></span></div>`);
|
351
|
+
# const div = await page.$('div');
|
352
|
+
# // Waiting for the 'span' selector relative to the div.
|
353
|
+
# const span = await div.waitForSelector('span', { state: 'attached' });
|
354
|
+
# ```
|
355
|
+
#
|
356
|
+
# **NOTE** This method does not work across navigations, use `page.waitForSelector(selector[, options])` instead.
|
357
|
+
def wait_for_selector(selector, state: nil, timeout: nil)
|
358
|
+
raise NotImplementedError.new('wait_for_selector is not implemented yet.')
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|