playwright-ruby-client 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/CODE_OF_CONDUCT.md +74 -0
  4. data/Gemfile +8 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +49 -0
  7. data/Rakefile +3 -0
  8. data/bin/console +11 -0
  9. data/bin/setup +8 -0
  10. data/lib/playwright.rb +39 -0
  11. data/lib/playwright/channel.rb +28 -0
  12. data/lib/playwright/channel_owner.rb +80 -0
  13. data/lib/playwright/channel_owners/android.rb +3 -0
  14. data/lib/playwright/channel_owners/binding_call.rb +4 -0
  15. data/lib/playwright/channel_owners/browser.rb +80 -0
  16. data/lib/playwright/channel_owners/browser_context.rb +13 -0
  17. data/lib/playwright/channel_owners/browser_type.rb +26 -0
  18. data/lib/playwright/channel_owners/chromium_browser.rb +8 -0
  19. data/lib/playwright/channel_owners/chromium_browser_context.rb +8 -0
  20. data/lib/playwright/channel_owners/electron.rb +3 -0
  21. data/lib/playwright/channel_owners/firefox_browser.rb +8 -0
  22. data/lib/playwright/channel_owners/frame.rb +44 -0
  23. data/lib/playwright/channel_owners/page.rb +53 -0
  24. data/lib/playwright/channel_owners/playwright.rb +57 -0
  25. data/lib/playwright/channel_owners/request.rb +5 -0
  26. data/lib/playwright/channel_owners/response.rb +5 -0
  27. data/lib/playwright/channel_owners/selectors.rb +4 -0
  28. data/lib/playwright/channel_owners/webkit_browser.rb +8 -0
  29. data/lib/playwright/connection.rb +238 -0
  30. data/lib/playwright/errors.rb +35 -0
  31. data/lib/playwright/event_emitter.rb +62 -0
  32. data/lib/playwright/events.rb +86 -0
  33. data/lib/playwright/playwright_api.rb +75 -0
  34. data/lib/playwright/transport.rb +86 -0
  35. data/lib/playwright/version.rb +5 -0
  36. data/lib/playwright_api/accessibility.rb +39 -0
  37. data/lib/playwright_api/binding_call.rb +5 -0
  38. data/lib/playwright_api/browser.rb +123 -0
  39. data/lib/playwright_api/browser_context.rb +285 -0
  40. data/lib/playwright_api/browser_type.rb +144 -0
  41. data/lib/playwright_api/cdp_session.rb +34 -0
  42. data/lib/playwright_api/chromium_browser_context.rb +26 -0
  43. data/lib/playwright_api/console_message.rb +22 -0
  44. data/lib/playwright_api/dialog.rb +46 -0
  45. data/lib/playwright_api/download.rb +54 -0
  46. data/lib/playwright_api/element_handle.rb +361 -0
  47. data/lib/playwright_api/file_chooser.rb +31 -0
  48. data/lib/playwright_api/frame.rb +526 -0
  49. data/lib/playwright_api/js_handle.rb +69 -0
  50. data/lib/playwright_api/keyboard.rb +101 -0
  51. data/lib/playwright_api/mouse.rb +47 -0
  52. data/lib/playwright_api/page.rb +986 -0
  53. data/lib/playwright_api/playwright.rb +35 -0
  54. data/lib/playwright_api/request.rb +119 -0
  55. data/lib/playwright_api/response.rb +61 -0
  56. data/lib/playwright_api/route.rb +53 -0
  57. data/lib/playwright_api/selectors.rb +51 -0
  58. data/lib/playwright_api/touchscreen.rb +10 -0
  59. data/lib/playwright_api/video.rb +14 -0
  60. data/lib/playwright_api/web_socket.rb +21 -0
  61. data/lib/playwright_api/worker.rb +34 -0
  62. data/playwright.gemspec +35 -0
  63. metadata +216 -0
