playwright-ruby-client 1.22.0 → 1.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/docs/api/accessibility.md +8 -0
  3. data/documentation/docs/api/api_request_context.md +8 -8
  4. data/documentation/docs/api/browser.md +30 -5
  5. data/documentation/docs/api/browser_context.md +20 -7
  6. data/documentation/docs/api/browser_type.md +4 -0
  7. data/documentation/docs/api/download.md +1 -1
  8. data/documentation/docs/api/element_handle.md +1 -6
  9. data/documentation/docs/api/experimental/android_device.md +4 -0
  10. data/documentation/docs/api/file_chooser.md +1 -1
  11. data/documentation/docs/api/locator.md +15 -7
  12. data/documentation/docs/api/page.md +21 -4
  13. data/documentation/docs/api/request.md +3 -1
  14. data/documentation/docs/api/response.md +12 -1
  15. data/documentation/docs/api/route.md +65 -0
  16. data/documentation/docs/api/selectors.md +2 -2
  17. data/documentation/docs/api/tracing.md +1 -1
  18. data/documentation/docs/include/api_coverage.md +5 -3
  19. data/documentation/package.json +4 -4
  20. data/documentation/yarn.lock +1876 -1304
  21. data/lib/playwright/channel.rb +1 -3
  22. data/lib/playwright/channel_owner.rb +13 -1
  23. data/lib/playwright/channel_owners/browser.rb +13 -0
  24. data/lib/playwright/channel_owners/browser_context.rb +82 -14
  25. data/lib/playwright/channel_owners/browser_type.rb +4 -0
  26. data/lib/playwright/channel_owners/frame.rb +16 -2
  27. data/lib/playwright/channel_owners/local_utils.rb +29 -0
  28. data/lib/playwright/channel_owners/page.rb +43 -15
  29. data/lib/playwright/channel_owners/request.rb +31 -6
  30. data/lib/playwright/channel_owners/response.rb +6 -0
  31. data/lib/playwright/channel_owners/route.rb +104 -45
  32. data/lib/playwright/connection.rb +20 -9
  33. data/lib/playwright/har_router.rb +82 -0
  34. data/lib/playwright/http_headers.rb +1 -1
  35. data/lib/playwright/javascript/regex.rb +23 -0
  36. data/lib/playwright/javascript/value_parser.rb +4 -0
  37. data/lib/playwright/javascript/value_serializer.rb +5 -4
  38. data/lib/playwright/javascript.rb +1 -0
  39. data/lib/playwright/locator_impl.rb +3 -5
  40. data/lib/playwright/route_handler.rb +2 -6
  41. data/lib/playwright/utils.rb +31 -6
  42. data/lib/playwright/version.rb +2 -2
  43. data/lib/playwright.rb +2 -0
  44. data/lib/playwright_api/accessibility.rb +8 -0
  45. data/lib/playwright_api/android_device.rb +5 -1
  46. data/lib/playwright_api/api_request_context.rb +8 -8
  47. data/lib/playwright_api/browser.rb +28 -2
  48. data/lib/playwright_api/browser_context.rb +19 -9
  49. data/lib/playwright_api/browser_type.rb +8 -2
  50. data/lib/playwright_api/download.rb +1 -1
  51. data/lib/playwright_api/element_handle.rb +1 -12
  52. data/lib/playwright_api/file_chooser.rb +1 -1
  53. data/lib/playwright_api/locator.rb +13 -13
  54. data/lib/playwright_api/page.rb +19 -6
  55. data/lib/playwright_api/request.rb +8 -1
  56. data/lib/playwright_api/response.rb +14 -1
  57. data/lib/playwright_api/route.rb +61 -2
  58. data/lib/playwright_api/selectors.rb +1 -1
  59. data/lib/playwright_api/tracing.rb +1 -1
  60. metadata +5 -4
  61. data/lib/playwright_api/local_utils.rb +0 -9
@@ -18,12 +18,21 @@ module Playwright
18
18
  # ```
19
19
  class Browser < PlaywrightApi
