playwright-ruby-client 0.3.0 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -5
  3. data/docs/api_coverage.md +14 -25
  4. data/lib/playwright/channel.rb +19 -9
  5. data/lib/playwright/channel_owners/artifact.rb +30 -0
  6. data/lib/playwright/channel_owners/browser.rb +21 -0
  7. data/lib/playwright/channel_owners/browser_context.rb +5 -0
  8. data/lib/playwright/channel_owners/browser_type.rb +28 -0
  9. data/lib/playwright/channel_owners/element_handle.rb +1 -1
  10. data/lib/playwright/channel_owners/frame.rb +25 -2
  11. data/lib/playwright/channel_owners/js_handle.rb +2 -2
  12. data/lib/playwright/channel_owners/page.rb +78 -15
  13. data/lib/playwright/channel_owners/playwright.rb +22 -29
  14. data/lib/playwright/channel_owners/stream.rb +15 -0
  15. data/lib/playwright/connection.rb +11 -32
  16. data/lib/playwright/download.rb +27 -0
  17. data/lib/playwright/errors.rb +6 -0
  18. data/lib/playwright/events.rb +2 -5
  19. data/lib/playwright/keyboard_impl.rb +1 -1
  20. data/lib/playwright/mouse_impl.rb +41 -0
  21. data/lib/playwright/route_handler_entry.rb +1 -9
  22. data/lib/playwright/transport.rb +27 -6
  23. data/lib/playwright/url_matcher.rb +1 -1
  24. data/lib/playwright/utils.rb +8 -0
  25. data/lib/playwright/version.rb +1 -1
  26. data/lib/playwright/video.rb +51 -0
  27. data/lib/playwright/wait_helper.rb +2 -2
  28. data/lib/playwright.rb +47 -9
  29. data/lib/playwright_api/accessibility.rb +39 -1
  30. data/lib/playwright_api/android.rb +10 -10
  31. data/lib/playwright_api/android_device.rb +10 -9
  32. data/lib/playwright_api/browser.rb +83 -8
  33. data/lib/playwright_api/browser_context.rb +163 -15
  34. data/lib/playwright_api/browser_type.rb +35 -4
  35. data/lib/playwright_api/console_message.rb +6 -6
  36. data/lib/playwright_api/dialog.rb +28 -8
  37. data/lib/playwright_api/element_handle.rb +111 -37
  38. data/lib/playwright_api/file_chooser.rb +5 -0
  39. data/lib/playwright_api/frame.rb +228 -37
  40. data/lib/playwright_api/js_handle.rb +26 -3
  41. data/lib/playwright_api/keyboard.rb +48 -1
  42. data/lib/playwright_api/mouse.rb +26 -5
  43. data/lib/playwright_api/page.rb +456 -48
  44. data/lib/playwright_api/playwright.rb +26 -9
  45. data/lib/playwright_api/request.rb +34 -6
  46. data/lib/playwright_api/response.rb +8 -8
  47. data/lib/playwright_api/route.rb +30 -6
  48. data/lib/playwright_api/selectors.rb +32 -6
  49. data/lib/playwright_api/touchscreen.rb +1 -1
  50. data/lib/playwright_api/worker.rb +25 -1
  51. data/playwright.gemspec +4 -2
  52. metadata +37 -14
  53. data/lib/playwright/channel_owners/chromium_browser.rb +0 -8
  54. data/lib/playwright/channel_owners/chromium_browser_context.rb +0 -8
  55. data/lib/playwright/channel_owners/download.rb +0 -27
  56. data/lib/playwright/channel_owners/firefox_browser.rb +0 -8
  57. data/lib/playwright/channel_owners/webkit_browser.rb +0 -8
  58. data/lib/playwright_api/binding_call.rb +0 -32
  59. data/lib/playwright_api/chromium_browser_context.rb +0 -59
  60. data/lib/playwright_api/download.rb +0 -95
  61. data/lib/playwright_api/video.rb +0 -24
@@ -15,6 +15,22 @@ module Playwright
15
15
  # })();
