playwright-ruby-client 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/README.md +33 -0
  3. data/documentation/babel.config.js +3 -0
  4. data/documentation/docs/api/accessibility.md +7 -0
  5. data/documentation/docs/api/browser.md +185 -0
  6. data/documentation/docs/api/browser_context.md +398 -0
  7. data/documentation/docs/api/browser_type.md +105 -0
  8. data/documentation/docs/api/cdp_session.md +7 -0
  9. data/documentation/docs/api/console_message.md +41 -0
  10. data/documentation/docs/api/dialog.md +74 -0
  11. data/documentation/docs/api/element_handle.md +640 -0
  12. data/documentation/docs/api/experimental/_category_.yml +3 -0
  13. data/documentation/docs/api/experimental/android.md +25 -0
  14. data/documentation/docs/api/experimental/android_device.md +91 -0
  15. data/documentation/docs/api/experimental/android_input.md +38 -0
  16. data/documentation/docs/api/experimental/android_socket.md +7 -0
  17. data/documentation/docs/api/experimental/android_web_view.md +7 -0
  18. data/documentation/docs/api/file_chooser.md +51 -0
  19. data/documentation/docs/api/frame.md +867 -0
  20. data/documentation/docs/api/js_handle.md +116 -0
  21. data/documentation/docs/api/keyboard.md +157 -0
  22. data/documentation/docs/api/mouse.md +69 -0
  23. data/documentation/docs/api/page.md +1469 -0
  24. data/documentation/docs/api/playwright.md +63 -0
  25. data/documentation/docs/api/request.md +188 -0
  26. data/documentation/docs/api/response.md +97 -0
  27. data/documentation/docs/api/route.md +80 -0
  28. data/documentation/docs/api/selectors.md +23 -0
  29. data/documentation/docs/api/touchscreen.md +8 -0
  30. data/documentation/docs/api/tracing.md +54 -0
  31. data/documentation/docs/api/web_socket.md +7 -0
  32. data/documentation/docs/api/worker.md +7 -0
  33. data/documentation/docs/article/api_coverage.mdx +11 -0
  34. data/documentation/docs/article/getting_started.md +152 -0
  35. data/documentation/docs/article/guides/_category_.yml +3 -0
  36. data/documentation/docs/article/guides/download_playwright_driver.md +49 -0
  37. data/documentation/docs/article/guides/launch_browser.md +119 -0
  38. data/documentation/docs/article/guides/rails_integration.md +51 -0
  39. data/{docs → documentation/docs/include}/api_coverage.md +0 -0
  40. data/documentation/docusaurus.config.js +107 -0
  41. data/documentation/package.json +39 -0
  42. data/documentation/sidebars.js +15 -0
  43. data/documentation/src/components/HomepageFeatures.js +61 -0
  44. data/documentation/src/components/HomepageFeatures.module.css +13 -0
  45. data/documentation/src/css/custom.css +44 -0
  46. data/documentation/src/pages/index.js +50 -0
  47. data/documentation/src/pages/index.module.css +41 -0
  48. data/documentation/src/pages/markdown-page.md +7 -0
  49. data/documentation/static/.nojekyll +0 -0
  50. data/documentation/static/img/playwright-logo.svg +9 -0
  51. data/documentation/static/img/undraw_dropdown_menu.svg +1 -0
  52. data/documentation/static/img/undraw_web_development.svg +1 -0
  53. data/documentation/static/img/undraw_windows.svg +1 -0
  54. data/documentation/yarn.lock +8805 -0
  55. data/lib/playwright/channel_owners/binding_call.rb +33 -0
  56. data/lib/playwright/channel_owners/browser_context.rb +2 -2
  57. data/lib/playwright/channel_owners/element_handle.rb +2 -10
  58. data/lib/playwright/channel_owners/frame.rb +6 -28
  59. data/lib/playwright/channel_owners/js_handle.rb +2 -10
  60. data/lib/playwright/channel_owners/page.rb +10 -1
  61. data/lib/playwright/input_files.rb +0 -8
  62. data/lib/playwright/javascript.rb +0 -10
  63. data/lib/playwright/javascript/expression.rb +2 -7
  64. data/lib/playwright/version.rb +1 -1
  65. data/lib/playwright_api/accessibility.rb +7 -89
  66. data/lib/playwright_api/android.rb +7 -64
  67. data/lib/playwright_api/android_device.rb +8 -8
  68. data/lib/playwright_api/browser.rb +15 -169
  69. data/lib/playwright_api/browser_context.rb +47 -609
  70. data/lib/playwright_api/browser_type.rb +13 -103
  71. data/lib/playwright_api/cdp_session.rb +2 -25
  72. data/lib/playwright_api/console_message.rb +6 -6
  73. data/lib/playwright_api/dialog.rb +11 -92
  74. data/lib/playwright_api/element_handle.rb +60 -362
  75. data/lib/playwright_api/file_chooser.rb +0 -28
  76. data/lib/playwright_api/frame.rb +74 -713
  77. data/lib/playwright_api/js_handle.rb +16 -90
  78. data/lib/playwright_api/keyboard.rb +21 -213
  79. data/lib/playwright_api/mouse.rb +1 -45
  80. data/lib/playwright_api/page.rb +155 -1635
  81. data/lib/playwright_api/playwright.rb +14 -117
  82. data/lib/playwright_api/request.rb +15 -121
  83. data/lib/playwright_api/response.rb +9 -9
  84. data/lib/playwright_api/route.rb +8 -105
  85. data/lib/playwright_api/selectors.rb +6 -97
  86. data/lib/playwright_api/tracing.rb +1 -61
  87. data/lib/playwright_api/web_socket.rb +1 -1
  88. data/lib/playwright_api/worker.rb +6 -42
  89. metadata +55 -4
  90. data/lib/playwright/javascript/function.rb +0 -67
@@ -1,58 +1,10 @@
1
1
  module Playwright
2
2
  # BrowserType provides methods to launch a specific browser instance or connect to an existing one. The following is a
