playwright-ruby-client 0.5.8 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/documentation/README.md +33 -0
  4. data/documentation/babel.config.js +3 -0
  5. data/documentation/docs/api/accessibility.md +7 -0
  6. data/documentation/docs/api/browser.md +187 -0
  7. data/documentation/docs/api/browser_context.md +397 -0
  8. data/documentation/docs/api/browser_type.md +105 -0
  9. data/documentation/docs/api/cdp_session.md +7 -0
  10. data/documentation/docs/api/console_message.md +41 -0
  11. data/documentation/docs/api/dialog.md +71 -0
  12. data/documentation/docs/api/element_handle.md +618 -0
  13. data/documentation/docs/api/experimental/_category_.yml +3 -0
  14. data/documentation/docs/api/experimental/android.md +25 -0
  15. data/documentation/docs/api/experimental/android_device.md +92 -0
  16. data/documentation/docs/api/experimental/android_input.md +38 -0
  17. data/documentation/docs/api/experimental/android_socket.md +7 -0
  18. data/documentation/docs/api/experimental/android_web_view.md +7 -0
  19. data/documentation/docs/api/file_chooser.md +50 -0
  20. data/documentation/docs/api/frame.md +866 -0
  21. data/documentation/docs/api/js_handle.md +113 -0
  22. data/documentation/docs/api/keyboard.md +157 -0
  23. data/documentation/docs/api/mouse.md +69 -0
  24. data/documentation/docs/api/page.md +1402 -0
  25. data/documentation/docs/api/playwright.md +63 -0
  26. data/documentation/docs/api/request.md +188 -0
  27. data/documentation/docs/api/response.md +97 -0
  28. data/documentation/docs/api/route.md +80 -0
  29. data/documentation/docs/api/selectors.md +23 -0
  30. data/documentation/docs/api/touchscreen.md +8 -0
  31. data/documentation/docs/api/tracing.md +54 -0
  32. data/documentation/docs/api/web_socket.md +7 -0
  33. data/documentation/docs/api/worker.md +24 -0
  34. data/documentation/docs/article/api_coverage.mdx +11 -0
  35. data/documentation/docs/article/getting_started.md +152 -0
  36. data/documentation/docs/article/guides/_category_.yml +3 -0
  37. data/documentation/docs/article/guides/download_playwright_driver.md +49 -0
  38. data/documentation/docs/article/guides/launch_browser.md +119 -0
  39. data/documentation/docs/article/guides/rails_integration.md +51 -0
  40. data/{docs → documentation/docs/include}/api_coverage.md +13 -2
  41. data/documentation/docusaurus.config.js +107 -0
  42. data/documentation/package.json +39 -0
  43. data/documentation/sidebars.js +15 -0
  44. data/documentation/src/components/HomepageFeatures.js +61 -0
  45. data/documentation/src/components/HomepageFeatures.module.css +13 -0
  46. data/documentation/src/css/custom.css +44 -0
  47. data/documentation/src/pages/index.js +50 -0
  48. data/documentation/src/pages/index.module.css +41 -0
  49. data/documentation/src/pages/markdown-page.md +7 -0
  50. data/documentation/static/.nojekyll +0 -0
  51. data/documentation/static/img/playwright-logo.svg +9 -0
  52. data/documentation/static/img/undraw_dropdown_menu.svg +1 -0
  53. data/documentation/static/img/undraw_web_development.svg +1 -0
  54. data/documentation/static/img/undraw_windows.svg +1 -0
  55. data/documentation/yarn.lock +8805 -0
  56. data/lib/playwright/channel_owners/binding_call.rb +33 -0
  57. data/lib/playwright/channel_owners/browser.rb +27 -2
  58. data/lib/playwright/channel_owners/browser_context.rb +54 -3
  59. data/lib/playwright/channel_owners/browser_type.rb +8 -1
  60. data/lib/playwright/channel_owners/element_handle.rb +17 -16
  61. data/lib/playwright/channel_owners/frame.rb +29 -34
  62. data/lib/playwright/channel_owners/js_handle.rb +2 -10
  63. data/lib/playwright/channel_owners/page.rb +35 -51
  64. data/lib/playwright/channel_owners/worker.rb +4 -0
  65. data/lib/playwright/download.rb +3 -2
  66. data/lib/playwright/events.rb +4 -0
  67. data/lib/playwright/input_files.rb +0 -8
  68. data/lib/playwright/javascript.rb +0 -10
  69. data/lib/playwright/javascript/expression.rb +2 -7
  70. data/lib/playwright/playwright_api.rb +16 -1
  71. data/lib/playwright/tracing_impl.rb +31 -0
  72. data/lib/playwright/version.rb +2 -1
  73. data/lib/playwright_api/accessibility.rb +7 -88
  74. data/lib/playwright_api/android.rb +2 -59
  75. data/lib/playwright_api/android_device.rb +6 -5
  76. data/lib/playwright_api/browser.rb +13 -122
  77. data/lib/playwright_api/browser_context.rb +66 -433
  78. data/lib/playwright_api/browser_type.rb +28 -78
  79. data/lib/playwright_api/cdp_session.rb +2 -25
  80. data/lib/playwright_api/console_message.rb +2 -0
  81. data/lib/playwright_api/dialog.rb +5 -63
  82. data/lib/playwright_api/element_handle.rb +96 -294
  83. data/lib/playwright_api/file_chooser.rb +0 -21
  84. data/lib/playwright_api/frame.rb +99 -565
  85. data/lib/playwright_api/js_handle.rb +10 -67
  86. data/lib/playwright_api/keyboard.rb +22 -166
  87. data/lib/playwright_api/mouse.rb +1 -45
  88. data/lib/playwright_api/page.rb +222 -1223
  89. data/lib/playwright_api/playwright.rb +8 -93
  90. data/lib/playwright_api/request.rb +9 -87
  91. data/lib/playwright_api/response.rb +1 -1
  92. data/lib/playwright_api/route.rb +3 -80
  93. data/lib/playwright_api/selectors.rb +0 -66
  94. data/lib/playwright_api/tracing.rb +39 -0
  95. data/lib/playwright_api/web_socket.rb +1 -1
  96. data/lib/playwright_api/worker.rb +28 -42
  97. data/playwright.gemspec +2 -2
  98. metadata +60 -20
  99. data/lib/playwright/javascript/function.rb +0 -67