16
16
  # ```
17
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 firefox = playwright.firefox()
25
+ # Browser browser = firefox.launch();
26
+ # Page page = browser.newPage();
27
+ # page.navigate('https://example.com');
28
+ # browser.close();
29
+ # }
30
+ # }
31
+ # }
32
+ # ```
33
+ #
18
34
  # ```python async
19
35
  # import asyncio
20
36
  # from playwright.async_api import async_playwright
@@ -69,6 +85,13 @@ module Playwright
69
85
  # console.log(browser.contexts().length); // prints `1`
70
86
  # ```
71
87
  #
88
+ # ```java
89
+ # Browser browser = pw.webkit().launch();
90
+ # System.out.println(browser.contexts().size()); // prints "0"
91
+ # BrowserContext context = browser.newContext();
92
+ # System.out.println(browser.contexts().size()); // prints "1"
93
+ # ```
94
+ #
72
95
  # ```python async
73
96
  # browser = await pw.webkit.launch()
74
97
  # print(len(browser.contexts())) # prints `0`
@@ -91,6 +114,13 @@ module Playwright
91
114
  wrap_impl(@impl.connected?)
92
115
  end
93
116
 
117
+ # > NOTE: CDP Sessions are only supported on Chromium-based browsers.
118
+ #
119
+ # Returns the newly created browser session.
120
+ def new_browser_cdp_session
121
+ raise NotImplementedError.new('new_browser_cdp_session is not implemented yet.')
122
+ end
123
+
94
124
  # Creates a new browser context. It won't share cookies/cache with other browser contexts.
95
125
  #
96
126
  #
@@ -105,6 +135,15 @@ module Playwright
105
135
  # })();
106
136
  # ```
107
137
  #
138
+ # ```java
139
+ # Browser browser = playwright.firefox().launch(); // Or 'chromium' or 'webkit'.
140
+ # // Create a new incognito browser context.
141
+ # BrowserContext context = browser.newContext();
142
+ # // Create a new page in a pristine context.
143
+ # Page page = context.newPage();
144
+ # page.navigate('https://example.com');
145
+ # ```
146
+ #
108
147
  # ```python async
109
148
  # browser = await playwright.firefox.launch() # or "chromium" or "webkit".
110
149
  # # create a new incognito browser context.
@@ -143,12 +182,13 @@ module Playwright
143
182
  record_har_path: nil,
144
183
  record_video_dir: nil,
145
184
  record_video_size: nil,
185
+ screen: nil,
146
186
  storageState: nil,
147
187
  timezoneId: nil,
148
188
  userAgent: nil,
149
189
  viewport: nil,
150
190
  &block)
151
- wrap_impl(@impl.new_context(acceptDownloads: unwrap_impl(acceptDownloads), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
191
+ wrap_impl(@impl.new_context(acceptDownloads: unwrap_impl(acceptDownloads), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), screen: unwrap_impl(screen), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
152
192
  end
153
193
 
154
194
  # Creates a new page in a new browser context. Closing this page will close the context as well.
@@ -177,11 +217,46 @@ module Playwright
177
217
  record_har_path: nil,
178
218
  record_video_dir: nil,
179
219
  record_video_size: nil,
220
+ screen: nil,
180
221
  storageState: nil,
181
222
  timezoneId: nil,
182
223
  userAgent: nil,
183
224
  viewport: nil)
184
- wrap_impl(@impl.new_page(acceptDownloads: unwrap_impl(acceptDownloads), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport)))
225
+ wrap_impl(@impl.new_page(acceptDownloads: unwrap_impl(acceptDownloads), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), screen: unwrap_impl(screen), storageState: unwrap_impl(storageState), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport)))
226
+ end
227
+
228
+ # > NOTE: Tracing is only supported on Chromium-based browsers.
229
+ #
230
+ # You can use [`method: Browser.startTracing`] and [`method: Browser.stopTracing`] to create a trace file that can be
231
+ # opened in Chrome DevTools performance panel.
232
+ #
233
+ #
234
+ # ```js
235
+ # await browser.startTracing(page, {path: 'trace.json'});
236
+ # await page.goto('https://www.google.com');
237
+ # await browser.stopTracing();
238
+ # ```
239
+ #
240
+ # ```python async
241
+ # await browser.start_tracing(page, path="trace.json")
242
+ # await page.goto("https://www.google.com")
243
+ # await browser.stop_tracing()
244
+ # ```
245
+ #
246
+ # ```python sync
247
+ # browser.start_tracing(page, path="trace.json")
248
+ # page.goto("https://www.google.com")
249
+ # browser.stop_tracing()
250
+ # ```
251
+ def start_tracing(page: nil, categories: nil, path: nil, screenshots: nil)
252
+ wrap_impl(@impl.start_tracing(page: unwrap_impl(page), categories: unwrap_impl(categories), path: unwrap_impl(path), screenshots: unwrap_impl(screenshots)))
253
+ end
254
+
255
+ # > NOTE: Tracing is only supported on Chromium-based browsers.
256
+ #
257
+ # Returns the buffer with trace data.
258
+ def stop_tracing
259
+ wrap_impl(@impl.stop_tracing)
185
260
  end
