playwright-ruby-client 1.40.0 → 1.42.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/docs/api/browser_context.md +17 -10
  3. data/documentation/docs/api/element_handle.md +3 -2
  4. data/documentation/docs/api/experimental/android.md +0 -6
  5. data/documentation/docs/api/frame.md +1 -1
  6. data/documentation/docs/api/keyboard.md +1 -1
  7. data/documentation/docs/api/locator.md +2 -1
  8. data/documentation/docs/api/locator_assertions.md +5 -5
  9. data/documentation/docs/api/page.md +21 -11
  10. data/documentation/docs/api/tracing.md +2 -2
  11. data/documentation/docs/include/api_coverage.md +3 -0
  12. data/documentation/docusaurus.config.js +6 -0
  13. data/documentation/package.json +2 -2
  14. data/documentation/yarn.lock +1732 -1815
  15. data/lib/playwright/channel_owners/browser_context.rb +6 -1
  16. data/lib/playwright/channel_owners/element_handle.rb +2 -0
  17. data/lib/playwright/channel_owners/frame.rb +8 -1
  18. data/lib/playwright/channel_owners/page.rb +13 -2
  19. data/lib/playwright/connection.rb +4 -2
  20. data/lib/playwright/har_router.rb +7 -0
  21. data/lib/playwright/javascript/source_url.rb +16 -0
  22. data/lib/playwright/javascript.rb +1 -0
  23. data/lib/playwright/locator_impl.rb +2 -0
  24. data/lib/playwright/version.rb +2 -2
  25. data/lib/playwright/waiter.rb +8 -6
  26. data/lib/playwright_api/android.rb +0 -6
  27. data/lib/playwright_api/browser_context.rb +7 -1
  28. data/lib/playwright_api/element_handle.rb +4 -3
  29. data/lib/playwright_api/frame.rb +1 -1
  30. data/lib/playwright_api/keyboard.rb +1 -1
  31. data/lib/playwright_api/locator.rb +3 -2
  32. data/lib/playwright_api/locator_assertions.rb +6 -6
  33. data/lib/playwright_api/page.rb +80 -10
  34. data/lib/playwright_api/request.rb +4 -4
  35. data/lib/playwright_api/response.rb +4 -4
  36. data/lib/playwright_api/tracing.rb +2 -2
  37. data/playwright.gemspec +3 -3
  38. data/sig/playwright.rbs +7 -5
  39. metadata +15 -14
@@ -299,7 +299,7 @@ module Playwright
299
299
  def add_init_script(path: nil, script: nil)
300
300
  source =
301
301
  if path
302
- File.read(path)
302
+ JavaScript::SourceUrl.new(File.read(path), path).to_s
303
303
  elsif script
304
304
  script
305
305
  else
@@ -335,6 +335,11 @@ module Playwright
335
335
  update_interception_patterns
336
336
  end
337
337
 
338
+ def unroute_all(behavior: nil)
339
+ @routes.clear
340
+ update_interception_patterns
341
+ end
342
+
338
343
  def unroute(url, handler: nil)
339
344
  @routes.reject! do |handler_entry|
340
345
  handler_entry.same_value?(url: url, handler: handler)
@@ -301,6 +301,7 @@ module Playwright
301
301
  path: nil,
302
302
  quality: nil,
303
303
  scale: nil,
304
+ style: nil,
304
305
  timeout: nil,
305
306
  type: nil)
306
307
 
@@ -312,6 +313,7 @@ module Playwright
312
313
  path: path,
313
314
  quality: quality,
314
315
  scale: scale,
316
+ style: style,
315
317
  timeout: timeout,
316
318
  type: type,
317
319
  }.compact
@@ -163,6 +163,13 @@ module Playwright
163
163
  actual_state == option_state
164
164
  }
165
165
  waiter.wait_for_event(@event_emitter, 'loadstate', predicate: predicate)