20
20
 
21
+ # Get the browser type (chromium, firefox or webkit) that the browser belongs to.
22
+ def browser_type
23
+ wrap_impl(@impl.browser_type)
24
+ end
25
+
21
26
  # In case this browser is obtained using [`method: BrowserType.launch`], closes the browser and all of its pages (if any
22
27
  # were opened).
23
28
  #
24
29
  # In case this browser is connected to, clears all created contexts belonging to this browser and disconnects from the
25
30
  # browser server.
26
31
  #
32
+ # > NOTE: This is similar to force quitting the browser. Therefore, you should call [`method: BrowserContext.close`] on
33
+ # any `BrowserContext`'s you explicitly created earlier with [`method: Browser.newContext`] **before** calling
34
+ # [`method: Browser.close`].
35
+ #
27
36
  # The `Browser` object itself is considered to be disposed and cannot be used anymore.
28
37
  def close
29
38
  wrap_impl(@impl.close)
@@ -55,6 +64,11 @@ module Playwright
55
64
 
56
65
  # Creates a new browser context. It won't share cookies/cache with other browser contexts.
57
66
  #
67
+ # > NOTE: If directly using this method to create `BrowserContext`s, it is best practice to explicitly close the returned
68
+ # context via [`method: BrowserContext.close`] when your code is done with the `BrowserContext`, and before calling
69
+ # [`method: Browser.close`]. This will ensure the `context` is closed gracefully and any artifacts—like HARs and
70
+ # videos—are fully flushed and saved.
71
+ #
58
72
  # ```python sync
59
73
  # browser = playwright.firefox.launch() # or "chromium" or "webkit".
60
74
  # # create a new incognito browser context.
@@ -62,6 +76,10 @@ module Playwright
62
76
  # # create a new page in a pristine context.
63
77
  # page = context.new_page()
64
78
  # page.goto("https://example.com")
79
+ #
80
+ # # gracefully close up everything
81
+ # context.close()
82
+ # browser.close()
65
83
  # ```
66
84
  def new_context(
67
85
  acceptDownloads: nil,
@@ -82,19 +100,23 @@ module Playwright
82
100
  offline: nil,
83
101
  permissions: nil,
84
102
  proxy: nil,
103
+ record_har_content: nil,
104
+ record_har_mode: nil,
85
105
  record_har_omit_content: nil,
86
106
  record_har_path: nil,
107
+ record_har_url_filter: nil,
87
108
  record_video_dir: nil,
88
109
  record_video_size: nil,
89
110
  reducedMotion: nil,
90
111
  screen: nil,
112
+ serviceWorkers: nil,
91
113
  storageState: nil,
92
114
  strictSelectors: nil,
93
115
  timezoneId: nil,
94
116
  userAgent: nil,
95
117
  viewport: nil,
96
118
  &block)
97
- wrap_impl(@impl.new_context(acceptDownloads: unwrap_impl(acceptDownloads), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), 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), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), storageState: unwrap_impl(storageState), strictSelectors: unwrap_impl(strictSelectors), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
119
+ wrap_impl(@impl.new_context(acceptDownloads: unwrap_impl(acceptDownloads), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), 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_content: unwrap_impl(record_har_content), record_har_mode: unwrap_impl(record_har_mode), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_har_url_filter: unwrap_impl(record_har_url_filter), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), serviceWorkers: unwrap_impl(serviceWorkers), storageState: unwrap_impl(storageState), strictSelectors: unwrap_impl(strictSelectors), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
98
120
  end
99
121
 
100
122
  # Creates a new page in a new browser context. Closing this page will close the context as well.
@@ -121,19 +143,23 @@ module Playwright
121
143
  offline: nil,
122
144
  permissions: nil,
123
145
  proxy: nil,
146
+ record_har_content: nil,
147
+ record_har_mode: nil,
124
148
  record_har_omit_content: nil,
125
149
  record_har_path: nil,
150
+ record_har_url_filter: nil,
126
151
  record_video_dir: nil,