186
261
 
187
262
  # Returns the browser version.
@@ -189,12 +264,6 @@ module Playwright
189
264
  wrap_impl(@impl.version)
190
265
  end
191
266
 
192
- # -- inherited from EventEmitter --
193
- # @nodoc
194
- def off(event, callback)
195
- event_emitter_proxy.off(event, callback)
196
- end
197
-
198
267
  # -- inherited from EventEmitter --
199
268
  # @nodoc
200
269
  def once(event, callback)
@@ -207,6 +276,12 @@ module Playwright
207
276
  event_emitter_proxy.on(event, callback)
208
277
  end
209
278
 
279
+ # -- inherited from EventEmitter --
280
+ # @nodoc
281
+ def off(event, callback)
282
+ event_emitter_proxy.off(event, callback)
283
+ end
284
+
210
285
  private def event_emitter_proxy
211
286
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
212
287
  end
@@ -20,6 +20,16 @@ module Playwright
20
20
  # await context.close();
21
21
  # ```
22
22
  #
23
+ # ```java
24
+ # // Create a new incognito browser context
25
+ # BrowserContext context = browser.newContext();
26
+ # // Create a new page inside context.
27
+ # Page page = context.newPage();
28
+ # page.navigate("https://example.com");
29
+ # // Dispose context once it"s no longer needed.
30
+ # context.close();
31
+ # ```
32
+ #
23
33
  # ```python async
24
34
  # # create a new incognito browser context
25
35
  # context = await browser.new_context()
@@ -49,6 +59,10 @@ module Playwright
49
59
  # await browserContext.addCookies([cookieObject1, cookieObject2]);
50
60
  # ```
51
61
  #
62
+ # ```java
63
+ # browserContext.addCookies(Arrays.asList(cookieObject1, cookieObject2));
64
+ # ```
65
+ #
52
66
  # ```python async
53
67
  # await browser_context.add_cookies([cookie_object1, cookie_object2])
54
68
  # ```
@@ -84,6 +98,11 @@ module Playwright
84
98
  # });
85
99
  # ```
86
100
  #
101
+ # ```java
102
+ # // In your playwright script, assuming the preload.js file is in same directory.
103
+ # browserContext.addInitScript(Paths.get("preload.js"));
104
+ # ```
105
+ #
87
106
  # ```python async
88
107
  # # in your playwright script, assuming the preload.js file is in same directory.
89
108
  # await browser_context.add_init_script(path="preload.js")
@@ -100,6 +119,13 @@ module Playwright
100
119
  wrap_impl(@impl.add_init_script(path: unwrap_impl(path), script: unwrap_impl(script)))
101
120
  end
102
121
 