166
+
167
+ # Sometimes event is already fired durting setup.
168
+ if @load_states.include?(option_state)
169
+ waiter.force_fulfill(option_state)
170
+ return
171
+ end
172
+
166
173
  waiter.result.value!
167
174
 
168
175
  nil
@@ -293,7 +300,7 @@ module Playwright
293
300
  url: url,
294
301
  }.compact
295
302
  if path
296
- params[:content] = "#{File.read(path)}\n//# sourceURL=#{path}"
303
+ params[:content] = JavaScript::SourceUrl.new(File.read(path), path).to_s
297
304
  end
298
305
  resp = @channel.send_message_to_server('addScriptTag', params)
299
306
  ChannelOwners::ElementHandle.from(resp)
@@ -397,7 +397,7 @@ module Playwright
397
397
  def add_init_script(path: nil, script: nil)
398
398
  source =
399
399
  if path
400
- File.read(path)
400
+ JavaScript::SourceUrl.new(File.read(path), path).to_s
401
401
  elsif script
402
402
  script
403
403
  else
@@ -414,6 +414,11 @@ module Playwright
414
414
  update_interception_patterns
415
415
  end
416
416
 
417
+ def unroute_all(behavior: nil)
418
+ @routes.clear
419
+ update_interception_patterns
420
+ end
421
+
417
422
  def unroute(url, handler: nil)
418
423
  @routes.reject! do |handler_entry|
419
424
  handler_entry.same_value?(url: url, handler: handler)
@@ -457,6 +462,7 @@ module Playwright
457
462
  path: nil,
458
463
  quality: nil,
459
464
  scale: nil,
465
+ style: nil,
460
466
  timeout: nil,
461
467
  type: nil)
462
468
 
@@ -470,6 +476,7 @@ module Playwright
470
476
  animations: animations,
471
477
  caret: caret,
472
478
  scale: scale,
479
+ style: style,
473
480
  timeout: timeout,
474
481
  }.compact
475
482
  if mask.is_a?(Enumerable)
@@ -829,7 +836,9 @@ module Playwright
829
836
  preferCSSPageSize: nil,
830
837
  printBackground: nil,
831
838
  scale: nil,
832
- width: nil)
839
+ width: nil,
840
+ tagged: nil,
841
+ outline: nil)
833
842
 
834
843
  params = {
835
844
  displayHeaderFooter: displayHeaderFooter,
@@ -844,6 +853,8 @@ module Playwright
844
853
  printBackground: printBackground,
845
854
  scale: scale,
846
855
  width: width,
856
+ tagged: tagged,
857
+ outline: outline,
847
858
  }.compact
848
859
  encoded_binary = @channel.send_message_to_server('pdf', params)
849
860
  decoded_binary = Base64.strict_decode64(encoded_binary)
@@ -80,7 +80,9 @@ module Playwright
80
80
  @callbacks[id] = callback
81
81
 
82
82
  _metadata = {}
83
+ frames = []
83
84
  if metadata
85
+ frames = metadata[:stack]
84
86
  _metadata[:wallTime] = metadata[:wallTime]
85
87
  _metadata[:apiName] = metadata[:apiName]
86
88
  _metadata[:location] = metadata[:stack].first
@@ -104,8 +106,8 @@ module Playwright
104
106
  raise unless err.is_a?(Transport::AlreadyDisconnectedError)
105
107
  end
106
108
 
107
- if @tracing_count > 0 && !metadata[:stack].empty? && guid != 'localUtils'
108
- @local_utils.add_stack_to_tracing_no_reply(id, metadata[:stack])
109
+ if @tracing_count > 0 && !frames.empty? && guid != 'localUtils'
110
+ @local_utils.add_stack_to_tracing_no_reply(id, frames)
109
111
  end
110
112
  end
111
113
 
@@ -46,6 +46,13 @@ module Playwright
46
46
  puts "pw:api HAR: #{request.url} redirected to #{redirect_url}" if @debug
47
47
  route.redirect_navigation_request(redirect_url)