127
152
  record_video_size: nil,
128
153
  reducedMotion: nil,
129
154
  screen: nil,
155
+ serviceWorkers: nil,
130
156
  storageState: nil,
131
157
  strictSelectors: nil,
132
158
  timezoneId: nil,
133
159
  userAgent: nil,
134
160
  viewport: nil,
135
161
  &block)
136
- wrap_impl(@impl.new_page(acceptDownloads: unwrap_impl(acceptDownloads), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), 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), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), storageState: unwrap_impl(storageState), strictSelectors: unwrap_impl(strictSelectors), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
162
+ wrap_impl(@impl.new_page(acceptDownloads: unwrap_impl(acceptDownloads), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), 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_content: unwrap_impl(record_har_content), record_har_mode: unwrap_impl(record_har_mode), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_har_url_filter: unwrap_impl(record_har_url_filter), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), serviceWorkers: unwrap_impl(serviceWorkers), storageState: unwrap_impl(storageState), strictSelectors: unwrap_impl(strictSelectors), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
137
163
  end
138
164
 
139
165
  # > NOTE: This API controls [Chromium Tracing](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool)
@@ -131,7 +131,7 @@ module Playwright
131
131
  # <button onclick="onClick()">Click me</button>
132
132
  # <div></div>
133
133
  # """)
134
- # page.click("button")
134
+ # page.locator("button").click()
135
135
  #
136
136
  # with sync_playwright() as playwright:
137
137
  # run(playwright)
@@ -190,7 +190,7 @@ module Playwright
190
190
  # <button onclick="onClick()">Click me</button>
191
191
  # <div></div>
192
192
  # """)
193
- # page.click("button")
193
+ # page.locator("button").click()
194
194
  #
195
195
  # with sync_playwright() as playwright:
196
196
  # run(playwright)
@@ -225,9 +225,9 @@ module Playwright
225
225
  # Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
226
226
  # is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
227
227
  #
228
- # > NOTE: [`method: Page.route`] will not intercept requests intercepted by Service Worker. See
228
+ # > NOTE: [`method: BrowserContext.route`] will not intercept requests intercepted by Service Worker. See
229
229
  # [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
230
- # request interception. Via `await context.addInitScript(() => delete window.navigator.serviceWorker);`
230
+ # request interception by setting `Browser.newContext.serviceWorkers` to `'block'`.
231
231
  #
232
232
  # An example of a naive handler that aborts all image requests:
233
233
  #
@@ -273,6 +273,16 @@ module Playwright
273
273
  wrap_impl(@impl.route(unwrap_impl(url), unwrap_impl(handler), times: unwrap_impl(times)))
274
274
  end
275
275
 
276
+ # If specified the network requests that are made in the context will be served from the HAR file. Read more about
277
+ # [Replaying from HAR](../network.md#replaying-from-har).
278
+ #
279
+ # Playwright will not serve requests intercepted by Service Worker from the HAR file. See
280
+ # [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
281
+ # request interception by setting `Browser.newContext.serviceWorkers` to `'block'`.
282
+ def route_from_har(har, notFound: nil, update: nil, url: nil)
283
+ wrap_impl(@impl.route_from_har(unwrap_impl(har), notFound: unwrap_impl(notFound), update: unwrap_impl(update), url: unwrap_impl(url)))
284
+ end
285
+
276
286
  # > NOTE: Service workers are only supported on Chromium-based browsers.
277
287
  #
278
288
  # All existing service workers in the context.
@@ -348,7 +358,7 @@ module Playwright
348
358
  #
349
359
  # ```python sync
350
360
  # with context.expect_event("page") as event_info:
351
- # page.click("button")
361
+ # page.locator("button").click()
352
362
  # page = event_info.value
353
363
  # ```
354
364
  def expect_event(event, predicate: nil, timeout: nil, &block)
@@ -372,13 +382,13 @@ module Playwright
372
382
  end
373
383
 
374
384
  # @nodoc
