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,69 @@
1
+ module Playwright
2
+ # JSHandle represents an in-page JavaScript object. JSHandles can be created with the `page.evaluateHandle(pageFunction[, arg])` method.
3
+ #
4
+ # ```js
5
+ # const windowHandle = await page.evaluateHandle(() => window);
6
+ # // ...
7
+ # ```
8
+ # JSHandle prevents the referenced JavaScript object being garbage collected unless the handle is exposed with `jsHandle.dispose()`. JSHandles are auto-disposed when their origin frame gets navigated or the parent context gets destroyed.
9
+ # JSHandle instances can be used as an argument in `page.$eval(selector, pageFunction[, arg])`, `page.evaluate(pageFunction[, arg])` and `page.evaluateHandle(pageFunction[, arg])` methods.
10
+ class JSHandle < PlaywrightApi
11
+
12
+ # Returns either `null` or the object handle itself, if the object handle is an instance of ElementHandle.
13
+ def as_element
14
+ raise NotImplementedError.new('as_element is not implemented yet.')
15
+ end
16
+
17
+ # The `jsHandle.dispose` method stops referencing the element handle.
18
+ def dispose
19
+ raise NotImplementedError.new('dispose is not implemented yet.')
20
+ end
21
+
22
+ # Returns the return value of `pageFunction`
23
+ # This method passes this handle as the first argument to `pageFunction`.
24
+ # If `pageFunction` returns a Promise, then `handle.evaluate` would wait for the promise to resolve and return its value.
25
+ # Examples:
26
+ #
27
+ # ```js
28
+ # const tweetHandle = await page.$('.tweet .retweets');
29
+ # expect(await tweetHandle.evaluate((node, suffix) => node.innerText, ' retweets')).toBe('10 retweets');
30
+ # ```
31
+ def evaluate(pageFunction, arg: nil)
32
+ raise NotImplementedError.new('evaluate is not implemented yet.')
33
+ end
34
+
35
+ # Returns the return value of `pageFunction` as in-page object (JSHandle).
36
+ # This method passes this handle as the first argument to `pageFunction`.
37
+ # The only difference between `jsHandle.evaluate` and `jsHandle.evaluateHandle` is that `jsHandle.evaluateHandle` returns in-page object (JSHandle).
38
+ # If the function passed to the `jsHandle.evaluateHandle` returns a Promise, then `jsHandle.evaluateHandle` would wait for the promise to resolve and return its value.
39
+ # See `page.evaluateHandle(pageFunction[, arg])` for more details.
40
+ def evaluate_handle(pageFunction, arg: nil)
41
+ raise NotImplementedError.new('evaluate_handle is not implemented yet.')
42
+ end
43
+
44
+ # The method returns a map with **own property names** as keys and JSHandle instances for the property values.
45
+ #
46
+ # ```js
47
+ # const handle = await page.evaluateHandle(() => ({window, document}));
48
+ # const properties = await handle.getProperties();
49
+ # const windowHandle = properties.get('window');
50
+ # const documentHandle = properties.get('document');
51
+ # await handle.dispose();
52
+ # ```
53
+ def get_properties
54
+ raise NotImplementedError.new('get_properties is not implemented yet.')
55
+ end
56
+
57
+ # Fetches a single property from the referenced object.
58
+ def get_property(propertyName)
59
+ raise NotImplementedError.new('get_property is not implemented yet.')
60
+ end
61
+
62
+ # Returns a JSON representation of the object. If the object has a `toJSON` function, it **will not be called**.
63
+ #
64
+ # **NOTE** The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an error if the object has circular references.
65
+ def json_value
66
+ raise NotImplementedError.new('json_value is not implemented yet.')
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,101 @@
1
+ module Playwright
2
+ # Keyboard provides an api for managing a virtual keyboard. The high level api is `keyboard.type(text[, options])`, which takes raw characters and generates proper keydown, keypress/input, and keyup events on your page.
3
+ # For finer control, you can use `keyboard.down(key)`, `keyboard.up(key)`, and `keyboard.insertText(text)` to manually fire events as if they were generated from a real keyboard.
4
+ # An example of holding down `Shift` in order to select and delete some text:
5
+ #
6
+ # ```js
7
+ # await page.keyboard.type('Hello World!');
8
+ # await page.keyboard.press('ArrowLeft');
9
+ #
10
+ # await page.keyboard.down('Shift');
11
+ # for (let i = 0; i < ' World'.length; i++)
12
+ # await page.keyboard.press('ArrowLeft');
13
+ # await page.keyboard.up('Shift');
14
+ #
15
+ # await page.keyboard.press('Backspace');
16
+ # // Result text will end up saying 'Hello!'
17
+ # ```
18
+ # An example of pressing uppercase `A`
19
+ #
20
+ # ```js
21
+ # await page.keyboard.press('Shift+KeyA');
22
+ # // or
23
+ # await page.keyboard.press('Shift+A');
24
+ # ```
25
+ # An example to trigger select-all with the keyboard
26
+ #
27
+ # ```js
28
+ # // on Windows and Linux
29
+ # await page.keyboard.press('Control+A');
30
+ # // on macOS
31
+ # await page.keyboard.press('Meta+A');
32
+ # ```
33
+ class Keyboard < PlaywrightApi
34
+
35
+ # Dispatches a `keydown` event.
36
+ # `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:
37
+ # `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
38
+ # Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
39
+ # Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
40
+ # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.
41
+ # If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with that modifier active. To release the modifier key, use `keyboard.up(key)`.
42
+ # After the key is pressed once, subsequent calls to `keyboard.down(key)` will have repeat set to true. To release the key, use `keyboard.up(key)`.
43
+ #
44
+ # **NOTE** Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case.
45
+ def down(key)
46
+ raise NotImplementedError.new('down is not implemented yet.')
47
+ end
48
+
49
+ # Dispatches only `input` event, does not emit the `keydown`, `keyup` or `keypress` events.
50
+ #
51
+ # ```js
52
+ # page.keyboard.insertText('嗨');
53
+ # ```
54
+ #
55
+ # **NOTE** Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case.
56
+ def insert_text(text)
57
+ raise NotImplementedError.new('insert_text is not implemented yet.')
58
+ end
59
+
60
+ # `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:
61
+ # `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
62
+ # Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
63
+ # Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
64
+ # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.
65
+ # 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.
66
+ #
67
+ # ```js
68
+ # const page = await browser.newPage();
69
+ # await page.goto('https://keycode.info');
70
+ # await page.keyboard.press('A');
71
+ # await page.screenshot({ path: 'A.png' });
72
+ # await page.keyboard.press('ArrowLeft');
73
+ # await page.screenshot({ path: 'ArrowLeft.png' });
74
+ # await page.keyboard.press('Shift+O');
75
+ # await page.screenshot({ path: 'O.png' });
76
+ # await browser.close();
77
+ # ```
78
+ # Shortcut for `keyboard.down(key)` and `keyboard.up(key)`.
79
+ def press(key, delay: nil)
80
+ raise NotImplementedError.new('press is not implemented yet.')
81
+ end
82
+
83
+ # Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
84
+ # To press a special key, like `Control` or `ArrowDown`, use `keyboard.press(key[, options])`.
85
+ #
86
+ # ```js
87
+ # await page.keyboard.type('Hello'); // Types instantly
88
+ # await page.keyboard.type('World', {delay: 100}); // Types slower, like a user
89
+ # ```
90
+ #
91
+ # **NOTE** Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.
92
+ def type_text(text, delay: nil)
93
+ raise NotImplementedError.new('type_text is not implemented yet.')
94
+ end
95
+
96
+ # Dispatches a `keyup` event.
97
+ def up(key)
98
+ raise NotImplementedError.new('up is not implemented yet.')
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,47 @@
1
+ module Playwright
2
+ # The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.
3
+ # Every `page` object has its own Mouse, accessible with page.mouse.
4
+ #
5
+ # ```js
6
+ # // Using ‘page.mouse’ to trace a 100x100 square.
7
+ # await page.mouse.move(0, 0);
8
+ # await page.mouse.down();
9
+ # await page.mouse.move(0, 100);
10
+ # await page.mouse.move(100, 100);
11
+ # await page.mouse.move(100, 0);
12
+ # await page.mouse.move(0, 0);
13
+ # await page.mouse.up();
14
+ # ```
15
+ class Mouse < PlaywrightApi
16
+
17
+ # Shortcut for `mouse.move(x, y[, options])`, `mouse.down([options])`, `mouse.up([options])`.
18
+ def click(
19
+ x,
20
+ y,
21
+ button: nil,
22
+ clickCount: nil,
23
+ delay: nil)
24
+ raise NotImplementedError.new('click is not implemented yet.')
25
+ end
26
+
27
+ # Shortcut for `mouse.move(x, y[, options])`, `mouse.down([options])`, `mouse.up([options])`, `mouse.down([options])` and `mouse.up([options])`.
28
+ def dblclick(x, y, button: nil, delay: nil)
29
+ raise NotImplementedError.new('dblclick is not implemented yet.')
30
+ end
31
+
32
+ # Dispatches a `mousedown` event.
33
+ def down(button: nil, clickCount: nil)
34
+ raise NotImplementedError.new('down is not implemented yet.')
35
+ end
36
+
37
+ # Dispatches a `mousemove` event.
38
+ def move(x, y, steps: nil)
39
+ raise NotImplementedError.new('move is not implemented yet.')
40
+ end
41
+
42
+ # Dispatches a `mouseup` event.
43
+ def up(button: nil, clickCount: nil)
44
+ raise NotImplementedError.new('up is not implemented yet.')
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,986 @@
1
+ module Playwright
2
+ # Page provides methods to interact with a single tab in a Browser, or an extension background page in Chromium. One Browser instance might have multiple Page instances.
3
+ # This example creates a page, navigates it to a URL, and then saves a screenshot:
4
+ #
5
+ # ```js
6
+ # const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.
7
+ #
8
+ # (async () => {
9
+ # const browser = await webkit.launch();
10
+ # const context = await browser.newContext();
11
+ # const page = await context.newPage();
12
+ # await page.goto('https://example.com');
13
+ # await page.screenshot({path: 'screenshot.png'});
14
+ # await browser.close();
15
+ # })();
16
+ # ```
17
+ # The Page class emits various events (described below) which can be handled using any of Node's native `EventEmitter` methods, such as `on`, `once` or `removeListener`.
18
+ # This example logs a message for a single page `load` event:
19
+ #
20
+ # ```js
21
+ # page.once('load', () => console.log('Page loaded!'));
22
+ # ```
23
+ # To unsubscribe from events use the `removeListener` method:
24
+ #
25
+ # ```js
26
+ # function logRequest(interceptedRequest) {
27
+ # console.log('A request was made:', interceptedRequest.url());
28
+ # }
29
+ # page.on('request', logRequest);
30
+ # // Sometime later...
31
+ # page.removeListener('request', logRequest);
32
+ # ```
33
+ class Page < PlaywrightApi
34
+
35
+ def accessibility # property
36
+ wrap_channel_owner(@channel_owner.accessibility)
37
+ end
38
+
39
+ # Browser-specific Coverage implementation, only available for Chromium atm. See ChromiumCoverage for more details.
40
+ def coverage # property
41
+ raise NotImplementedError.new('coverage is not implemented yet.')
42
+ end
43
+
44
+ def keyboard # property
45
+ wrap_channel_owner(@channel_owner.keyboard)
46
+ end
47
+
48
+ def mouse # property
49
+ wrap_channel_owner(@channel_owner.mouse)
50
+ end
51
+
52
+ def touchscreen # property
53
+ wrap_channel_owner(@channel_owner.touchscreen)
54
+ end
55
+
56
+ # The method finds an element matching the specified selector within the page. If no elements match the selector, the return value resolves to `null`.
57
+ # Shortcut for main frame's `frame.$(selector)`.
58
+ def S(selector)
59
+ raise NotImplementedError.new('S is not implemented yet.')
60
+ end
61
+
62
+ # The method finds all elements matching the specified selector within the page. If no elements match the selector, the return value resolves to `[]`.
63
+ # Shortcut for main frame's `frame.$$(selector)`.
64
+ def SS(selector)
65
+ raise NotImplementedError.new('SS is not implemented yet.')
66
+ end
67
+
68
+ # The method finds an element matching the specified selector within the page and passes it as a first argument to `pageFunction`. If no elements match the selector, the method throws an error. Returns the value of `pageFunction`.
69
+ # If `pageFunction` returns a Promise, then `page.$eval(selector, pageFunction[, arg])` would wait for the promise to resolve and return its value.
70
+ # Examples:
71
+ #
72
+ # ```js
73
+ # const searchValue = await page.$eval('#search', el => el.value);
74
+ # const preloadHref = await page.$eval('link[rel=preload]', el => el.href);
75
+ # const html = await page.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
76
+ # ```
77
+ # Shortcut for main frame's `frame.$eval(selector, pageFunction[, arg])`.
78
+ def Seval(selector, pageFunction, arg: nil)
79
+ raise NotImplementedError.new('Seval is not implemented yet.')
80
+ end
81
+
82
+ # The method finds all elements matching the specified selector within the page and passes an array of matched elements as a first argument to `pageFunction`. Returns the result of `pageFunction` invocation.
83
+ # If `pageFunction` returns a Promise, then `page.$$eval(selector, pageFunction[, arg])` would wait for the promise to resolve and return its value.
84
+ # Examples:
85
+ #
86
+ # ```js
87
+ # const divsCounts = await page.$$eval('div', (divs, min) => divs.length >= min, 10);
88
+ # ```
89
+ def SSeval(selector, pageFunction, arg: nil)
90
+ raise NotImplementedError.new('SSeval is not implemented yet.')
91
+ end
92
+
93
+ # Adds a script which would be evaluated in one of the following scenarios:
94
+ #
95
+ # Whenever the page is navigated.
96
+ # Whenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly attached frame.
97
+ #
98
+ # The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend the JavaScript environment, e.g. to seed `Math.random`.
99
+ # An example of overriding `Math.random` before the page loads:
100
+ #
101
+ # ```js
102
+ # // preload.js
103
+ # Math.random = () => 42;
104
+ #
105
+ # // In your playwright script, assuming the preload.js file is in same directory
106
+ # const preloadFile = fs.readFileSync('./preload.js', 'utf8');
107
+ # await page.addInitScript(preloadFile);
108
+ # ```
109
+ #
110
+ # **NOTE** The order of evaluation of multiple scripts installed via `browserContext.addInitScript(script[, arg])` and `page.addInitScript(script[, arg])` is not defined.
111
+ def add_init_script(script, arg: nil)
112
+ raise NotImplementedError.new('add_init_script is not implemented yet.')
113
+ end
114
+
115
+ # Adds a `<script>` tag into the page with the desired url or content. Returns the added tag when the script's onload fires or when the script content was injected into frame.
116
+ # Shortcut for main frame's `frame.addScriptTag(params)`.
117
+ def add_script_tag(params)
118
+ raise NotImplementedError.new('add_script_tag is not implemented yet.')
119
+ end
120
+
121
+ # Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the content. Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame.
122
+ # Shortcut for main frame's `frame.addStyleTag(params)`.
123
+ def add_style_tag(params)
124
+ raise NotImplementedError.new('add_style_tag is not implemented yet.')
125
+ end
126
+
127
+ # Brings page to front (activates tab).
128
+ def bring_to_front
129
+ raise NotImplementedError.new('bring_to_front is not implemented yet.')
130
+ end
131
+
132
+ # This method checks an element matching `selector` by performing the following steps:
133
+ #
134
+ # Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
135
+ # 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.
136
+ # 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.
137
+ # Scroll the element into view if needed.
138
+ # Use page.mouse to click in the center of the element.
139
+ # Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
140
+ # Ensure that the element is now checked. If not, this method rejects.
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
+ # Shortcut for main frame's `frame.check(selector[, options])`.
144
+ def check(selector, force: nil, noWaitAfter: nil, timeout: nil)
145
+ raise NotImplementedError.new('check is not implemented yet.')
146
+ end
147
+
148
+ # This method clicks an element matching `selector` by performing the following steps:
149
+ #
150
+ # Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
151
+ # 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.
152
+ # Scroll the element into view if needed.
153
+ # Use page.mouse to click in the center of the element, or the specified `position`.
154
+ # Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
155
+ #
156
+ # When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
157
+ # Shortcut for main frame's `frame.click(selector[, options])`.
158
+ def click(
159
+ selector,
160
+ button: nil,
161
+ clickCount: nil,
162
+ delay: nil,
163
+ position: nil,
164
+ modifiers: nil,
165
+ force: nil,
166
+ noWaitAfter: nil,
167
+ timeout: nil)
168
+ raise NotImplementedError.new('click is not implemented yet.')
169
+ end
170
+
171
+ # If `runBeforeUnload` is `false`, does not run any unload handlers and waits for the page to be closed. If `runBeforeUnload` is `true` the method will run unload handlers, but will **not** wait for the page to close.
172
+ # By default, `page.close()` **does not** run `beforeunload` handlers.
173
+ #
174
+ # **NOTE** if `runBeforeUnload` is passed as true, a `beforeunload` dialog might be summoned
175
+ # and should be handled manually via page.on('dialog') event.
176
+ def close(runBeforeUnload: nil)
177
+ raise NotImplementedError.new('close is not implemented yet.')
178
+ end
179
+
180
+ # Gets the full HTML contents of the page, including the doctype.
181
+ def content
182
+ raise NotImplementedError.new('content is not implemented yet.')
183
+ end
184
+
185
+ # Get the browser context that the page belongs to.
186
+ def context
187
+ raise NotImplementedError.new('context is not implemented yet.')
188
+ end
189
+
190
+ # This method double clicks an element matching `selector` by performing the following steps:
191
+ #
192
+ # Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
193
+ # 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.
194
+ # Scroll the element into view if needed.
195
+ # Use page.mouse to double click in the center of the element, or the specified `position`.
196
+ # 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.
197
+ #
198
+ # When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
199
+ #
200
+ # **NOTE** `page.dblclick()` dispatches two `click` events and a single `dblclick` event.
201
+ #
202
+ # Shortcut for main frame's `frame.dblclick(selector[, options])`.
203
+ def dblclick(
204
+ selector,
205
+ button: nil,
206
+ delay: nil,
207
+ position: nil,
208
+ modifiers: nil,
209
+ force: nil,
210
+ noWaitAfter: nil,
211
+ timeout: nil)
212
+ raise NotImplementedError.new('dblclick is not implemented yet.')
213
+ end
214
+
215
+ # 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().
216
+ #
217
+ # ```js
218
+ # await page.dispatchEvent('button#submit', 'click');
219
+ # ```
220
+ # 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.
221
+ # Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
222
+ #
223
+ # DragEvent
224
+ # FocusEvent
225
+ # KeyboardEvent
226
+ # MouseEvent
227
+ # PointerEvent
228
+ # TouchEvent
229
+ # Event
230
+ #
231
+ # You can also specify `JSHandle` as the property value if you want live objects to be passed into the event:
232
+ #
233
+ # ```js
234
+ # // Note you can only create DataTransfer in Chromium and Firefox
235
+ # const dataTransfer = await page.evaluateHandle(() => new DataTransfer());
236
+ # await page.dispatchEvent('#source', 'dragstart', { dataTransfer });
237
+ # ```
238
+ def dispatch_event(selector, type, eventInit: nil, timeout: nil)
239
+ raise NotImplementedError.new('dispatch_event is not implemented yet.')
240
+ end
241
+
242
+ #
243
+ # ```js
244
+ # await page.evaluate(() => matchMedia('screen').matches);
245
+ # // → true
246
+ # await page.evaluate(() => matchMedia('print').matches);
247
+ # // → false
248
+ #
249
+ # await page.emulateMedia({ media: 'print' });
250
+ # await page.evaluate(() => matchMedia('screen').matches);
251
+ # // → false
252
+ # await page.evaluate(() => matchMedia('print').matches);
253
+ # // → true
254
+ #
255
+ # await page.emulateMedia({});
256
+ # await page.evaluate(() => matchMedia('screen').matches);
257
+ # // → true
258
+ # await page.evaluate(() => matchMedia('print').matches);
259
+ # // → false
260
+ # ```
261
+ #
262
+ # ```js
263
+ # await page.emulateMedia({ colorScheme: 'dark' });
264
+ # await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches);
265
+ # // → true
266
+ # await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches);
267
+ # // → false
268
+ # await page.evaluate(() => matchMedia('(prefers-color-scheme: no-preference)').matches);
269
+ # // → false
270
+ # ```
271
+ def emulate_media(params)
272
+ raise NotImplementedError.new('emulate_media is not implemented yet.')
273
+ end
274
+
275
+ # Returns the value of the `pageFunction` invacation.
276
+ # If the function passed to the `page.evaluate` returns a Promise, then `page.evaluate` would wait for the promise to resolve and return its value.
277
+ # If the function passed to the `page.evaluate` returns a non-Serializable value, then `page.evaluate` resolves to `undefined`. DevTools Protocol also supports transferring some additional values that are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`, and bigint literals.
278
+ # Passing argument to `pageFunction`:
279
+ #
280
+ # ```js
281
+ # const result = await page.evaluate(([x, y]) => {
282
+ # return Promise.resolve(x * y);
283
+ # }, [7, 8]);
284
+ # console.log(result); // prints "56"
285
+ # ```
286
+ # A string can also be passed in instead of a function:
287
+ #
288
+ # ```js
289
+ # console.log(await page.evaluate('1 + 2')); // prints "3"
290
+ # const x = 10;
291
+ # console.log(await page.evaluate(`1 + ${x}`)); // prints "11"
292
+ # ```
293
+ # ElementHandle instances can be passed as an argument to the `page.evaluate`:
294
+ #
295
+ # ```js
296
+ # const bodyHandle = await page.$('body');
297
+ # const html = await page.evaluate(([body, suffix]) => body.innerHTML + suffix, [bodyHandle, 'hello']);
298
+ # await bodyHandle.dispose();
299
+ # ```
300
+ # Shortcut for main frame's `frame.evaluate(pageFunction[, arg])`.
301
+ def evaluate(pageFunction, arg: nil)
302
+ raise NotImplementedError.new('evaluate is not implemented yet.')
303
+ end
304
+
305
+ # Returns the value of the `pageFunction` invacation as in-page object (JSHandle).
306
+ # The only difference between `page.evaluate` and `page.evaluateHandle` is that `page.evaluateHandle` returns in-page object (JSHandle).
307
+ # If the function passed to the `page.evaluateHandle` returns a Promise, then `page.evaluateHandle` would wait for the promise to resolve and return its value.
308
+ # A string can also be passed in instead of a function:
309
+ #
310
+ # ```js
311
+ # const aHandle = await page.evaluateHandle('document'); // Handle for the 'document'
312
+ # ```
313
+ # JSHandle instances can be passed as an argument to the `page.evaluateHandle`:
314
+ #
315
+ # ```js
316
+ # const aHandle = await page.evaluateHandle(() => document.body);
317
+ # const resultHandle = await page.evaluateHandle(body => body.innerHTML, aHandle);
318
+ # console.log(await resultHandle.jsonValue());
319
+ # await resultHandle.dispose();
320
+ # ```
321
+ def evaluate_handle(pageFunction, arg: nil)
322
+ raise NotImplementedError.new('evaluate_handle is not implemented yet.')
323
+ end
324
+
325
+ # The method adds a function called `name` on the `window` object of every frame in this page. When called, the function executes `playwrightBinding` and returns a Promise which resolves to the return value of `playwrightBinding`. If the `playwrightBinding` returns a Promise, it will be awaited.
326
+ # The first argument of the `playwrightBinding` function contains information about the caller: `{ browserContext: BrowserContext, page: Page, frame: Frame }`.
327
+ # See `browserContext.exposeBinding(name, playwrightBinding[, options])` for the context-wide version.
328
+ #
329
+ # **NOTE** Functions installed via `page.exposeBinding` survive navigations.
330
+ #
331
+ # An example of exposing page URL to all frames in a page:
332
+ #
333
+ # ```js
334
+ # const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.
335
+ #
336
+ # (async () => {
337
+ # const browser = await webkit.launch({ headless: false });
338
+ # const context = await browser.newContext();
339
+ # const page = await context.newPage();
340
+ # await page.exposeBinding('pageURL', ({ page }) => page.url());
341
+ # await page.setContent(`
342
+ # <script>
343
+ # async function onClick() {
344
+ # document.querySelector('div').textContent = await window.pageURL();
345
+ # }
346
+ # </script>
347
+ # <button onclick="onClick()">Click me</button>
348
+ # <div></div>
349
+ # `);
350
+ # await page.click('button');
351
+ # })();
352
+ # ```
353
+ # An example of passing an element handle:
354
+ #
355
+ # ```js
356
+ # await page.exposeBinding('clicked', async (source, element) => {
357
+ # console.log(await element.textContent());
358
+ # }, { handle: true });
359
+ # await page.setContent(`
360
+ # <script>
361
+ # document.addEventListener('click', event => window.clicked(event.target));
362
+ # </script>
363
+ # <div>Click me</div>
364
+ # <div>Or click me</div>
365
+ # `);
366
+ # ```
367
+ def expose_binding(name, playwrightBinding, handle: nil)
368
+ raise NotImplementedError.new('expose_binding is not implemented yet.')
369
+ end
370
+
371
+ # The method adds a function called `name` on the `window` object of every frame in the page. When called, the function executes `playwrightFunction` and returns a Promise which resolves to the return value of `playwrightFunction`.
372
+ # If the `playwrightFunction` returns a Promise, it will be awaited.
373
+ # See `browserContext.exposeFunction(name, playwrightFunction)` for context-wide exposed function.
374
+ #
375
+ # **NOTE** Functions installed via `page.exposeFunction` survive navigations.
376
+ #
377
+ # An example of adding an `md5` function to the page:
378
+ #
379
+ # ```js
380
+ # const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.
381
+ # const crypto = require('crypto');
382
+ #
383
+ # (async () => {
384
+ # const browser = await webkit.launch({ headless: false });
385
+ # const page = await browser.newPage();
386
+ # await page.exposeFunction('md5', text => crypto.createHash('md5').update(text).digest('hex'));
387
+ # await page.setContent(`
388
+ # <script>
389
+ # async function onClick() {
390
+ # document.querySelector('div').textContent = await window.md5('PLAYWRIGHT');
391
+ # }
392
+ # </script>
393
+ # <button onclick="onClick()">Click me</button>
394
+ # <div></div>
395
+ # `);
396
+ # await page.click('button');
397
+ # })();
398
+ # ```
399
+ # An example of adding a `window.readfile` function to the page:
400
+ #
401
+ # ```js
402
+ # const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
403
+ # const fs = require('fs');
404
+ #
405
+ # (async () => {
406
+ # const browser = await chromium.launch();
407
+ # const page = await browser.newPage();
408
+ # page.on('console', msg => console.log(msg.text()));
409
+ # await page.exposeFunction('readfile', async filePath => {
410
+ # return new Promise((resolve, reject) => {
411
+ # fs.readFile(filePath, 'utf8', (err, text) => {
412
+ # if (err)
413
+ # reject(err);
414
+ # else
415
+ # resolve(text);
416
+ # });
417
+ # });
418
+ # });
419
+ # await page.evaluate(async () => {
420
+ # // use window.readfile to read contents of a file
421
+ # const content = await window.readfile('/etc/hosts');
422
+ # console.log(content);
423
+ # });
424
+ # await browser.close();
425
+ # })();
426
+ # ```
427
+ def expose_function(name, playwrightFunction)
428
+ raise NotImplementedError.new('expose_function is not implemented yet.')
429
+ end
430
+
431
+ # 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.
432
+ # To send fine-grained keyboard events, use `page.type(selector, text[, options])`.
433
+ # Shortcut for main frame's `frame.fill(selector, value[, options])`
434
+ def fill(selector, value, noWaitAfter: nil, timeout: nil)
435
+ raise NotImplementedError.new('fill is not implemented yet.')
436
+ end
437
+
438
+ # 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.
439
+ # Shortcut for main frame's `frame.focus(selector[, options])`.
440
+ def focus(selector, timeout: nil)
441
+ raise NotImplementedError.new('focus is not implemented yet.')
442
+ end
443
+
444
+ # Returns frame matching the specified criteria. Either `name` or `url` must be specified.
445
+ #
446
+ # ```js
447
+ # const frame = page.frame('frame-name');
448
+ # ```
449
+ #
450
+ # ```js
451
+ # const frame = page.frame({ url: /.*domain.*/ });
452
+ # ```
453
+ def frame(frameSelector)
454
+ raise NotImplementedError.new('frame is not implemented yet.')
455
+ end
456
+
457
+ # An array of all frames attached to the page.
458
+ def frames
459
+ raise NotImplementedError.new('frames is not implemented yet.')
460
+ end
461
+
462
+ # Returns element attribute value.
463
+ def get_attribute(selector, name, timeout: nil)
464
+ raise NotImplementedError.new('get_attribute is not implemented yet.')
465
+ end
466
+
467
+ # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect. If can not go back, returns `null`.
468
+ # Navigate to the previous page in history.
469
+ def go_back(timeout: nil, waitUntil: nil)
470
+ raise NotImplementedError.new('go_back is not implemented yet.')
471
+ end
472
+
473
+ # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect. If can not go forward, returns `null`.
474
+ # Navigate to the next page in history.
475
+ def go_forward(timeout: nil, waitUntil: nil)
476
+ raise NotImplementedError.new('go_forward is not implemented yet.')
477
+ end
478
+
479
+ # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect.
480
+ # `page.goto` will throw an error if:
481
+ #
482
+ # there's an SSL error (e.g. in case of self-signed certificates).
483
+ # target URL is invalid.
484
+ # the `timeout` is exceeded during navigation.
485
+ # the remote server does not respond or is unreachable.
486
+ # the main resource failed to load.
487
+ #
488
+ # `page.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()`.
489
+ #
490
+ # **NOTE** `page.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`.
491
+ # **NOTE** Headless mode doesn't support navigation to a PDF document. See the upstream issue.
492
+ #
493
+ # Shortcut for main frame's `frame.goto(url[, options])`
494
+ def goto(url, timeout: nil, waitUntil: nil, referer: nil)
495
+ wrap_channel_owner(@channel_owner.goto(url, timeout: timeout, waitUntil: waitUntil, referer: referer))
496
+ end
497
+
498
+ # This method hovers over an element matching `selector` by performing the following steps:
499
+ #
500
+ # Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
501
+ # 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.
502
+ # Scroll the element into view if needed.
503
+ # Use page.mouse to hover over the center of the element, or the specified `position`.
504
+ # Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
505
+ #
506
+ # When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
507
+ # Shortcut for main frame's `frame.hover(selector[, options])`.
508
+ def hover(
509
+ selector,
510
+ position: nil,
511
+ modifiers: nil,
512
+ force: nil,
513
+ timeout: nil)
514
+ raise NotImplementedError.new('hover is not implemented yet.')
515
+ end
516
+
517
+ # Returns `element.innerHTML`.
518
+ def inner_html(selector, timeout: nil)
519
+ raise NotImplementedError.new('inner_html is not implemented yet.')
520
+ end
521
+
522
+ # Returns `element.innerText`.
523
+ def inner_text(selector, timeout: nil)
524
+ raise NotImplementedError.new('inner_text is not implemented yet.')
525
+ end
526
+
527
+ # Indicates that the page has been closed.
528
+ def closed?
529
+ raise NotImplementedError.new('closed? is not implemented yet.')
530
+ end
531
+
532
+ # The page's main frame. Page is guaranteed to have a main frame which persists during navigations.
533
+ def main_frame
534
+ wrap_channel_owner(@channel_owner.main_frame)
535
+ end
536
+
537
+ # Returns the opener for popup pages and `null` for others. If the opener has been closed already the returns `null`.
538
+ def opener
539
+ raise NotImplementedError.new('opener is not implemented yet.')
540
+ end
541
+
542
+ # Returns the PDF buffer.
543
+ #
544
+ # **NOTE** Generating a pdf is currently only supported in Chromium headless.
545
+ #
546
+ # `page.pdf()` generates a pdf of the page with `print` css media. To generate a pdf with `screen` media, call `page.emulateMedia(params)` before calling `page.pdf()`:
547
+ #
548
+ # **NOTE** By default, `page.pdf()` generates a pdf with modified colors for printing. Use the `-webkit-print-color-adjust` property to force rendering of exact colors.
549
+ #
550
+ #
551
+ # ```js
552
+ # // Generates a PDF with 'screen' media type.
553
+ # await page.emulateMedia({media: 'screen'});
554
+ # await page.pdf({path: 'page.pdf'});
555
+ # ```
556
+ # The `width`, `height`, and `margin` options accept values labeled with units. Unlabeled values are treated as pixels.
557
+ # A few examples:
558
+ #
559
+ # `page.pdf({width: 100})` - prints with width set to 100 pixels
560
+ # `page.pdf({width: '100px'})` - prints with width set to 100 pixels
561
+ # `page.pdf({width: '10cm'})` - prints with width set to 10 centimeters.
562
+ #
563
+ # All possible units are:
564
+ #
565
+ # `px` - pixel
566
+ # `in` - inch
567
+ # `cm` - centimeter
568
+ # `mm` - millimeter
569
+ #
570
+ # The `format` options are:
571
+ #
572
+ # `Letter`: 8.5in x 11in
573
+ # `Legal`: 8.5in x 14in
574
+ # `Tabloid`: 11in x 17in
575
+ # `Ledger`: 17in x 11in
576
+ # `A0`: 33.1in x 46.8in
577
+ # `A1`: 23.4in x 33.1in
578
+ # `A2`: 16.54in x 23.4in
579
+ # `A3`: 11.7in x 16.54in
580
+ # `A4`: 8.27in x 11.7in
581
+ # `A5`: 5.83in x 8.27in
582
+ # `A6`: 4.13in x 5.83in
583
+ #
584
+ #
585
+ # **NOTE** `headerTemplate` and `footerTemplate` markup have the following limitations:
586
+ #
587
+ # Script tags inside templates are not evaluated.
588
+ # Page styles are not visible inside templates.
589
+ def pdf(
590
+ path: nil,
591
+ scale: nil,
592
+ displayHeaderFooter: nil,
593
+ headerTemplate: nil,
594
+ footerTemplate: nil,
595
+ printBackground: nil,
596
+ landscape: nil,
597
+ pageRanges: nil,
598
+ format: nil,
599
+ width: nil,
600
+ height: nil,
601
+ margin: nil,
602
+ preferCSSPageSize: nil)
603
+ raise NotImplementedError.new('pdf is not implemented yet.')
604
+ end
605
+
606
+ # Focuses the element, and then uses `keyboard.down(key)` and `keyboard.up(key)`.
607
+ # `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:
608
+ # `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`, `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
609
+ # Following modification shortcuts are also suported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
610
+ # Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
611
+ # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective texts.
612
+ # 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.
613
+ #
614
+ # ```js
615
+ # const page = await browser.newPage();
616
+ # await page.goto('https://keycode.info');
617
+ # await page.press('body', 'A');
618
+ # await page.screenshot({ path: 'A.png' });
619
+ # await page.press('body', 'ArrowLeft');
620
+ # await page.screenshot({ path: 'ArrowLeft.png' });
621
+ # await page.press('body', 'Shift+O');
622
+ # await page.screenshot({ path: 'O.png' });
623
+ # await browser.close();
624
+ # ```
625
+ def press(
626
+ selector,
627
+ key,
628
+ delay: nil,
629
+ noWaitAfter: nil,
630
+ timeout: nil)
631
+ raise NotImplementedError.new('press is not implemented yet.')
632
+ end
633
+
634
+ # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect.
635
+ def reload(timeout: nil, waitUntil: nil)
636
+ raise NotImplementedError.new('reload is not implemented yet.')
637
+ end
638
+
639
+ # Routing provides the capability to modify network requests that are made by a page.
640
+ # Once routing is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
641
+ #
642
+ # **NOTE** The handler will only be called for the first url if the response is a redirect.
643
+ #
644
+ # An example of a naïve handler that aborts all image requests:
645
+ #
646
+ # ```js
647
+ # const page = await browser.newPage();
648
+ # await page.route('**/*.{png,jpg,jpeg}', route => route.abort());
649
+ # await page.goto('https://example.com');
650
+ # await browser.close();
651
+ # ```
652
+ # or the same snippet using a regex pattern instead:
653
+ #
654
+ # ```js
655
+ # const page = await browser.newPage();
656
+ # await page.route(/(\.png$)|(\.jpg$)/, route => route.abort());
657
+ # await page.goto('https://example.com');
658
+ # await browser.close();
659
+ # ```
660
+ # Page routes take precedence over browser context routes (set up with `browserContext.route(url, handler)`) when request matches both handlers.
661
+ #
662
+ # **NOTE** Enabling routing disables http cache.
663
+ def route(url, handler)
664
+ raise NotImplementedError.new('route is not implemented yet.')
665
+ end
666
+
667
+ # Returns the buffer with the captured screenshot.
668
+ #
669
+ # **NOTE** Screenshots take at least 1/6 second on Chromium OS X and Chromium Windows. See https://crbug.com/741689 for discussion.
670
+ def screenshot(
671
+ path: nil,
672
+ type: nil,
673
+ quality: nil,
674
+ fullPage: nil,
675
+ clip: nil,
676
+ omitBackground: nil,
677
+ timeout: nil)
678
+ wrap_channel_owner(@channel_owner.screenshot(path: path, type: type, quality: quality, fullPage: fullPage, clip: clip, omitBackground: omitBackground, timeout: timeout))
679
+ end
680
+
681
+ # Returns the array of option values that have been successfully selected.
682
+ # 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.
683
+ #
684
+ # ```js
685
+ # // single selection matching the value
686
+ # page.selectOption('select#colors', 'blue');
687
+ #
688
+ # // single selection matching both the value and the label
689
+ # page.selectOption('select#colors', { label: 'Blue' });
690
+ #
691
+ # // multiple selection
692
+ # page.selectOption('select#colors', ['red', 'green', 'blue']);
693
+ #
694
+ # ```
695
+ # Shortcut for main frame's `frame.selectOption(selector, values[, options])`
696
+ def select_option(selector, values, noWaitAfter: nil, timeout: nil)
697
+ raise NotImplementedError.new('select_option is not implemented yet.')
698
+ end
699
+
700
+ def set_content(html, timeout: nil, waitUntil: nil)
701
+ raise NotImplementedError.new('set_content is not implemented yet.')
702
+ end
703
+
704
+ # This setting will change the default maximum navigation time for the following methods and related shortcuts:
705
+ #
706
+ # `page.goBack([options])`
707
+ # `page.goForward([options])`
708
+ # `page.goto(url[, options])`
709
+ # `page.reload([options])`
710
+ # `page.setContent(html[, options])`
711
+ # `page.waitForNavigation([options])`
712
+ #
713
+ #
714
+ # **NOTE** `page.setDefaultNavigationTimeout(timeout)` takes priority over `page.setDefaultTimeout(timeout)`, `browserContext.setDefaultTimeout(timeout)` and `browserContext.setDefaultNavigationTimeout(timeout)`.
715
+ def set_default_navigation_timeout(timeout)
716
+ raise NotImplementedError.new('set_default_navigation_timeout is not implemented yet.')
717
+ end
718
+
719
+ # This setting will change the default maximum time for all the methods accepting `timeout` option.
720
+ #
721
+ # **NOTE** `page.setDefaultNavigationTimeout(timeout)` takes priority over `page.setDefaultTimeout(timeout)`.
722
+ def set_default_timeout(timeout)
723
+ raise NotImplementedError.new('set_default_timeout is not implemented yet.')
724
+ end
725
+
726
+ # The extra HTTP headers will be sent with every request the page initiates.
727
+ #
728
+ # **NOTE** page.setExtraHTTPHeaders does not guarantee the order of headers in the outgoing requests.
729
+ def set_extra_http_headers(headers)
730
+ raise NotImplementedError.new('set_extra_http_headers is not implemented yet.')
731
+ end
732
+
733
+ # This method expects `selector` to point to an input element.
734
+ # 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.
735
+ def set_input_files(selector, files, noWaitAfter: nil, timeout: nil)
736
+ raise NotImplementedError.new('set_input_files is not implemented yet.')
737
+ end
738
+
739
+ # In the case of multiple pages in a single browser, each page can have its own viewport size. However, `browser.newContext([options])` allows to set viewport size (and more) for all pages in the context at once.
740
+ # `page.setViewportSize` will resize the page. A lot of websites don't expect phones to change size, so you should set the viewport size before navigating to the page.
741
+ #
742
+ # ```js
743
+ # const page = await browser.newPage();
744
+ # await page.setViewportSize({
745
+ # width: 640,
746
+ # height: 480,
747
+ # });
748
+ # await page.goto('https://example.com');
749
+ # ```
750
+ def set_viewport_size(viewportSize)
751
+ raise NotImplementedError.new('set_viewport_size is not implemented yet.')
752
+ end
753
+
754
+ # This method taps an element matching `selector` by performing the following steps:
755
+ #
756
+ # Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
757
+ # 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.
758
+ # Scroll the element into view if needed.
759
+ # Use page.touchscreen to tap the center of the element, or the specified `position`.
760
+ # Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
761
+ #
762
+ # When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
763
+ #
764
+ # **NOTE** `page.tap()` requires that the `hasTouch` option of the browser context be set to true.
765
+ #
766
+ # Shortcut for main frame's `frame.tap(selector[, options])`.
767
+ def tap_point(
768
+ selector,
769
+ position: nil,
770
+ modifiers: nil,
771
+ noWaitAfter: nil,
772
+ force: nil,
773
+ timeout: nil)
774
+ raise NotImplementedError.new('tap_point is not implemented yet.')
775
+ end
776
+
777
+ # Returns `element.textContent`.
778
+ def text_content(selector, timeout: nil)
779
+ raise NotImplementedError.new('text_content is not implemented yet.')
780
+ end
781
+
782
+ # Returns the page's title. Shortcut for main frame's `frame.title()`.
783
+ def title
784
+ raise NotImplementedError.new('title is not implemented yet.')
785
+ end
786
+
787
+ # Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `page.type` can be used to send fine-grained keyboard events. To fill values in form fields, use `page.fill(selector, value[, options])`.
788
+ # To press a special key, like `Control` or `ArrowDown`, use `keyboard.press(key[, options])`.
789
+ #
790
+ # ```js
791
+ # await page.type('#mytextarea', 'Hello'); // Types instantly
792
+ # await page.type('#mytextarea', 'World', {delay: 100}); // Types slower, like a user
793
+ # ```
794
+ # Shortcut for main frame's `frame.type(selector, text[, options])`.
795
+ def type_text(
796
+ selector,
797
+ text,
798
+ delay: nil,
799
+ noWaitAfter: nil,
800
+ timeout: nil)
801
+ raise NotImplementedError.new('type_text is not implemented yet.')
802
+ end
803
+
804
+ # This method unchecks an element matching `selector` by performing the following steps:
805
+ #
806
+ # Find an element match matching `selector`. If there is none, wait until a matching element is attached to the DOM.
807
+ # 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.
808
+ # 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.
809
+ # Scroll the element into view if needed.
810
+ # Use page.mouse to click in the center of the element.
811
+ # Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
812
+ # Ensure that the element is now unchecked. If not, this method rejects.
813
+ #
814
+ # When all steps combined have not finished during the specified `timeout`, this method rejects with a TimeoutError. Passing zero timeout disables this.
815
+ # Shortcut for main frame's `frame.uncheck(selector[, options])`.
816
+ def uncheck(selector, force: nil, noWaitAfter: nil, timeout: nil)
817
+ raise NotImplementedError.new('uncheck is not implemented yet.')
818
+ end
819
+
820
+ # Removes a route created with `page.route(url, handler)`. When `handler` is not specified, removes all routes for the `url`.
821
+ def unroute(url, handler: nil)
822
+ raise NotImplementedError.new('unroute is not implemented yet.')
823
+ end
824
+
825
+ # Shortcut for main frame's `frame.url()`.
826
+ def url
827
+ raise NotImplementedError.new('url is not implemented yet.')
828
+ end
829
+
830
+ # Video object associated with this page.
831
+ def video
832
+ raise NotImplementedError.new('video is not implemented yet.')
833
+ end
834
+
835
+ def viewport_size
836
+ raise NotImplementedError.new('viewport_size is not implemented yet.')
837
+ end
838
+
839
+ # Returns the event data value.
840
+ # Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy value. Will throw an error if the page is closed before the event is fired.
841
+ def wait_for_event(event, optionsOrPredicate: nil)
842
+ raise NotImplementedError.new('wait_for_event is not implemented yet.')
843
+ end
844
+
845
+ # Returns when the `pageFunction` returns a truthy value. It resolves to a JSHandle of the truthy value.
846
+ # The `waitForFunction` can be used to observe viewport size change:
847
+ #
848
+ # ```js
849
+ # const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.
850
+ #
851
+ # (async () => {
852
+ # const browser = await webkit.launch();
853
+ # const page = await browser.newPage();
854
+ # const watchDog = page.waitForFunction('window.innerWidth < 100');
855
+ # await page.setViewportSize({width: 50, height: 50});
856
+ # await watchDog;
857
+ # await browser.close();
858
+ # })();
859
+ # ```
860
+ # To pass an argument to the predicate of `page.waitForFunction` function:
861
+ #
862
+ # ```js
863
+ # const selector = '.foo';
864
+ # await page.waitForFunction(selector => !!document.querySelector(selector), selector);
865
+ # ```
866
+ # Shortcut for main frame's `frame.waitForFunction(pageFunction[, arg, options])`.
867
+ def wait_for_function(pageFunction, arg: nil, polling: nil, timeout: nil)
868
+ raise NotImplementedError.new('wait_for_function is not implemented yet.')
869
+ end
870
+
871
+ # Returns when the required load state has been reached.
872
+ # This resolves when the page 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.
873
+ #
874
+ # ```js
875
+ # await page.click('button'); // Click triggers navigation.
876
+ # await page.waitForLoadState(); // The promise resolves after 'load' event.
877
+ # ```
878
+ #
879
+ # ```js
880
+ # const [popup] = await Promise.all([
881
+ # page.waitForEvent('popup'),
882
+ # page.click('button'), // Click triggers a popup.
883
+ # ])
884
+ # await popup.waitForLoadState('domcontentloaded'); // The promise resolves after 'domcontentloaded' event.
885
+ # console.log(await popup.title()); // Popup is ready to use.
886
+ # ```
887
+ # Shortcut for main frame's `frame.waitForLoadState([state, options])`.
888
+ def wait_for_load_state(state: nil, timeout: nil)
889
+ raise NotImplementedError.new('wait_for_load_state is not implemented yet.')
890
+ end
891
+
892
+ # 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`.
893
+ # This resolves when the page navigates to a new URL or reloads. It is useful for when you run code which will indirectly cause the page to navigate. e.g. The click target has an `onclick` handler that triggers navigation from a `setTimeout`. Consider this example:
894
+ #
895
+ # ```js
896
+ # const [response] = await Promise.all([
897
+ # page.waitForNavigation(), // The promise resolves after navigation has finished
898
+ # page.click('a.delayed-navigation'), // Clicking the link will indirectly cause a navigation
899
+ # ]);
900
+ # ```
901
+ # **NOTE** Usage of the History API to change the URL is considered a navigation.
902
+ # Shortcut for main frame's `frame.waitForNavigation([options])`.
903
+ def wait_for_navigation(timeout: nil, url: nil, waitUntil: nil)
904
+ raise NotImplementedError.new('wait_for_navigation is not implemented yet.')
905
+ end
906
+
907
+ # Waits for the matching request and returns it.
908
+ #
909
+ # ```js
910
+ # const firstRequest = await page.waitForRequest('http://example.com/resource');
911
+ # const finalRequest = await page.waitForRequest(request => request.url() === 'http://example.com' && request.method() === 'GET');
912
+ # return firstRequest.url();
913
+ # ```
914
+ #
915
+ # ```js
916
+ # await page.waitForRequest(request => request.url().searchParams.get('foo') === 'bar' && request.url().searchParams.get('foo2') === 'bar2');
917
+ # ```
918
+ def wait_for_request(urlOrPredicate, timeout: nil)
919
+ raise NotImplementedError.new('wait_for_request is not implemented yet.')
920
+ end
921
+
922
+ # Returns the matched response.
923
+ #
924
+ # ```js
925
+ # const firstResponse = await page.waitForResponse('https://example.com/resource');
926
+ # const finalResponse = await page.waitForResponse(response => response.url() === 'https://example.com' && response.status() === 200);
927
+ # return finalResponse.ok();
928
+ # ```
929
+ def wait_for_response(urlOrPredicate, timeout: nil)
930
+ raise NotImplementedError.new('wait_for_response is not implemented yet.')
931
+ end
932
+
933
+ # Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or `detached`.
934
+ # 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.
935
+ # This method works across navigations:
936
+ #
937
+ # ```js
938
+ # const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
939
+ #
940
+ # (async () => {
941
+ # const browser = await chromium.launch();
942
+ # const page = await browser.newPage();
943
+ # let currentURL;
944
+ # page
945
+ # .waitForSelector('img')
946
+ # .then(() => console.log('First URL with image: ' + currentURL));
947
+ # for (currentURL of ['https://example.com', 'https://google.com', 'https://bbc.com']) {
948
+ # await page.goto(currentURL);
949
+ # }
950
+ # await browser.close();
951
+ # })();
952
+ # ```
953
+ def wait_for_selector(selector, state: nil, timeout: nil)
954
+ raise NotImplementedError.new('wait_for_selector is not implemented yet.')
955
+ end
956
+
957
+ # Waits for the given `timeout` in milliseconds.
958
+ # Note that `page.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.
959
+ #
960
+ # ```js
961
+ # // wait for 1 second
962
+ # await page.waitForTimeout(1000);
963
+ # ```
964
+ # Shortcut for main frame's `frame.waitForTimeout(timeout)`.
965
+ def wait_for_timeout(timeout)
966
+ raise NotImplementedError.new('wait_for_timeout is not implemented yet.')
967
+ end
968
+
969
+ # This method returns all of the dedicated WebWorkers associated with the page.
970
+ #
971
+ # **NOTE** This does not contain ServiceWorkers
972
+ def workers
973
+ raise NotImplementedError.new('workers is not implemented yet.')
974
+ end
975
+
976
+ # @nodoc
977
+ def owned_context=(req)
978
+ wrap_channel_owner(@channel_owner.owned_context=(req))
979
+ end
980
+
981
+ # @nodoc
982
+ def after_initialize
983
+ wrap_channel_owner(@channel_owner.after_initialize)
984
+ end
985
+ end
986
+ end