48
48
  when 'fulfill'
49
+ # If the response status is -1, the request was canceled or stalled, so we just stall it here.
50
+ # See https://github.com/microsoft/playwright/issues/29311.
51
+ # TODO: it'd be better to abort such requests, but then we likely need to respect the timing,
52
+ # because the request might have been stalled for a long time until the very end of the
53
+ # test when HAR was recorded but we'd abort it immediately.
54
+ return if response['status'] == -1
55
+
49
56
  route.fulfill(
50
57
  status: response['status'],
51
58
  headers: response['headers'].map { |header| [header['name'], header['value']] }.to_h,
@@ -0,0 +1,16 @@
1
+ module Playwright
2
+ module JavaScript
3
+ class SourceUrl
4
+ # @param source [String]
5
+ # @param path [String]
6
+ def initialize(source, path)
7
+ @source = source
8
+ @source_url = path.to_s.gsub("\n", '')
9
+ end
10
+
11
+ def to_s
12
+ "#{@source}\n//# sourceURL=#{@source_url}"
13
+ end
14
+ end
15
+ end
16
+ end
@@ -2,3 +2,4 @@ require_relative './javascript/expression'
2
2
  require_relative './javascript/value_parser'
3
3
  require_relative './javascript/value_serializer'
4
4
  require_relative './javascript/regex'
5
+ require_relative './javascript/source_url'
@@ -363,6 +363,7 @@ module Playwright
363
363
  path: nil,
364
364
  quality: nil,
365
365
  scale: nil,
366
+ style: nil,
366
367
  timeout: nil,
367
368
  type: nil)
368
369
 
@@ -376,6 +377,7 @@ module Playwright
376
377
  path: path,
377
378
  quality: quality,
378
379
  scale: scale,
380
+ style: style,
379
381
  timeout: options[:timeout],
380
382
  type: type)
381
383
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playwright
4
- VERSION = '1.40.0'
5
- COMPATIBLE_PLAYWRIGHT_VERSION = '1.40.1'
4
+ VERSION = '1.42.1'
5
+ COMPATIBLE_PLAYWRIGHT_VERSION = '1.42.1'
6
6
  end
@@ -75,21 +75,23 @@ module Playwright
75
75
  @registered_listeners.clear
76
76
  end
77
77
 
78
+ def force_fulfill(result)
79
+ fulfill(result)
80
+ end
81
+
78
82
  private def fulfill(result)
79
83
  cleanup
80
- unless @result.resolved?
81
- @result.fulfill(result)
82
- end
84
+ return if @result.resolved?
85
+ @result.fulfill(result)
83
86
  wait_for_event_info_after
84
87
  end
85
88
 
86
89
  private def reject(error)
87
90
  cleanup
91
+ return if @result.resolved?
88
92
  klass = error.is_a?(TimeoutError) ? TimeoutError : Error
89
93
  ex = klass.new(message: "#{error.message}#{format_log_recording(@logs)}")
90
- unless @result.resolved?
91
- @result.reject(ex)
92
- end
94
+ @result.reject(ex)
93
95
  wait_for_event_info_after(error: ex)
94
96
  end
95
97
 
@@ -16,12 +16,6 @@ module Playwright
16
16
  # *How to run*
17
17
  #
18
18
  # An example of the Android automation script would be:
19
- #
20
- # Note that since you don't need Playwright to install web browsers when testing Android, you can omit browser download via setting the following environment variable when installing Playwright:
21
- #
22
- # ```bash js
23
- # PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
24
- # ```
25
19
  class Android < PlaywrightApi
26
20
 
27
21
  #
@@ -280,7 +280,7 @@ module Playwright
280
280
  # It is possible to examine the request to decide the route action. For example, mocking all requests that contain some post data, and leaving all other requests as is:
281
281
  #
282
282
  # ```python sync
283
- # def handle_route(route):
283
+ # def handle_route(route: Route):
284
284
  # if ("my-string" in route.request.post_data):