122
+ # > NOTE: Background pages are only supported on Chromium-based browsers.
123
+ #
124
+ # All existing background pages in the context.
125
+ def background_pages
126
+ raise NotImplementedError.new('background_pages is not implemented yet.')
127
+ end
128
+
103
129
  # Returns the browser instance of the context. If it was launched as a persistent context null gets returned.
104
130
  def browser
105
131
  wrap_impl(@impl.browser)
@@ -120,6 +146,13 @@ module Playwright
120
146
  # context.clearPermissions();
121
147
  # ```
122
148
  #
149
+ # ```java
150
+ # BrowserContext context = browser.newContext();
151
+ # context.grantPermissions(Arrays.asList("clipboard-read"));
152
+ # // do stuff ..
153
+ # context.clearPermissions();
154
+ # ```
155
+ #
123
156
  # ```python async
124
157
  # context = await browser.new_context()
125
158
  # await context.grant_permissions(["clipboard-read"])
@@ -183,6 +216,30 @@ module Playwright
183
216
  # })();
184
217
  # ```
185
218
  #
219
+ # ```java
220
+ # import com.microsoft.playwright.*;
221
+ #
222
+ # public class Example {
223
+ # public static void main(String[] args) {
224
+ # try (Playwright playwright = Playwright.create()) {
225
+ # BrowserType webkit = playwright.webkit()
226
+ # Browser browser = webkit.launch(new BrowserType.LaunchOptions().setHeadless(false));
227
+ # BrowserContext context = browser.newContext();
228
+ # context.exposeBinding("pageURL", (source, args) -> source.page().url());
229
+ # Page page = context.newPage();
230
+ # page.setContent("<script>\n" +
231
+ # " async function onClick() {\n" +
232
+ # " document.querySelector('div').textContent = await window.pageURL();\n" +
233
+ # " }\n" +
234
+ # "</script>\n" +
235
+ # "<button onclick=\"onClick()\">Click me</button>\n" +
236
+ # "<div></div>");
237
+ # page.click("button");
238
+ # }
239
+ # }
240
+ # }
241
+ # ```
242
+ #
186
243
  # ```python async
187
244
  # import asyncio
188
245
  # from playwright.async_api import async_playwright
@@ -250,6 +307,20 @@ module Playwright
250
307
  # `);
251
308
  # ```
252
309
  #
310
+ # ```java
311
+ # context.exposeBinding("clicked", (source, args) -> {
312
+ # ElementHandle element = (ElementHandle) args[0];
313
+ # System.out.println(element.textContent());
314
+ # return null;
315
+ # }, new BrowserContext.ExposeBindingOptions().setHandle(true));
316
+ # page.setContent("" +
317
+ # "<script>\n" +
318
+ # " document.addEventListener('click', event => window.clicked(event.target));\n" +
319
+ # "</script>\n" +
320
+ # "<div>Click me</div>\n" +
321
+ # "<div>Or click me</div>\n");
322
+ # ```
323
+ #
253
324
  # ```python async
254
325
  # async def print(source, element):
255
326
  # print(await element.text_content())
@@ -313,6 +384,44 @@ module Playwright
313
384
  # })();
314
385
  # ```
315
386
  #
387
+ # ```java
388
+ # import com.microsoft.playwright.*;
389
+ #
390
+ # import java.nio.charset.StandardCharsets;
391
+ # import java.security.MessageDigest;
392
+ # import java.security.NoSuchAlgorithmException;
393
+ # import java.util.Base64;
394
+ #
395
+ # public class Example {
396
+ # public static void main(String[] args) {
397
+ # try (Playwright playwright = Playwright.create()) {
398
+ # BrowserType webkit = playwright.webkit()
399
+ # Browser browser = webkit.launch(new BrowserType.LaunchOptions().setHeadless(false));
400
+ # context.exposeFunction("sha1", args -> {
401
+ # String text = (String) args[0];
402
+ # MessageDigest crypto;
403
+ # try {
404
+ # crypto = MessageDigest.getInstance("SHA-1");
405
+ # } catch (NoSuchAlgorithmException e) {
406
+ # return null;
407
+ # }
408
+ # byte[] token = crypto.digest(text.getBytes(StandardCharsets.UTF_8));
409
+ # return Base64.getEncoder().encodeToString(token);
410
+ # });
411
+ # Page page = context.newPage();
412
+ # page.setContent("<script>\n" +
413
+ # " async function onClick() {\n" +
414
+ # " document.querySelector('div').textContent = await window.sha1('PLAYWRIGHT');\n" +
415
+ # " }\n" +
416
+ # "</script>\n" +
417
+ # "<button onclick=\"onClick()\">Click me</button>\n" +
418
+ # "<div></div>\n");
419
+ # page.click("button");
420
+ # }
421
+ # }
422
+ # }
423
+ # ```
424
+ #
316
425
  # ```python async