3
3
  # typical example of using Playwright to drive automation:
4
- #
5
4
  #
6
- # ```js
7
- # const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
8
- #
9
- # (async () => {
10
- # const browser = await chromium.launch();
11
- # const page = await browser.newPage();
12
- # await page.goto('https://example.com');
13
- # // other actions...
14
- # await browser.close();
15
- # })();
16
- # ```
17
- #
18
- # ```java
19
- # import com.microsoft.playwright.*;
20
- #
21
- # public class Example {
22
- # public static void main(String[] args) {
23
- # try (Playwright playwright = Playwright.create()) {
24
- # BrowserType chromium = playwright.chromium();
25
- # Browser browser = chromium.launch();
26
- # Page page = browser.newPage();
27
- # page.navigate("https://example.com");
28
- # // other actions...
29
- # browser.close();
30
- # }
31
- # }
32
- # }
33
- # ```
34
- #
35
- # ```python async
36
- # import asyncio
37
- # from playwright.async_api import async_playwright
38
- #
39
- # async def run(playwright):
40
- # chromium = playwright.chromium
41
- # browser = await chromium.launch()
42
- # page = await browser.new_page()
43
- # await page.goto("https://example.com")
44
- # # other actions...
45
- # await browser.close()
46
- #
47
- # async def main():
48
- # async with async_playwright() as playwright:
49
- # await run(playwright)
50
- # asyncio.run(main())
51
- # ```
52
- #
53
5
  # ```python sync
54
6
  # from playwright.sync_api import sync_playwright
55
- #
7
+ #
56
8
  # def run(playwright):
57
9
  # chromium = playwright.chromium
58
10
  # browser = chromium.launch()
@@ -60,29 +12,10 @@ module Playwright
60
12
  # page.goto("https://example.com")
61
13
  # # other actions...
62
14
  # browser.close()
63
- #
15
+ #
64
16
  # with sync_playwright() as playwright:
65
17
  # run(playwright)
66
18
  # ```
67
- #
68
- # ```csharp
69
- # using Microsoft.Playwright;
70
- # using System.Threading.Tasks;
71
- #
72
- # class BrowserTypeExamples
73
- # {
74
- # public static async Task Run()
75
- # {
76
- # using var playwright = await Playwright.CreateAsync();
77
- # var chromium = playwright.Chromium;
78
- # var browser = await chromium.LaunchAsync();
79
- # var page = await browser.NewPageAsync();
80
- # await page.GoToAsync("https://www.bing.com");
81
- # // other actions
82
- # await browser.CloseAsync();
83
- # }
84
- # }
85
- # ```
86
19
  class BrowserType < PlaywrightApi
87
20
 
88
21
  # This methods attaches Playwright to an existing browser instance.
@@ -91,9 +24,9 @@ module Playwright
91
24
  end
92
25
 
93
26
  # This methods attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
94
- #
27
+ #
95
28
  # The default browser context is accessible via [`method: Browser.contexts`].
96
- #
29
+ #
97
30
  # > NOTE: Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