@@ -0,0 +1,31 @@
1
+ module Playwright
2
+ # FileChooser objects are dispatched by the page in the page.on('filechooser') event.
3
+ #
4
+ # ```js
5
+ # page.on('filechooser', async (fileChooser) => {
6
+ # await fileChooser.setFiles('/tmp/myfile.pdf');
7
+ # });
8
+ # ```
9
+ class FileChooser < PlaywrightApi
10
+
11
+ # Returns input element associated with this file chooser.
12
+ def element
13
+ raise NotImplementedError.new('element is not implemented yet.')
14
+ end
15
+
16
+ # Returns whether this file chooser accepts multiple files.
17
+ def multiple?
18
+ raise NotImplementedError.new('multiple? is not implemented yet.')
19
+ end
20
+
21
+ # Returns page this file chooser belongs to.
22
+ def page
23
+ raise NotImplementedError.new('page is not implemented yet.')
24
+ end
25
+
26
+ # Sets the value of the file input this chooser is associated with. 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.
27
+ def set_files(files, noWaitAfter: nil, timeout: nil)
28
+ raise NotImplementedError.new('set_files is not implemented yet.')
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,526 @@
1
+ module Playwright
2
+ # At every point of time, page exposes its current frame tree via the `page.mainFrame()` and `frame.childFrames()` methods.
3
+ # Frame object's lifecycle is controlled by three events, dispatched on the page object:
4
+ #
5
+ # page.on('frameattached') - fired when the frame gets attached to the page. A Frame can be attached to the page only once.
6
+ # page.on('framenavigated') - fired when the frame commits navigation to a different URL.
7
+ # page.on('framedetached') - fired when the frame gets detached from the page. A Frame can be detached from the page only once.
8
+ #
9
+ # An example of dumping frame tree:
10
+ #
11
+ # ```js
12
+ # const { firefox } = require('playwright'); // Or 'chromium' or 'webkit'.
13
+ #
14
+ # (async () => {
15
+ # const browser = await firefox.launch();
16
+ # const page = await browser.newPage();
17
+ # await page.goto('https://www.google.com/chrome/browser/canary.html');
18
+ # dumpFrameTree(page.mainFrame(), '');
19
+ # await browser.close();
20
+ #
21
+ # function dumpFrameTree(frame, indent) {
22
+ # console.log(indent + frame.url());
23
+ # for (const child of frame.childFrames()) {
24
+ # dumpFrameTree(child, indent + ' ');
25
+ # }
26
+ # }
27
+ # })();
28
+ # ```
29
+ # An example of getting text from an iframe element:
30
+ #
31
+ # ```js
32
+ # const frame = page.frames().find(frame => frame.name() === 'myframe');
33
+ # const text = await frame.$eval('.selector', element => element.textContent);
34
+ # console.log(text);
35
+ # ```
36
+ class Frame < PlaywrightApi
37
+
38
+ # Returns the ElementHandle pointing to the frame element.
39
+ # The method finds an element matching the specified selector within the frame. See Working with selectors for more details. If no elements match the selector, returns `null`.
40
+ def S(selector)
41
+ raise NotImplementedError.new('S is not implemented yet.')
42
+ end
43
+
44
+ # Returns the ElementHandles pointing to the frame elements.
45
+ # The method finds all elements matching the specified selector within the frame. See Working with selectors for more details. If no elements match the selector, returns empty array.
46
+ def SS(selector)
47
+ raise NotImplementedError.new('SS is not implemented yet.')
48
+ end
49
+
50
+ # Returns the return value of `pageFunction`
51
+ # The method finds an element matching the specified selector within the frame 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.
52
+ # If `pageFunction` returns a Promise, then `frame.$eval` would wait for the promise to resolve and return its value.
53
+ # Examples:
54
+ #
55
+ # ```js
56
+ # const searchValue = await frame.$eval('#search', el => el.value);
57
+ # const preloadHref = await frame.$eval('link[rel=preload]', el => el.href);
58
+ # const html = await frame.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
59
+ # ```
60
+ def Seval(selector, pageFunction, arg: nil)
61
+ raise NotImplementedError.new('Seval is not implemented yet.')
62
+ end
63
+
64
+ # Returns the return value of `pageFunction`
65
+ # The method finds all elements matching the specified selector within the frame and passes an array of matched elements as a first argument to `pageFunction`. See Working with selectors for more details.
66
+ # If `pageFunction` returns a Promise, then `frame.$$eval` would wait for the promise to resolve and return its value.
67
+ # Examples:
68
+ #
69
+ # ```js
70
+ # const divsCounts = await frame.$$eval('div', (divs, min) => divs.length >= min, 10);
71
+ # ```
72
+ def SSeval(selector, pageFunction, arg: nil)
73
+ raise NotImplementedError.new('SSeval is not implemented yet.')
74
+ end
75
+
76
+ # Returns the added tag when the script's onload fires or when the script content was injected into frame.
77
+ # Adds a `<script>` tag into the page with the desired url or content.
78
+ def add_script_tag(params)
79
+ raise NotImplementedError.new('add_script_tag is not implemented yet.')
80
+ end
81
+
82
+ # Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame.
83
+ # Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the content.
84
+ def add_style_tag(params)
85
+ raise NotImplementedError.new('add_style_tag is not implemented yet.')
86
+ end
87
+
88
+ # This method checks an element matching `selector` by performing the following steps:
89
+ #
90
+ # Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
91
+ # Ensure that matched element is a checkbox or a radio input. If not, this method rejects. If the element is already checked, this method returns immediately.
92
+ # Wait for actionability checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
93
+ # Scroll the element into view if needed.
94
+ # Use page.mouse to click in the center of the element.
95
+ # Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
96
+ # Ensure that the element is now checked. If not, this method rejects.
97
+ #
98
+ # When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
99
+ def check(selector, force: nil, noWaitAfter: nil, timeout: nil)
100
+ raise NotImplementedError.new('check is not implemented yet.')
101
+ end
102
+
103
+ def child_frames
104
+ raise NotImplementedError.new('child_frames is not implemented yet.')
105
+ end
106
+
107
+ # This method clicks an element matching `selector` by performing the following steps:
108
+ #
109
+ # Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
110
+ # Wait for actionability checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
111
+ # Scroll the element into view if needed.
112
+ # Use page.mouse to click in the center of the element, or the specified `position`.
113
+ # Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
114
+ #
115
+ # When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
116
+ def click(
117
+ selector,
118
+ button: nil,
119
+ clickCount: nil,
120
+ delay: nil,
121
+ position: nil,
122
+ modifiers: nil,
123
+ force: nil,
124
+ noWaitAfter: nil,
125
+ timeout: nil)
126
+ raise NotImplementedError.new('click is not implemented yet.')
127
+ end
128
+
129
+ # Gets the full HTML contents of the frame, including the doctype.
130
+ def content
131
+ raise NotImplementedError.new('content is not implemented yet.')
132
+ end
133
+
134
+ # This method double clicks an element matching `selector` by performing the following steps:
135
+ #
136
+ # Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
137
+ # Wait for actionability checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
138
+ # Scroll the element into view if needed.
139
+ # Use page.mouse to double click in the center of the element, or the specified `position`.
140
+ # 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.
141
+ #
142
+ # When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
143
+ #
144
+ # **NOTE** `frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
145
+ def dblclick(
146
+ selector,
147
+ button: nil,
148
+ delay: nil,
149
+ position: nil,
150
+ modifiers: nil,
151
+ force: nil,
152
+ noWaitAfter: nil,
153
+ timeout: nil)
154
+ raise NotImplementedError.new('dblclick is not implemented yet.')
155
+ end
156
+
157
+ # 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().
158
+ #
159
+ # ```js
160
+ # await frame.dispatchEvent('button#submit', 'click');
161
+ # ```
162
+ # 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.
163
+ # Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
164
+ #
165
+ # DragEvent
166
+ # FocusEvent
167
+ # KeyboardEvent
168
+ # MouseEvent
169
+ # PointerEvent
170
+ # TouchEvent
171
+ # Event
172
+ #
173
+ # You can also specify `JSHandle` as the property value if you want live objects to be passed into the event:
174
+ #
175
+ # ```js
176
+ # // Note you can only create DataTransfer in Chromium and Firefox
177
+ # const dataTransfer = await frame.evaluateHandle(() => new DataTransfer());
178
+ # await frame.dispatchEvent('#source', 'dragstart', { dataTransfer });
179
+ # ```
180
+ def dispatch_event(selector, type, eventInit: nil, timeout: nil)
181
+ raise NotImplementedError.new('dispatch_event is not implemented yet.')
182
+ end
183
+
184
+ # Returns the return value of `pageFunction`
185
+ # If the function passed to the `frame.evaluate` returns a Promise, then `frame.evaluate` would wait for the promise to resolve and return its value.
186
+ # If the function passed to the `frame.evaluate` returns a non-Serializable value, then `frame.evaluate` returns `undefined`. DevTools Protocol also supports transferring some additional values that are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`, and bigint literals.
187
+ #
188
+ # ```js
189
+ # const result = await frame.evaluate(([x, y]) => {
190
+ # return Promise.resolve(x * y);
191
+ # }, [7, 8]);
192
+ # console.log(result); // prints "56"
193
+ # ```
194
+ # A string can also be passed in instead of a function.
195
+ #
196
+ # ```js
197
+ # console.log(await frame.evaluate('1 + 2')); // prints "3"
198
+ # ```
199
+ # ElementHandle instances can be passed as an argument to the `frame.evaluate`:
200
+ #
201
+ # ```js
202
+ # const bodyHandle = await frame.$('body');
203
+ # const html = await frame.evaluate(([body, suffix]) => body.innerHTML + suffix, [bodyHandle, 'hello']);
204
+ # await bodyHandle.dispose();
205
+ # ```
206
+ def evaluate(pageFunction, arg: nil)
207
+ raise NotImplementedError.new('evaluate is not implemented yet.')
208
+ end
209
+
210
+ # Returns the return value of `pageFunction` as in-page object (JSHandle).
211
+ # The only difference between `frame.evaluate` and `frame.evaluateHandle` is that `frame.evaluateHandle` returns in-page object (JSHandle).
212
+ # If the function, passed to the `frame.evaluateHandle`, returns a Promise, then `frame.evaluateHandle` would wait for the promise to resolve and return its value.
213
+ #
214
+ # ```js
215
+ # const aWindowHandle = await frame.evaluateHandle(() => Promise.resolve(window));
216
+ # aWindowHandle; // Handle for the window object.
217
+ # ```
218
+ # A string can also be passed in instead of a function.
219
+ #
220
+ # ```js
221
+ # const aHandle = await frame.evaluateHandle('document'); // Handle for the 'document'.
222
+ # ```
223
+ # JSHandle instances can be passed as an argument to the `frame.evaluateHandle`:
224
+ #
225
+ # ```js
226
+ # const aHandle = await frame.evaluateHandle(() => document.body);
227
+ # const resultHandle = await frame.evaluateHandle(([body, suffix]) => body.innerHTML + suffix, [aHandle, 'hello']);
228
+ # console.log(await resultHandle.jsonValue());
229
+ # await resultHandle.dispose();
230
+ # ```
231
+ def evaluate_handle(pageFunction, arg: nil)
232
+ raise NotImplementedError.new('evaluate_handle is not implemented yet.')
233
+ end
234
+
235
+ # This method waits for an element matching `selector`, waits for actionability checks, focuses the element, fills it and triggers an `input` event after filling. If the element matching `selector` 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.
236
+ # To send fine-grained keyboard events, use `frame.type(selector, text[, options])`.
237
+ def fill(selector, value, noWaitAfter: nil, timeout: nil)
238
+ raise NotImplementedError.new('fill is not implemented yet.')
239
+ end
240
+
241
+ # This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the method waits until a matching element appears in the DOM.
242
+ def focus(selector, timeout: nil)
243
+ raise NotImplementedError.new('focus is not implemented yet.')
244
+ end
245
+
246
+ # Returns the `frame` or `iframe` element handle which corresponds to this frame.
247
+ # This is an inverse of `elementHandle.contentFrame()`. Note that returned handle actually belongs to the parent frame.
248
+ # This method throws an error if the frame has been detached before `frameElement()` returns.
249
+ #
250
+ # ```js
251
+ # const frameElement = await frame.frameElement();
252
+ # const contentFrame = await frameElement.contentFrame();
253
+ # console.log(frame === contentFrame); // -> true
254
+ # ```
255
+ def frame_element
256
+ raise NotImplementedError.new('frame_element is not implemented yet.')
257
+ end
258
+
259
+ # Returns element attribute value.
260
+ def get_attribute(selector, name, timeout: nil)
261
+ raise NotImplementedError.new('get_attribute is not implemented yet.')
262
+ end
263
+
264
+ # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect.
265
+ # `frame.goto` will throw an error if:
266
+ #
267
+ # there's an SSL error (e.g. in case of self-signed certificates).
268
+ # target URL is invalid.
269
+ # the `timeout` is exceeded during navigation.
270
+ # the remote server does not respond or is unreachable.
271
+ # the main resource failed to load.
272
+ #
273
+ # `frame.goto` will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling `response.status()`.
274
+ #
275
+ # **NOTE** `frame.goto` either throws an error or returns a main resource response. The only exceptions are navigation to `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
276
+ # **NOTE** Headless mode doesn't support navigation to a PDF document. See the upstream issue.
277
+ def goto(url, timeout: nil, waitUntil: nil, referer: nil)
278
+ wrap_channel_owner(@channel_owner.goto(url, timeout: timeout, waitUntil: waitUntil, referer: referer))
279
+ end
280
+
281
+ # This method hovers over an element matching `selector` by performing the following steps:
282
+ #
283
+ # Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
284
+ # Wait for actionability checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
285
+ # Scroll the element into view if needed.
286
+ # Use page.mouse to hover over the center of the element, or the specified `position`.
287
+ # Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
288
+ #
289
+ # When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
290
+ def hover(
291
+ selector,
292
+ position: nil,
293
+ modifiers: nil,
294
+ force: nil,
295
+ timeout: nil)
296
+ raise NotImplementedError.new('hover is not implemented yet.')
297
+ end
298
+
299
+ # Returns `element.innerHTML`.
300
+ def inner_html(selector, timeout: nil)
301
+ raise NotImplementedError.new('inner_html is not implemented yet.')
302
+ end
303
+
304
+ # Returns `element.innerText`.
305
+ def inner_text(selector, timeout: nil)
306
+ raise NotImplementedError.new('inner_text is not implemented yet.')
307
+ end
308
+
309
+ # Returns `true` if the frame has been detached, or `false` otherwise.
310
+ def detached?
311
+ raise NotImplementedError.new('detached? is not implemented yet.')
312
+ end
313
+
314
+ # Returns frame's name attribute as specified in the tag.
315
+ # If the name is empty, returns the id attribute instead.
316
+ #
317
+ # **NOTE** This value is calculated once when the frame is created, and will not update if the attribute is changed later.
318
+ def name
319
+ raise NotImplementedError.new('name is not implemented yet.')
320
+ end
321
+
322
+ # Returns the page containing this frame.
323
+ def page
324
+ wrap_channel_owner(@channel_owner.page)
325
+ end
326
+
327
+ # Parent frame, if any. Detached frames and main frames return `null`.
328
+ def parent_frame
329
+ raise NotImplementedError.new('parent_frame is not implemented yet.')
330
+ end
331
+
332
+ # `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:
333
+ # `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
334
+ # Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
335
+ # Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
336
+ # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.
337
+ # 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.
338
+ def press(
339
+ selector,
340
+ key,
341
+ delay: nil,
342
+ noWaitAfter: nil,
343
+ timeout: nil)
344
+ raise NotImplementedError.new('press is not implemented yet.')
345
+ end
346
+
347
+ # Returns the array of option values that have been successfully selected.
348
+ # Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element matching `selector`, the method throws an error.
349
+ #
350
+ # ```js
351
+ # // single selection matching the value
352
+ # frame.selectOption('select#colors', 'blue');
353
+ #
354
+ # // single selection matching both the value and the label
355
+ # frame.selectOption('select#colors', { label: 'Blue' });
356
+ #
357
+ # // multiple selection
358
+ # frame.selectOption('select#colors', 'red', 'green', 'blue');
359
+ # ```
360
+ def select_option(selector, values, noWaitAfter: nil, timeout: nil)
361
+ raise NotImplementedError.new('select_option is not implemented yet.')
362
+ end
363
+
364
+ def set_content(html, timeout: nil, waitUntil: nil)
365
+ raise NotImplementedError.new('set_content is not implemented yet.')
366
+ end
367
+
368
+ # This method expects `selector` to point to an input element.
369
+ # 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.
370
+ def set_input_files(selector, files, noWaitAfter: nil, timeout: nil)
371
+ raise NotImplementedError.new('set_input_files is not implemented yet.')
372
+ end
373
+
374
+ # This method taps an element matching `selector` by performing the following steps:
375
+ #
376
+ # Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
377
+ # Wait for actionability checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
378
+ # Scroll the element into view if needed.
379
+ # Use page.touchscreen to tap the center of the element, or the specified `position`.
380
+ # Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
381
+ #
382
+ # When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
383
+ #
384
+ # **NOTE** `frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
385
+ def tap_point(
386
+ selector,
387
+ position: nil,
388
+ modifiers: nil,
389
+ noWaitAfter: nil,
390
+ force: nil,
391
+ timeout: nil)
392
+ raise NotImplementedError.new('tap_point is not implemented yet.')
393
+ end
394
+
395
+ # Returns `element.textContent`.
396
+ def text_content(selector, timeout: nil)
397
+ raise NotImplementedError.new('text_content is not implemented yet.')
398
+ end
399
+
400
+ # Returns the page title.
401
+ def title
402
+ raise NotImplementedError.new('title is not implemented yet.')
403
+ end
404
+
405
+ # Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `frame.type` can be used to send fine-grained keyboard events. To fill values in form fields, use `frame.fill(selector, value[, options])`.
406
+ # To press a special key, like `Control` or `ArrowDown`, use `keyboard.press(key[, options])`.
407
+ #
408
+ # ```js
409
+ # await frame.type('#mytextarea', 'Hello'); // Types instantly
410
+ # await frame.type('#mytextarea', 'World', {delay: 100}); // Types slower, like a user
411
+ # ```
412
+ def type_text(
413
+ selector,
414
+ text,
415
+ delay: nil,
416
+ noWaitAfter: nil,
417
+ timeout: nil)
418
+ raise NotImplementedError.new('type_text is not implemented yet.')
419
+ end
420
+
421
+ # This method checks an element matching `selector` by performing the following steps:
422
+ #
423
+ # Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
424
+ # Ensure that matched element is a checkbox or a radio input. If not, this method rejects. If the element is already unchecked, this method returns immediately.
425
+ # Wait for actionability checks on the matched element, unless `force` option is set. If the element is detached during the checks, the whole action is retried.
426
+ # Scroll the element into view if needed.
427
+ # Use page.mouse to click in the center of the element.
428
+ # Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
429
+ # Ensure that the element is now unchecked. If not, this method rejects.
430
+ #
431
+ # When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
432
+ def uncheck(selector, force: nil, noWaitAfter: nil, timeout: nil)
433
+ raise NotImplementedError.new('uncheck is not implemented yet.')
434
+ end
435
+
436
+ # Returns frame's url.
437
+ def url
438
+ raise NotImplementedError.new('url is not implemented yet.')
439
+ end
440
+
441
+ # Returns when the `pageFunction` returns a truthy value, returns that value.
442
+ # The `waitForFunction` can be used to observe viewport size change:
443
+ #
444
+ # ```js
445
+ # const { firefox } = require('playwright'); // Or 'chromium' or 'webkit'.
446
+ #
447
+ # (async () => {
448
+ # const browser = await firefox.launch();
449
+ # const page = await browser.newPage();
450
+ # const watchDog = page.mainFrame().waitForFunction('window.innerWidth < 100');
451
+ # page.setViewportSize({width: 50, height: 50});
452
+ # await watchDog;
453
+ # await browser.close();
454
+ # })();
455
+ # ```
456
+ # To pass an argument to the predicate of `frame.waitForFunction` function:
457
+ #
458
+ # ```js
459
+ # const selector = '.foo';
460
+ # await frame.waitForFunction(selector => !!document.querySelector(selector), selector);
461
+ # ```
462
+ def wait_for_function(pageFunction, arg: nil, polling: nil, timeout: nil)
463
+ raise NotImplementedError.new('wait_for_function is not implemented yet.')
464
+ end
465
+
466
+ # Waits for the required load state to be reached.
467
+ # This returns when the frame reaches a required load state, `load` by default. The navigation must have been committed when this method is called. If current document has already reached the required state, resolves immediately.
468
+ #
469
+ # ```js
470
+ # await frame.click('button'); // Click triggers navigation.
471
+ # await frame.waitForLoadState(); // Waits for 'load' state by default.
472
+ # ```
473
+ def wait_for_load_state(state: nil, timeout: nil)
474
+ raise NotImplementedError.new('wait_for_load_state is not implemented yet.')
475
+ end
476
+
477
+ # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect. In case of navigation to a different anchor or navigation due to History API usage, the navigation will resolve with `null`.
478
+ # This method waits for the frame to navigate to a new URL. It is useful for when you run code which will indirectly cause the frame to navigate. Consider this example:
479
+ #
480
+ # ```js
481
+ # const [response] = await Promise.all([
482
+ # frame.waitForNavigation(), // Wait for the navigation to finish
483
+ # frame.click('a.my-link'), // Clicking the link will indirectly cause a navigation
484
+ # ]);
485
+ # ```
486
+ # **NOTE** Usage of the History API to change the URL is considered a navigation.
487
+ def wait_for_navigation(timeout: nil, url: nil, waitUntil: nil)
488
+ raise NotImplementedError.new('wait_for_navigation is not implemented yet.')
489
+ end
490
+
491
+ # Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or `detached`.
492
+ # Wait for the `selector` 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.
493
+ # This method works across navigations:
494
+ #
495
+ # ```js
496
+ # const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.
497
+ #
498
+ # (async () => {
499
+ # const browser = await webkit.launch();
500
+ # const page = await browser.newPage();
501
+ # let currentURL;
502
+ # page.mainFrame()
503
+ # .waitForSelector('img')
504
+ # .then(() => console.log('First URL with image: ' + currentURL));
505
+ # for (currentURL of ['https://example.com', 'https://google.com', 'https://bbc.com']) {
506
+ # await page.goto(currentURL);
507
+ # }
508
+ # await browser.close();
509
+ # })();
510
+ # ```
511
+ def wait_for_selector(selector, state: nil, timeout: nil)
512
+ raise NotImplementedError.new('wait_for_selector is not implemented yet.')
513
+ end
514
+
515
+ # Waits for the given `timeout` in milliseconds.
516
+ # Note that `frame.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to be flaky. Use signals such as network events, selectors becoming visible and others instead.
517
+ def wait_for_timeout(timeout)
518
+ raise NotImplementedError.new('wait_for_timeout is not implemented yet.')
519
+ end
520
+
521
+ # @nodoc
522
+ def after_initialize
523
+ wrap_channel_owner(@channel_owner.after_initialize)
524
+ end
525
+ end
526
+ end