317
426
  # import asyncio
318
427
  # import hashlib
@@ -388,13 +497,19 @@ module Playwright
388
497
  wrap_impl(@impl.grant_permissions(unwrap_impl(permissions), origin: unwrap_impl(origin)))
389
498
  end
390
499
 
500
+ # > NOTE: CDP sessions are only supported on Chromium-based browsers.
501
+ #
502
+ # Returns the newly created session.
503
+ def new_cdp_session(page)
504
+ raise NotImplementedError.new('new_cdp_session is not implemented yet.')
505
+ end
506
+
391
507
  # Creates a new page in the browser context.
392
508
  def new_page
393
509
  wrap_impl(@impl.new_page)
394
510
  end
395
511
 
396
- # Returns all open pages in the context. Non visible pages, such as `"background_page"`, will not be listed here. You can
397
- # find them using [`method: ChromiumBrowserContext.backgroundPages`].
512
+ # Returns all open pages in the context.
398
513
  def pages
399
514
  wrap_impl(@impl.pages)
400
515
  end
@@ -402,7 +517,7 @@ module Playwright
402
517
  # Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
403
518
  # is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
404
519
  #
405
- # An example of a naïve handler that aborts all image requests:
520
+ # An example of a naive handler that aborts all image requests:
406
521
  #
407
522
  #
408
523
  # ```js
@@ -413,6 +528,14 @@ module Playwright
413
528
  # await browser.close();
414
529
  # ```
415
530
  #
531
+ # ```java
532
+ # BrowserContext context = browser.newContext();
533
+ # context.route("**/*.{png,jpg,jpeg}", route -> route.abort());
534
+ # Page page = context.newPage();
535
+ # page.navigate("https://example.com");
536
+ # browser.close();
537
+ # ```
538
+ #
416
539
  # ```python async
417
540
  # context = await browser.new_context()
418
541
  # page = await context.new_page()
@@ -440,6 +563,14 @@ module Playwright
440
563
  # await browser.close();
441
564
  # ```
442
565
  #
566
+ # ```java
567
+ # BrowserContext context = browser.newContext();
568
+ # context.route(Pattern.compile("(\\.png$)|(\\.jpg$)"), route -> route.abort());
569
+ # Page page = context.newPage();
570
+ # page.navigate("https://example.com");
571
+ # browser.close();
572
+ # ```
573
+ #
443
574
  # ```python async
444
575
  # context = await browser.new_context()
445
576
  # page = await context.new_page()
@@ -462,11 +593,20 @@ module Playwright
462
593
  # Page routes (set up with [`method: Page.route`]) take precedence over browser context routes when request matches both
463
594
  # handlers.
464
595
  #
596
+ # To remove a route with its handler you can use [`method: BrowserContext.unroute`].
597
+ #
465
598
  # > NOTE: Enabling routing disables http cache.
466
599
  def route(url, handler)
467
600
  wrap_impl(@impl.route(unwrap_impl(url), unwrap_impl(handler)))
468
601
  end
469
602
 
603
+ # > NOTE: Service workers are only supported on Chromium-based browsers.
604
+ #
605
+ # All existing service workers in the context.
606
+ def service_workers
607
+ raise NotImplementedError.new('service_workers is not implemented yet.')
608
+ end
609
+
470
610
  # This setting will change the default maximum navigation time for the following methods and related shortcuts:
471
611
  # - [`method: Page.goBack`]
472
612
  # - [`method: Page.goForward`]
@@ -508,6 +648,10 @@ module Playwright
508
648
  # await browserContext.setGeolocation({latitude: 59.95, longitude: 30.31667});
509
649
  # ```
510
650
  #
651
+ # ```java
652
+ # browserContext.setGeolocation(new Geolocation(59.95, 30.31667));
653
+ # ```
654
+ #
511
655
  # ```python async
512
656
  # await browser_context.set_geolocation({"latitude": 59.95, "longitude": 30.31667})
513
657
  # ```
@@ -550,6 +694,10 @@ module Playwright
550
694
  # ]);
551
695
  # ```
552
696
  #
697
+ # ```java
698
+ # Page newPage = context.waitForPage(() -> page.click("button"));
699
+ # ```
700
+ #
553
701
  # ```python async
554
702
  # async with context.expect_event("page") as event_info:
555
703
  # await page.click("button")
@@ -582,18 +730,13 @@ module Playwright
582
730
  end
583
731
 
584
732
  # @nodoc
585
- def browser=(req)
586
- wrap_impl(@impl.browser=(unwrap_impl(req)))
587
- end
588
-
589
- # @nodoc
590
- def owner_page=(req)
591
- wrap_impl(@impl.owner_page=(unwrap_impl(req)))
733
+ def options=(req)
734
+ wrap_impl(@impl.options=(unwrap_impl(req)))
592
735
  end
593
736
 
594
737
  # @nodoc
595
- def options=(req)
596
- wrap_impl(@impl.options=(unwrap_impl(req)))
738
+ def browser=(req)
739
+ wrap_impl(@impl.browser=(unwrap_impl(req)))
597
740
  end
598
741
 
599
742
  # @nodoc
@@ -601,10 +744,9 @@ module Playwright
601
744
  wrap_impl(@impl.pause)
602
745
  end
603
746
 
604
- # -- inherited from EventEmitter --
605
747
  # @nodoc
606
- def off(event, callback)
607
- event_emitter_proxy.off(event, callback)
748
+ def owner_page=(req)
749
+ wrap_impl(@impl.owner_page=(unwrap_impl(req)))
608
750
  end
609
751
 
610
752
  # -- inherited from EventEmitter --
@@ -619,6 +761,12 @@ module Playwright
619
761
  event_emitter_proxy.on(event, callback)
620
762
  end
621
763
 
764
+ # -- inherited from EventEmitter --
765
+ # @nodoc
766
+ def off(event, callback)
767
+ event_emitter_proxy.off(event, callback)
768
+ end
769
+
622
770
  private def event_emitter_proxy
623
771
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
624
772
  end
@@ -15,6 +15,23 @@ module Playwright
15
15
  # })();
16
16
  # ```
17
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
+ #
18
35
  # ```python async
19
36
  # import asyncio
20
37
  # from playwright.async_api import async_playwright
@@ -65,6 +82,12 @@ module Playwright
65
82
  # });
66
83
  # ```
67
84
  #
85
+ # ```java
86
+ # // Or "firefox" or "webkit".
87
+ # Browser browser = chromium.launch(new BrowserType.LaunchOptions()
88
+ # .setIgnoreDefaultArgs(Arrays.asList("--mute-audio")));
89
+ # ```
90
+ #
68
91
  # ```python async
69
92
  # browser = await playwright.chromium.launch( # or "firefox" or "webkit".
70
93
  # ignore_default_args=["--mute-audio"]
@@ -93,6 +116,7 @@ module Playwright
93
116
  # describes some differences for Linux users.
94
117
  def launch(
95
118
  args: nil,
119
+ channel: nil,
96
120
  chromiumSandbox: nil,
97
121
  devtools: nil,
98
122
  downloadsPath: nil,
@@ -108,7 +132,7 @@ module Playwright
108
132
  slowMo: nil,
109
133
  timeout: nil,
110
134
  &block)