@@ -0,0 +1,113 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # JSHandle
6
+
7
+ JSHandle represents an in-page JavaScript object. JSHandles can be created with the [Page#evaluate_handle](./page#evaluate_handle)
8
+ method.
9
+
10
+ ```ruby
11
+ window_handle = page.evaluate_handle("window")
12
+ # ...
13
+ ```
14
+
15
+ JSHandle prevents the referenced JavaScript object being garbage collected unless the handle is exposed with
16
+ [JSHandle#dispose](./js_handle#dispose). JSHandles are auto-disposed when their origin frame gets navigated or the parent context
17
+ gets destroyed.
18
+
19
+ JSHandle instances can be used as an argument in [Page#eval_on_selector](./page#eval_on_selector), [Page#evaluate](./page#evaluate) and
20
+ [Page#evaluate_handle](./page#evaluate_handle) methods.
21
+
22
+ ## as_element
23
+
24
+ ```
25
+ def as_element
26
+ ```
27
+
28
+ Returns either `null` or the object handle itself, if the object handle is an instance of [ElementHandle](./element_handle).
29
+
30
+ ## dispose
31
+
32
+ ```
33
+ def dispose
34
+ ```
35
+
36
+ The `jsHandle.dispose` method stops referencing the element handle.
37
+
38
+ ## evaluate
39
+
40
+ ```
41
+ def evaluate(expression, arg: nil)
42
+ ```
43
+
44
+ Returns the return value of `expression`.
45
+
46
+ This method passes this handle as the first argument to `expression`.
47
+
48
+ If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then `handle.evaluate` would wait for the promise to resolve and return its value.
49
+
50
+ Examples:
51
+
52
+ ```ruby
53
+ tweet_handle = page.query_selector(".tweet .retweets")
54
+ tweet_handle.evaluate("node => node.innerText") # => "10 retweets"
55
+ ```
56
+
57
+
58
+
59
+ ## evaluate_handle
60
+
61
+ ```
62
+ def evaluate_handle(expression, arg: nil)
63
+ ```
64
+
65
+ Returns the return value of `expression` as a [JSHandle](./js_handle).
66
+
67
+ This method passes this handle as the first argument to `expression`.
68
+
69
+ The only difference between [JSHandle#evaluate](./js_handle#evaluate) and [JSHandle#evaluate_handle](./js_handle#evaluate_handle) is that [JSHandle#evaluate_handle](./js_handle#evaluate_handle) returns
70
+ [JSHandle](./js_handle).
71
+
72
+ If the function passed to the [JSHandle#evaluate_handle](./js_handle#evaluate_handle) returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [JSHandle#evaluate_handle](./js_handle#evaluate_handle) would wait
73
+ for the promise to resolve and return its value.
74
+
75
+ See [Page#evaluate_handle](./page#evaluate_handle) for more details.
76
+
77
+ ## get_properties
78
+
79
+ ```
80
+ def get_properties
81
+ ```
82
+ alias: `properties`
83
+
84
+ The method returns a map with **own property names** as keys and JSHandle instances for the property values.
85
+
86
+ ```ruby
87
+ page.goto('https://example.com/')
88
+ window_handle = page.evaluate_handle("window")
89
+ properties = window_handle.properties
90
+ puts properties
91
+ window_handle.dispose
92
+ ```
93
+
94
+
95
+
96
+ ## get_property
97
+
98
+ ```
99
+ def get_property(propertyName)
100
+ ```
101
+
102
+ Fetches a single property from the referenced object.
103
+
104
+ ## json_value
105
+
106
+ ```
107
+ def json_value
108
+ ```
109
+
110
+ Returns a JSON representation of the object. If the object has a `toJSON` function, it **will not be called**.
111
+
112
+ > NOTE: The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an
113
+ error if the object has circular references.
@@ -0,0 +1,157 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # Keyboard
6
+
7
+ Keyboard provides an api for managing a virtual keyboard. The high level api is [Keyboard#type](./keyboard#type), which takes
8
+ raw characters and generates proper keydown, keypress/input, and keyup events on your page.
9
+
10
+ For finer control, you can use [Keyboard#down](./keyboard#down), [Keyboard#up](./keyboard#up), and [Keyboard#insert_text](./keyboard#insert_text)
11
+ to manually fire events as if they were generated from a real keyboard.
12
+
13
+ An example of holding down `Shift` in order to select and delete some text:
14
+
15
+ ```python sync title=example_575870a45e4fe08d3e06be3420e8a11be03f85791cd8174f27198c016031ae72.py
16
+ page.keyboard.type("Hello World!")
17
+ page.keyboard.press("ArrowLeft")
18
+ page.keyboard.down("Shift")
19
+ for i in range(6):
20
+ page.keyboard.press("ArrowLeft")
21
+ page.keyboard.up("Shift")
22
+ page.keyboard.press("Backspace")
23
+ # result text will end up saying "Hello!"
24
+
25
+ ```
26
+
27
+ An example of pressing uppercase `A`
28
+
29
+ ```python sync title=example_a4f00f0cd486431b7eca785304f4e9715522da45b66dda7f3a5f6899b889b9fd.py
30
+ page.keyboard.press("Shift+KeyA")
31
+ # or
32
+ page.keyboard.press("Shift+A")
33
+
34
+ ```
35
+
36
+ An example to trigger select-all with the keyboard
37
+
38
+ ```python sync title=example_2deda0786a20a28cec9e8b438078a5fc567f7c7e5cf369419ab3c4d80a319ff6.py
39
+ # on windows and linux
40
+ page.keyboard.press("Control+A")
41
+ # on mac_os
42
+ page.keyboard.press("Meta+A")
43
+
44
+ ```
45
+
46
+
47
+
48
+ ## down
49
+
50
+ ```
51
+ def down(key)
52
+ ```
53
+
54
+ Dispatches a `keydown` event.
55
+
56
+ `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
57
+ value or a single character to generate the text for. A superset of the `key` values can be found
58
+ [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
59
+
60
+ `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
61
+ `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
62
+
63
+ Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
64
+
65
+ Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
66
+
67
+ If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
68
+ texts.
69
+
70
+ If `key` is a modifier key, `Shift`, `Meta`, `Control`, or `Alt`, subsequent key presses will be sent with that modifier
71
+ active. To release the modifier key, use [Keyboard#up](./keyboard#up).
72
+
73
+ After the key is pressed once, subsequent calls to [Keyboard#down](./keyboard#down) will have
74
+ [repeat](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat) set to true. To release the key, use
75
+ [Keyboard#up](./keyboard#up).
76
+
77
+ > NOTE: Modifier keys DO influence `keyboard.down`. Holding down `Shift` will type the text in upper case.
78
+
79
+ ## insert_text
80
+
81
+ ```
82
+ def insert_text(text)
83
+ ```
84
+
85
+ Dispatches only `input` event, does not emit the `keydown`, `keyup` or `keypress` events.
86
+
87
+ ```python sync title=example_a9cc2667e9f3e3b8c619649d7e4a7f5db9463e0b76d67a5e588158093a9e9124.py
88
+ page.keyboard.insert_text("嗨")
89
+
90
+ ```
91
+
92
+ > NOTE: Modifier keys DO NOT effect `keyboard.insertText`. Holding down `Shift` will not type the text in upper case.
93
+
94
+ ## press
95
+
96
+ ```
97
+ def press(key, delay: nil)
98
+ ```
99
+
100
+ `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
101
+ value or a single character to generate the text for. A superset of the `key` values can be found
102
+ [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
103
+
104
+ `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
105
+ `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
106
+
107
+ Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
108
+
109
+ Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
110
+
111
+ If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
112
+ texts.
113
+
114
+ Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
115
+ modifier, modifier is pressed and being held while the subsequent key is being pressed.
116
+
117
+ ```python sync title=example_88943eb85c1ac7c261601e6edbdead07a31c2784326c496e10667ede1a853bab.py
118
+ page = browser.new_page()
119
+ page.goto("https://keycode.info")
120
+ page.keyboard.press("a")
121
+ page.screenshot(path="a.png")
122
+ page.keyboard.press("ArrowLeft")
123
+ page.screenshot(path="arrow_left.png")
124
+ page.keyboard.press("Shift+O")
125
+ page.screenshot(path="o.png")
126
+ browser.close()
127
+
128
+ ```
129
+
130
+ Shortcut for [Keyboard#down](./keyboard#down) and [Keyboard#up](./keyboard#up).
131
+
132
+ ## type
133
+
134
+ ```
135
+ def type(text, delay: nil)
136
+ ```
137
+
138
+ Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
139
+
140
+ To press a special key, like `Control` or `ArrowDown`, use [Keyboard#press](./keyboard#press).
141
+
142
+ ```python sync title=example_d9ced919f139961fd2b795c71375ca96f788a19c1f8e1479c5ec905fb5c02d43.py
143
+ page.keyboard.type("Hello") # types instantly
144
+ page.keyboard.type("World", delay=100) # types slower, like a user
145
+
146
+ ```
147
+
148
+ > NOTE: Modifier keys DO NOT effect `keyboard.type`. Holding down `Shift` will not type the text in upper case.
149
+ > NOTE: For characters that are not on a US keyboard, only an `input` event will be sent.
150
+
151
+ ## up
152
+
153
+ ```
154
+ def up(key)
155
+ ```
156
+
157
+ Dispatches a `keyup` event.
@@ -0,0 +1,69 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # Mouse
6
+
7
+ The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.
8
+
9
+ Every `page` object has its own Mouse, accessible with [Page#mouse](./page#mouse).
10
+
11
+ ```python sync title=example_ba01da1f358cafb4c22b792488ff2f3de4dbd82d4ee1cc4050e3f0c24a2bd7dd.py
12
+ # using ‘page.mouse’ to trace a 100x100 square.
13
+ page.mouse.move(0, 0)
14
+ page.mouse.down()
15
+ page.mouse.move(0, 100)
16
+ page.mouse.move(100, 100)
17
+ page.mouse.move(100, 0)
18
+ page.mouse.move(0, 0)
19
+ page.mouse.up()
20
+
21
+ ```
22
+
23
+
24
+
25
+ ## click
26
+
27
+ ```
28
+ def click(
29
+ x,
30
+ y,
31
+ button: nil,
32
+ clickCount: nil,
33
+ delay: nil)
34
+ ```
35
+
36
+ Shortcut for [Mouse#move](./mouse#move), [Mouse#down](./mouse#down), [Mouse#up](./mouse#up).
37
+
38
+ ## dblclick
39
+
40
+ ```
41
+ def dblclick(x, y, button: nil, delay: nil)
42
+ ```
43
+
44
+ Shortcut for [Mouse#move](./mouse#move), [Mouse#down](./mouse#down), [Mouse#up](./mouse#up), [Mouse#down](./mouse#down) and
45
+ [Mouse#up](./mouse#up).
46
+
47
+ ## down
48
+
49
+ ```
50
+ def down(button: nil, clickCount: nil)
51
+ ```
52
+
53
+ Dispatches a `mousedown` event.
54
+
55
+ ## move
56
+
57
+ ```
58
+ def move(x, y, steps: nil)
59
+ ```
60
+
61
+ Dispatches a `mousemove` event.
62
+
63
+ ## up
64
+
65
+ ```
66
+ def up(button: nil, clickCount: nil)
67
+ ```
68
+
69
+ Dispatches a `mouseup` event.
@@ -0,0 +1,1402 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # Page
6
+
7
+ - extends: [EventEmitter]
8
+
9
+ Page provides methods to interact with a single tab in a [Browser](./browser), or an
10
+ [extension background page](https://developer.chrome.com/extensions/background_pages) in Chromium. One [Browser](./browser)
11
+ instance might have multiple [Page](./page) instances.
12
+
13
+ This example creates a page, navigates it to a URL, and then saves a screenshot:
14
+
15
+ ```ruby
16
+ playwright.webkit.launch do |browser|
17
+ page = browser.new_page
18
+ page.goto('https://example.com/')
19
+ page.screenshot(path: 'screenshot.png')
20
+ end
21
+ ```
22
+
23
+ The Page class emits various events (described below) which can be handled using any of Node's native
24
+ [`EventEmitter`](https://nodejs.org/api/events.html#events_class_eventemitter) methods, such as `on`, `once` or
25
+ `removeListener`.
26
+
27
+ This example logs a message for a single page `load` event:
28
+
29
+ ```ruby
30
+ page.once("load", -> (page) { puts "page loaded!" })
31
+ ```
32
+
33
+ To unsubscribe from events use the `removeListener` method:
34
+
35
+ ```ruby
36
+ listener = -> (req) { puts "a request was made: #{req.url}" }
37
+ page.on('request', listener)
38
+ page.goto('https://example.com/') # => prints 'a request was made: https://example.com/'
39
+ page.off('request', listener)
40
+ page.goto('https://example.com/') # => no print
41
+ ```
42
+
43
+
44
+
45
+ ## add_init_script
46
+
47
+ ```
48
+ def add_init_script(path: nil, script: nil)
49
+ ```
50
+
51
+ Adds a script which would be evaluated in one of the following scenarios:
52
+ - Whenever the page is navigated.
53
+ - Whenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly
54
+ attached frame.
55
+
56
+ The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend
57
+ the JavaScript environment, e.g. to seed `Math.random`.
58
+
59
+ An example of overriding `Math.random` before the page loads:
60
+
61
+ ```ruby
62
+ # in your playwright script, assuming the preload.js file is in same directory
63
+ page.add_init_script(path: "./preload.js")
64
+ ```
65
+
66
+ > NOTE: The order of evaluation of multiple scripts installed via [BrowserContext#add_init_script](./browser_context#add_init_script) and
67
+ [Page#add_init_script](./page#add_init_script) is not defined.
68
+
69
+ ## add_script_tag
70
+
71
+ ```
72
+ def add_script_tag(content: nil, path: nil, type: nil, url: nil)
73
+ ```
74
+
75
+ Adds a `<script>` tag into the page with the desired url or content. Returns the added tag when the script's onload
76
+ fires or when the script content was injected into frame.
77
+
78
+ Shortcut for main frame's [Frame#add_script_tag](./frame#add_script_tag).
79
+
80
+ ## add_style_tag
81
+
82
+ ```
83
+ def add_style_tag(content: nil, path: nil, url: nil)
84
+ ```
85
+
86
+ Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the
87
+ content. Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame.
88
+
89
+ Shortcut for main frame's [Frame#add_style_tag](./frame#add_style_tag).
90
+
91
+ ## bring_to_front
92
+
93
+ ```
94
+ def bring_to_front
95
+ ```
96
+
97
+ Brings page to front (activates tab).
98
+
99
+ ## check
100
+
101
+ ```
102
+ def check(
103
+ selector,
104
+ force: nil,
105
+ noWaitAfter: nil,
106
+ position: nil,
107
+ timeout: nil,
108
+ trial: nil)
109
+ ```
110
+
111
+ This method checks an element matching `selector` by performing the following steps:
112
+ 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
113
+ 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already
114
+ checked, this method returns immediately.
115
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the
116
+ element is detached during the checks, the whole action is retried.
117
+ 1. Scroll the element into view if needed.
118
+ 1. Use [Page#mouse](./page#mouse) to click in the center of the element.
119
+ 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
120
+ 1. Ensure that the element is now checked. If not, this method throws.
121
+
122
+ When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
123
+ zero timeout disables this.
124
+
125
+ Shortcut for main frame's [Frame#check](./frame#check).
126
+
127
+ ## click
128
+
129
+ ```
130
+ def click(
131
+ selector,
132
+ button: nil,
133
+ clickCount: nil,
134
+ delay: nil,
135
+ force: nil,
136
+ modifiers: nil,
137
+ noWaitAfter: nil,
138
+ position: nil,
139
+ timeout: nil,
140
+ trial: nil)
141
+ ```
142
+
143
+ This method clicks an element matching `selector` by performing the following steps:
144
+ 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
145
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the
146
+ element is detached during the checks, the whole action is retried.
147
+ 1. Scroll the element into view if needed.
148
+ 1. Use [Page#mouse](./page#mouse) to click in the center of the element, or the specified `position`.
149
+ 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
150
+
151
+ When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
152
+ zero timeout disables this.
153
+
154
+ Shortcut for main frame's [Frame#click](./frame#click).
155
+
156
+ ## close
157
+
158
+ ```
159
+ def close(runBeforeUnload: nil)
160
+ ```
161
+
162
+ If `runBeforeUnload` is `false`, does not run any unload handlers and waits for the page to be closed. If
163
+ `runBeforeUnload` is `true` the method will run unload handlers, but will **not** wait for the page to close.
164
+
165
+ By default, `page.close()` **does not** run `beforeunload` handlers.
166
+
167
+ > NOTE: if `runBeforeUnload` is passed as true, a `beforeunload` dialog might be summoned and should be handled manually
168
+ via [`event: Page.dialog`] event.
169
+
170
+ ## content
171
+
172
+ ```
173
+ def content
174
+ ```
175
+
176
+ Gets the full HTML contents of the page, including the doctype.
177
+
178
+ ## context
179
+
180
+ ```
181
+ def context
182
+ ```
183
+
184
+ Get the browser context that the page belongs to.
185
+
186
+ ## dblclick
187
+
188
+ ```
189
+ def dblclick(
190
+ selector,
191
+ button: nil,
192
+ delay: nil,
193
+ force: nil,
194
+ modifiers: nil,
195
+ noWaitAfter: nil,
196
+ position: nil,
197
+ timeout: nil,
198
+ trial: nil)
199
+ ```
200
+
201
+ This method double clicks an element matching `selector` by performing the following steps:
202
+ 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
203
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the
204
+ element is detached during the checks, the whole action is retried.
205
+ 1. Scroll the element into view if needed.
206
+ 1. Use [Page#mouse](./page#mouse) to double click in the center of the element, or the specified `position`.
207
+ 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the
208
+ first click of the `dblclick()` triggers a navigation event, this method will throw.
209
+
210
+ When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
211
+ zero timeout disables this.
212
+
213
+ > NOTE: `page.dblclick()` dispatches two `click` events and a single `dblclick` event.
214
+
215
+ Shortcut for main frame's [Frame#dblclick](./frame#dblclick).
216
+
217
+ ## dispatch_event
218
+
219
+ ```
220
+ def dispatch_event(selector, type, eventInit: nil, timeout: nil)
221
+ ```
222
+
223
+ The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
224
+ `click` is dispatched. This is equivalent to calling
225
+ [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
226
+
227
+ ```ruby
228
+ page.content = '<button id="submit">Send</button>'
229
+ page.dispatch_event("button#submit", "click")
230
+ ```
231
+
232
+ Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
233
+ and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
234
+
235
+ Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
236
+ - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
237
+ - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
238
+ - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
239
+ - [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
240
+ - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
241
+ - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
242
+ - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
243
+
244
+ You can also specify [JSHandle](./js_handle) as the property value if you want live objects to be passed into the event:
245
+
246
+ ```ruby
247
+ page.content = '<div id="source">Drag</div>'
248
+
249
+ # note you can only create data_transfer in chromium and firefox
250
+ data_transfer = page.evaluate_handle("new DataTransfer()")
251
+ page.dispatch_event("#source", "dragstart", eventInit: { dataTransfer: data_transfer })
252
+ ```
253
+
254
+
255
+
256
+ ## emulate_media
257
+
258
+ ```
259
+ def emulate_media(colorScheme: nil, media: nil, reducedMotion: nil)
260
+ ```
261
+
262
+ This method changes the `CSS media type` through the `media` argument, and/or the `'prefers-colors-scheme'` media
263
+ feature, using the `colorScheme` argument.
264
+
265
+ ```ruby
266
+ page.evaluate("matchMedia('screen').matches") # => true
267
+ page.evaluate("matchMedia('print').matches") # => false
268
+
269
+ page.emulate_media(media: "print")
270
+ page.evaluate("matchMedia('screen').matches") # => false
271
+ page.evaluate("matchMedia('print').matches") # => true
272
+
273
+ page.emulate_media
274
+ page.evaluate("matchMedia('screen').matches") # => true
275
+ page.evaluate("matchMedia('print').matches") # => false
276
+ ```
277
+
278
+ ```ruby
279
+ page.emulate_media(colorScheme="dark")
280
+ page.evaluate("matchMedia('(prefers-color-scheme: dark)').matches") # => true
281
+ page.evaluate("matchMedia('(prefers-color-scheme: light)').matches") # => false
282
+ page.evaluate("matchMedia('(prefers-color-scheme: no-preference)').matches") # => false
283
+ ```
284
+
285
+
286
+
287
+ ## eval_on_selector
288
+
289
+ ```
290
+ def eval_on_selector(selector, expression, arg: nil)
291
+ ```
292
+
293
+ The method finds an element matching the specified selector within the page and passes it as a first argument to
294
+ `expression`. If no elements match the selector, the method throws an error. Returns the value of `expression`.
295
+
296
+ If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [Page#eval_on_selector](./page#eval_on_selector) would wait for the promise to resolve and
297
+ return its value.
298
+
299
+ Examples:
300
+
301
+ ```ruby
302
+ search_value = page.eval_on_selector("#search", "el => el.value")
303
+ preload_href = page.eval_on_selector("link[rel=preload]", "el => el.href")
304
+ html = page.eval_on_selector(".main-container", "(e, suffix) => e.outer_html + suffix", arg: "hello")
305
+ ```
306
+
307
+ Shortcut for main frame's [Frame#eval_on_selector](./frame#eval_on_selector).
308
+
309
+ ## eval_on_selector_all
310
+
311
+ ```
312
+ def eval_on_selector_all(selector, expression, arg: nil)
313
+ ```
314
+
315
+ The method finds all elements matching the specified selector within the page and passes an array of matched elements as
316
+ a first argument to `expression`. Returns the result of `expression` invocation.
317
+
318
+ If `expression` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [Page#eval_on_selector_all](./page#eval_on_selector_all) would wait for the promise to resolve and
319
+ return its value.
320
+
321
+ Examples:
322
+
323
+ ```ruby
324
+ div_counts = page.eval_on_selector_all("div", "(divs, min) => divs.length >= min", arg: 10)
325
+ ```
326
+
327
+
328
+
329
+ ## evaluate
330
+
331
+ ```
332
+ def evaluate(expression, arg: nil)
333
+ ```
334
+
335
+ Returns the value of the `expression` invocation.
336
+
337
+ If the function passed to the [Page#evaluate](./page#evaluate) returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [Page#evaluate](./page#evaluate) would wait
338
+ for the promise to resolve and return its value.
339
+
340
+ If the function passed to the [Page#evaluate](./page#evaluate) returns a non-[Serializable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#description) value, then
341
+ [Page#evaluate](./page#evaluate) resolves to `undefined`. Playwright also supports transferring some additional values that are
342
+ not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
343
+
344
+ Passing argument to `expression`:
345
+
346
+ ```ruby
347
+ result = page.evaluate("([x, y]) => Promise.resolve(x * y)", arg: [7, 8])
348
+ puts result # => "56"
349
+ ```
350
+
351
+ A string can also be passed in instead of a function:
352
+
353
+ ```ruby
354
+ puts page.evaluate("1 + 2") # => 3
355
+ x = 10
356
+ puts page.evaluate("1 + #{x}") # => "11"
357
+ ```
358
+
359
+ [ElementHandle](./element_handle) instances can be passed as an argument to the [Page#evaluate](./page#evaluate):
360
+
361
+ ```ruby
362
+ body_handle = page.query_selector("body")
363
+ html = page.evaluate("([body, suffix]) => body.innerHTML + suffix", arg: [body_handle, "hello"])
364
+ body_handle.dispose
365
+ ```
366
+
367
+ Shortcut for main frame's [Frame#evaluate](./frame#evaluate).
368
+
369
+ ## evaluate_handle
370
+
371
+ ```
372
+ def evaluate_handle(expression, arg: nil)
373
+ ```
374
+
375
+ Returns the value of the `expression` invocation as a [JSHandle](./js_handle).
376
+
377
+ The only difference between [Page#evaluate](./page#evaluate) and [Page#evaluate_handle](./page#evaluate_handle) is that
378
+ [Page#evaluate_handle](./page#evaluate_handle) returns [JSHandle](./js_handle).
379
+
380
+ If the function passed to the [Page#evaluate_handle](./page#evaluate_handle) returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), then [Page#evaluate_handle](./page#evaluate_handle)
381
+ would wait for the promise to resolve and return its value.
382
+
383
+ ```ruby
384
+ a_window_handle = page.evaluate_handle("Promise.resolve(window)")
385
+ a_window_handle # handle for the window object.
386
+ ```
387
+
388
+ A string can also be passed in instead of a function:
389
+
390
+ ```ruby
391
+ a_handle = page.evaluate_handle("document") # handle for the "document"
392
+ ```
393
+
394
+ [JSHandle](./js_handle) instances can be passed as an argument to the [Page#evaluate_handle](./page#evaluate_handle):
395
+
396
+ ```ruby
397
+ body_handle = page.evaluate_handle("document.body")
398
+ result_handle = page.evaluate_handle("body => body.innerHTML", arg: body_handle)
399
+ puts result_handle.json_value
400
+ result_handle.dispose
401
+ ```
402
+
403
+
404
+
405
+ ## expose_binding
406
+
407
+ ```
408
+ def expose_binding(name, callback, handle: nil)
409
+ ```
410
+
411
+ The method adds a function called `name` on the `window` object of every frame in this page. When called, the function
412
+ executes `callback` and returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) which resolves to the return value of `callback`. If the `callback` returns
413
+ a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), it will be awaited.
414
+
415
+ The first argument of the `callback` function contains information about the caller: `{ browser_context: BrowserContext, page: Page, frame: Frame }`.
416
+
417
+ See [BrowserContext#expose_binding](./browser_context#expose_binding) for the context-wide version.
418
+
419
+ > NOTE: Functions installed via [Page#expose_binding](./page#expose_binding) survive navigations.
420
+
421
+ An example of exposing page URL to all frames in a page:
422
+
423
+ ```ruby
424
+ page.expose_binding("pageURL", ->(source) { source[:page].url })
425
+ page.content = <<~HTML
426
+ <script>
427
+ async function onClick() {
428
+ document.querySelector('div').textContent = await window.pageURL();
429
+ }
430
+ </script>
431
+ <button onclick="onClick()">Click me</button>
432
+ <div></div>
433
+ HTML
434
+ page.click("button")
435
+ ```
436
+
437
+ An example of passing an element handle:
438
+
439
+ ```ruby
440
+ def print_text(source, element)
441
+ element.text_content
442
+ end
443
+
444
+ page.expose_binding("clicked", method(:print_text), handle: true)
445
+ page.content = <<~HTML
446
+ <script>
447
+ document.addEventListener('click', async (event) => {
448
+ alert(await window.clicked(event.target));
449
+ })
450
+ </script>
451
+ <div>Click me</div>
452
+ <div>Or click me</div>
453
+ HTML
454
+
455
+ page.click('div')
456
+ ```
457
+
458
+
459
+
460
+ ## expose_function
461
+
462
+ ```
463
+ def expose_function(name, callback)
464
+ ```
465
+
466
+ The method adds a function called `name` on the `window` object of every frame in the page. When called, the function
467
+ executes `callback` and returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) which resolves to the return value of `callback`.
468
+
469
+ If the `callback` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), it will be awaited.
470
+
471
+ See [BrowserContext#expose_function](./browser_context#expose_function) for context-wide exposed function.
472
+
473
+ > NOTE: Functions installed via [Page#expose_function](./page#expose_function) survive navigations.
474
+
475
+ An example of adding a `sha256` function to the page:
476
+
477
+ ```ruby
478
+ require 'digest'
479
+
480
+ def sha1(text)
481
+ Digest::SHA256.hexdigest(text)
482
+ end
483
+
484
+ page.expose_function("sha256", method(:sha256))
485
+ page.content = <<~HTML
486
+ <script>
487
+ async function onClick() {
488
+ document.querySelector('div').textContent = await window.sha256('PLAYWRIGHT');
489
+ }
490
+ </script>
491
+ <button onclick="onClick()">Click me</button>
492
+ <div></div>
493
+ HTML
494
+ page.click("button")
495
+ ```
496
+
497
+
498
+
499
+ ## fill
500
+
501
+ ```
502
+ def fill(selector, value, noWaitAfter: nil, timeout: nil)
503
+ ```
504
+
505
+ This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/python/docs/actionability) checks, focuses the
506
+ element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input
507
+ field.
508
+
509
+ If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
510
+ However, if the element is inside the `<label>` element that has an associated
511
+ [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled
512
+ instead.
513
+
514
+ To send fine-grained keyboard events, use [Page#type](./page#type).
515
+
516
+ Shortcut for main frame's [Frame#fill](./frame#fill).
517
+
518
+ ## focus
519
+
520
+ ```
521
+ def focus(selector, timeout: nil)
522
+ ```
523
+
524
+ This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the method
525
+ waits until a matching element appears in the DOM.
526
+
527
+ Shortcut for main frame's [Frame#focus](./frame#focus).
528
+
529
+ ## frame
530
+
531
+ ```
532
+ def frame(name: nil, url: nil)
533
+ ```
534
+
535
+ Returns frame matching the specified criteria. Either `name` or `url` must be specified.
536
+
537
+ ```ruby
538
+ frame = page.frame(name: "frame-name")
539
+ ```
540
+
541
+ ```ruby
542
+ frame = page.frame(url: /.*domain.*/)
543
+ ```
544
+
545
+
546
+
547
+ ## frames
548
+
549
+ ```
550
+ def frames
551
+ ```
552
+
553
+ An array of all frames attached to the page.
554
+
555
+ ## get_attribute
556
+
557
+ ```
558
+ def get_attribute(selector, name, timeout: nil)
559
+ ```
560
+
561
+ Returns element attribute value.
562
+
563
+ ## go_back
564
+
565
+ ```
566
+ def go_back(timeout: nil, waitUntil: nil)
567
+ ```
568
+
569
+ Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
570
+ last redirect. If can not go back, returns `null`.
571
+
572
+ Navigate to the previous page in history.
573
+
574
+ ## go_forward
575
+
576
+ ```
577
+ def go_forward(timeout: nil, waitUntil: nil)
578
+ ```
579
+
580
+ Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
581
+ last redirect. If can not go forward, returns `null`.
582
+
583
+ Navigate to the next page in history.
584
+
585
+ ## goto
586
+
587
+ ```
588
+ def goto(url, referer: nil, timeout: nil, waitUntil: nil)
589
+ ```
590
+
591
+ Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
592
+ last redirect.
593
+
594
+ `page.goto` will throw an error if:
595
+ - there's an SSL error (e.g. in case of self-signed certificates).
596
+ - target URL is invalid.
597
+ - the `timeout` is exceeded during navigation.
598
+ - the remote server does not respond or is unreachable.
599
+ - the main resource failed to load.
600
+
601
+ `page.goto` will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not
602
+ Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
603
+ [Response#status](./response#status).
604
+
605
+ > NOTE: `page.goto` either throws an error or returns a main resource response. The only exceptions are navigation to
606
+ `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
607
+ > NOTE: Headless mode doesn't support navigation to a PDF document. See the
608
+ [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
609
+
610
+ Shortcut for main frame's [Frame#goto](./frame#goto)
611
+
612
+ ## hover
613
+
614
+ ```
615
+ def hover(
616
+ selector,
617
+ force: nil,
618
+ modifiers: nil,
619
+ position: nil,
620
+ timeout: nil,
621
+ trial: nil)
622
+ ```
623
+
624
+ This method hovers over an element matching `selector` by performing the following steps:
625
+ 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
626
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the
627
+ element is detached during the checks, the whole action is retried.
628
+ 1. Scroll the element into view if needed.
629
+ 1. Use [Page#mouse](./page#mouse) to hover over the center of the element, or the specified `position`.
630
+ 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
631
+
632
+ When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
633
+ zero timeout disables this.
634
+
635
+ Shortcut for main frame's [Frame#hover](./frame#hover).
636
+
637
+ ## inner_html
638
+
639
+ ```
640
+ def inner_html(selector, timeout: nil)
641
+ ```
642
+
643
+ Returns `element.innerHTML`.
644
+
645
+ ## inner_text
646
+
647
+ ```
648
+ def inner_text(selector, timeout: nil)
649
+ ```
650
+
651
+ Returns `element.innerText`.
652
+
653
+ ## checked?
654
+
655
+ ```
656
+ def checked?(selector, timeout: nil)
657
+ ```
658
+
659
+ Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
660
+
661
+ ## closed?
662
+
663
+ ```
664
+ def closed?
665
+ ```
666
+
667
+ Indicates that the page has been closed.
668
+
669
+ ## disabled?
670
+
671
+ ```
672
+ def disabled?(selector, timeout: nil)
673
+ ```
674
+
675
+ Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/python/docs/actionability).
676
+
677
+ ## editable?
678
+
679
+ ```
680
+ def editable?(selector, timeout: nil)
681
+ ```
682
+
683
+ Returns whether the element is [editable](https://playwright.dev/python/docs/actionability).
684
+
685
+ ## enabled?
686
+
687
+ ```
688
+ def enabled?(selector, timeout: nil)
689
+ ```
690
+
691
+ Returns whether the element is [enabled](https://playwright.dev/python/docs/actionability).
692
+
693
+ ## hidden?
694
+
695
+ ```
696
+ def hidden?(selector, timeout: nil)
697
+ ```
698
+
699
+ Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/python/docs/actionability). `selector` that does not
700
+ match any elements is considered hidden.
701
+
702
+ ## visible?
703
+
704
+ ```
705
+ def visible?(selector, timeout: nil)
706
+ ```
707
+
708
+ Returns whether the element is [visible](https://playwright.dev/python/docs/actionability). `selector` that does not match any elements is
709
+ considered not visible.
710
+
711
+ ## main_frame
712
+
713
+ ```
714
+ def main_frame
715
+ ```
716
+
717
+ The page's main frame. Page is guaranteed to have a main frame which persists during navigations.
718
+
719
+ ## opener
720
+
721
+ ```
722
+ def opener
723
+ ```
724
+
725
+ Returns the opener for popup pages and `null` for others. If the opener has been closed already the returns `null`.
726
+
727
+ ## pdf
728
+
729
+ ```
730
+ def pdf(
731
+ displayHeaderFooter: nil,
732
+ footerTemplate: nil,
733
+ format: nil,
734
+ headerTemplate: nil,
735
+ height: nil,
736
+ landscape: nil,
737
+ margin: nil,
738
+ pageRanges: nil,
739
+ path: nil,
740
+ preferCSSPageSize: nil,
741
+ printBackground: nil,
742
+ scale: nil,
743
+ width: nil)
744
+ ```
745
+
746
+ Returns the PDF buffer.
747
+
748
+ > NOTE: Generating a pdf is currently only supported in Chromium headless.
749
+
750
+ `page.pdf()` generates a pdf of the page with `print` css media. To generate a pdf with `screen` media, call
751
+ [Page#emulate_media](./page#emulate_media) before calling `page.pdf()`:
752
+
753
+ > NOTE: By default, `page.pdf()` generates a pdf with modified colors for printing. Use the
754
+ [`-webkit-print-color-adjust`](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-print-color-adjust) property to
755
+ force rendering of exact colors.
756
+
757
+ ```ruby
758
+ # generates a pdf with "screen" media type.
759
+ page.emulate_media(media: "screen")
760
+ page.pdf(path: "page.pdf")
761
+ ```
762
+
763
+ The `width`, `height`, and `margin` options accept values labeled with units. Unlabeled values are treated as pixels.
764
+
765
+ A few examples:
766
+ - `page.pdf({width: 100})` - prints with width set to 100 pixels
767
+ - `page.pdf({width: '100px'})` - prints with width set to 100 pixels
768
+ - `page.pdf({width: '10cm'})` - prints with width set to 10 centimeters.
769
+
770
+ All possible units are:
771
+ - `px` - pixel
772
+ - `in` - inch
773
+ - `cm` - centimeter
774
+ - `mm` - millimeter
775
+
776
+ The `format` options are:
777
+ - `Letter`: 8.5in x 11in
778
+ - `Legal`: 8.5in x 14in
779
+ - `Tabloid`: 11in x 17in
780
+ - `Ledger`: 17in x 11in
781
+ - `A0`: 33.1in x 46.8in
782
+ - `A1`: 23.4in x 33.1in
783
+ - `A2`: 16.54in x 23.4in
784
+ - `A3`: 11.7in x 16.54in
785
+ - `A4`: 8.27in x 11.7in
786
+ - `A5`: 5.83in x 8.27in
787
+ - `A6`: 4.13in x 5.83in
788
+
789
+ > NOTE: `headerTemplate` and `footerTemplate` markup have the following limitations: > 1. Script tags inside templates
790
+ are not evaluated. > 2. Page styles are not visible inside templates.
791
+
792
+ ## press
793
+
794
+ ```
795
+ def press(
796
+ selector,
797
+ key,
798
+ delay: nil,
799
+ noWaitAfter: nil,
800
+ timeout: nil)
801
+ ```
802
+
803
+ Focuses the element, and then uses [Keyboard#down](./keyboard#down) and [Keyboard#up](./keyboard#up).
804
+
805
+ `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
806
+ value or a single character to generate the text for. A superset of the `key` values can be found
807
+ [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
808
+
809
+ `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
810
+ `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
811
+
812
+ Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
813
+
814
+ Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
815
+
816
+ If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
817
+ texts.
818
+
819
+ Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
820
+ modifier, modifier is pressed and being held while the subsequent key is being pressed.
821
+
822
+ ```ruby
823
+ page.goto("https://keycode.info")
824
+ page.press("body", "A")
825
+ page.screenshot(path: "a.png")
826
+ page.press("body", "ArrowLeft")
827
+ page.screenshot(path: "arrow_left.png")
828
+ page.press("body", "Shift+O")
829
+ page.screenshot(path: "o.png")
830
+ ```
831
+
832
+
833
+
834
+ ## query_selector
835
+
836
+ ```
837
+ def query_selector(selector)
838
+ ```
839
+
840
+ The method finds an element matching the specified selector within the page. If no elements match the selector, the
841
+ return value resolves to `null`. To wait for an element on the page, use [Page#wait_for_selector](./page#wait_for_selector).
842
+
843
+ Shortcut for main frame's [Frame#query_selector](./frame#query_selector).
844
+
845
+ ## query_selector_all
846
+
847
+ ```
848
+ def query_selector_all(selector)
849
+ ```
850
+
851
+ The method finds all elements matching the specified selector within the page. If no elements match the selector, the
852
+ return value resolves to `[]`.
853
+
854
+ Shortcut for main frame's [Frame#query_selector_all](./frame#query_selector_all).
855
+
856
+ ## reload
857
+
858
+ ```
859
+ def reload(timeout: nil, waitUntil: nil)
860
+ ```
861
+
862
+ Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
863
+ last redirect.
864
+
865
+ ## route
866
+
867
+ ```
868
+ def route(url, handler)
869
+ ```
870
+
871
+ Routing provides the capability to modify network requests that are made by a page.
872
+
873
+ Once routing is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
874
+
875
+ > NOTE: The handler will only be called for the first url if the response is a redirect.
876
+
877
+ An example of a naive handler that aborts all image requests:
878
+
879
+ ```ruby
880
+ page.route("**/*.{png,jpg,jpeg}", ->(route, request) { route.abort })
881
+ page.goto("https://example.com")
882
+ ```
883
+
884
+ or the same snippet using a regex pattern instead:
885
+
886
+ ```ruby
887
+ page.route(/\.(png|jpg)$/, ->(route, request) { route.abort })
888
+ page.goto("https://example.com")
889
+ ```
890
+
891
+ It is possible to examine the request to decide the route action. For example, mocking all requests that contain some
892
+ post data, and leaving all other requests as is:
893
+
894
+ ```ruby
895
+ def handle_route(route, request)
896
+ if request.post_data["my-string"]
897
+ mocked_data = request.post_data.merge({ "my-string" => 'mocked-data'})
898
+ route.fulfill(postData: mocked_data)
899
+ else
900
+ route.continue
901
+ end
902
+ end
903
+ page.route("/api/**", method(:handle_route))
904
+ ```
905
+
906
+ Page routes take precedence over browser context routes (set up with [BrowserContext#route](./browser_context#route)) when request
907
+ matches both handlers.
908
+
909
+ To remove a route with its handler you can use [Page#unroute](./page#unroute).
910
+
911
+ > NOTE: Enabling routing disables http cache.
912
+
913
+ ## screenshot
914
+
915
+ ```
916
+ def screenshot(
917
+ clip: nil,
918
+ fullPage: nil,
919
+ omitBackground: nil,
920
+ path: nil,
921
+ quality: nil,
922
+ timeout: nil,
923
+ type: nil)
924
+ ```
925
+
926
+ Returns the buffer with the captured screenshot.
927
+
928
+ ## select_option
929
+
930
+ ```
931
+ def select_option(
932
+ selector,
933
+ element: nil,
934
+ index: nil,
935
+ value: nil,
936
+ label: nil,
937
+ noWaitAfter: nil,
938
+ timeout: nil)
939
+ ```
940
+
941
+ This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/python/docs/actionability) checks, waits until
942
+ all specified options are present in the `<select>` element and selects these options.
943
+
944
+ If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the
945
+ `<label>` element that has an associated
946
+ [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
947
+
948
+ Returns the array of option values that have been successfully selected.
949
+
950
+ Triggers a `change` and `input` event once all the provided options have been selected.
951
+
952
+ ```ruby
953
+ # single selection matching the value
954
+ page.select_option("select#colors", value: "blue")
955
+ # single selection matching both the label
956
+ page.select_option("select#colors", label: "blue")
957
+ # multiple selection
958
+ page.select_option("select#colors", value: ["red", "green", "blue"])
959
+ ```
960
+
961
+ Shortcut for main frame's [Frame#select_option](./frame#select_option).
962
+
963
+ ## set_content
964
+
965
+ ```
966
+ def set_content(html, timeout: nil, waitUntil: nil)
967
+ ```
968
+ alias: `content=`
969
+
970
+
971
+
972
+ ## set_default_navigation_timeout
973
+
974
+ ```
975
+ def set_default_navigation_timeout(timeout)
976
+ ```
977
+ alias: `default_navigation_timeout=`
978
+
979
+ This setting will change the default maximum navigation time for the following methods and related shortcuts:
980
+ - [Page#go_back](./page#go_back)
981
+ - [Page#go_forward](./page#go_forward)
982
+ - [Page#goto](./page#goto)
983
+ - [Page#reload](./page#reload)
984
+ - [Page#set_content](./page#set_content)
985
+ - [Page#expect_navigation](./page#expect_navigation)
986
+ - [Page#wait_for_url](./page#wait_for_url)
987
+
988
+ > NOTE: [Page#set_default_navigation_timeout](./page#set_default_navigation_timeout) takes priority over [Page#set_default_timeout](./page#set_default_timeout),
989
+ [BrowserContext#set_default_timeout](./browser_context#set_default_timeout) and [BrowserContext#set_default_navigation_timeout](./browser_context#set_default_navigation_timeout).
990
+
991
+ ## set_default_timeout
992
+
993
+ ```
994
+ def set_default_timeout(timeout)
995
+ ```
996
+ alias: `default_timeout=`
997
+
998
+ This setting will change the default maximum time for all the methods accepting `timeout` option.
999
+
1000
+ > NOTE: [Page#set_default_navigation_timeout](./page#set_default_navigation_timeout) takes priority over [Page#set_default_timeout](./page#set_default_timeout).
1001
+
1002
+ ## set_extra_http_headers
1003
+
1004
+ ```
1005
+ def set_extra_http_headers(headers)
1006
+ ```
1007
+ alias: `extra_http_headers=`
1008
+
1009
+ The extra HTTP headers will be sent with every request the page initiates.
1010
+
1011
+ > NOTE: [Page#set_extra_http_headers](./page#set_extra_http_headers) does not guarantee the order of headers in the outgoing requests.
1012
+
1013
+ ## set_input_files
1014
+
1015
+ ```
1016
+ def set_input_files(selector, files, noWaitAfter: nil, timeout: nil)
1017
+ ```
1018
+
1019
+ This method expects `selector` to point to an
1020
+ [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
1021
+
1022
+ Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
1023
+ are resolved relative to the the current working directory. For empty array, clears the selected files.
1024
+
1025
+ ## set_viewport_size
1026
+
1027
+ ```
1028
+ def set_viewport_size(viewportSize)
1029
+ ```
1030
+ alias: `viewport_size=`
1031
+
1032
+ In the case of multiple pages in a single browser, each page can have its own viewport size. However,
1033
+ [Browser#new_context](./browser#new_context) allows to set viewport size (and more) for all pages in the context at once.
1034
+
1035
+ `page.setViewportSize` will resize the page. A lot of websites don't expect phones to change size, so you should set the
1036
+ viewport size before navigating to the page.
1037
+
1038
+ ```ruby
1039
+ page.viewport_size = { width: 640, height: 480 }
1040
+ page.goto("https://example.com")
1041
+ ```
1042
+
1043
+
1044
+
1045
+ ## tap_point
1046
+
1047
+ ```
1048
+ def tap_point(
1049
+ selector,
1050
+ force: nil,
1051
+ modifiers: nil,
1052
+ noWaitAfter: nil,
1053
+ position: nil,
1054
+ timeout: nil,
1055
+ trial: nil)
1056
+ ```
1057
+
1058
+ This method taps an element matching `selector` by performing the following steps:
1059
+ 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
1060
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the
1061
+ element is detached during the checks, the whole action is retried.
1062
+ 1. Scroll the element into view if needed.
1063
+ 1. Use [Page#touchscreen](./page#touchscreen) to tap the center of the element, or the specified `position`.
1064
+ 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
1065
+
1066
+ When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
1067
+ zero timeout disables this.
1068
+
1069
+ > NOTE: [Page#tap_point](./page#tap_point) requires that the `hasTouch` option of the browser context be set to true.
1070
+
1071
+ Shortcut for main frame's [Frame#tap_point](./frame#tap_point).
1072
+
1073
+ ## text_content
1074
+
1075
+ ```
1076
+ def text_content(selector, timeout: nil)
1077
+ ```
1078
+
1079
+ Returns `element.textContent`.
1080
+
1081
+ ## title
1082
+
1083
+ ```
1084
+ def title
1085
+ ```
1086
+
1087
+ Returns the page's title. Shortcut for main frame's [Frame#title](./frame#title).
1088
+
1089
+ ## type
1090
+
1091
+ ```
1092
+ def type(
1093
+ selector,
1094
+ text,
1095
+ delay: nil,
1096
+ noWaitAfter: nil,
1097
+ timeout: nil)
1098
+ ```
1099
+
1100
+ Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `page.type` can be used to send
1101
+ fine-grained keyboard events. To fill values in form fields, use [Page#fill](./page#fill).
1102
+
1103
+ To press a special key, like `Control` or `ArrowDown`, use [Keyboard#press](./keyboard#press).
1104
+
1105
+ ```ruby
1106
+ page.type("#mytextarea", "hello") # types instantly
1107
+ page.type("#mytextarea", "world", delay: 100) # types slower, like a user
1108
+ ```
1109
+
1110
+ Shortcut for main frame's [Frame#type](./frame#type).
1111
+
1112
+ ## uncheck
1113
+
1114
+ ```
1115
+ def uncheck(
1116
+ selector,
1117
+ force: nil,
1118
+ noWaitAfter: nil,
1119
+ position: nil,
1120
+ timeout: nil,
1121
+ trial: nil)
1122
+ ```
1123
+
1124
+ This method unchecks an element matching `selector` by performing the following steps:
1125
+ 1. Find an element matching `selector`. If there is none, wait until a matching element is attached to the DOM.
1126
+ 1. Ensure that matched element is a checkbox or a radio input. If not, this method throws. If the element is already
1127
+ unchecked, this method returns immediately.
1128
+ 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the matched element, unless `force` option is set. If the
1129
+ element is detached during the checks, the whole action is retried.
1130
+ 1. Scroll the element into view if needed.
1131
+ 1. Use [Page#mouse](./page#mouse) to click in the center of the element.
1132
+ 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
1133
+ 1. Ensure that the element is now unchecked. If not, this method throws.
1134
+
1135
+ When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
1136
+ zero timeout disables this.
1137
+
1138
+ Shortcut for main frame's [Frame#uncheck](./frame#uncheck).
1139
+
1140
+ ## unroute
1141
+
1142
+ ```
1143
+ def unroute(url, handler: nil)
1144
+ ```
1145
+
1146
+ Removes a route created with [Page#route](./page#route). When `handler` is not specified, removes all routes for the `url`.
1147
+
1148
+ ## url
1149
+
1150
+ ```
1151
+ def url
1152
+ ```
1153
+
1154
+ Shortcut for main frame's [Frame#url](./frame#url).
1155
+
1156
+ ## video
1157
+
1158
+ ```
1159
+ def video
1160
+ ```
1161
+
1162
+ Video object associated with this page.
1163
+
1164
+ ## viewport_size
1165
+
1166
+ ```
1167
+ def viewport_size
1168
+ ```
1169
+
1170
+
1171
+
1172
+ ## expect_console_message
1173
+
1174
+ ```
1175
+ def expect_console_message(predicate: nil, timeout: nil, &block)
1176
+ ```
1177
+
1178
+ Performs action and waits for a [ConsoleMessage](./console_message) to be logged by in the page. If predicate is provided, it passes
1179
+ [ConsoleMessage](./console_message) value into the `predicate` function and waits for `predicate(message)` to return a truthy value. Will
1180
+ throw an error if the page is closed before the [`event: Page.console`] event is fired.
1181
+
1182
+ ## expect_download
1183
+
1184
+ ```
1185
+ def expect_download(predicate: nil, timeout: nil, &block)
1186
+ ```
1187
+
1188
+ Performs action and waits for a new `Download`. If predicate is provided, it passes `Download` value into the
1189
+ `predicate` function and waits for `predicate(download)` to return a truthy value. Will throw an error if the page is
1190
+ closed before the download event is fired.
1191
+
1192
+ ## expect_event
1193
+
1194
+ ```
1195
+ def expect_event(event, predicate: nil, timeout: nil, &block)
1196
+ ```
1197
+
1198
+ Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
1199
+ value. Will throw an error if the page is closed before the event is fired. Returns the event data value.
1200
+
1201
+ ```ruby
1202
+ frame = page.expect_event("framenavigated") do
1203
+ page.click("button")
1204
+ end
1205
+ ```
1206
+
1207
+
1208
+ ## expect_file_chooser
1209
+
1210
+ ```
1211
+ def expect_file_chooser(predicate: nil, timeout: nil, &block)
1212
+ ```
1213
+
1214
+ Performs action and waits for a new [FileChooser](./file_chooser) to be created. If predicate is provided, it passes [FileChooser](./file_chooser) value
1215
+ into the `predicate` function and waits for `predicate.call(fileChooser)` to return a truthy value. Will throw an error if
1216
+ the page is closed before the file chooser is opened.
1217
+
1218
+ ## wait_for_function
1219
+
1220
+ ```
1221
+ def wait_for_function(expression, arg: nil, polling: nil, timeout: nil)
1222
+ ```
1223
+
1224
+ Returns when the `expression` returns a truthy value. It resolves to a JSHandle of the truthy value.
1225
+
1226
+ The [Page#wait_for_function](./page#wait_for_function) can be used to observe viewport size change:
1227
+
1228
+ ```ruby
1229
+ page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);")
1230
+ page.wait_for_function("() => window.x > 0")
1231
+ ```
1232
+
1233
+ To pass an argument to the predicate of [Page#wait_for_function](./page#wait_for_function) function:
1234
+
1235
+ ```ruby
1236
+ selector = ".foo"
1237
+ page.wait_for_function("selector => !!document.querySelector(selector)", arg: selector)
1238
+ ```
1239
+
1240
+ Shortcut for main frame's [Frame#wait_for_function](./frame#wait_for_function).
1241
+
1242
+ ## wait_for_load_state
1243
+
1244
+ ```
1245
+ def wait_for_load_state(state: nil, timeout: nil)
1246
+ ```
1247
+
1248
+ Returns when the required load state has been reached.
1249
+
1250
+ This resolves when the page reaches a required load state, `load` by default. The navigation must have been committed
1251
+ when this method is called. If current document has already reached the required state, resolves immediately.
1252
+
1253
+ ```ruby
1254
+ page.click("button") # click triggers navigation.
1255
+ page.wait_for_load_state # the promise resolves after "load" event.
1256
+ ```
1257
+
1258
+ ```ruby
1259
+ popup = page.expect_popup do
1260
+ page.click("button") # click triggers a popup.
1261
+ end
1262
+
1263
+ # Following resolves after "domcontentloaded" event.
1264
+ popup.wait_for_load_state("domcontentloaded")
1265
+ puts popup.title # popup is ready to use.
1266
+ ```
1267
+
1268
+ Shortcut for main frame's [Frame#wait_for_load_state](./frame#wait_for_load_state).
1269
+
1270
+ ## expect_navigation
1271
+
1272
+ ```
1273
+ def expect_navigation(timeout: nil, url: nil, waitUntil: nil, &block)
1274
+ ```
1275
+
1276
+ Waits for the main frame navigation and returns the main resource response. In case of multiple redirects, the
1277
+ navigation will resolve with the response of the last redirect. In case of navigation to a different anchor or
1278
+ navigation due to History API usage, the navigation will resolve with `null`.
1279
+
1280
+ This resolves when the page navigates to a new URL or reloads. It is useful for when you run code which will indirectly
1281
+ cause the page to navigate. e.g. The click target has an `onclick` handler that triggers navigation from a `setTimeout`.
1282
+ Consider this example:
1283
+
1284
+ ```ruby
1285
+ page.expect_navigation do
1286
+ page.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
1287
+ end # Resolves after navigation has finished
1288
+ ```
1289
+
1290
+ > NOTE: Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is
1291
+ considered a navigation.
1292
+
1293
+ Shortcut for main frame's [Frame#expect_navigation](./frame#expect_navigation).
1294
+
1295
+ ## expect_popup
1296
+
1297
+ ```
1298
+ def expect_popup(predicate: nil, timeout: nil, &block)
1299
+ ```
1300
+
1301
+ Performs action and waits for a popup [Page](./page). If predicate is provided, it passes popup [Page](./page) value into the predicate function and waits for `predicate.call(page)` to return a truthy value. Will throw an error if the page is closed before the popup event is fired.
1302
+
1303
+ ## expect_request
1304
+
1305
+ ```
1306
+ def expect_request(urlOrPredicate, timeout: nil, &block)
1307
+ ```
1308
+
1309
+ Waits for the matching request and returns it. See [waiting for event](https://playwright.dev/python/docs/events) for more details
1310
+ about events.
1311
+
1312
+ ```ruby
1313
+ page.content = '<form action="https://example.com/resource"><input type="submit" /></form>'
1314
+ request = page.expect_request(/example.com\/resource/) do
1315
+ page.click("input")
1316
+ end
1317
+ puts request.headers
1318
+
1319
+ page.wait_for_load_state # wait for request finished.
1320
+
1321
+ # or with a predicate
1322
+ page.content = '<form action="https://example.com/resource"><input type="submit" /></form>'
1323
+ request = page.expect_request(->(req) { req.url.start_with? 'https://example.com/resource' }) do
1324
+ page.click("input")
1325
+ end
1326
+ puts request.headers
1327
+ ```
1328
+
1329
+
1330
+
1331
+ ## expect_response
1332
+
1333
+ ```
1334
+ def expect_response(urlOrPredicate, timeout: nil, &block)
1335
+ ```
1336
+
1337
+ Returns the matched response. See [waiting for event](https://playwright.dev/python/docs/events) for more details about events.
1338
+
1339
+ ```ruby
1340
+ page.content = '<form action="https://example.com/resource"><input type="submit" /></form>'
1341
+ response = page.expect_response(/example.com\/resource/) do
1342
+ page.click("input")
1343
+ end
1344
+ puts response.body
1345
+
1346
+ # or with a predicate
1347
+ page.content = '<form action="https://example.com/resource"><input type="submit" /></form>'
1348
+ response = page.expect_response(->(res) { res.url.start_with? 'https://example.com/resource' }) do
1349
+ page.click("input")
1350
+ end
1351
+ puts response.body
1352
+ ```
1353
+
1354
+
1355
+
1356
+ ## wait_for_selector
1357
+
1358
+ ```
1359
+ def wait_for_selector(selector, state: nil, timeout: nil)
1360
+ ```
1361
+
1362
+ Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
1363
+ `detached`.
1364
+
1365
+ Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at
1366
+ the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the
1367
+ selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
1368
+
1369
+ This method works across navigations:
1370
+
1371
+ ```ruby
1372
+ %w[https://google.com https://bbc.com].each do |current_url|
1373
+ page.goto(current_url, waitUntil: "domcontentloaded")
1374
+ element = page.wait_for_selector("img")
1375
+ puts "Loaded image: #{element["src"]}"
1376
+ end
1377
+ ```
1378
+
1379
+
1380
+
1381
+ ## wait_for_url
1382
+
1383
+ ```
1384
+ def wait_for_url(url, timeout: nil, waitUntil: nil)
1385
+ ```
1386
+
1387
+ Waits for the main frame to navigate to the given URL.
1388
+
1389
+ ```ruby
1390
+ page.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
1391
+ page.wait_for_url("**/target.html")
1392
+ ```
1393
+
1394
+ Shortcut for main frame's [Frame#wait_for_url](./frame#wait_for_url).
1395
+
1396
+ ## accessibility
1397
+
1398
+ ## keyboard
1399
+
1400
+ ## mouse
1401
+
1402
+ ## touchscreen