375
- def options=(req)
376
- wrap_impl(@impl.options=(unwrap_impl(req)))
385
+ def pause
386
+ wrap_impl(@impl.pause)
377
387
  end
378
388
 
379
389
  # @nodoc
380
- def pause
381
- wrap_impl(@impl.pause)
390
+ def options=(req)
391
+ wrap_impl(@impl.options=(unwrap_impl(req)))
382
392
  end
383
393
 
384
394
  # @nodoc
@@ -18,7 +18,9 @@ module Playwright
18
18
  # ```
19
19
  class BrowserType < PlaywrightApi
20
20
 
21
- # This method attaches Playwright to an existing browser instance.
21
+ # This method attaches Playwright to an existing browser instance. When connecting to another browser launched via
22
+ # `BrowserType.launchServer` in Node.js, the major and minor version needs to match the client version (1.2.3 → is
23
+ # compatible with 1.2.x).
22
24
  def connect(wsEndpoint, headers: nil, slowMo: nil, timeout: nil)
23
25
  raise NotImplementedError.new('connect is not implemented yet.')
24
26
  end
@@ -124,12 +126,16 @@ module Playwright
124
126
  offline: nil,
125
127
  permissions: nil,
126
128
  proxy: nil,
129
+ record_har_content: nil,
130
+ record_har_mode: nil,
127
131
  record_har_omit_content: nil,
128
132
  record_har_path: nil,
133
+ record_har_url_filter: nil,
129
134
  record_video_dir: nil,
130
135
  record_video_size: nil,
131
136
  reducedMotion: nil,
132
137
  screen: nil,
138
+ serviceWorkers: nil,
133
139
  slowMo: nil,
134
140
  strictSelectors: nil,
135
141
  timeout: nil,
@@ -138,7 +144,7 @@ module Playwright
138
144
  userAgent: nil,
139
145
  viewport: nil,
140
146
  &block)
141
- wrap_impl(@impl.launch_persistent_context(unwrap_impl(userDataDir), acceptDownloads: unwrap_impl(acceptDownloads), args: unwrap_impl(args), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), channel: unwrap_impl(channel), chromiumSandbox: unwrap_impl(chromiumSandbox), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), devtools: unwrap_impl(devtools), downloadsPath: unwrap_impl(downloadsPath), env: unwrap_impl(env), executablePath: unwrap_impl(executablePath), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), geolocation: unwrap_impl(geolocation), handleSIGHUP: unwrap_impl(handleSIGHUP), handleSIGINT: unwrap_impl(handleSIGINT), handleSIGTERM: unwrap_impl(handleSIGTERM), hasTouch: unwrap_impl(hasTouch), headless: unwrap_impl(headless), httpCredentials: unwrap_impl(httpCredentials), ignoreDefaultArgs: unwrap_impl(ignoreDefaultArgs), 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), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), slowMo: unwrap_impl(slowMo), strictSelectors: unwrap_impl(strictSelectors), timeout: unwrap_impl(timeout), timezoneId: unwrap_impl(timezoneId), tracesDir: unwrap_impl(tracesDir), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
147
+ wrap_impl(@impl.launch_persistent_context(unwrap_impl(userDataDir), acceptDownloads: unwrap_impl(acceptDownloads), args: unwrap_impl(args), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), channel: unwrap_impl(channel), chromiumSandbox: unwrap_impl(chromiumSandbox), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), devtools: unwrap_impl(devtools), downloadsPath: unwrap_impl(downloadsPath), env: unwrap_impl(env), executablePath: unwrap_impl(executablePath), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), geolocation: unwrap_impl(geolocation), handleSIGHUP: unwrap_impl(handleSIGHUP), handleSIGINT: unwrap_impl(handleSIGINT), handleSIGTERM: unwrap_impl(handleSIGTERM), hasTouch: unwrap_impl(hasTouch), headless: unwrap_impl(headless), httpCredentials: unwrap_impl(httpCredentials), ignoreDefaultArgs: unwrap_impl(ignoreDefaultArgs), 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_content: unwrap_impl(record_har_content), record_har_mode: unwrap_impl(record_har_mode), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_har_url_filter: unwrap_impl(record_har_url_filter), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), serviceWorkers: unwrap_impl(serviceWorkers), slowMo: unwrap_impl(slowMo), strictSelectors: unwrap_impl(strictSelectors), timeout: unwrap_impl(timeout), timezoneId: unwrap_impl(timezoneId), tracesDir: unwrap_impl(tracesDir), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
142
148
  end