285
285
  # route.fulfill(body="mocked-data")
286
286
  # else:
@@ -384,6 +384,12 @@ module Playwright
384
384
  wrap_impl(@impl.storage_state(path: unwrap_impl(path)))
385
385
  end
386
386
 
387
+ #
388
+ # Removes all routes created with [`method: BrowserContext.route`] and [`method: BrowserContext.routeFromHAR`].
389
+ def unroute_all(behavior: nil)
390
+ wrap_impl(@impl.unroute_all(behavior: unwrap_impl(behavior)))
391
+ end
392
+
387
393
  #
388
394
  # Removes a route created with [`method: BrowserContext.route`]. When `handler` is not specified, removes all
389
395
  # routes for the `url`.
@@ -346,7 +346,7 @@ module Playwright
346
346
  # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
347
347
  # respective texts.
348
348
  #
349
- # Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
349
+ # Shortcuts such as `key: "Control+o"`, `key: "Control++` or `key: "Control+Shift+T"` are supported as well. When specified with the
350
350
  # modifier, modifier is pressed and being held while the subsequent key is being pressed.
351
351
  def press(key, delay: nil, noWaitAfter: nil, timeout: nil)
352
352
  wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
@@ -382,9 +382,10 @@ module Playwright
382
382
  path: nil,
383
383
  quality: nil,
384
384
  scale: nil,
385
+ style: nil,
385
386
  timeout: nil,
386
387
  type: nil)
387
- wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), caret: unwrap_impl(caret), mask: unwrap_impl(mask), maskColor: unwrap_impl(maskColor), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), scale: unwrap_impl(scale), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
388
+ wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), caret: unwrap_impl(caret), mask: unwrap_impl(mask), maskColor: unwrap_impl(maskColor), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), scale: unwrap_impl(scale), style: unwrap_impl(style), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
388
389
  end
389
390
 
390
391
  #
@@ -538,7 +539,7 @@ module Playwright
538
539
  # Depending on the `state` parameter, this method waits for one of the [actionability](../actionability.md) checks
539
540
  # to pass. This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
540
541
  # - `"visible"` Wait until the element is [visible](../actionability.md#visible).
541
- # - `"hidden"` Wait until the element is [not visible](../actionability.md#visible) or [not attached](../actionability.md#attached). Note that waiting for hidden does not throw when the element detaches.
542
+ # - `"hidden"` Wait until the element is [not visible](../actionability.md#visible) or not attached. Note that waiting for hidden does not throw when the element detaches.
542
543
  # - `"stable"` Wait until the element is both [visible](../actionability.md#visible) and [stable](../actionability.md#stable).
543
544
  # - `"enabled"` Wait until the element is [enabled](../actionability.md#enabled).
544
545
  # - `"disabled"` Wait until the element is [not enabled](../actionability.md#enabled).
@@ -714,7 +714,7 @@ module Playwright
714
714
  # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
715
715
  # respective texts.
716
716
  #
717
- # Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
717
+ # Shortcuts such as `key: "Control+o"`, `key: "Control++` or `key: "Control+Shift+T"` are supported as well. When specified with the
718
718
  # modifier, modifier is pressed and being held while the subsequent key is being pressed.
719
719
  def press(
720
720
  selector,
@@ -99,7 +99,7 @@ module Playwright
99
99
  # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
100
100
  # respective texts.
101
101
  #
102
- # Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
102
+ # Shortcuts such as `key: "Control+o"`, `key: "Control++` or `key: "Control+Shift+T"` are supported as well. When specified with the
103
103
  # modifier, modifier is pressed and being held while the subsequent key is being pressed.
104
104
  #
105
105
  # **Usage**
@@ -890,7 +890,7 @@ module Playwright
890
890
  # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
891
891
  # respective texts.
892
892
  #
893
- # Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
893
+ # Shortcuts such as `key: "Control+o"`, `key: "Control++` or `key: "Control+Shift+T"` are supported as well. When specified with the
894
894
  # modifier, modifier is pressed and being held while the subsequent key is being pressed.
895
895
  def press(key, delay: nil, noWaitAfter: nil, timeout: nil)
896
896
  wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
@@ -953,9 +953,10 @@ module Playwright
953
953
  path: nil,
954
954
  quality: nil,
955
955
  scale: nil,
956
+ style: nil,
956
957
  timeout: nil,
957
958
  type: nil)
