playwright-ruby-client 1.39.1 → 1.41.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/docs/api/api_request_context.md +1 -2
  3. data/documentation/docs/api/browser.md +1 -1
  4. data/documentation/docs/api/browser_context.md +10 -1
  5. data/documentation/docs/api/browser_type.md +1 -0
  6. data/documentation/docs/api/download.md +1 -2
  7. data/documentation/docs/api/element_handle.md +5 -1
  8. data/documentation/docs/api/frame.md +4 -1
  9. data/documentation/docs/api/locator.md +5 -1
  10. data/documentation/docs/api/locator_assertions.md +12 -2
  11. data/documentation/docs/api/page.md +16 -3
  12. data/documentation/docs/api/tracing.md +2 -2
  13. data/documentation/docs/article/guides/rails_integration.md +80 -51
  14. data/documentation/docs/article/guides/rspec_integration.md +59 -0
  15. data/documentation/docs/include/api_coverage.md +2 -0
  16. data/documentation/docusaurus.config.js +1 -1
  17. data/documentation/package.json +7 -7
  18. data/documentation/yarn.lock +4641 -5023
  19. data/lib/playwright/api_response_impl.rb +2 -2
  20. data/lib/playwright/channel_owners/api_request_context.rb +12 -3
  21. data/lib/playwright/channel_owners/browser.rb +11 -7
  22. data/lib/playwright/channel_owners/browser_context.rb +40 -15
  23. data/lib/playwright/channel_owners/element_handle.rb +2 -0
  24. data/lib/playwright/channel_owners/frame.rb +38 -14
  25. data/lib/playwright/channel_owners/page.rb +36 -16
  26. data/lib/playwright/channel_owners/web_socket.rb +8 -13
  27. data/lib/playwright/connection.rb +18 -2
  28. data/lib/playwright/errors.rb +20 -2
  29. data/lib/playwright/input_files.rb +4 -4
  30. data/lib/playwright/locator_assertions_impl.rb +15 -15
  31. data/lib/playwright/locator_impl.rb +2 -0
  32. data/lib/playwright/test.rb +2 -2
  33. data/lib/playwright/utils.rb +3 -10
  34. data/lib/playwright/version.rb +2 -2
  35. data/lib/playwright/waiter.rb +146 -0
  36. data/lib/playwright.rb +1 -1
  37. data/lib/playwright_api/api_request_context.rb +1 -2
  38. data/lib/playwright_api/browser.rb +2 -2
  39. data/lib/playwright_api/browser_context.rb +9 -3
  40. data/lib/playwright_api/browser_type.rb +2 -1
  41. data/lib/playwright_api/download.rb +1 -2
  42. data/lib/playwright_api/element_handle.rb +6 -2
  43. data/lib/playwright_api/frame.rb +4 -1
  44. data/lib/playwright_api/locator.rb +6 -2
  45. data/lib/playwright_api/locator_assertions.rb +14 -4
  46. data/lib/playwright_api/page.rb +20 -10
  47. data/lib/playwright_api/request.rb +4 -4
  48. data/lib/playwright_api/tracing.rb +2 -2
  49. data/lib/playwright_api/worker.rb +4 -4
  50. data/sig/playwright.rbs +12 -10
  51. metadata +7 -6
  52. data/lib/playwright/wait_helper.rb +0 -73
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9c0bd246e9fc2ccd9358b60aa056266dfcee1f3fd2ee0174ae7a23173a1a9cb
4
- data.tar.gz: 7e68e6e420040c24cdb9514dcde89ec6a2fd68ceda91b9590ed367ef5b1e52b7
3
+ metadata.gz: ed3850992222f0ca034bfb21929941320408b44967cf2a6670f59697f773918f
4
+ data.tar.gz: 9e9137831c4e1cc10929809bd2d5f477df3c8d0e5ffdbd1f050cb697a655aa00
5
5
  SHA512:
6
- metadata.gz: e67763b081ab137ab5da3cfbb0e397a664b4489574a3368e0059566b0e6c519d8685e252bedf76213cd7a8cad34cde3e0b2c4587adcc2241b255095ad1ffa3c7
7
- data.tar.gz: 675f7ad040dace09c78d5d12672999d7c5a6d2ae067c89a078dd75e6f866db53191d1890a76d816f8aef797d83f0b12ed7d1311c3cbf00c90f62d38cfb407e62
6
+ metadata.gz: f38e9f6ab657a84cffa1d7ef20282dcc68bb2b99a142788455a1824f575f1c1ac858b0a8b3d4570f43e7df5e07c0fc965a1951afef3c419d6b4507169fcf802f
7
+ data.tar.gz: b2624ca693431803afe83cb77c9dbe83d9d96c30618e4c827666737210db5c296ed0b4e10abe131c3fdf1ed9f7ca166eca158d0569f6b68be74c94007f06f470
@@ -85,8 +85,7 @@ def dispose
85
85
  ```
86
86
 
87
87
 
88
- All responses returned by [APIRequestContext#get](./api_request_context#get) and similar methods are stored in the memory, so that you can later call [APIResponse#body](./api_response#body). This method
89
- discards all stored responses, and makes [APIResponse#body](./api_response#body) throw "Response disposed" error.
88
+ All responses returned by [APIRequestContext#get](./api_request_context#get) and similar methods are stored in the memory, so that you can later call [APIResponse#body](./api_response#body).This method discards all its resources, calling any method on disposed [APIRequestContext](./api_request_context) will throw an exception.
90
89
 
91
90
  ## fetch
92
91
 
@@ -31,7 +31,7 @@ Get the browser type (chromium, firefox or webkit) that the browser belongs to.
31
31
  ## close
32
32
 
33
33
  ```
34
- def close
34
+ def close(reason: nil)
35
35
  ```
36
36
 
37
37
 
@@ -120,7 +120,7 @@ context.clear_permissions
120
120
  ## close
121
121
 
122
122
  ```
123
- def close
123
+ def close(reason: nil)
124
124
  ```
125
125
 
126
126
 
@@ -441,6 +441,15 @@ def storage_state(path: nil)
441
441
 
442
442
  Returns storage state for this browser context, contains current cookies and local storage snapshot.
443
443
 
444
+ ## unroute_all
445
+
446
+ ```
447
+ def unroute_all(behavior: nil)
448
+ ```
449
+
450
+
451
+ Removes all routes created with [BrowserContext#route](./browser_context#route) and [BrowserContext#route_from_har](./browser_context#route_from_har).
452
+
444
453
  ## unroute
445
454
 
446
455
  ```
