playwright-ruby-client 0.5.10 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -64,8 +64,46 @@ module Playwright
64
64
  # with sync_playwright() as playwright:
65
65
  # run(playwright)
66
66
  # ```
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
+ # ```
67
86
  class BrowserType < PlaywrightApi
68
87
 
88
+ # This methods attaches Playwright to an existing browser instance.
89
+ def connect(wsEndpoint, headers: nil, slowMo: nil, timeout: nil)
90
+ raise NotImplementedError.new('connect is not implemented yet.')
91
+ end
92
+
93
+ # This methods attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
94
+ #
95
+ # The default browser context is accessible via [`method: Browser.contexts`].
96
+ #
97
+ # > NOTE: Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
98
+ def connect_over_cdp(
99
+ endpointURL,
100
+ headers: nil,
101
+ slowMo: nil,
102
+ timeout: nil,
103
+ &block)
104
+ wrap_impl(@impl.connect_over_cdp(unwrap_impl(endpointURL), headers: unwrap_impl(headers), slowMo: unwrap_impl(slowMo), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
105
+ end
106
+
69
107
  # A path where Playwright expects to find a bundled browser executable.
70
108
  def executable_path
71
109
  wrap_impl(@impl.executable_path)
@@ -100,6 +138,10 @@ module Playwright
100
138
  # )
101
139
  # ```
102
140
  #
141
+ # ```csharp
142
+ # var browser = await playwright.Chromium.LaunchAsync(ignoreDefaultArgs: new[] { "--mute-audio" })
143
+ # ```
144
+ #
103
145
  # > **Chromium-only** Playwright can also be used to control the Google Chrome or Microsoft Edge browsers, but it works
104
146
  # best with the version of Chromium it is bundled with. There is no guarantee it will work with any other version. Use
105
147
  # `executablePath` option with extreme caution.
@@ -131,8 +173,9 @@ module Playwright
131
173
  proxy: nil,
132
174
  slowMo: nil,
133
175
  timeout: nil,
176
+ traceDir: nil,
134
177
  &block)
135
- wrap_impl(@impl.launch(args: unwrap_impl(args), channel: unwrap_impl(channel), chromiumSandbox: unwrap_impl(chromiumSandbox), devtools: unwrap_impl(devtools), downloadsPath: unwrap_impl(downloadsPath), env: unwrap_impl(env), executablePath: unwrap_impl(executablePath), firefoxUserPrefs: unwrap_impl(firefoxUserPrefs), handleSIGHUP: unwrap_impl(handleSIGHUP), handleSIGINT: unwrap_impl(handleSIGINT), handleSIGTERM: unwrap_impl(handleSIGTERM), headless: unwrap_impl(headless), ignoreDefaultArgs: unwrap_impl(ignoreDefaultArgs), proxy: unwrap_impl(proxy), slowMo: unwrap_impl(slowMo), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
178
+ wrap_impl(@impl.launch(args: unwrap_impl(args), channel: unwrap_impl(channel), chromiumSandbox: unwrap_impl(chromiumSandbox), devtools: unwrap_impl(devtools), downloadsPath: unwrap_impl(downloadsPath), env: unwrap_impl(env), executablePath: unwrap_impl(executablePath), firefoxUserPrefs: unwrap_impl(firefoxUserPrefs), handleSIGHUP: unwrap_impl(handleSIGHUP), handleSIGINT: unwrap_impl(handleSIGINT), handleSIGTERM: unwrap_impl(handleSIGTERM), headless: unwrap_impl(headless), ignoreDefaultArgs: unwrap_impl(ignoreDefaultArgs), proxy: unwrap_impl(proxy), slowMo: unwrap_impl(slowMo), timeout: unwrap_impl(timeout), traceDir: unwrap_impl(traceDir), &wrap_block_call(block)))
136
179
  end
137
180
 
138
181
  # Returns the persistent browser context instance.
@@ -177,6 +220,7 @@ module Playwright
177
220
  slowMo: nil,
178
221
  timeout: nil,
179
222
  timezoneId: nil,
223
+ traceDir: nil,
180
224
  userAgent: nil,
181
225
  viewport: nil)
182
226
  raise NotImplementedError.new('launch_persistent_context is not implemented yet.')
@@ -187,11 +231,6 @@ module Playwright
187
231
  wrap_impl(@impl.name)
188
232
  end
189
233
 
190
- # @nodoc
191
- def connect_over_cdp(endpointURL, slowMo: nil, timeout: nil, &block)
192
- wrap_impl(@impl.connect_over_cdp(unwrap_impl(endpointURL), slowMo: unwrap_impl(slowMo), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
193
- end
194
-
195
234
  # -- inherited from EventEmitter --
196
235
  # @nodoc
197
236
  def off(event, callback)
@@ -2,6 +2,7 @@ module Playwright
2
2
  # `ConsoleMessage` objects are dispatched by page via the [`event: Page.console`] event.
3
3
  class ConsoleMessage < PlaywrightApi
4
4
 
5
+ # List of arguments passed to a `console` function call. See also [`event: Page.console`].
5
6
  def args
6
7
  wrap_impl(@impl.args)
7
8
  end
@@ -10,6 +11,7 @@ module Playwright
10
11
  wrap_impl(@impl.location)
11
12
  end
12
13
 
14
+ # The text of the console message.
13
15
  def text
14
16
  wrap_impl(@impl.text)
15
17
  end
@@ -80,6 +80,29 @@ module Playwright
80
80
  # run(playwright)
81
81
  # ```
82
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
+ #
83
106
  # > NOTE: Dialogs are dismissed automatically, unless there is a [`event: Page.dialog`] listener. When listener is
84
107
  # present, it **must** either [`method: Dialog.accept`] or [`method: Dialog.dismiss`] the dialog - otherwise the page will
85
108
  # [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking) waiting for the dialog, and
@@ -73,6 +73,24 @@ module Playwright
73
73
  # run(playwright)
74
74
  # ```
75
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
+ #
76
94
  # ElementHandle prevents DOM element from garbage collection unless the handle is disposed with
77
95
  # [`method: JSHandle.dispose`]. ElementHandles are auto-disposed when their origin frame gets navigated.
78
96
  #
@@ -113,6 +131,11 @@ module Playwright
113
131
  # box = element_handle.bounding_box()
114
132
  # page.mouse.click(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2)
115
133
  # ```
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
+ # ```
116
139
  def bounding_box
117
140
  wrap_impl(@impl.bounding_box)
118
141
  end
@@ -130,8 +153,13 @@ module Playwright
130
153
  #
131
154
  # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
132
155
  # zero timeout disables this.
133
- def check(force: nil, noWaitAfter: nil, position: nil, timeout: nil)
134
- wrap_impl(@impl.check(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
156
+ def check(
157
+ force: nil,
158
+ noWaitAfter: nil,
159
+ position: nil,
160
+ timeout: nil,
161
+ trial: nil)
162
+ wrap_impl(@impl.check(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
135
163
  end
136
164
 
137
165
  # This method clicks the element by performing the following steps:
@@ -152,8 +180,9 @@ module Playwright
152
180
  modifiers: nil,
153
181
  noWaitAfter: nil,
154
182
  position: nil,
155
- timeout: nil)
156
- wrap_impl(@impl.click(button: unwrap_impl(button), clickCount: unwrap_impl(clickCount), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
183
+ timeout: nil,
184
+ trial: nil)
185
+ wrap_impl(@impl.click(button: unwrap_impl(button), clickCount: unwrap_impl(clickCount), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
157
186
  end
158
187
 
159
188
  # Returns the content frame for element handles referencing iframe nodes, or `null` otherwise
@@ -181,8 +210,9 @@ module Playwright
181
210
  modifiers: nil,
182
211
  noWaitAfter: nil,
183
212
  position: nil,
184
- timeout: nil)
185
- wrap_impl(@impl.dblclick(button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
213
+ timeout: nil,
214
+ trial: nil)
215
+ wrap_impl(@impl.dblclick(button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
186
216
  end
187
217
 
188
218
  # The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
@@ -206,6 +236,10 @@ module Playwright
206
236
  # element_handle.dispatch_event("click")
207
237
  # ```
208
238
  #
239
+ # ```csharp
240
+ # await elementHandle.DispatchEventAsync("click");
241
+ # ```
242
+ #
209
243
  # Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
210
244
  # and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
211
245
  #
@@ -246,6 +280,14 @@ module Playwright
246
280
  # data_transfer = page.evaluate_handle("new DataTransfer()")
247
281
  # element_handle.dispatch_event("#source", "dragstart", {"dataTransfer": data_transfer})
248
282
  # ```
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
+ # ```
249
291
  def dispatch_event(type, eventInit: nil)
250
292
  wrap_impl(@impl.dispatch_event(unwrap_impl(type), eventInit: unwrap_impl(eventInit)))
251
293
  end
@@ -285,6 +327,12 @@ module Playwright
285
327
  # assert tweet_handle.eval_on_selector(".like", "node => node.innerText") == "100"
286
328
  # assert tweet_handle.eval_on_selector(".retweets", "node => node.innerText") = "10"
287
329
  # ```
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
+ # ```
288
336
  def eval_on_selector(selector, expression, arg: nil)
289
337
  wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
290
338
  end
@@ -326,15 +374,24 @@ module Playwright
326
374
  # feed_handle = page.query_selector(".feed")
327
375
  # assert feed_handle.eval_on_selector_all(".tweet", "nodes => nodes.map(n => n.innerText)") == ["hello!", "hi!"]
328
376
  # ```
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
+ # ```
329
382
  def eval_on_selector_all(selector, expression, arg: nil)
330
383
  wrap_impl(@impl.eval_on_selector_all(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
331
384
  end
332
385
 
333
386
  # This method waits for [actionability](./actionability.md) checks, focuses the element, fills it and triggers an `input`
334
- # event after filling. If the element is inside the `<label>` element that has associated
335
- # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), that control will be filled
336
- # instead. If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method
337
- # throws an error. Note that you can pass an empty string to clear the input field.
387
+ # event after filling. Note that you can pass an empty string to clear the input field.
388
+ #
389
+ # If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
390
+ # However, if the element is inside the `<label>` element that has an associated
391
+ # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled
392
+ # instead.
393
+ #
394
+ # To send fine-grained keyboard events, use [`method: ElementHandle.type`].
338
395
  def fill(value, noWaitAfter: nil, timeout: nil)
339
396
  wrap_impl(@impl.fill(unwrap_impl(value), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
340
397
  end
@@ -360,8 +417,13 @@ module Playwright
360
417
  #
361
418
  # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
362
419
  # zero timeout disables this.
363
- def hover(force: nil, modifiers: nil, position: nil, timeout: nil)
364
- wrap_impl(@impl.hover(force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
420
+ def hover(
421
+ force: nil,
422
+ modifiers: nil,
423
+ position: nil,
424
+ timeout: nil,
425
+ trial: nil)
426
+ wrap_impl(@impl.hover(force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
365
427
  end
366
428
 
367
429
  # Returns the `element.innerHTML`.
@@ -466,12 +528,16 @@ module Playwright
466
528
  wrap_impl(@impl.scroll_into_view_if_needed(timeout: unwrap_impl(timeout)))
467
529
  end
468
530
 
469
- # Returns the array of option values that have been successfully selected.
531
+ # This method waits for [actionability](./actionability.md) checks, waits until all specified options are present in the
532
+ # `<select>` element and selects these options.
533
+ #
534
+ # If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the
535
+ # `<label>` element that has an associated
536
+ # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
470
537
  #
471
- # Triggers a `change` and `input` event once all the provided options have been selected. If element is not a `<select>`
472
- # element, the method throws an error.
538
+ # Returns the array of option values that have been successfully selected.
473
539
  #
474
- # Will wait until all specified options are present in the `<select>` element.
540
+ # Triggers a `change` and `input` event once all the provided options have been selected.
475
541
  #
476
542
  #
477
543
  # ```js
@@ -522,6 +588,20 @@ module Playwright
522
588
  # # multiple selection for blue, red and second option
523
589
  # handle.select_option(value="blue", { index: 2 }, "red")
524
590
  # ```
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
+ # ```
525
605
  def select_option(
526
606
  element: nil,
527
607
  index: nil,
@@ -565,8 +645,9 @@ module Playwright
565
645
  modifiers: nil,
566
646
  noWaitAfter: nil,
567
647
  position: nil,
568
- timeout: nil)
569
- wrap_impl(@impl.tap_point(force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
648
+ timeout: nil,
649
+ trial: nil)
650
+ wrap_impl(@impl.tap_point(force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
570
651
  end
571
652
 
572
653
  # Returns the `node.textContent`.
@@ -599,6 +680,11 @@ module Playwright
599
680
  # element_handle.type("world", delay=100) # types slower, like a user
600
681
  # ```
601
682
  #
683
+ # ```csharp
684
+ # await elementHandle.TypeAsync("Hello"); // Types instantly
685
+ # await elementHandle.TypeAsync("World", delay: 100); // Types slower, like a user
686
+ # ```
687
+ #
602
688
  # An example of typing into a text field and then submitting the form:
603
689
  #
604
690
  #
@@ -625,6 +711,12 @@ module Playwright
625
711
  # element_handle.type("some text")
626
712
  # element_handle.press("Enter")
627
713
  # ```
714
+ #
715
+ # ```csharp
716
+ # var elementHandle = await page.QuerySelectorAsync("input");
717
+ # await elementHandle.TypeAsync("some text");
718
+ # await elementHandle.PressAsync("Enter");
719
+ # ```
628
720
  def type(text, delay: nil, noWaitAfter: nil, timeout: nil)
629
721
  wrap_impl(@impl.type(unwrap_impl(text), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
630
722
  end
@@ -642,8 +734,13 @@ module Playwright
642
734
  #
643
735
  # When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`. Passing
644
736
  # zero timeout disables this.
645
- def uncheck(force: nil, noWaitAfter: nil, position: nil, timeout: nil)
646
- wrap_impl(@impl.uncheck(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
737
+ def uncheck(
738
+ force: nil,
739
+ noWaitAfter: nil,
740
+ position: nil,
741
+ timeout: nil,
742
+ trial: nil)
743
+ wrap_impl(@impl.uncheck(force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
647
744
  end
648
745
 
649
746
  # Returns when the element satisfies the `state`.
@@ -702,6 +799,13 @@ module Playwright
702
799
  # span = div.wait_for_selector("span", state="attached")
703
800
  # ```
704
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
+ #
705
809
  # > NOTE: This method does not work across navigations, use [`method: Page.waitForSelector`] instead.
706
810
  def wait_for_selector(selector, state: nil, timeout: nil)
707
811
  wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
@@ -28,6 +28,13 @@ module Playwright
28
28
  # file_chooser = fc_info.value
29
29
  # file_chooser.set_files("myfile.pdf")
30
30
  # ```
31
+ #
32
+ # ```csharp
33
+ # var waitForFileChooserTask = page.WaitForFileChooserAsync();
34
+ # await page.ClickAsync("upload");
35
+ # var fileChooser = await waitForFileChooserTask;
36
+ # await fileChooser.SetFilesAsync("temp.txt");
37
+ # ```
31
38
  class FileChooser < PlaywrightApi
32
39
 
33
40
  # Returns input element associated with this file chooser.
@@ -96,6 +96,32 @@ module Playwright
96
96
  # with sync_playwright() as playwright:
97
97
  # run(playwright)
98
98
  # ```
99
+ #
100
+ # ```csharp
101
+ # using Microsoft.Playwright;
102
+ # using System;
103
+ # using System.Threading.Tasks;
104
+ #
105
+ # class FrameExamples
106
+ # {
107
+ # public static async Task Main()
108
+ # {
109
+ # using var playwright = await Playwright.CreateAsync();
110
+ # await using var browser = await playwright.Firefox.LaunchAsync();
111
+ # var page = await browser.NewPageAsync();
112
+ #
113
+ # await page.GotoAsync("https://www.bing.com");
114
+ # DumpFrameTree(page.MainFrame, string.Empty);
115
+ # }
116
+ #
117
+ # private static void DumpFrameTree(IFrame frame, string indent)
118
+ # {
119
+ # Console.WriteLine($"{indent}{frame.Url}");
120
+ # foreach (var child in frame.ChildFrames)
121
+ # DumpFrameTree(child, indent + " ");
122
+ # }
123
+ # }
124
+ # ```
99
125
  class Frame < PlaywrightApi
100
126
 
101
127
  # Returns the added tag when the script's onload fires or when the script content was injected into frame.
@@ -131,8 +157,9 @@ module Playwright
131
157
  force: nil,
132
158
  noWaitAfter: nil,
133
159
  position: nil,
134
- timeout: nil)
135
- wrap_impl(@impl.check(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
160
+ timeout: nil,
161
+ trial: nil)
162
+ wrap_impl(@impl.check(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
136
163
  end
137
164
 
138
165
  def child_frames
@@ -158,8 +185,9 @@ module Playwright
158
185
  modifiers: nil,
159
186
  noWaitAfter: nil,
160
187
  position: nil,
161
- timeout: nil)
162
- wrap_impl(@impl.click(unwrap_impl(selector), button: unwrap_impl(button), clickCount: unwrap_impl(clickCount), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
188
+ timeout: nil,
189
+ trial: nil)
190
+ wrap_impl(@impl.click(unwrap_impl(selector), button: unwrap_impl(button), clickCount: unwrap_impl(clickCount), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
163
191
  end
164
192
 
165
193
  # Gets the full HTML contents of the frame, including the doctype.
@@ -188,8 +216,9 @@ module Playwright
188
216
  modifiers: nil,
189
217
  noWaitAfter: nil,
190
218
  position: nil,
191
- timeout: nil)
192
- wrap_impl(@impl.dblclick(unwrap_impl(selector), button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
219
+ timeout: nil,
220
+ trial: nil)
221
+ wrap_impl(@impl.dblclick(unwrap_impl(selector), button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
193
222
  end
194
223
 
195
224
  # The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
@@ -213,6 +242,10 @@ module Playwright
213
242
  # frame.dispatch_event("button#submit", "click")
214
243
  # ```
215
244
  #
245
+ # ```csharp
246
+ # await frame.DispatchEventAsync("button#submit", "click");
247
+ # ```
248
+ #
216
249
  # Under the hood, it creates an instance of an event based on the given `type`, initializes it with `eventInit` properties
217
250
  # and dispatches it on the element. Events are `composed`, `cancelable` and bubble by default.
218
251
  #
@@ -253,6 +286,12 @@ module Playwright
253
286
  # data_transfer = frame.evaluate_handle("new DataTransfer()")
254
287
  # frame.dispatch_event("#source", "dragstart", { "dataTransfer": data_transfer })
255
288
  # ```
289
+ #
290
+ # ```csharp
291
+ # // Note you can only create DataTransfer in Chromium and Firefox
292
+ # var dataTransfer = await frame.EvaluateHandleAsync("() => new DataTransfer()");
293
+ # await frame.DispatchEventAsync("#source", "dragstart", new { dataTransfer });
294
+ # ```
256
295
  def dispatch_event(selector, type, eventInit: nil, timeout: nil)
257
296
  wrap_impl(@impl.dispatch_event(unwrap_impl(selector), unwrap_impl(type), eventInit: unwrap_impl(eventInit), timeout: unwrap_impl(timeout)))
258
297
  end
@@ -292,6 +331,12 @@ module Playwright
292
331
  # preload_href = frame.eval_on_selector("link[rel=preload]", "el => el.href")
293
332
  # html = frame.eval_on_selector(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello")
294
333
  # ```
334
+ #
335
+ # ```csharp
336
+ # var searchValue = await frame.EvalOnSelectorAsync<string>("#search", "el => el.value");
337
+ # var preloadHref = await frame.EvalOnSelectorAsync<string>("link[rel=preload]", "el => el.href");
338
+ # var html = await frame.EvalOnSelectorAsync(".main-container", "(e, suffix) => e.outerHTML + suffix", "hello");
339
+ # ```
295
340
  def eval_on_selector(selector, expression, arg: nil)
296
341
  wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
297
342
  end
@@ -322,6 +367,10 @@ module Playwright
322
367
  # ```python sync
323
368
  # divs_counts = frame.eval_on_selector_all("div", "(divs, min) => divs.length >= min", 10)
324
369
  # ```
370
+ #
371
+ # ```csharp
372
+ # var divsCount = await frame.EvalOnSelectorAllAsync<bool>("div", "(divs, min) => divs.length >= min", 10);
373
+ # ```
325
374
  def eval_on_selector_all(selector, expression, arg: nil)
326
375
  wrap_impl(@impl.eval_on_selector_all(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg)))
327
376
  end
@@ -360,6 +409,11 @@ module Playwright
360
409
  # print(result) # prints "56"
361
410
  # ```
362
411
  #
412
+ # ```csharp
413
+ # var result = await frame.EvaluateAsync<int>("([x, y]) => Promise.resolve(x * y)", new[] { 7, 8 });
414
+ # Console.WriteLine(result);
415
+ # ```
416
+ #
363
417
  # A string can also be passed in instead of a function.
364
418
  #
365
419
  #
@@ -383,6 +437,10 @@ module Playwright
383
437
  # print(frame.evaluate(f"1 + {x}")) # prints "11"
384
438
  # ```
385
439
  #
440
+ # ```csharp
441
+ # Console.WriteLine(await frame.EvaluateAsync<int>("1 + 2")); // prints "3"
442
+ # ```
443
+ #
386
444
  # `ElementHandle` instances can be passed as an argument to the [`method: Frame.evaluate`]:
387
445
  #
388
446
  #
@@ -409,6 +467,12 @@ module Playwright
409
467
  # html = frame.evaluate("([body, suffix]) => body.innerHTML + suffix", [body_handle, "hello"])
410
468
  # body_handle.dispose()
411
469
  # ```
470
+ #
471
+ # ```csharp
472
+ # var bodyHandle = await frame.QuerySelectorAsync("body");
473
+ # var html = await frame.EvaluateAsync<string>("([body, suffix]) => body.innerHTML + suffix", new object [] { bodyHandle, "hello" });
474
+ # await bodyHandle.DisposeAsync();
475
+ # ```
412
476
  def evaluate(expression, arg: nil)
413
477
  wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
414
478
  end
@@ -442,6 +506,11 @@ module Playwright
442
506
  # a_window_handle # handle for the window object.
443
507
  # ```
444
508
  #
509
+ # ```csharp
510
+ # // Handle for the window object.
511
+ # var aWindowHandle = await frame.EvaluateHandleAsync("() => Promise.resolve(window)");
512
+ # ```
513
+ #
445
514
  # A string can also be passed in instead of a function.
446
515
  #
447
516
  #
@@ -461,6 +530,10 @@ module Playwright
461
530
  # a_handle = page.evaluate_handle("document") # handle for the "document"
462
531
  # ```
463
532
  #
533
+ # ```csharp
534
+ # var docHandle = await frame.EvalueHandleAsync("document"); // Handle for the `document`
535
+ # ```
536
+ #
464
537
  # `JSHandle` instances can be passed as an argument to the [`method: Frame.evaluateHandle`]:
465
538
  #
466
539
  #
@@ -491,15 +564,25 @@ module Playwright
491
564
  # print(result_handle.json_value())
492
565
  # result_handle.dispose()
493
566
  # ```
567
+ #
568
+ # ```csharp
569
+ # var handle = await frame.EvaluateHandleAsync("() => document.body");
570
+ # var resultHandle = await frame.EvaluateHandleAsync("([body, suffix]) => body.innerHTML + suffix", new object[] { handle, "hello" });
571
+ # Console.WriteLine(await resultHandle.JsonValueAsync<string>());
572
+ # await resultHandle.DisposeAsync();
573
+ # ```
494
574
  def evaluate_handle(expression, arg: nil)
495
575
  wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg)))
496
576
  end
497
577
 
498
578
  # This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, focuses the
499
- # element, fills it and triggers an `input` event after filling. If the element is inside the `<label>` element that has
500
- # associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), that control will be
501
- # filled instead. If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this
502
- # method throws an error. Note that you can pass an empty string to clear the input field.
579
+ # element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input
580
+ # field.
581
+ #
582
+ # If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
583
+ # However, if the element is inside the `<label>` element that has an associated
584
+ # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled
585
+ # instead.
503
586
  #
504
587
  # To send fine-grained keyboard events, use [`method: Frame.type`].
505
588
  def fill(selector, value, noWaitAfter: nil, timeout: nil)
@@ -543,6 +626,12 @@ module Playwright
543
626
  # content_frame = frame_element.content_frame()
544
627
  # assert frame == content_frame
545
628
  # ```
629
+ #
630
+ # ```csharp
631
+ # var frameElement = await frame.FrameElementAsync();
632
+ # var contentFrame = await frameElement.ContentFrameAsync();
633
+ # Console.WriteLine(frame == contentFrame); // -> True
634
+ # ```
546
635
  def frame_element
547
636
  wrap_impl(@impl.frame_element)
548
637
  end
@@ -589,8 +678,9 @@ module Playwright
589
678
  force: nil,
590
679
  modifiers: nil,
591
680
  position: nil,
592
- timeout: nil)
593
- wrap_impl(@impl.hover(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
681
+ timeout: nil,
682
+ trial: nil)
683
+ wrap_impl(@impl.hover(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
594
684
  end
595
685
 
596
686
  # Returns `element.innerHTML`.
@@ -700,12 +790,16 @@ module Playwright
700
790
  wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
701
791
  end
702
792
 
703
- # Returns the array of option values that have been successfully selected.
793
+ # This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, waits until
794
+ # all specified options are present in the `<select>` element and selects these options.
704
795
  #
705
- # Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
706
- # matching `selector`, the method throws an error.
796
+ # If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the
797
+ # `<label>` element that has an associated
798
+ # [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
707
799
  #
708
- # Will wait until all specified options are present in the `<select>` element.
800
+ # Returns the array of option values that have been successfully selected.
801
+ #
802
+ # Triggers a `change` and `input` event once all the provided options have been selected.
709
803
  #
710
804
  #
711
805
  # ```js
@@ -745,6 +839,15 @@ module Playwright
745
839
  # # multiple selection
746
840
  # frame.select_option("select#colors", value=["red", "green", "blue"])
747
841
  # ```
842
+ #
843
+ # ```csharp
844
+ # // single selection matching the value
845
+ # await frame.SelectOptionAsync("select#colors", new[] { "blue" });
846
+ # // single selection matching both the value and the label
847
+ # await frame.SelectOptionAsync("select#colors", new[] { new SelectOptionValue() { Label = "blue" } });
848
+ # // multiple selection
849
+ # await frame.SelectOptionAsync("select#colors", new[] { "red", "green", "blue" });
850
+ # ```
748
851
  def select_option(
749
852
  selector,
750
853
  element: nil,
@@ -788,8 +891,9 @@ module Playwright
788
891
  modifiers: nil,
789
892
  noWaitAfter: nil,
790
893
  position: nil,
791
- timeout: nil)
792
- wrap_impl(@impl.tap_point(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
894
+ timeout: nil,
895
+ trial: nil)
896
+ wrap_impl(@impl.tap_point(unwrap_impl(selector), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
793
897
  end
794
898
 
795
899
  # Returns `element.textContent`.
@@ -829,6 +933,11 @@ module Playwright
829
933
  # frame.type("#mytextarea", "hello") # types instantly
830
934
  # frame.type("#mytextarea", "world", delay=100) # types slower, like a user
831
935
  # ```
936
+ #
937
+ # ```csharp
938
+ # await frame.TypeAsync("#mytextarea", "hello"); // types instantly
939
+ # await frame.TypeAsync("#mytextarea", "world", delay: 100); // types slower, like a user
940
+ # ```
832
941
  def type(
833
942
  selector,
834
943
  text,
@@ -856,8 +965,9 @@ module Playwright
856
965
  force: nil,
857
966
  noWaitAfter: nil,
858
967
  position: nil,
859
- timeout: nil)
860
- wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout)))
968
+ timeout: nil,
969
+ trial: nil)
970
+ wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
861
971
  end
862
972
 
863
973
  # Returns frame's url.
@@ -933,6 +1043,23 @@ module Playwright
933
1043
  # run(playwright)
934
1044
  # ```
935
1045
  #
1046
+ # ```csharp
1047
+ # using Microsoft.Playwright;
1048
+ # using System.Threading.Tasks;
1049
+ #
1050
+ # class FrameExamples
1051
+ # {
1052
+ # public static async Task Main()
1053
+ # {
1054
+ # using var playwright = await Playwright.CreateAsync();
1055
+ # await using var browser = await playwright.Firefox.LaunchAsync();
1056
+ # var page = await browser.NewPageAsync();
1057
+ # await page.SetViewportSizeAsync(50, 50);
1058
+ # await page.MainFrame.WaitForFunctionAsync("window.innerWidth < 100");
1059
+ # }
1060
+ # }
1061
+ # ```
1062
+ #
936
1063
  # To pass an argument to the predicate of `frame.waitForFunction` function:
937
1064
  #
938
1065
  #
@@ -955,6 +1082,11 @@ module Playwright
955
1082
  # selector = ".foo"
956
1083
  # frame.wait_for_function("selector => !!document.querySelector(selector)", selector)
957
1084
  # ```
1085
+ #
1086
+ # ```csharp
1087
+ # var selector = ".foo";
1088
+ # await page.MainFrame.WaitForFunctionAsync("selector => !!document.querySelector(selector)", selector);
1089
+ # ```
958
1090
  def wait_for_function(expression, arg: nil, polling: nil, timeout: nil)
959
1091
  wrap_impl(@impl.wait_for_function(unwrap_impl(expression), arg: unwrap_impl(arg), polling: unwrap_impl(polling), timeout: unwrap_impl(timeout)))
960
1092
  end
@@ -984,6 +1116,11 @@ module Playwright
984
1116
  # frame.click("button") # click triggers navigation.
985
1117
  # frame.wait_for_load_state() # the promise resolves after "load" event.
986
1118
  # ```
1119
+ #
1120
+ # ```csharp
1121
+ # await frame.ClickAsync("button");
1122
+ # await frame.WaitForLoadStateAsync(); // Defaults to LoadState.Load
1123
+ # ```
987
1124
  def wait_for_load_state(state: nil, timeout: nil)
988
1125
  wrap_impl(@impl.wait_for_load_state(state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
989
1126
  end
@@ -1023,6 +1160,14 @@ module Playwright
1023
1160
  # # Resolves after navigation has finished
1024
1161
  # ```
1025
1162
  #
1163
+ # ```csharp
1164
+ # await Task.WhenAll(
1165
+ # frame.WaitForNavigationAsync(),
1166
+ # // clicking the link will indirectly cause a navigation
1167
+ # frame.ClickAsync("a.delayed-navigation"));
1168
+ # // Resolves after navigation has finished
1169
+ # ```
1170
+ #
1026
1171
  # > NOTE: Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is
1027
1172
  # considered a navigation.
1028
1173
  def expect_navigation(timeout: nil, url: nil, waitUntil: nil, &block)
@@ -1110,6 +1255,29 @@ module Playwright
1110
1255
  # with sync_playwright() as playwright:
1111
1256
  # run(playwright)
1112
1257
  # ```
1258
+ #
1259
+ # ```csharp
1260
+ # using Microsoft.Playwright;
1261
+ # using System;
1262
+ # using System.Threading.Tasks;
1263
+ #
1264
+ # class FrameExamples
1265
+ # {
1266
+ # public static async Task Main()
1267
+ # {
1268
+ # using var playwright = await Playwright.CreateAsync();
1269
+ # await using var browser = await playwright.Chromium.LaunchAsync();
1270
+ # var page = await browser.NewPageAsync();
1271
+ #
1272
+ # foreach (var currentUrl in new[] { "https://www.google.com", "https://bbc.com" })
1273
+ # {
1274
+ # await page.GotoAsync(currentUrl);
1275
+ # element = await page.MainFrame.WaitForSelectorAsync("img");
1276
+ # Console.WriteLine($"Loaded image: {await element.GetAttributeAsync("src")}");
1277
+ # }
1278
+ # }
1279
+ # }
1280
+ # ```
1113
1281
  def wait_for_selector(selector, state: nil, timeout: nil)
1114
1282
  wrap_impl(@impl.wait_for_selector(unwrap_impl(selector), state: unwrap_impl(state), timeout: unwrap_impl(timeout)))
1115
1283
  end
@@ -1144,6 +1312,11 @@ module Playwright
1144
1312
  # frame.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
1145
1313
  # frame.wait_for_url("**/target.html")
1146
1314
  # ```
1315
+ #
1316
+ # ```csharp
1317
+ # await frame.ClickAsync("a.delayed-navigation"); // clicking the link will indirectly cause a navigation
1318
+ # await frame.WaitForURLAsync("**/target.html");
1319
+ # ```
1147
1320
  def wait_for_url(url, timeout: nil, waitUntil: nil)
1148
1321
  wrap_impl(@impl.wait_for_url(unwrap_impl(url), timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
1149
1322
  end