958
- wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), caret: unwrap_impl(caret), mask: unwrap_impl(mask), maskColor: unwrap_impl(maskColor), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), scale: unwrap_impl(scale), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
959
+ wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), caret: unwrap_impl(caret), mask: unwrap_impl(mask), maskColor: unwrap_impl(maskColor), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), scale: unwrap_impl(scale), style: unwrap_impl(style), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
959
960
  end
960
961
 
961
962
  #
@@ -80,8 +80,8 @@ module Playwright
80
80
 
81
81
  #
82
82
  # The opposite of [`method: LocatorAssertions.toHaveAttribute`].
83
- def not_to_have_attribute(name, value, timeout: nil)
84
- wrap_impl(@impl.not_to_have_attribute(unwrap_impl(name), unwrap_impl(value), timeout: unwrap_impl(timeout)))
83
+ def not_to_have_attribute(name, value, ignoreCase: nil, timeout: nil)
84
+ wrap_impl(@impl.not_to_have_attribute(unwrap_impl(name), unwrap_impl(value), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout)))
85
85
  end
86
86
 
87
87
  #
@@ -133,7 +133,7 @@ module Playwright
133
133
  end
134
134
 
135
135
  #
136
- # Ensures that `Locator` points to an [attached](../actionability.md#attached) DOM node.
136
+ # Ensures that `Locator` points to an element that is [connected](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected) to a Document or a ShadowRoot.
137
137
  #
138
138
  # **Usage**
139
139
  #
@@ -274,7 +274,7 @@ module Playwright
274
274
  end
275
275
 
276
276
  #
277
- # Ensures that `Locator` points to an [attached](../actionability.md#attached) and [visible](../actionability.md#visible) DOM node.
277
+ # Ensures that `Locator` points to an attached and [visible](../actionability.md#visible) DOM node.
278
278
  #
279
279
  # To check that at least one element from the list is visible, use [`method: Locator.first`].
280
280
  #
@@ -299,7 +299,7 @@ module Playwright
299
299
  end
300
300
 
301
301
  #
302
- # Ensures the `Locator` points to an element that contains the given text. You can use regular expressions for the value as well.
302
+ # Ensures the `Locator` points to an element that contains the given text. All nested elements will be considered when computing the text content of the element. You can use regular expressions for the value as well.
303
303
  #
304
304
  # **Details**
305
305
  #
@@ -461,7 +461,7 @@ module Playwright
461
461
  end
462
462
 
463
463
  #
464
- # Ensures the `Locator` points to an element with the given text. You can use regular expressions for the value as well.
464
+ # Ensures the `Locator` points to an element with the given text. All nested elements will be considered when computing the text content of the element. You can use regular expressions for the value as well.
465
465
  #
466
466
  # **Details**
467
467
  #
@@ -1010,13 +1010,15 @@ module Playwright
1010
1010
  height: nil,
1011
1011
  landscape: nil,
1012
1012
  margin: nil,
1013
+ outline: nil,
1013
1014
  pageRanges: nil,
1014
1015
  path: nil,
1015
1016
  preferCSSPageSize: nil,
1016
1017
  printBackground: nil,
1017
1018
  scale: nil,
1019
+ tagged: nil,
1018
1020
  width: nil)