@@ -127,6 +127,7 @@ def launch_persistent_context(
127
127
  env: nil,
128
128
  executablePath: nil,
129
129
  extraHTTPHeaders: nil,
130
+ firefoxUserPrefs: nil,
130
131
  forcedColors: nil,
131
132
  geolocation: nil,
132
133
  handleSIGHUP: nil,
@@ -68,8 +68,7 @@ def path
68
68
  ```
69
69
 
70
70
 
71
- Returns path to the downloaded file in case of successful download. The method will
72
- wait for the download to finish if necessary. The method throws when connected remotely.
71
+ Returns path to the downloaded file for a successful download, or throws for a failed/canceled download. The method will wait for the download to finish if necessary. The method throws when connected remotely.
73
72
 
74
73
  Note that the download's file name is a random GUID, use [Download#suggested_filename](./download#suggested_filename)
75
74
  to get suggested file name.
@@ -180,13 +180,16 @@ default.
180
180
 
181
181
  Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial
182
182
  properties:
183
+ - [DeviceMotionEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent/DeviceMotionEvent)
184
+ - [DeviceOrientationEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent/DeviceOrientationEvent)
183
185
  - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
186
+ - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
184
187
  - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
185
188
  - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
186
189
  - [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
187
190
  - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
188
191
  - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
189
- - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
192
+ - [WheelEvent](https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/WheelEvent)
190
193
 
191
194
  You can also specify [JSHandle](./js_handle) as the property value if you want live objects to be passed into the event:
192
195
 
@@ -455,6 +458,7 @@ def screenshot(
455
458
  path: nil,
456
459
  quality: nil,
457
460
  scale: nil,
461
+ style: nil,
458
462
  timeout: nil,
459
463
  type: nil)
460
464
  ```
@@ -178,13 +178,16 @@ default.
178
178
 
179
179
  Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial
180
180
  properties:
181
+ - [DeviceMotionEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent/DeviceMotionEvent)
182
+ - [DeviceOrientationEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent/DeviceOrientationEvent)
181
183
  - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
184
+ - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
182
185
  - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
183
186
  - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
184
187
  - [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
185
188
  - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
186
189
  - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
187
- - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
190
+ - [WheelEvent](https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/WheelEvent)
188
191
 
189
192
  You can also specify [JSHandle](./js_handle) as the property value if you want live objects to be passed into the event:
190
193
 
@@ -303,13 +303,16 @@ default.
303
303
 
304
304
  Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial
305
305
  properties:
306
+ - [DeviceMotionEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent/DeviceMotionEvent)
307
+ - [DeviceOrientationEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent/DeviceOrientationEvent)
306
308
  - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
309
+ - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
307
310
  - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
308
311
  - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
309
312
  - [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
310
313
  - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
311
314
  - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
312
- - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
315
+ - [WheelEvent](https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/WheelEvent)
313
316
 
314
317
  You can also specify [JSHandle](./js_handle) as the property value if you want live objects to be passed into the event:
315
318
 
@@ -1096,6 +1099,7 @@ def screenshot(
1096
1099
  path: nil,
1097
1100
  quality: nil,
1098
1101
  scale: nil,
1102
+ style: nil,
1099
1103
  timeout: nil,
1100
1104
  type: nil)
1101
1105
  ```
@@ -128,7 +128,7 @@ The opposite of [LocatorAssertions#to_contain_text](./locator_assertions#to_cont
128
128
  ## not_to_have_attribute
129
129
 
130
130
  ```ruby
131
- expect(locator).not_to have_attribute(name, value, timeout: nil)
131
+ expect(locator).not_to have_attribute(name, value, ignoreCase: nil, timeout: nil)
132
132
  ```
133
133
 
134
134
 
@@ -400,6 +400,11 @@ expect(locator).to contain_text(expected, ignoreCase: nil, timeout: nil, useInne
400
400
 
401
401
  Ensures the [Locator](./locator) points to an element that contains the given text. You can use regular expressions for the value as well.
402
402
 
403
+ **Details**
404
+
405
+ When `expected` parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual text and
406
+ in the expected string before matching. When regular expression is used, the actual text is matched as is.
407
+
403
408
  **Usage**
404
409
 
405
410
  ```ruby
@@ -443,7 +448,7 @@ expect(page.locator("ul")).to contain_text(["Text 3"])
443
448
  ## to_have_attribute
444
449
 
445
450
  ```ruby
446
- expect(locator).to have_attribute(name, value, timeout: nil)
451
+ expect(locator).to have_attribute(name, value, ignoreCase: nil, timeout: nil)
447
452
  ```
448
453
 
449
454
 
@@ -559,6 +564,11 @@ expect(locator).to have_text(expected, ignoreCase: nil, timeout: nil, useInnerTe
559
564
 
560
565
  Ensures the [Locator](./locator) points to an element with the given text. You can use regular expressions for the value as well.
561
566
 
567
+ **Details**
568
+
569
+ When `expected` parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual text and
570
+ in the expected string before matching. When regular expression is used, the actual text is matched as is.
571
+
562
572
  **Usage**
563
573
 
564
574
  ```ruby
@@ -152,7 +152,7 @@ When all steps combined have not finished during the specified `timeout`, this m
152
152
  ## close
153
153
 
154
154
  ```
155
- def close(runBeforeUnload: nil)
155
+ def close(reason: nil, runBeforeUnload: nil)
156
156
  ```
157
157
 
158
158
 
@@ -240,13 +240,16 @@ default.
240
240
 
241
241
  Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial
242
242
  properties:
243
+ - [DeviceMotionEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent/DeviceMotionEvent)
244
+ - [DeviceOrientationEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent/DeviceOrientationEvent)
243
245
  - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
246
+ - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
244
247
  - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
245
248
  - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
246
249
  - [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
247
250
  - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
248
251
  - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
249
- - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
252
+ - [WheelEvent](https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/WheelEvent)
250
253
 
251
254
  You can also specify [JSHandle](./js_handle) as the property value if you want live objects to be passed into the event:
252
255
 
@@ -473,7 +476,7 @@ page.content = <<~HTML
473
476
  <button onclick="onClick()">Click me</button>
474
477
  <div></div>
475
478
  HTML
476
- page.locator("button").click
479
+ page.click("button")
477
480
  ```
478
481
 
479
482
  An example of passing an element handle:
@@ -1291,6 +1294,7 @@ def screenshot(
1291
1294
  path: nil,
1292
1295
  quality: nil,
1293
1296
  scale: nil,
1297
+ style: nil,
1294
1298
  timeout: nil,
1295
1299
  type: nil)
1296
1300
  ```
@@ -1545,6 +1549,15 @@ This method unchecks an element matching `selector` by performing the following
1545
1549
  When all steps combined have not finished during the specified `timeout`, this method throws a
1546
1550
  `TimeoutError`. Passing zero timeout disables this.
1547
1551
 
1552
+ ## unroute_all
1553
+
1554
+ ```
1555
+ def unroute_all(behavior: nil)
1556
+ ```
1557
+
1558
+
1559
+ Removes all routes created with [Page#route](./page#route) and [Page#route_from_har](./page#route_from_har).
1560
+
1548
1561
  ## unroute
1549
1562
 
1550
1563
  ```
@@ -35,7 +35,7 @@ Start tracing.
35
35
  **Usage**
36
36
 
37
37
  ```ruby
38
- context.tracing.start(name: 'trace', screenshots: true, snapshots: true)
38
+ context.tracing.start(screenshots: true, snapshots: true)
39
39
  page = context.new_page
40
40
  page.goto('https://playwright.dev')
41
41
  context.tracing.stop(path: 'trace.zip')
@@ -53,7 +53,7 @@ Start a new trace chunk. If you'd like to record multiple traces on the same [Br
53
53
  **Usage**
54
54
 
55
55
  ```ruby
56
- context.tracing.start(name: "trace", screenshots: true, snapshots: true)
56
+ context.tracing.start(screenshots: true, snapshots: true)
57
57
  page = context.new_page
58
58
  page.goto("https://playwright.dev")
59
59
 
@@ -33,7 +33,7 @@ end
33
33
 
34
34
  ### Update timeout
35
35
 
36
- Capybara sets the default value of timeout to *2 seconds*. Generally it is too short to wait for HTTP responses.
36
+ Capybara sets the default value of timeout to _2 seconds_. Generally it is too short to wait for HTTP responses.
37
37
 
38
38
  It is recommended to set the timeout to 15-30 seconds for Playwright driver.
39
39
 
@@ -56,50 +56,50 @@ It is not mandatry. Without changing the default driver, you can still use Playw
56
56
 
57
57
  These parameters can be passed into `Capybara::Playwright::Driver.new`
58
58
 
59
- * `playwright_cli_executable_path`
60
- * Refer [this article](./download_playwright_driver) to understand what to specify.
61
- * `browser_type`
62
- * `:chromium` (default), `:firefox`, or `:webkit`
63
- * Parameters for [Playwright::BrowserType#launch](/docs/api/browser_type#launch)
64
- * args
65
- * channel
66
- * `chrome`, `msedge`, `chrome-beta`, `chrome-dev`, `chrome-canary`, `msedge-beta`, `msedge-dev` Browser distribution channel. Read more about using [Google Chrome & Microsoft Edge](https://playwright.dev/docs/browsers#google-chrome--microsoft-edge)
67
- * devtools
68
- * downloadsPath
69
- * env
70
- * executablePath
71
- * firefoxUserPrefs
72
- * headless
73
- * ignoreDefaultArgs
74
- * proxy
75
- * slowMo
76
- * timeout
77
- * Parameters for [Playwright::Browser#new_context](/docs/api/browser#new_context)
78
- * bypassCSP
79
- * colorScheme
80
- * deviceScaleFactor
81
- * extraHTTPHeaders
82
- * geolocation
83
- * hasTouch
84
- * httpCredentials
85
- * ignoreHTTPSErrors
86
- * isMobile
87
- * javaScriptEnabled
88
- * locale
89
- * noViewport
90
- * offline
91
- * permissions
92
- * proxy
93
- * record_har_omit_content
94
- * record_har_path
95
- * record_video_dir
96
- * record_video_size
97
- * screen
98
- * serviceWorkers
99
- * storageState
100
- * timezoneId
101
- * userAgent
102
- * viewport
59
+ - `playwright_cli_executable_path`
60
+ - Refer [this article](./download_playwright_driver) to understand what to specify.
61
+ - `browser_type`
62
+ - `:chromium` (default), `:firefox`, or `:webkit`
63
+ - Parameters for [Playwright::BrowserType#launch](/docs/api/browser_type#launch)
64
+ - args
65
+ - channel
66
+ - `chrome`, `msedge`, `chrome-beta`, `chrome-dev`, `chrome-canary`, `msedge-beta`, `msedge-dev` Browser distribution channel. Read more about using [Google Chrome & Microsoft Edge](https://playwright.dev/docs/browsers#google-chrome--microsoft-edge)
67
+ - devtools
68
+ - downloadsPath
69
+ - env
70
+ - executablePath
71
+ - firefoxUserPrefs
72
+ - headless
73
+ - ignoreDefaultArgs
74
+ - proxy
75
+ - slowMo
76
+ - timeout
77
+ - Parameters for [Playwright::Browser#new_context](/docs/api/browser#new_context)
78
+ - bypassCSP
79
+ - colorScheme
80
+ - deviceScaleFactor
81
+ - extraHTTPHeaders
82
+ - geolocation
83
+ - hasTouch
84
+ - httpCredentials
85
+ - ignoreHTTPSErrors
86
+ - isMobile
87
+ - javaScriptEnabled
88
+ - locale
89
+ - noViewport
90
+ - offline
91
+ - permissions
92
+ - proxy
93
+ - record_har_omit_content
94
+ - record_har_path
95
+ - record_video_dir
96
+ - record_video_size
97
+ - screen
98
+ - serviceWorkers
99
+ - storageState
100
+ - timezoneId
101
+ - userAgent
102
+ - viewport
103
103
 
104
104
  ```ruby
105
105
  driver_opts = {
@@ -119,14 +119,13 @@ driver_opts = {
119
119
  Capybara::Playwright::Driver.new(app, driver_opts)
120
120
  ```
121
121
 
122
-
123
122
  ## Available functions and Limitations
124
123
 
125
124
  ### Capybara DSL
126
125
 
127
126
  Most of the methods of `Capybara::Session` and `Capybara::Node::Element` are available. However the following method is not yet implemented.
128
127
 
129
- * `Capybara::Node::Element#drop`
128
+ - `Capybara::Node::Element#drop`
130
129
 
131
130
  ### Playwright-native scripting
132
131
 
@@ -181,7 +180,6 @@ end
181
180
 
182
181
  For more details, refer [Recording video](./recording_video.md#using-screen-recording-from-capybara-driver)
183
182
 
184
-
185
183
  ### Screenshot just before teardown
186
184
 
187
185
  In addition to `Capybara::Session#save_screenshot`, capybara-playwright-driver have another method for storing last screen state just before teardown.
@@ -201,8 +199,39 @@ before do |example|
201
199
  end
202
200
  ```
203
201
 
202
+ ### Tracing for postmortem
203
+
204
+ Playwright users often expect to see what happened in the browser when the test failed. `capybara-playwright-driver` provides a feature to store the trace easily.
205
+
206
+ ```ruby
207
+ before do |example|
208
+ Capybara.current_session.driver.on_save_trace do |trace_zip_path|
209
+ Allure.add_attachment(
210
+ name: "trace - #{example.description}",
211
+ source: File.read(trace_zip_path),
212
+ type: 'application/zip',
213
+ test_case: true,
214
+ )
215
+ end
216
+ end
217
+ ```
218
+
219
+ This example code would attach the trace zip file to Allure report for each test case.
220
+
221
+ ![add trace image](https://user-images.githubusercontent.com/11763113/282307106-520d800b-67ac-4e14-98bb-75a8bbb98a1f.png)
222
+
223
+ We can download and show the trace with `playwright show-trace` command.
224
+
225
+ ```
226
+ npx playwright show-trace ababcdcdefef.zip
227
+ ```
228
+
229
+ ![show-trace image](https://user-images.githubusercontent.com/11763113/282307098-a4167c32-d5e7-4631-a3b6-62d278efbeef.png)
230
+
231
+ Instead of the easy configuration using `on_save_trace`, we can also use `page.driver.start_tracing` / `page.driver.stop_tracing` or `page.driver.with_trace do { ... }` for storing the trace with detailed options. See [the PR](https://github.com/YusukeIwaki/capybara-playwright-driver/pull/66) for more details including example codes for RSpec.
232
+
204
233
  ### Limitations
205
234
 
206
- * Playwright doesn't allow clicking invisible DOM elements or moving elements. `click` sometimes doesn't work as Selenium does. See the detail in https://playwright.dev/docs/actionability/
207
- * `current_window.maximize` and `current_window.fullscreen` work only on headful (non-headless) mode, as selenium driver does.
208
- * `Capybara::Node::Element#drag_to` does not accept `html5` parameter. HTML5 drag and drop is not fully supported in Playwright.
235
+ - Playwright doesn't allow clicking invisible DOM elements or moving elements. `click` sometimes doesn't work as Selenium does. See the detail in https://playwright.dev/docs/actionability/
236
+ - `current_window.maximize` and `current_window.fullscreen` work only on headful (non-headless) mode, as selenium driver does.
237
+ - `Capybara::Node::Element#drag_to` does not accept `html5` parameter. HTML5 drag and drop is not fully supported in Playwright.
@@ -0,0 +1,59 @@
1
+ ---
2
+ sidebar_position: 5
3
+ ---
4
+
5
+ # Web-First assertions for RSpec
6
+
7
+ Playwright introduces clever assertions for E2E testing, so called [web-first assertions](https://playwright.dev/docs/test-assertions).
8
+
9
+ ```ruby
10
+ it 'should show username after login' do
11
+ page.fill('input[name="username"]', 'playwright')
12
+ page.fill('input[name="password"]', 'password123')
13
+ page.expect_navigation do
14
+ page.locator('button[type="submit"]').click
15
+ end
16
+
17
+ dashboard_container = page.locator('.dashboard')
18
+
19
+ # Not web-first assertion
20
+ expect(dashboard_container.text_content).to include('Hi, playwright!')
21
+
22
+ # Web-first assertion
23
+ expect(dashboard_container).to have_text('Hi, playwright!')
24
+ end
25
+ ```
26
+
27
+ The spec above have 2 similar expectations. The first one is a normal assertion, which is not web-first. The second one is a web-first assertion, which is introduced by Playwright.
28
+
29
+ Imagine the case that 'Hi, playwright!' is shown after loading some data from API server. In this case, the first assertion may fail because 'Hi, playwright!' is not present soon after login. On the other hand, the second assertion automatically waits for the 'Hi, playwright!' to be shown.
30
+
31
+ ## Configure
32
+
33
+ For avoiding matcher name conflicts, web-first assertions are not loaded by default. To enable web-first assertions, we have to configure RSpec as below:
34
+
35
+ ```ruby title=spec/support/web_first_assertion.rb
36
+ require 'playwright/test'
37
+
38
+ RSpec.configure do |config|
39
+ # include web-first assertions just for feature specs.
40
+ config.include Playwright::RSpec::Matchers, type: :feature
41
+ end
42
+ ```
43
+
44
+ If you want to use web-first assertions only for some specs, you can include `Playwright::RSpec::Matchers` in the spec file directly.
45
+
46
+ ```ruby title=spec/system/example_spec.rb
47
+ require 'rails_helper'
48
+ require 'playwright/test'
49
+
50
+ describe 'example' do
51
+ include Playwright::RSpec::Matchers
52
+
53
+ it 'should work' do
54
+ ...
55
+ ```
56
+
57
+ ## Matchers
58
+
59
+ Please refer to [API doc](/docs/api/locator_assertions).
@@ -315,6 +315,7 @@
315
315
  * title
316
316
  * type
317
317
  * uncheck
318
+ * unroute_all
318
319
  * unroute
319
320
  * url
320
321
  * video
@@ -368,6 +369,7 @@
368
369
  * set_geolocation
369
370
  * set_offline
370
371
  * storage_state
372
+ * unroute_all
371
373
  * unroute
372
374
  * expect_console_message
373
375
  * expect_event
@@ -81,7 +81,7 @@ module.exports = {
81
81
  ],
82
82
  },
83
83
  ],
84
- copyright: `Copyright © ${new Date().getFullYear()} @YusukeIwaki. <p>Built with <a href="https://v2.docusaurus.io/">Docusaurus</a>.</p>`,
84
+ copyright: `Copyright © ${new Date().getFullYear()} @YusukeIwaki. <p>Built with <a href="https://docusaurus.io/">Docusaurus</a>.</p>`,
85
85
  },
86
86
  prism: {
87
87
  additionalLanguages: ['bash', 'ruby'],
@@ -14,14 +14,14 @@
14
14
  "write-heading-ids": "docusaurus write-heading-ids"
15
15
  },
16
16
  "dependencies": {
17
- "@docusaurus/core": "^2.0.1",
18
- "@docusaurus/preset-classic": "^2.0.1",
19
- "@mdx-js/react": "^1.6.22",
20
- "@svgr/webpack": "^6.3.1",
21
- "clsx": "^1.2.1",
17
+ "@docusaurus/core": "^3.0.0",
18
+ "@docusaurus/preset-classic": "^3.0.0",
19
+ "@mdx-js/react": "^3.0.0",
20
+ "@svgr/webpack": "^8.1.0",
21
+ "clsx": "^2.0.0",
22
22
  "file-loader": "^6.2.0",
23
- "react": "^18.0.0",
24
- "react-dom": "^18.0.0",
23
+ "react": "^18.2.0",
24
+ "react-dom": "^18.2.0",
25
25
  "url-loader": "^4.1.1"
26
26
  },
27
27
  "browserslist": {