98
31
  def connect_over_cdp(
99
32
  endpointURL,
@@ -110,38 +43,15 @@ module Playwright
110
43
  end
111
44
 
112
45
  # Returns the browser instance.
113
- #
46
+ #
114
47
  # You can use `ignoreDefaultArgs` to filter out `--mute-audio` from default arguments:
115
- #
116
48
  #
117
- # ```js
118
- # const browser = await chromium.launch({ // Or 'firefox' or 'webkit'.
119
- # ignoreDefaultArgs: ['--mute-audio']
120
- # });
121
- # ```
122
- #
123
- # ```java
124
- # // Or "firefox" or "webkit".
125
- # Browser browser = chromium.launch(new BrowserType.LaunchOptions()
126
- # .setIgnoreDefaultArgs(Arrays.asList("--mute-audio")));
127
- # ```
128
- #
129
- # ```python async
130
- # browser = await playwright.chromium.launch( # or "firefox" or "webkit".
131
- # ignore_default_args=["--mute-audio"]
132
- # )
133
- # ```
134
- #
135
49
  # ```python sync
136
50
  # browser = playwright.chromium.launch( # or "firefox" or "webkit".
137
51
  # ignore_default_args=["--mute-audio"]
138
52
  # )
139
53
  # ```
140
- #
141
- # ```csharp
142
- # var browser = await playwright.Chromium.LaunchAsync(ignoreDefaultArgs: new[] { "--mute-audio" })
143
- # ```
144
- #
54
+ #
145
55
  # > **Chromium-only** Playwright can also be used to control the Google Chrome or Microsoft Edge browsers, but it works
146
56
  # best with the version of Chromium it is bundled with. There is no guarantee it will work with any other version. Use
147
57
  # `executablePath` option with extreme caution.
@@ -179,7 +89,7 @@ module Playwright
179
89
  end
180
90
 
181
91
  # Returns the persistent browser context instance.
182
- #
92
+ #
183
93
  # Launches browser that uses persistent storage located at `userDataDir` and returns the only context. Closing this
184
94
  # context will automatically close the browser.
185
95
  def launch_persistent_context(
@@ -233,20 +143,20 @@ module Playwright
233
143
 
234
144
  # -- inherited from EventEmitter --
235
145
  # @nodoc
236
- def off(event, callback)
237
- event_emitter_proxy.off(event, callback)
146
+ def on(event, callback)
147
+ event_emitter_proxy.on(event, callback)
238
148
  end
239
149
 
240
150
  # -- inherited from EventEmitter --
241
151
  # @nodoc
242
- def once(event, callback)
243
- event_emitter_proxy.once(event, callback)
152
+ def off(event, callback)
153
+ event_emitter_proxy.off(event, callback)
244
154
  end
245
155
 
246
156
  # -- inherited from EventEmitter --
247
157
  # @nodoc
248
- def on(event, callback)
249
- event_emitter_proxy.on(event, callback)
158
+ def once(event, callback)
159
+ event_emitter_proxy.once(event, callback)
250
160
  end
251
161
 
252
162
  private def event_emitter_proxy
@@ -1,39 +1,16 @@
1
1
  module Playwright
2
2
  # - extends: [EventEmitter]
3
- #
3
+ #
4
4
  # The `CDPSession` instances are used to talk raw Chrome Devtools Protocol:
5
5
  # - protocol methods can be called with `session.send` method.
6
6
  # - protocol events can be subscribed to with `session.on` method.
7
- #
7
+ #
8
8
  # Useful links:
9
9
  # - Documentation on DevTools Protocol can be found here:
10
10
  # [DevTools Protocol Viewer](https://chromedevtools.github.io/devtools-protocol/).
11
11
  # - Getting Started with DevTools Protocol:
12
12
  # https://github.com/aslushnikov/getting-started-with-cdp/blob/master/README.md
13
- #
14
13
  #
15
- # ```js
16
- # const client = await page.context().newCDPSession(page);
17
- # await client.send('Animation.enable');
18
- # client.on('Animation.animationCreated', () => console.log('Animation created!'));
19
- # const response = await client.send('Animation.getPlaybackRate');
20
- # console.log('playback rate is ' + response.playbackRate);
21
- # await client.send('Animation.setPlaybackRate', {
22
- # playbackRate: response.playbackRate / 2
23
- # });
24
- # ```
25
- #
26
- # ```python async
27
- # client = await page.context().new_cdp_session(page)
28
- # await client.send("animation.enable")
29
- # client.on("animation.animation_created", lambda: print("animation created!"))
30
- # response = await client.send("animation.get_playback_rate")
31
- # print("playback rate is " + response["playback_rate"])
32
- # await client.send("animation.set_playback_rate", {
33
- # playback_rate: response["playback_rate"] / 2
34
- # })
35
- # ```
36
- #
37
14
  # ```python sync
38
15
  # client = page.context().new_cdp_session(page)
39
16
  # client.send("animation.enable")
@@ -25,20 +25,20 @@ module Playwright
25
25
 
26
26
  # -- inherited from EventEmitter --
27
27
  # @nodoc
28
- def off(event, callback)
29
- event_emitter_proxy.off(event, callback)
28
+ def on(event, callback)
29
+ event_emitter_proxy.on(event, callback)
30
30
  end
31
31
 
32
32
  # -- inherited from EventEmitter --
33
33
  # @nodoc
34
- def once(event, callback)
35
- event_emitter_proxy.once(event, callback)
34
+ def off(event, callback)
35
+ event_emitter_proxy.off(event, callback)
36
36
  end
37
37
 
38
38
  # -- inherited from EventEmitter --
39
39
  # @nodoc
40
- def on(event, callback)
41
- event_emitter_proxy.on(event, callback)
40
+ def once(event, callback)
41
+ event_emitter_proxy.once(event, callback)
42
42
  end
43
43
 
44
44
  private def event_emitter_proxy
@@ -1,73 +1,15 @@
1
1
  module Playwright
2
2
  # `Dialog` objects are dispatched by page via the [`event: Page.dialog`] event.
3
- #
3
+ #
4
4
  # An example of using `Dialog` class:
5
- #
6
5
  #
7
- # ```js
8
- # const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
9
- #
10
- # (async () => {
11
- # const browser = await chromium.launch();
12
- # const page = await browser.newPage();
13
- # page.on('dialog', async dialog => {
14
- # console.log(dialog.message());
15
- # await dialog.dismiss();
16
- # });
17
- # await page.evaluate(() => alert('1'));
18
- # await browser.close();
19
- # })();
20
- # ```
21
- #
22
- # ```java
23
- # import com.microsoft.playwright.*;
24
- #
25
- # public class Example {
26
- # public static void main(String[] args) {
27
- # try (Playwright playwright = Playwright.create()) {
28
- # BrowserType chromium = playwright.chromium();
29
- # Browser browser = chromium.launch();
30
- # Page page = browser.newPage();
31
- # page.onDialog(dialog -> {
32
- # System.out.println(dialog.message());
33
- # dialog.dismiss();
34
- # });
35
- # page.evaluate("alert('1')");
36
- # browser.close();
37
- # }
38
- # }
39
- # }
40
- # ```
41
- #
42
- # ```python async
43
- # import asyncio
44
- # from playwright.async_api import async_playwright
45
- #
46
- # async def handle_dialog(dialog):
47
- # print(dialog.message)
48
- # await dialog.dismiss()
49
- #
50
- # async def run(playwright):
51
- # chromium = playwright.chromium
52
- # browser = await chromium.launch()
53
- # page = await browser.new_page()
54
- # page.on("dialog", handle_dialog)
55
- # page.evaluate("alert('1')")
56
- # await browser.close()
57
- #
58
- # async def main():
59
- # async with async_playwright() as playwright:
60
- # await run(playwright)
61
- # asyncio.run(main())
62
- # ```
63
- #
64
6
  # ```python sync
65
7
  # from playwright.sync_api import sync_playwright
66
- #
8
+ #
67
9
  # def handle_dialog(dialog):
68
10
  # print(dialog.message)
69
11
  # dialog.dismiss()
70
- #
12
+ #
71
13
  # def run(playwright):
72
14
  # chromium = playwright.chromium
73
15
  # browser = chromium.launch()
@@ -75,34 +17,11 @@ module Playwright
75
17
  # page.on("dialog", handle_dialog)
76
18
  # page.evaluate("alert('1')")
77
19
  # browser.close()
78
- #
20
+ #
79
21
  # with sync_playwright() as playwright:
80
22
  # run(playwright)
81
23
  # ```
82
- #
83
- # ```csharp
84
- # using Microsoft.Playwright;
85
- # using System.Threading.Tasks;
86
- #
87
- # class DialogExample
88
- # {
89
- # public static async Task Run()
90
- # {
91
- # using var playwright = await Playwright.CreateAsync();
92
- # await using var browser = await playwright.Chromium.LaunchAsync();
93
- # var page = await browser.NewPageAsync();
94
- #
95
- # page.Dialog += async (_, dialog) =>
96
- # {
97
- # System.Console.WriteLine(dialog.Message);
98
- # await dialog.DismissAsync();
99
- # };
100
- #
101
- # await page.EvaluateAsync("alert('1');");
102
- # }
103
- # }
104
- # ```
105
- #
24
+ #
106
25
  # > NOTE: Dialogs are dismissed automatically, unless there is a [`event: Page.dialog`] listener. When listener is
107
26
  # present, it **must** either [`method: Dialog.accept`] or [`method: Dialog.dismiss`] the dialog - otherwise the page will
108
27
  # [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking) waiting for the dialog, and
@@ -141,20 +60,20 @@ module Playwright
141
60
 
142
61
  # -- inherited from EventEmitter --
143
62
  # @nodoc
144
- def off(event, callback)
145
- event_emitter_proxy.off(event, callback)
63
+ def on(event, callback)
64
+ event_emitter_proxy.on(event, callback)
146
65
  end
147
66
 
148
67
  # -- inherited from EventEmitter --
149
68
  # @nodoc
150
- def once(event, callback)
151
- event_emitter_proxy.once(event, callback)
69
+ def off(event, callback)
70
+ event_emitter_proxy.off(event, callback)
152
71
  end
153
72
 
154
73
  # -- inherited from EventEmitter --
155
74
  # @nodoc
156
- def on(event, callback)
157
- event_emitter_proxy.on(event, callback)
75
+ def once(event, callback)
76
+ event_emitter_proxy.once(event, callback)
158
77
  end
159
78
 
160
79
  private def event_emitter_proxy
@@ -2,64 +2,13 @@ require_relative './js_handle.rb'
2
2
 
3
3
  module Playwright
4
4
  # - extends: `JSHandle`
5
- #
5
+ #
6
6
  # ElementHandle represents an in-page DOM element. ElementHandles can be created with the [`method: Page.querySelector`]
7
7
  # method.
8
- #
9
8
  #
10
- # ```js
11
- # const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
12
- #
13
- # (async () => {
14
- # const browser = await chromium.launch();
15
- # const page = await browser.newPage();
16
- # await page.goto('https://example.com');
17
- # const hrefElement = await page.$('a');
18
- # await hrefElement.click();
19
- # // ...
20
- # })();
21
- # ```
22
- #
23
- # ```java
24
- # import com.microsoft.playwright.*;
25
- #
26
- # public class Example {
27
- # public static void main(String[] args) {
28
- # try (Playwright playwright = Playwright.create()) {
29
- # BrowserType chromium = playwright.chromium();
30
- # Browser browser = chromium.launch();
31
- # Page page = browser.newPage();
32
- # page.navigate("https://example.com");
33
- # ElementHandle hrefElement = page.querySelector("a");
34
- # hrefElement.click();
35
- # // ...
36
- # }
37
- # }
38
- # }
39
- # ```
40
- #
41
- # ```python async
42
- # import asyncio
43
- # from playwright.async_api import async_playwright
44
- #
45
- # async def run(playwright):
46
- # chromium = playwright.chromium
47
- # browser = await chromium.launch()
48
- # page = await browser.new_page()
49
- # await page.goto("https://example.com")
50
- # href_element = await page.query_selector("a")
51
- # await href_element.click()
52
- # # ...
53
- #
54
- # async def main():
55
- # async with async_playwright() as playwright:
56
- # await run(playwright)
57
- # asyncio.run(main())
58
- # ```
59
- #
60
9
  # ```python sync
61
10
  # from playwright.sync_api import sync_playwright
62
- #
11
+ #
63
12
  # def run(playwright):
64
13
  # chromium = playwright.chromium
65
14
  # browser = chromium.launch()
@@ -68,74 +17,35 @@ module Playwright
68
17
  # href_element = page.query_selector("a")
69
18
  # href_element.click()
70
19
  # # ...
71
- #
20
+ #
72
21
  # with sync_playwright() as playwright:
73
22
  # run(playwright)
74
23
  # ```
75
- #
76
- # ```csharp
77
- # using Microsoft.Playwright;
78
- # using System.Threading.Tasks;
79
- #
80
- # class HandleExamples
81
- # {
82
- # public static async Task Run()
83
- # {
84
- # using var playwright = await Playwright.CreateAsync();
85
- # var browser = await playwright.Chromium.LaunchAsync(headless: false);
86
- # var page = await browser.NewPageAsync();
87
- # await page.GotoAsync("https://www.bing.com");
88
- # var handle = await page.QuerySelectorAsync("a");
89
- # await handle.ClickAsync();
90
- # }
91
- # }
92
- # ```
93
- #
24
+ #
94
25
  # ElementHandle prevents DOM element from garbage collection unless the handle is disposed with
95
26
  # [`method: JSHandle.dispose`]. ElementHandles are auto-disposed when their origin frame gets navigated.
96
- #
27
+ #
97
28
  # ElementHandle instances can be used as an argument in [`method: Page.evalOnSelector`] and [`method: Page.evaluate`]
98
29
  # methods.
99
30
  class ElementHandle < JSHandle
100
31
 
101
32
  # This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
102
33
  # calculated relative to the main frame viewport - which is usually the same as the browser window.
103
- #
34
+ #
104
35
  # Scrolling affects the returned bonding box, similarly to
105
36
  # [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That
106
37
  # means `x` and/or `y` may be negative.
107
- #
38
+ #
108
39
  # Elements from child frames return the bounding box relative to the main frame, unlike the
109
40
  # [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect).
110
- #
41
+ #
111
42
  # Assuming the page is static, it is safe to use bounding box coordinates to perform input. For example, the following
112
43
  # snippet should click the center of the element.
113
- #
114
44
  #
115
- # ```js
116
- # const box = await elementHandle.boundingBox();
117
- # await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
118
- # ```
119
- #
120
- # ```java
121
- # BoundingBox box = elementHandle.boundingBox();
122
- # page.mouse().click(box.x + box.width / 2, box.y + box.height / 2);
123
- # ```
124
- #
125
- # ```python async
126
- # box = await element_handle.bounding_box()
127
- # await page.mouse.click(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2)
128
- # ```
129
- #
130
45
  # ```python sync
131
46
  # box = element_handle.bounding_box()
132
47
  # page.mouse.click(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2)
133
48
  # ```
134
- #
135
- # ```csharp
136
- # var box = await elementHandle.BoundingBoxAsync();
137
- # await page.Mouse.ClickAsync(box.X + box.Width / 2, box.Y + box.Height / 2);
138
- # ```
139
49
  def bounding_box
140
50
  wrap_impl(@impl.bounding_box)
141
51
  end
@@ -148,9 +58,9 @@ module Playwright
148
58
  # 1. Use [`property: Page.mouse`] to click in the center of the element.
149
59
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
150
60
  # 1. Ensure that the element is now checked. If not, this method throws.
151
- #
61
+ #
152
62
  # If the element is detached from the DOM at any moment during the action, this method throws.
153
- #
63
+ #
154
64
  # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
155
65
  # zero timeout disables this.
156
66
  def check(
@@ -167,9 +77,9 @@ module Playwright
167
77
  # 1. Scroll the element into view if needed.
168
78
  # 1. Use [`property: Page.mouse`] to click in the center of the element, or the specified `position`.
169
79
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
170
- #
80
+ #
171
81
  # If the element is detached from the DOM at any moment during the action, this method throws.
172
- #
82
+ #
173
83
  # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
174
84
  # zero timeout disables this.
175
85
  def click(
@@ -196,12 +106,12 @@ module Playwright
196
106
  # 1. Use [`property: Page.mouse`] to double click in the center of the element, or the specified `position`.
197
107
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set. Note that if the
198
108
  # first click of the `dblclick()` triggers a navigation event, this method will throw.
199
- #
109
+ #
200
110
  # If the element is detached from the DOM at any moment during the action, this method throws.
201
- #
111
+ #
202
112
  # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
203
113
  # zero timeout disables this.
204
- #
114
+ #
205
115
  # > NOTE: `elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event.
206
116
  def dblclick(
207
117
  button: nil,
@@ -218,31 +128,14 @@ module Playwright
218
128
  # The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
219
129
  # `click` is dispatched. This is equivalent to calling
220
130
  # [element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
221
- #
222
131
  #
223
- # ```js
224
- # await elementHandle.dispatchEvent('click');
225
- # ```
226
- #
227
- # ```java
228
- # elementHandle.dispatchEvent("click");
229
- # ```
230
- #
231
- # ```python async
232
- # await element_handle.dispatch_event("click")
233
- # ```
234
- #
235
132
  # ```python sync
236
133
  # element_handle.dispatch_event("click")
237
134
  # ```
238
- #
239
- # ```csharp
240
- # await elementHandle.DispatchEventAsync("click");
241
- # ```
242
- #
135
+ #
243
136
  # Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
244
137
  # and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
245
- #
138
+ #
246
139
  # Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial properties:
247
140
  # - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
248
141
  # - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
@@ -251,146 +144,71 @@ module Playwright
251
144
  # - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
252
145
  # - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
253
146
  # - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
254
- #
147
+ #
255
148
  # You can also specify `JSHandle` as the property value if you want live objects to be passed into the event:
256
- #
257
149
  #
258
- # ```js
259
- # // Note you can only create DataTransfer in Chromium and Firefox
260
- # const dataTransfer = await page.evaluateHandle(() => new DataTransfer());
261
- # await elementHandle.dispatchEvent('dragstart', { dataTransfer });
262
- # ```
263
- #
264
- # ```java
265
- # // Note you can only create DataTransfer in Chromium and Firefox
266
- # JSHandle dataTransfer = page.evaluateHandle("() => new DataTransfer()");
267
- # Map<String, Object> arg = new HashMap<>();
268
- # arg.put("dataTransfer", dataTransfer);
269
- # elementHandle.dispatchEvent("dragstart", arg);
270
- # ```
271
- #
272
- # ```python async
273
- # # note you can only create data_transfer in chromium and firefox
274
- # data_transfer = await page.evaluate_handle("new DataTransfer()")
275
- # await element_handle.dispatch_event("#source", "dragstart", {"dataTransfer": data_transfer})
276
- # ```
277
- #
278
150
  # ```python sync
279
151
  # # note you can only create data_transfer in chromium and firefox
280
152
  # data_transfer = page.evaluate_handle("new DataTransfer()")
281
153
  # element_handle.dispatch_event("#source", "dragstart", {"dataTransfer": data_transfer})
282
154
  # ```
283
- #
284
- # ```csharp
285
- # var handle = await page.EvaluateHandleAsync("() => new DataTransfer()");
286
- # await handle.AsElement.DispatchEventAsync("dragstart", new Dictionary<string, object>
287
- # {
288
- # { "dataTransfer", dataTransfer }
289
- # });
290
- # ```
291
155
  def dispatch_event(type, eventInit: nil)
292
156
  wrap_impl(@impl.dispatch_event(unwrap_impl(type), eventInit: unwrap_impl(eventInit)))
293
157
  end
294
158
 
295
159
  # Returns the return value of `expression`.
296
- #
160
+ #
297
161
  # The method finds an element matching the specified selector in the `ElementHandle`s subtree and passes it as a first
298
162
  # argument to `expression`. See [Working with selectors](./selectors.md) for more details. If no elements match the
299
163
  # selector, the method throws an error.
300
- #
164
+ #
301
165
  # If `expression` returns a [Promise], then [`method: ElementHandle.evalOnSelector`] would wait for the promise to resolve
302
166
  # and return its value.
303
- #
167
+ #
304
168
  # Examples:
305
- #
306
169
  #
307
- # ```js
308
- # const tweetHandle = await page.$('.tweet');
309
- # expect(await tweetHandle.$eval('.like', node => node.innerText)).toBe('100');
310
- # expect(await tweetHandle.$eval('.retweets', node => node.innerText)).toBe('10');
311
- # ```
312
- #
313
- # ```java
314
- # ElementHandle tweetHandle = page.querySelector(".tweet");
315
- # assertEquals("100", tweetHandle.evalOnSelector(".like", "node => node.innerText"));
316
- # assertEquals("10", tweetHandle.evalOnSelector(".retweets", "node => node.innerText"));
317
- # ```
318
- #
319
- # ```python async
320
- # tweet_handle = await page.query_selector(".tweet")
321
- # assert await tweet_handle.eval_on_selector(".like", "node => node.innerText") == "100"
322
- # assert await tweet_handle.eval_on_selector(".retweets", "node => node.innerText") = "10"
323
- # ```
324
- #
325
170
  # ```python sync
326
171
  # tweet_handle = page.query_selector(".tweet")
327
172
  # assert tweet_handle.eval_on_selector(".like", "node => node.innerText") == "100"
328
173
  # assert tweet_handle.eval_on_selector(".retweets", "node => node.innerText") = "10"
329
174
  # ```
330
- #
331
- # ```csharp
332
- # var tweetHandle = await page.QuerySelectorAsync(".tweet");
333
- # Assert.Equals("100", await tweetHandle.EvalOnSelectorAsync(".like", "node => node.innerText"));
334
- # Assert.Equals("10", await tweetHandle.EvalOnSelectorAsync(".retweets", "node => node.innerText"));
335
- # ```
336
175
  def eval_on_selector(selector, expression, arg: nil)
337
176
  wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
338
177
  end
339
178
 
340
179
  # Returns the return value of `expression`.
341
- #
180
+ #
342
181
  # The method finds all elements matching the specified selector in the `ElementHandle`'s subtree and passes an array of
343
182
  # matched elements as a first argument to `expression`. See [Working with selectors](./selectors.md) for more details.
344
- #
183
+ #
345
184
  # If `expression` returns a [Promise], then [`method: ElementHandle.evalOnSelectorAll`] would wait for the promise to
346
185
  # resolve and return its value.
347
- #
186
+ #
348
187
  # Examples:
349
- #
188
+ #
350
189
  # ```html
351
190
  # <div class="feed">
352
191
  # <div class="tweet">Hello!</div>
353
192
  # <div class="tweet">Hi!</div>
354
193
  # </div>
355
194
  # ```
356
- #
357
195
  #
358
- # ```js
359
- # const feedHandle = await page.$('.feed');
360
- # expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!']);
361
- # ```
362
- #
363
- # ```java
364
- # ElementHandle feedHandle = page.querySelector(".feed");
365
- # assertEquals(Arrays.asList("Hello!", "Hi!"), feedHandle.evalOnSelectorAll(".tweet", "nodes => nodes.map(n => n.innerText)"));
366
- # ```
367
- #
368
- # ```python async
369
- # feed_handle = await page.query_selector(".feed")
370
- # assert await feed_handle.eval_on_selector_all(".tweet", "nodes => nodes.map(n => n.innerText)") == ["hello!", "hi!"]
371
- # ```
372
- #
373
196
  # ```python sync
374
197
  # feed_handle = page.query_selector(".feed")
375
198
  # assert feed_handle.eval_on_selector_all(".tweet", "nodes => nodes.map(n => n.innerText)") == ["hello!", "hi!"]
376
199
  # ```
377
- #
378
- # ```csharp
379
- # var feedHandle = await page.QuerySelectorAsync(".feed");
380
- # Assert.Equals(new [] { "Hello!", "Hi!" }, await feedHandle.EvalOnSelectorAllAsync<string[]>(".tweet", "nodes => nodes.map(n => n.innerText)"));
381
- # ```
382
200
  def eval_on_selector_all(selector, expression, arg: nil)
383
201
  wrap_impl(@impl.eval_on_selector_all(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
384
202
  end
385
203
 
386
204
  # This method waits for [actionability](./actionability.md) checks, focuses the element, fills it and triggers an `input`
387
205
  # event after filling. Note that you can pass an empty string to clear the input field.
388
- #
206
+ #
389
207
  # If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
390
208
  # However, if the element is inside the `<label>` element that has an associated
391
209
  # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled
392
210
  # instead.
393
- #
211
+ #
394
212
  # To send fine-grained keyboard events, use [`method: ElementHandle.type`].
395
213
  def fill(value, noWaitAfter: nil, timeout: nil)
396
214
  wrap_impl(@impl.fill(unwrap_impl(value), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
@@ -412,9 +230,9 @@ module Playwright
412
230
  # 1. Scroll the element into view if needed.
413
231
  # 1. Use [`property: Page.mouse`] to hover over the center of the element, or the specified `position`.
414
232
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
415
- #
233
+ #
416
234
  # If the element is detached from the DOM at any moment during the action, this method throws.
417
- #
235
+ #
418
236
  # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
419
237
  # zero timeout disables this.
420
238
  def hover(
@@ -472,21 +290,21 @@ module Playwright
472
290
  end
473
291
 
474
292
  # Focuses the element, and then uses [`method: Keyboard.down`] and [`method: Keyboard.up`].
475
- #
293
+ #
476
294
  # `key` can specify the intended [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
477
295
  # value or a single character to generate the text for. A superset of the `key` values can be found
478
296
  # [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:
479
- #
297
+ #
480
298
  # `F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
481
299
  # `Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.
482
- #
300
+ #
483
301
  # Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`.
484
- #
302
+ #
485
303
  # Holding down `Shift` will type the text that corresponds to the `key` in the upper case.
486
- #
304
+ #
487
305
  # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
488
306
  # texts.
489
- #
307
+ #
490
308
  # Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
491
309
  # modifier, modifier is pressed and being held while the subsequent key is being pressed.
492
310
  def press(key, delay: nil, noWaitAfter: nil, timeout: nil)
@@ -506,7 +324,7 @@ module Playwright
506
324
  end
507
325
 
508
326
  # Returns the buffer with the captured screenshot.
509
- #
327
+ #
510
328
  # This method waits for the [actionability](./actionability.md) checks, then scrolls element into view before taking a
511
329
  # screenshot. If the element is detached from DOM, the method throws an error.
512
330
  def screenshot(
@@ -521,7 +339,7 @@ module Playwright
521
339
  # This method waits for [actionability](./actionability.md) checks, then tries to scroll element into view, unless it is
522
340
  # completely visible as defined by
523
341
  # [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)'s `ratio`.
524
- #
342
+ #
525
343
  # Throws when `elementHandle` does not point to an element
526
344
  # [connected](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected) to a Document or a ShadowRoot.
527
345
  def scroll_into_view_if_needed(timeout: nil)
@@ -530,45 +348,15 @@ module Playwright
530
348
 
531
349
  # This method waits for [actionability](./actionability.md) checks, waits until all specified options are present in the
532
350
  # `<select>` element and selects these options.
533
- #
351
+ #
534
352
  # If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the
535
353
  # `<label>` element that has an associated
536
354
  # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
537
- #
355
+ #
538
356
  # Returns the array of option values that have been successfully selected.
539
- #
357
+ #
540
358
  # Triggers a `change` and `input` event once all the provided options have been selected.
541
- #
542
- #
543
- # ```js
544
- # // single selection matching the value
545
- # handle.selectOption('blue');
546
- #
547
- # // single selection matching the label
548
- # handle.selectOption({ label: 'Blue' });
549
- #
550
- # // multiple selection
551
- # handle.selectOption(['red', 'green', 'blue']);
552
- # ```
553
- #
554
- # ```java
555
- # // single selection matching the value
556
- # handle.selectOption("blue");
557
- # // single selection matching the label
558
- # handle.selectOption(new SelectOption().setLabel("Blue"));
559
- # // multiple selection
560
- # handle.selectOption(new String[] {"red", "green", "blue"});
561
- # ```
562
- #
563
- # ```python async
564
- # # single selection matching the value
565
- # await handle.select_option("blue")
566
- # # single selection matching the label
567
- # await handle.select_option(label="blue")
568
- # # multiple selection
569
- # await handle.select_option(value=["red", "green", "blue"])
570
- # ```
571
- #
359
+ #
572
360
  # ```python sync
573
361
  # # single selection matching the value
574
362
  # handle.select_option("blue")
@@ -577,7 +365,7 @@ module Playwright
577
365
  # # multiple selection
578
366
  # handle.select_option(value=["red", "green", "blue"])
579
367
  # ```
580
- #
368
+ #
581
369
  # ```python sync
582
370
  # # single selection matching the value
583
371
  # handle.select_option("blue")
@@ -588,20 +376,6 @@ module Playwright
588
376
  # # multiple selection for blue, red and second option
589
377
  # handle.select_option(value="blue", { index: 2 }, "red")
590
378
  # ```
591
- #
592
- # ```csharp
593
- # // single selection matching the value
594
- # await handle.SelectOptionAsync(new[] { "blue" });
595
- # // single selection matching the label
596
- # await handle.SelectOptionAsync(new[] { new SelectOptionValue() { Label = "blue" } });
597
- # // multiple selection
598
- # await handle.SelectOptionAsync(new[] { "red", "green", "blue" });
599
- # // multiple selection for blue, red and second option
600
- # await handle.SelectOptionAsync(new[] {
601
- # new SelectOptionValue() { Label = "blue" },
602
- # new SelectOptionValue() { Index = 2 },
603
- # new SelectOptionValue() { Value = "red" }});
604
- # ```
605
379
  def select_option(
606
380
  element: nil,
607
381
  index: nil,
@@ -620,7 +394,7 @@ module Playwright
620
394
 
621
395
  # This method expects `elementHandle` to point to an
622
396
  # [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input).
623
- #
397
+ #
624
398
  # Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
625
399
  # are resolved relative to the the current working directory. For empty array, clears the selected files.
626
400
  def set_input_files(files, noWaitAfter: nil, timeout: nil)
@@ -633,12 +407,12 @@ module Playwright
633
407
  # 1. Scroll the element into view if needed.
634
408
  # 1. Use [`property: Page.touchscreen`] to tap the center of the element, or the specified `position`.
635
409
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
636
- #
410
+ #
637
411
  # If the element is detached from the DOM at any moment during the action, this method throws.
638
- #
412
+ #
639
413
  # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
640
414
  # zero timeout disables this.
641
- #
415
+ #
642
416
  # > NOTE: `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true.
643
417
  def tap_point(
644
418
  force: nil,
@@ -656,67 +430,21 @@ module Playwright
656
430
  end
657
431
 
658
432
  # Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
659
- #
433
+ #
660
434
  # To press a special key, like `Control` or `ArrowDown`, use [`method: ElementHandle.press`].
661
- #
662
435
  #
663
- # ```js
664
- # await elementHandle.type('Hello'); // Types instantly
665
- # await elementHandle.type('World', {delay: 100}); // Types slower, like a user
666
- # ```
667
- #
668
- # ```java
669
- # elementHandle.type("Hello"); // Types instantly
670
- # elementHandle.type("World", new ElementHandle.TypeOptions().setDelay(100)); // Types slower, like a user
671
- # ```
672
- #
673
- # ```python async
674
- # await element_handle.type("hello") # types instantly
675
- # await element_handle.type("world", delay=100) # types slower, like a user
676
- # ```
677
- #
678
436
  # ```python sync
679
437
  # element_handle.type("hello") # types instantly
680
438
  # element_handle.type("world", delay=100) # types slower, like a user
681
439
  # ```
682
- #
683
- # ```csharp
684
- # await elementHandle.TypeAsync("Hello"); // Types instantly
685
- # await elementHandle.TypeAsync("World", delay: 100); // Types slower, like a user
686
- # ```
687
- #
440
+ #
688
441
  # An example of typing into a text field and then submitting the form:
689
- #
690
442
  #
691
- # ```js
692
- # const elementHandle = await page.$('input');
693
- # await elementHandle.type('some text');
694
- # await elementHandle.press('Enter');
695
- # ```
696
- #
697
- # ```java
698
- # ElementHandle elementHandle = page.querySelector("input");
699
- # elementHandle.type("some text");
700
- # elementHandle.press("Enter");
701
- # ```
702
- #
703
- # ```python async
704
- # element_handle = await page.query_selector("input")
705
- # await element_handle.type("some text")
706
- # await element_handle.press("Enter")
707
- # ```
708
- #
709
443
  # ```python sync
710
444
  # element_handle = page.query_selector("input")
711
445
  # element_handle.type("some text")
712
446
  # element_handle.press("Enter")
713
447
  # ```
714
- #
715
- # ```csharp
716
- # var elementHandle = await page.QuerySelectorAsync("input");
717
- # await elementHandle.TypeAsync("some text");
718
- # await elementHandle.PressAsync("Enter");
719
- # ```
720
448
  def type(text, delay: nil, noWaitAfter: nil, timeout: nil)
721
449
  wrap_impl(@impl.type(unwrap_impl(text), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
722
450
  end
@@ -729,9 +457,9 @@ module Playwright
729
457
  # 1. Use [`property: Page.mouse`] to click in the center of the element.
730
458
  # 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
731
459
  # 1. Ensure that the element is now unchecked. If not, this method throws.
732
- #
460
+ #
733
461
  # If the element is detached from the DOM at any moment during the action, this method throws.
734
- #
462
+ #
735
463
  # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
736
464
  # zero timeout disables this.
737
465
  def uncheck(
@@ -744,7 +472,7 @@ module Playwright
744
472
  end
745
473
 
746
474
  # Returns when the element satisfies the `state`.
747
- #
475
+ #
748
476
  # Depending on the `state` parameter, this method waits for one of the [actionability](./actionability.md) checks to pass.
749
477
  # This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
750
478
  # - `"visible"` Wait until the element is [visible](./actionability.md#visible).
@@ -755,7 +483,7 @@ module Playwright
755
483
  # - `"enabled"` Wait until the element is [enabled](./actionability.md#enabled).
756
484
  # - `"disabled"` Wait until the element is [not enabled](./actionability.md#enabled).
757
485
  # - `"editable"` Wait until the element is [editable](./actionability.md#editable).
758
- #
486
+ #
759
487
  # If the element does not satisfy the condition for the `timeout` milliseconds, this method will throw.
760
488
  def wait_for_element_state(state, timeout: nil)
761
489
  wrap_impl(@impl.wait_for_element_state(unwrap_impl(state), timeout: unwrap_impl(timeout)))
@@ -763,49 +491,19 @@ module Playwright
763
491
 
764
492
  # Returns element specified by selector when it satisfies `state` option. Returns `null` if waiting for `hidden` or
765
493
  # `detached`.
766
- #
494
+ #
767
495
  # Wait for the `selector` relative to the element handle to satisfy `state` option (either appear/disappear from dom, or
768
496
  # become visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method
769
497
  # will return immediately. If the selector doesn't satisfy the condition for the `timeout` milliseconds, the function will
770
498
  # throw.
771
- #
772
499
  #
773
- # ```js
774
- # await page.setContent(`<div><span></span></div>`);
775
- # const div = await page.$('div');
776
- # // Waiting for the 'span' selector relative to the div.
777
- # const span = await div.waitForSelector('span', { state: 'attached' });
778
- # ```
779
- #
780
- # ```java
781
- # page.setContent("<div><span></span></div>");
782
- # ElementHandle div = page.querySelector("div");
783
- # // Waiting for the "span" selector relative to the div.
784
- # ElementHandle span = div.waitForSelector("span", new ElementHandle.WaitForSelectorOptions()
785
- # .setState(WaitForSelectorState.ATTACHED));
786
- # ```
787
- #
788
- # ```python async
789
- # await page.set_content("<div><span></span></div>")
790
- # div = await page.query_selector("div")
791
- # # waiting for the "span" selector relative to the div.
792
- # span = await div.wait_for_selector("span", state="attached")
793
- # ```
794
- #
795
500
  # ```python sync
796
501
  # page.set_content("<div><span></span></div>")
797
502
  # div = page.query_selector("div")
798
503
  # # waiting for the "span" selector relative to the div.
799
504
  # span = div.wait_for_selector("span", state="attached")
800
505
  # ```
801
- #
802
- # ```csharp
803
- # await page.SetContentAsync("<div><span></span></div>");
804
- # var div = await page.QuerySelectorAsync("div");
805
- # // Waiting for the "span" selector relative to the div.
806
- # var span = await page.WaitForSelectorAsync("span", WaitForSelectorState.Attached);
807
- # ```
808
- #
506
+ #
809
507
  # > NOTE: This method does not work across navigations, use [`method: Page.waitForSelector`] instead.
810
508
  def wait_for_selector(selector, state: nil, timeout: nil)
811
509
  wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
@@ -813,20 +511,20 @@ module Playwright
813
511
 
814
512
  # -- inherited from EventEmitter --
815
513
  # @nodoc
816
- def off(event, callback)
817
- event_emitter_proxy.off(event, callback)
514
+ def on(event, callback)
515
+ event_emitter_proxy.on(event, callback)
818
516
  end
819
517
 
820
518
  # -- inherited from EventEmitter --
821
519
  # @nodoc
822
- def once(event, callback)
823
- event_emitter_proxy.once(event, callback)
520
+ def off(event, callback)
521
+ event_emitter_proxy.off(event, callback)
824
522
  end
825
523
 
826
524
  # -- inherited from EventEmitter --
827
525
  # @nodoc
828
- def on(event, callback)
829
- event_emitter_proxy.on(event, callback)
526
+ def once(event, callback)
527
+ event_emitter_proxy.once(event, callback)
830
528
  end
831
529
 
832
530
  private def event_emitter_proxy