1019
- wrap_impl(@impl.pdf(displayHeaderFooter: unwrap_impl(displayHeaderFooter), footerTemplate: unwrap_impl(footerTemplate), format: unwrap_impl(format), headerTemplate: unwrap_impl(headerTemplate), height: unwrap_impl(height), landscape: unwrap_impl(landscape), margin: unwrap_impl(margin), pageRanges: unwrap_impl(pageRanges), path: unwrap_impl(path), preferCSSPageSize: unwrap_impl(preferCSSPageSize), printBackground: unwrap_impl(printBackground), scale: unwrap_impl(scale), width: unwrap_impl(width)))
1021
+ wrap_impl(@impl.pdf(displayHeaderFooter: unwrap_impl(displayHeaderFooter), footerTemplate: unwrap_impl(footerTemplate), format: unwrap_impl(format), headerTemplate: unwrap_impl(headerTemplate), height: unwrap_impl(height), landscape: unwrap_impl(landscape), margin: unwrap_impl(margin), outline: unwrap_impl(outline), pageRanges: unwrap_impl(pageRanges), path: unwrap_impl(path), preferCSSPageSize: unwrap_impl(preferCSSPageSize), printBackground: unwrap_impl(printBackground), scale: unwrap_impl(scale), tagged: unwrap_impl(tagged), width: unwrap_impl(width)))
1020
1022
  end
1021
1023
 
1022
1024
  #
@@ -1037,7 +1039,7 @@ module Playwright
1037
1039
  # If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
1038
1040
  # respective texts.
1039
1041
  #
1040
- # Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
1042
+ # Shortcuts such as `key: "Control+o"`, `key: "Control++` or `key: "Control+Shift+T"` are supported as well. When specified with the
1041
1043
  # modifier, modifier is pressed and being held while the subsequent key is being pressed.
1042
1044
  #
1043
1045
  # **Usage**
@@ -1077,6 +1079,67 @@ module Playwright
1077
1079
  wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
1078
1080
  end
1079
1081
 
1082
+ #
1083
+ # Sometimes, the web page can show an overlay that obstructs elements behind it and prevents certain actions, like click, from completing. When such an overlay is shown predictably, we recommend dismissing it as a part of your test flow. However, sometimes such an overlay may appear non-deterministically, for example certain cookies consent dialogs behave this way. In this case, [`method: Page.addLocatorHandler`] allows handling an overlay during an action that it would block.
1084
+ #
1085
+ # This method registers a handler for an overlay that is executed once the locator is visible on the page. The handler should get rid of the overlay so that actions blocked by it can proceed. This is useful for nondeterministic interstitial pages or dialogs, like a cookie consent dialog.
1086
+ #
1087
+ # Note that execution time of the handler counts towards the timeout of the action/assertion that executed the handler.
1088
+ #
1089
+ # You can register multiple handlers. However, only a single handler will be running at a time. Any actions inside a handler must not require another handler to run.
1090
+ #
1091
+ # **NOTE**: Running the interceptor will alter your page state mid-test. For example it will change the currently focused element and move the mouse. Make sure that the actions that run after the interceptor are self-contained and do not rely on the focus and mouse state.
1092
+ # <br />
1093
+ # <br />
1094
+ # For example, consider a test that calls [`method: Locator.focus`] followed by [`method: Keyboard.press`]. If your handler clicks a button between these two actions, the focused element most likely will be wrong, and key press will happen on the unexpected element. Use [`method: Locator.press`] instead to avoid this problem.
1095
+ # <br />
1096
+ # <br />
1097
+ # Another example is a series of mouse actions, where [`method: Mouse.move`] is followed by [`method: Mouse.down`]. Again, when the handler runs between these two actions, the mouse position will be wrong during the mouse down. Prefer methods like [`method: Locator.click`] that are self-contained.
1098
+ #
1099
+ # **Usage**
1100
+ #
1101
+ # An example that closes a cookie dialog when it appears:
1102
+ #
1103
+ # ```python sync
1104
+ # # Setup the handler.
1105
+ # def handler():
1106
+ # page.get_by_role("button", name="Reject all cookies").click()
1107
+ # page.add_locator_handler(page.get_by_role("button", name="Accept all cookies"), handler)
1108
+ #
1109
+ # # Write the test as usual.
1110
+ # page.goto("https://example.com")
1111
+ # page.get_by_role("button", name="Start here").click()
1112
+ # ```
1113
+ #
1114
+ # An example that skips the "Confirm your security details" page when it is shown:
1115
+ #
1116
+ # ```python sync
1117
+ # # Setup the handler.
1118
+ # def handler():
1119
+ # page.get_by_role("button", name="Remind me later").click()
1120
+ # page.add_locator_handler(page.get_by_text("Confirm your security details"), handler)
1121
+ #
1122
+ # # Write the test as usual.
1123
+ # page.goto("https://example.com")
1124
+ # page.get_by_role("button", name="Start here").click()
1125
+ # ```
1126
+ #
1127
+ # An example with a custom callback on every actionability check. It uses a `<body>` locator that is always visible, so the handler is called before every actionability check:
1128
+ #
1129
+ # ```python sync
1130
+ # # Setup the handler.
1131
+ # def handler():
1132
+ # page.evaluate("window.removeObstructionsForTestIfNeeded()")
1133
+ # page.add_locator_handler(page.locator("body"), handler)
1134
+ #
1135
+ # # Write the test as usual.
1136
+ # page.goto("https://example.com")
1137
+ # page.get_by_role("button", name="Start here").click()
1138
+ # ```
1139
+ def add_locator_handler(locator, handler)
1140
+ raise NotImplementedError.new('add_locator_handler is not implemented yet.')
1141
+ end
1142
+
1080
1143
  #