143
149
 
144
150
  # Returns browser name. For example: `'chromium'`, `'webkit'` or `'firefox'`.
@@ -7,7 +7,7 @@ module Playwright
7
7
  #
8
8
  # ```python sync
9
9
  # with page.expect_download() as download_info:
10
- # page.click("a")
10
+ # page.locator("a").click()
11
11
  # download = download_info.value
12
12
  # # wait for download to complete
13
13
  # path = download.path()
@@ -45,7 +45,7 @@ module Playwright
45
45
  # This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
46
46
  # calculated relative to the main frame viewport - which is usually the same as the browser window.
47
47
  #
48
- # Scrolling affects the returned bonding box, similarly to
48
+ # Scrolling affects the returned bounding box, similarly to
49
49
  # [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That
50
50
  # means `x` and/or `y` may be negative.
51
51
  #
@@ -394,17 +394,6 @@ module Playwright
394
394
  # # multiple selection
395
395
  # handle.select_option(value=["red", "green", "blue"])
396
396
  # ```
397
- #
398
- # ```python sync
399
- # # single selection matching the value
400
- # handle.select_option("blue")
401
- # # single selection matching both the value and the label
402
- # handle.select_option(label="blue")
403
- # # multiple selection
404
- # handle.select_option("red", "green", "blue")
405
- # # multiple selection for blue, red and second option
406
- # handle.select_option(value="blue", { index: 2 }, "red")
407
- # ```
408
397
  def select_option(
409
398
  element: nil,
410
399
  index: nil,
@@ -3,7 +3,7 @@ module Playwright
3
3
  #
4
4
  # ```python sync
5
5
  # with page.expect_file_chooser() as fc_info:
6
- # page.click("upload")
6
+ # page.locator("upload").click()
7
7
  # file_chooser = fc_info.value
8
8
  # file_chooser.set_files("myfile.pdf")
9
9
  # ```
@@ -18,7 +18,7 @@ module Playwright
18
18
  # This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
19
19
  # calculated relative to the main frame viewport - which is usually the same as the browser window.
20
20
  #
21
- # Scrolling affects the returned bonding box, similarly to
21
+ # Scrolling affects the returned bounding box, similarly to
22
22
  # [Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That
23
23
  # means `x` and/or `y` may be negative.
24
24
  #
@@ -224,7 +224,17 @@ module Playwright
224
224
  wrap_impl(@impl.fill(unwrap_impl(value), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
225
225
  end
226
226
 
227
- # This method narrows existing locator according to the options, for example filters by text.
227
+ # This method narrows existing locator according to the options, for example filters by text. It can be chained to filter
228
+ # multiple times.
229
+ #
230
+ # ```python sync
231
+ # row_locator = page.locator("tr")
232
+ # # ...
233
+ # row_locator
234
+ # .filter(has_text="text in column 1")
235
+ # .filter(has=page.locator("tr", has_text="column 2 button"))
236
+ # .screenshot()
237
+ # ```
228
238
  def filter(has: nil, hasText: nil)
229
239
  wrap_impl(@impl.filter(has: unwrap_impl(has), hasText: unwrap_impl(hasText)))
230
240
  end
@@ -254,6 +264,7 @@ module Playwright
254
264
  def get_attribute(name, timeout: nil)
255
265
  wrap_impl(@impl.get_attribute(unwrap_impl(name), timeout: unwrap_impl(timeout)))
256
266
  end
267
+ alias_method :[], :get_attribute
257
268
 
258
269
  # Highlight the corresponding element(s) on the screen. Useful for debugging, don't commit the code that uses
259
270
  # [`method: Locator.highlight`].
@@ -418,17 +429,6 @@ module Playwright
418
429
  # # multiple selection
419
430
  # element.select_option(value=["red", "green", "blue"])
420
431
  # ```
421
- #
422
- # ```python sync
423
- # # single selection matching the value
424
- # element.select_option("blue")
425
- # # single selection matching both the value and the label
426
- # element.select_option(label="blue")
427
- # # multiple selection
428
- # element.select_option("red", "green", "blue")
429
- # # multiple selection for blue, red and second option
430
- # element.select_option(value="blue", { index: 2 }, "red")
431
- # ```
432
432
  def select_option(
433
433
  element: nil,
434
434
  index: nil,
@@ -44,6 +44,9 @@ module Playwright
44
44
  # ```
45
45
  class Page < PlaywrightApi
46
46
 
47
+ # **DEPRECATED** This property is deprecated. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you
48
+ # need to test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for
49
+ # integration with Axe.
47
50
  def accessibility # property
48
51
  wrap_impl(@impl.accessibility)
49
52
  end
@@ -853,7 +856,7 @@ module Playwright
853
856
  # > NOTE: The handler will only be called for the first url if the response is a redirect.
854
857
  # > NOTE: [`method: Page.route`] will not intercept requests intercepted by Service Worker. See
855
858
  # [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
856
- # request interception. Via `await context.addInitScript(() => delete window.navigator.serviceWorker);`
859
+ # request interception by setting `Browser.newContext.serviceWorkers` to `'block'`.
857
860
  #
858
861
  # An example of a naive handler that aborts all image requests:
859
862
  #
@@ -895,6 +898,16 @@ module Playwright
895
898
  wrap_impl(@impl.route(unwrap_impl(url), unwrap_impl(handler), times: unwrap_impl(times)))
896
899
  end
897
900
 
901
+ # If specified the network requests that are made in the page will be served from the HAR file. Read more about
902
+ # [Replaying from HAR](../network.md#replaying-from-har).
903
+ #
904
+ # Playwright will not serve requests intercepted by Service Worker from the HAR file. See
905
+ # [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using
906
+ # request interception by setting `Browser.newContext.serviceWorkers` to `'block'`.
907
+ def route_from_har(har, notFound: nil, update: nil, url: nil)
908
+ wrap_impl(@impl.route_from_har(unwrap_impl(har), notFound: unwrap_impl(notFound), update: unwrap_impl(update), url: unwrap_impl(url)))
909
+ end
910
+
898
911
  # Returns the buffer with the captured screenshot.
899
912
  def screenshot(
900
913
  animations: nil,
@@ -1399,6 +1412,11 @@ module Playwright
1399
1412
  wrap_impl(@impl.owned_context=(unwrap_impl(req)))
1400
1413
  end
1401
1414
 
1415
+ # @nodoc
1416
+ def guid
1417
+ wrap_impl(@impl.guid)
1418
+ end
1419
+
1402
1420
  # @nodoc
1403
1421
  def start_js_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
1404
1422
  wrap_impl(@impl.start_js_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
@@ -1419,11 +1437,6 @@ module Playwright
1419
1437
  wrap_impl(@impl.stop_css_coverage)
1420
1438
  end
1421
1439
 
1422
- # @nodoc
1423
- def guid
1424
- wrap_impl(@impl.guid)
1425
- end
1426
-
1427
1440
  # -- inherited from EventEmitter --
1428
1441
  # @nodoc
1429
1442
  def off(event, callback)
@@ -35,7 +35,9 @@ module Playwright
35
35
  wrap_impl(@impl.frame)
36
36
  end
37
37
 
38
- # **DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use [`method: Request.allHeaders`] instead.
38
+ # An object with the request HTTP headers. The header names are lower-cased. Note that this method does not return
39
+ # security-related headers, including cookie-related ones. You can use [`method: Request.allHeaders`] for complete list of
40
+ # headers that include `cookie` information.
39
41
  def headers
40
42
  wrap_impl(@impl.headers)
41
43
  end
@@ -149,6 +151,11 @@ module Playwright
149
151
  wrap_impl(@impl.url)
150
152
  end
151
153
 
154
+ # @nodoc
155
+ def apply_fallback_overrides(overrides)
156
+ wrap_impl(@impl.apply_fallback_overrides(unwrap_impl(overrides)))
157
+ end
158
+
152
159
  # @nodoc
153
160
  def header_values(name)
154
161
  wrap_impl(@impl.header_values(unwrap_impl(name)))
@@ -22,7 +22,15 @@ module Playwright
22
22
  wrap_impl(@impl.frame)
23
23
  end
24
24
 
25
- # **DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use [`method: Response.allHeaders`] instead.
25
+ # Indicates whether this Response was fulfilled by a Service Worker's Fetch Handler (i.e. via
26
+ # [FetchEvent.respondWith](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith)).
27
+ def from_service_worker
28
+ wrap_impl(@impl.from_service_worker)
29
+ end
30
+
31
+ # An object with the response HTTP headers. The header names are lower-cased. Note that this method does not return
32
+ # security-related headers, including cookie-related ones. You can use [`method: Response.allHeaders`] for complete list
33
+ # of headers that include `cookie` information.
26
34
  def headers
27
35
  wrap_impl(@impl.headers)
28
36
  end
@@ -92,6 +100,11 @@ module Playwright
92
100
  wrap_impl(@impl.url)
93
101
  end
94
102
 
103
+ # @nodoc
104
+ def from_service_worker?
105
+ wrap_impl(@impl.from_service_worker?)
106
+ end
107
+
95
108
  # @nodoc
96
109
  def ok?
97
110
  wrap_impl(@impl.ok?)
@@ -17,8 +17,8 @@ module Playwright
17
17
  # # override headers
18
18
  # headers = {
19
19
  # **request.headers,
20
- # "foo": "bar" # set "foo" header
21
- # "origin": None # remove "origin" header
20
+ # "foo": "foo-value" # set "foo" header
21
+ # "bar": None # remove "bar" header
22
22
  # }
23
23
  # route.continue_(headers=headers)
24
24
  # }
@@ -28,6 +28,60 @@ module Playwright
28
28
  wrap_impl(@impl.continue(headers: unwrap_impl(headers), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
29
29
  end
30
30
 
31
+ # When several routes match the given pattern, they run in the order opposite to their registration. That way the last
32
+ # registered route can always override all the previous ones. In the example below, request will be handled by the
33
+ # bottom-most handler first, then it'll fall back to the previous one and in the end will be aborted by the first
34
+ # registered route.
35
+ #
36
+ # ```python sync
37
+ # page.route("**/*", lambda route: route.abort()) # Runs last.
38
+ # page.route("**/*", lambda route: route.fallback()) # Runs second.
39
+ # page.route("**/*", lambda route: route.fallback()) # Runs first.
40
+ # ```
41
+ #
42
+ # Registering multiple routes is useful when you want separate handlers to handle different kinds of requests, for example
43
+ # API calls vs page resources or GET requests vs POST requests as in the example below.
44
+ #
45
+ # ```python sync
46
+ # # Handle GET requests.
47
+ # def handle_post(route):
48
+ # if route.request.method != "GET":
49
+ # route.fallback()
50
+ # return
51
+ # # Handling GET only.
52
+ # # ...
53
+ #
54
+ # # Handle POST requests.
55
+ # def handle_post(route):
56
+ # if route.request.method != "POST":
57
+ # route.fallback()
58
+ # return
59
+ # # Handling POST only.
60
+ # # ...
61
+ #
62
+ # page.route("**/*", handle_get)
63
+ # page.route("**/*", handle_post)
64
+ # ```
65
+ #
66
+ # One can also modify request while falling back to the subsequent handler, that way intermediate route handler can modify
67
+ # url, method, headers and postData of the request.
68
+ #
69
+ # ```python sync
70
+ # def handle(route, request):
71
+ # # override headers
72
+ # headers = {
73
+ # **request.headers,
74
+ # "foo": "foo-value" # set "foo" header
75
+ # "bar": None # remove "bar" header
76
+ # }
77
+ # route.fallback(headers=headers)
78
+ # }
79
+ # page.route("**/*", handle)
80
+ # ```
81
+ def fallback(headers: nil, method: nil, postData: nil, url: nil)
82
+ wrap_impl(@impl.fallback(headers: unwrap_impl(headers), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
83
+ end
84
+
31
85
  # Fulfills route's request with given response.
32
86
  #
33
87
  # An example of fulfilling all requests with 404 responses:
@@ -59,6 +113,11 @@ module Playwright
59
113
  wrap_impl(@impl.request)
60
114
  end
61
115
 
116
+ # @nodoc
117
+ def redirect_navigation_request(url)
118
+ wrap_impl(@impl.redirect_navigation_request(unwrap_impl(url)))
119
+ end
120
+
62
121
  # -- inherited from EventEmitter --
63
122
  # @nodoc
64
123
  def off(event, callback)
@@ -30,7 +30,7 @@ module Playwright
30
30
  # # Use the selector prefixed with its name.
31
31
  # button = page.locator('tag=button')
32
32
  # # Combine it with other selector engines.
33
- # page.click('tag=div >> text="Click me"')
33
+ # page.locator('tag=div >> text="Click me"').click()
34
34
  # # Can use it in any methods supporting selectors.
35
35
  # button_count = page.locator('tag=button').count()
36
36
  # print(button_count)
@@ -41,7 +41,7 @@ module Playwright
41
41
  # page.goto("https://playwright.dev")
42
42
  #
43
43
  # context.tracing.start_chunk()
44
- # page.click("text=Get Started")
44
+ # page.locator("text=Get Started").click()
45
45
  # # Everything between start_chunk and stop_chunk will be recorded in the trace.
46
46
  # context.tracing.stop_chunk(path = "trace1.zip")
47
47
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playwright-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.22.0
4
+ version: 1.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-18 00:00:00.000000000 Z
11
+ date: 2022-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -316,10 +316,12 @@ files:
316
316
  - lib/playwright/events.rb
317
317
  - lib/playwright/file_chooser_impl.rb
318
318
  - lib/playwright/frame_locator_impl.rb
319
+ - lib/playwright/har_router.rb
319
320
  - lib/playwright/http_headers.rb
320
321
  - lib/playwright/input_files.rb
321
322
  - lib/playwright/javascript.rb
322
323
  - lib/playwright/javascript/expression.rb
324
+ - lib/playwright/javascript/regex.rb
323
325
  - lib/playwright/javascript/value_parser.rb
324
326
  - lib/playwright/javascript/value_serializer.rb
325
327
  - lib/playwright/javascript/visitor_info.rb
@@ -362,7 +364,6 @@ files:
362
364
  - lib/playwright_api/frame_locator.rb
363
365
  - lib/playwright_api/js_handle.rb
364
366
  - lib/playwright_api/keyboard.rb
365
- - lib/playwright_api/local_utils.rb
366
367
  - lib/playwright_api/locator.rb
367
368
  - lib/playwright_api/mouse.rb
368
369
  - lib/playwright_api/page.rb
@@ -398,5 +399,5 @@ requirements: []
398
399
  rubygems_version: 3.3.7
399
400
  signing_key:
400
401
  specification_version: 4
401
- summary: The Ruby binding of playwright driver 1.22.1
402
+ summary: The Ruby binding of playwright driver 1.25.0
402
403
  test_files: []
@@ -1,9 +0,0 @@
1
- module Playwright
2
- class LocalUtils < PlaywrightApi
3
-
4
- # @nodoc
5
- def zip(zip_file, name_value_array)
6
- wrap_impl(@impl.zip(unwrap_impl(zip_file), unwrap_impl(name_value_array)))
7
- end
8
- end
9
- end