111
- wrap_impl(@impl.launch(args: unwrap_impl(args), 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)))
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)))
112
136
  end
113
137
 
114
138
  # Returns the persistent browser context instance.
@@ -120,6 +144,7 @@ module Playwright
120
144
  acceptDownloads: nil,
121
145
  args: nil,
122
146
  bypassCSP: nil,
147
+ channel: nil,
123
148
  chromiumSandbox: nil,
124
149
  colorScheme: nil,
125
150
  deviceScaleFactor: nil,
@@ -148,6 +173,7 @@ module Playwright
148
173
  record_har_path: nil,
149
174
  record_video_dir: nil,
150
175
  record_video_size: nil,
176
+ screen: nil,
151
177
  slowMo: nil,
152
178
  timeout: nil,
153
179
  timezoneId: nil,
@@ -161,10 +187,9 @@ module Playwright
161
187
  wrap_impl(@impl.name)
162
188
  end
163
189
 
164
- # -- inherited from EventEmitter --
165
190
  # @nodoc
166
- def off(event, callback)
167
- event_emitter_proxy.off(event, callback)
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)))
168
193
  end
169
194
 
170
195
  # -- inherited from EventEmitter --
@@ -179,6 +204,12 @@ module Playwright
179
204
  event_emitter_proxy.on(event, callback)
180
205
  end
181
206
 
207
+ # -- inherited from EventEmitter --
208
+ # @nodoc
209
+ def off(event, callback)
210
+ event_emitter_proxy.off(event, callback)
211
+ end
212
+
182
213
  private def event_emitter_proxy
183
214
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
184
215
  end
@@ -21,12 +21,6 @@ module Playwright
21
21
  wrap_impl(@impl.type)
22
22
  end
23
23
 
24
- # -- inherited from EventEmitter --
25
- # @nodoc
26
- def off(event, callback)
27
- event_emitter_proxy.off(event, callback)
28
- end
29
-
30
24
  # -- inherited from EventEmitter --
31
25
  # @nodoc
32
26
  def once(event, callback)
@@ -39,6 +33,12 @@ module Playwright
39
33
  event_emitter_proxy.on(event, callback)
40
34
  end
41
35
 
36
+ # -- inherited from EventEmitter --
37
+ # @nodoc
38
+ def off(event, callback)
39
+ event_emitter_proxy.off(event, callback)
40
+ end
41
+
42
42
  private def event_emitter_proxy
43
43
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
44
44
  end
@@ -13,12 +13,32 @@ module Playwright
13
13
  # page.on('dialog', async dialog => {
14
14
  # console.log(dialog.message());
15
15
  # await dialog.dismiss();
16
- # await browser.close();
17
16
  # });
18
- # page.evaluate(() => alert('1'));
17
+ # await page.evaluate(() => alert('1'));
18
+ # await browser.close();
19
19
  # })();
20
20
  # ```
21
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
+ #
22
42
  # ```python async
23
43
  # import asyncio
24
44
  # from playwright.async_api import async_playwright
@@ -96,12 +116,6 @@ module Playwright
96
116
  wrap_impl(@impl.accept_async(promptText: unwrap_impl(promptText)))
97
117
  end
98
118
 
99
- # -- inherited from EventEmitter --
100
- # @nodoc
101
- def off(event, callback)
102
- event_emitter_proxy.off(event, callback)
103
- end
104
-
105
119
  # -- inherited from EventEmitter --
106
120
  # @nodoc
107
121
  def once(event, callback)
@@ -114,6 +128,12 @@ module Playwright
114
128
  event_emitter_proxy.on(event, callback)
115
129
  end
116
130
 
131
+ # -- inherited from EventEmitter --
132
+ # @nodoc
133
+ def off(event, callback)
134
+ event_emitter_proxy.off(event, callback)
135
+ end
136
+
117
137
  private def event_emitter_proxy
118
138
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
119
139
  end