1081
1144
  # This method reloads the current page, in the same way as if the user had triggered a browser refresh.
1082
1145
  # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
@@ -1117,7 +1180,7 @@ module Playwright
1117
1180
  # It is possible to examine the request to decide the route action. For example, mocking all requests that contain some post data, and leaving all other requests as is:
1118
1181
  #
1119
1182
  # ```python sync
1120
- # def handle_route(route):
1183
+ # def handle_route(route: Route):
1121
1184
  # if ("my-string" in route.request.post_data):
1122
1185
  # route.fulfill(body="mocked-data")
1123
1186
  # else:
@@ -1162,9 +1225,10 @@ module Playwright
1162
1225
  path: nil,
1163
1226
  quality: nil,
1164
1227
  scale: nil,
1228
+ style: nil,
1165
1229
  timeout: nil,
1166
1230
  type: nil)
1167
- wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), caret: unwrap_impl(caret), clip: unwrap_impl(clip), fullPage: unwrap_impl(fullPage), mask: unwrap_impl(mask), maskColor: unwrap_impl(maskColor), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), scale: unwrap_impl(scale), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
1231
+ wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), caret: unwrap_impl(caret), clip: unwrap_impl(clip), fullPage: unwrap_impl(fullPage), mask: unwrap_impl(mask), maskColor: unwrap_impl(maskColor), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), scale: unwrap_impl(scale), style: unwrap_impl(style), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
1168
1232
  end
1169
1233
 
1170
1234
  #
@@ -1376,6 +1440,12 @@ module Playwright
1376
1440
  wrap_impl(@impl.uncheck(unwrap_impl(selector), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
1377
1441
  end
1378
1442
 
1443
+ #
1444
+ # Removes all routes created with [`method: Page.route`] and [`method: Page.routeFromHAR`].
1445
+ def unroute_all(behavior: nil)
1446
+ wrap_impl(@impl.unroute_all(behavior: unwrap_impl(behavior)))
1447
+ end
1448
+
1379
1449
  #
1380
1450
  # Removes a route created with [`method: Page.route`]. When `handler` is not specified, removes all routes for
1381
1451
  # the `url`.
@@ -1674,8 +1744,8 @@ module Playwright
1674
1744
  end
1675
1745
 
1676
1746
  # @nodoc
1677
- def stop_js_coverage
1678
- wrap_impl(@impl.stop_js_coverage)
1747
+ def start_css_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
1748
+ wrap_impl(@impl.start_css_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
1679
1749
  end
1680
1750
 
1681
1751
  # @nodoc
@@ -1684,13 +1754,13 @@ module Playwright
1684
1754
  end
1685
1755
 
1686
1756
  # @nodoc
1687
- def start_css_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
1688
- wrap_impl(@impl.start_css_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
1757
+ def stop_css_coverage
1758
+ wrap_impl(@impl.stop_css_coverage)
1689
1759
  end
1690
1760
 
1691
1761
  # @nodoc
1692
- def stop_css_coverage
1693
- wrap_impl(@impl.stop_css_coverage)
1762
+ def stop_js_coverage
1763
+ wrap_impl(@impl.stop_js_coverage)
1694
1764
  end
1695
1765
 
1696
1766
  # @nodoc
@@ -196,13 +196,13 @@ module Playwright
196
196
  end
197
197
 
198
198
  # @nodoc
199
- def header_values(name)
200
- wrap_impl(@impl.header_values(unwrap_impl(name)))
199
+ def apply_fallback_overrides(overrides)
200
+ wrap_impl(@impl.apply_fallback_overrides(unwrap_impl(overrides)))
201
201
  end
202
202
 
203
203
  # @nodoc
204
- def apply_fallback_overrides(overrides)
205
- wrap_impl(@impl.apply_fallback_overrides(unwrap_impl(overrides)))
204
+ def header_values(name)
205
+ wrap_impl(@impl.header_values(unwrap_impl(name)))
206
206
  end
207
207
 
208
208
  # -- inherited from EventEmitter --
@@ -118,13 +118,13 @@ module Playwright
118
118
  end
119
119
 
120
120
  # @nodoc
121
- def ok?
122
- wrap_impl(@impl.ok?)
121
+ def from_service_worker?
122
+ wrap_impl(@impl.from_service_worker?)
123
123
  end
124
124
 
125
125
  # @nodoc
126
- def from_service_worker?
127
- wrap_impl(@impl.from_service_worker?)
126
+ def ok?
127
+ wrap_impl(@impl.ok?)
128
128
  end
129
129
 
130
130
  # -- inherited from EventEmitter --
@@ -20,7 +20,7 @@ module Playwright
20
20
  # **Usage**
21
21
  #
22
22
  # ```python sync
23
- # context.tracing.start(name="trace", screenshots=True, snapshots=True)
23
+ # context.tracing.start(screenshots=True, snapshots=True)
24
24
  # page = context.new_page()
25
25
  # page.goto("https://playwright.dev")
26
26
  # context.tracing.stop(path = "trace.zip")
@@ -40,7 +40,7 @@ module Playwright
40
40
  # **Usage**
41
41
  #
42
42
  # ```python sync
43
- # context.tracing.start(name="trace", screenshots=True, snapshots=True)
43
+ # context.tracing.start(screenshots=True, snapshots=True)
44
44
  # page = context.new_page()
45
45
  # page.goto("https://playwright.dev")
46
46
  #
data/playwright.gemspec CHANGED
@@ -33,9 +33,9 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency 'faye-websocket'
34
34
  spec.add_development_dependency 'pry-byebug'
35
35
  spec.add_development_dependency 'puma'
36
- spec.add_development_dependency 'rake', '~> 13.0.3'
37
- spec.add_development_dependency 'rspec', '~> 3.10.0 '
38
- spec.add_development_dependency 'rspec_junit_formatter' # for CircleCI.
36
+ spec.add_development_dependency 'rack', '< 3'
37
+ spec.add_development_dependency 'rake'
38
+ spec.add_development_dependency 'rspec'
39
39
  spec.add_development_dependency 'rubocop-rspec'
40
40
  spec.add_development_dependency 'sinatra'
41
41
  end