playwright-ruby-client 1.56.0 → 1.57.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.
- checksums.yaml +4 -4
- data/documentation/docs/api/console_message.md +9 -0
- data/documentation/docs/api/element_handle.md +2 -0
- data/documentation/docs/api/frame.md +1 -0
- data/documentation/docs/api/locator.md +22 -0
- data/documentation/docs/api/page.md +1 -2
- data/documentation/docs/api/worker.md +20 -0
- data/documentation/docs/article/guides/playwright_on_alpine_linux.md +19 -0
- data/documentation/docs/article/guides/rails_integration.md +43 -2
- data/documentation/docs/include/api_coverage.md +3 -5
- data/documentation/package.json +2 -2
- data/documentation/yarn.lock +9003 -12370
- data/lib/playwright/channel_owners/browser_context.rb +5 -2
- data/lib/playwright/channel_owners/element_handle.rb +6 -2
- data/lib/playwright/channel_owners/frame.rb +9 -3
- data/lib/playwright/channel_owners/page.rb +30 -10
- data/lib/playwright/channel_owners/worker.rb +19 -0
- data/lib/playwright/console_message_impl.rb +3 -4
- data/lib/playwright/events.rb +1 -0
- data/lib/playwright/locator_impl.rb +25 -5
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright/web_socket_transport.rb +1 -1
- data/lib/playwright.rb +4 -0
- data/lib/playwright_api/console_message.rb +6 -0
- data/lib/playwright_api/element_handle.rb +4 -2
- data/lib/playwright_api/frame.rb +2 -1
- data/lib/playwright_api/locator.rb +22 -3
- data/lib/playwright_api/page.rb +8 -11
- data/lib/playwright_api/worker.rb +17 -0
- data/sig/playwright.rbs +10 -12
- metadata +2 -5
- data/documentation/docs/api/accessibility.md +0 -66
- data/lib/playwright/accessibility_impl.rb +0 -50
- data/lib/playwright_api/accessibility.rb +0 -57
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 430aa6a1bab67d9edca2cce8f72c76578402ec3aab93f296366335d23894d3dd
|
|
4
|
+
data.tar.gz: 0efe7aba9e4c2e45f6374c957dad31630e66157124f4b1b5dc2589815d39e6fc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5d19738002e6edef932c3eba936a99ffc3b54d805640a806cb3e255542d56b72be7526cf69c6752ed409c1337899f9c132494335c76b0231601c5cd7a596a677
|
|
7
|
+
data.tar.gz: 5864d506cb7f6cfc4d0a35a65900241ca7a686f2b5e59716f16e4d4f588e832153bcff19bf71fae82bda9b91e55a7c9ee1f974e33d1541ad1a49e78a51e4b341
|
|
@@ -74,3 +74,12 @@ def type
|
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
|
|
77
|
+
|
|
78
|
+
## worker
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
def worker
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
The web worker or service worker that produced this console message, if any. Note that console messages from web workers also have non-null [ConsoleMessage#page](./console_message#page).
|
|
@@ -103,6 +103,7 @@ def click(
|
|
|
103
103
|
modifiers: nil,
|
|
104
104
|
noWaitAfter: nil,
|
|
105
105
|
position: nil,
|
|
106
|
+
steps: nil,
|
|
106
107
|
timeout: nil,
|
|
107
108
|
trial: nil)
|
|
108
109
|
```
|
|
@@ -138,6 +139,7 @@ def dblclick(
|
|
|
138
139
|
modifiers: nil,
|
|
139
140
|
noWaitAfter: nil,
|
|
140
141
|
position: nil,
|
|
142
|
+
steps: nil,
|
|
141
143
|
timeout: nil,
|
|
142
144
|
trial: nil)
|
|
143
145
|
```
|
|
@@ -235,6 +235,7 @@ def click(
|
|
|
235
235
|
modifiers: nil,
|
|
236
236
|
noWaitAfter: nil,
|
|
237
237
|
position: nil,
|
|
238
|
+
steps: nil,
|
|
238
239
|
timeout: nil,
|
|
239
240
|
trial: nil)
|
|
240
241
|
```
|
|
@@ -296,6 +297,7 @@ def dblclick(
|
|
|
296
297
|
modifiers: nil,
|
|
297
298
|
noWaitAfter: nil,
|
|
298
299
|
position: nil,
|
|
300
|
+
steps: nil,
|
|
299
301
|
timeout: nil,
|
|
300
302
|
trial: nil)
|
|
301
303
|
```
|
|
@@ -334,6 +336,25 @@ button = page.get_by_test_id("btn-sub").describe("Subscribe button")
|
|
|
334
336
|
button.click
|
|
335
337
|
```
|
|
336
338
|
|
|
339
|
+
## description
|
|
340
|
+
|
|
341
|
+
```
|
|
342
|
+
def description
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
Returns locator description previously set with [Locator#describe](./locator#describe). Returns `null` if no custom description has been set. Prefer `Locator.toString()` for a human-readable representation, as it uses the description when available.
|
|
347
|
+
|
|
348
|
+
**Usage**
|
|
349
|
+
|
|
350
|
+
```ruby
|
|
351
|
+
button = page.get_by_role("button").describe("Subscribe button")
|
|
352
|
+
puts button.description # => "Subscribe button"
|
|
353
|
+
|
|
354
|
+
input = page.get_by_role("textbox")
|
|
355
|
+
puts input.description # => nil
|
|
356
|
+
```
|
|
357
|
+
|
|
337
358
|
## dispatch_event
|
|
338
359
|
|
|
339
360
|
```
|
|
@@ -387,6 +408,7 @@ def drag_to(
|
|
|
387
408
|
force: nil,
|
|
388
409
|
noWaitAfter: nil,
|
|
389
410
|
sourcePosition: nil,
|
|
411
|
+
steps: nil,
|
|
390
412
|
targetPosition: nil,
|
|
391
413
|
timeout: nil,
|
|
392
414
|
trial: nil)
|
|
@@ -266,6 +266,7 @@ def drag_and_drop(
|
|
|
266
266
|
force: nil,
|
|
267
267
|
noWaitAfter: nil,
|
|
268
268
|
sourcePosition: nil,
|
|
269
|
+
steps: nil,
|
|
269
270
|
strict: nil,
|
|
270
271
|
targetPosition: nil,
|
|
271
272
|
timeout: nil,
|
|
@@ -1932,8 +1933,6 @@ associated with the page.
|
|
|
1932
1933
|
|
|
1933
1934
|
Playwright has ability to mock clock and passage of time.
|
|
1934
1935
|
|
|
1935
|
-
## accessibility
|
|
1936
|
-
|
|
1937
1936
|
## keyboard
|
|
1938
1937
|
|
|
1939
1938
|
## mouse
|
|
@@ -61,3 +61,23 @@ def url
|
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
|
|
64
|
+
|
|
65
|
+
## expect_event
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
def expect_event(event, predicate: nil, timeout: nil, &block)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
Waits for event to fire and passes its value into the predicate function.
|
|
73
|
+
Returns when the predicate returns truthy value.
|
|
74
|
+
Will throw an error if the page is closed before the event is fired.
|
|
75
|
+
Returns the event data value.
|
|
76
|
+
|
|
77
|
+
**Usage**
|
|
78
|
+
|
|
79
|
+
```ruby
|
|
80
|
+
message = worker.expect_event("console") do
|
|
81
|
+
worker.evaluate("console.log(42)")
|
|
82
|
+
end
|
|
83
|
+
```
|
|
@@ -54,6 +54,25 @@ end
|
|
|
54
54
|
|
|
55
55
|
`wss://example.com:8888/ws` is an example of endpoint URL of the Playwright server. In local development environment, it is typically `"ws://127.0.0.1:#{port}/ws"`.
|
|
56
56
|
|
|
57
|
+
We can also pass launchOptions parameters using a `launch-options` query string like this:
|
|
58
|
+
|
|
59
|
+
```ruby {3-4}
|
|
60
|
+
require 'json'
|
|
61
|
+
|
|
62
|
+
launch_params = { headless: false }
|
|
63
|
+
Playwright.connect_to_browser_server("wss://example.com:8888/ws?launch-options=#{launch_params.to_json}") do |browser|
|
|
64
|
+
page = browser.new_page
|
|
65
|
+
page.goto('https://github.com/microsoft/playwright')
|
|
66
|
+
page.screenshot(path: 'github-microsoft-playwright_headful.png')
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
Playwright.connect_to_browser_server('wss://example.com:8888/ws') do |browser|
|
|
70
|
+
page = browser.new_page
|
|
71
|
+
page.goto('https://github.com/microsoft/playwright')
|
|
72
|
+
page.screenshot(path: 'github-microsoft-playwright_headless.png')
|
|
73
|
+
end
|
|
74
|
+
```
|
|
75
|
+
|
|
57
76
|
### Server code
|
|
58
77
|
|
|
59
78
|
With the [official Docker image](https://hub.docker.com/_/microsoft-playwright) or in the local development environment with Node.js, just execute `npx playwright install && npx playwright run-server --port $PORT --path /ws`. (`$PORT` is a port number of the server)
|
|
@@ -23,7 +23,7 @@ Note that capybara-playwright-driver does not depend on Selenium. But `selenium-
|
|
|
23
23
|
## Register and configure Capybara driver
|
|
24
24
|
|
|
25
25
|
```rb
|
|
26
|
-
Capybara.register_driver(:
|
|
26
|
+
Capybara.register_driver(:customized_playwright) do |app|
|
|
27
27
|
Capybara::Playwright::Driver.new(app,
|
|
28
28
|
browser_type: :chromium, # :chromium (default) or :firefox, :webkit
|
|
29
29
|
headless: false, # true for headless mode (default), false for headful mode.
|
|
@@ -31,6 +31,38 @@ Capybara.register_driver(:playwright) do |app|
|
|
|
31
31
|
end
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
:::note
|
|
35
|
+
|
|
36
|
+
Rails itself (since Rails 6.1) reserves the driver name `:playwright` for its built‑in integration (see [rails/rails#39987](https://github.com/rails/rails/issues/39987) and [YusukeIwaki/capybara-playwright-driver#93](https://github.com/YusukeIwaki/capybara-playwright-driver/issues/93)). **If you call `Capybara.register_driver(:playwright) { ... }` and then use `driven_by :playwright`, Rails' built‑in Playwright driver will be selected** instead of the one defined by `Capybara.register_driver(:playwright) { ... }`. Therefore, when you want to use the driver from this gem with custom options, register it with another name such as `:customized_playwright`.
|
|
37
|
+
|
|
38
|
+
:::
|
|
39
|
+
|
|
40
|
+
### When running Playwright in a container
|
|
41
|
+
|
|
42
|
+
If Playwright is running in an independent container, with docker-compose.yaml config like this
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
playwright: # this is our PLAYWRIGHT_HOST value
|
|
46
|
+
image: mcr.microsoft.com/playwright:v1.56.1-noble
|
|
47
|
+
command: >
|
|
48
|
+
/bin/sh -c "npx -y playwright@1.56.1 run-server --port 3000 --host 0.0.0.0 --path /ws"
|
|
49
|
+
init: true
|
|
50
|
+
restart: unless-stopped
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Configure capybara to use the `browser_server_endpoint_url`
|
|
54
|
+
|
|
55
|
+
```rb
|
|
56
|
+
Capybara.register_driver(:playwright_remote) do |app|
|
|
57
|
+
Capybara::Playwright::Driver.new(
|
|
58
|
+
app,
|
|
59
|
+
browser_type: :chromium,
|
|
60
|
+
headless: true,
|
|
61
|
+
browser_server_endpoint_url: "ws://#{ENV.fetch('PLAYWRIGHT_HOST')}:3000/ws"
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
```
|
|
65
|
+
|
|
34
66
|
### Update timeout
|
|
35
67
|
|
|
36
68
|
Capybara sets the default value of timeout to _2 seconds_. Generally it is too short to wait for HTTP responses.
|
|
@@ -50,7 +82,16 @@ Capybara.default_driver = :playwright
|
|
|
50
82
|
Capybara.javascript_driver = :playwright
|
|
51
83
|
```
|
|
52
84
|
|
|
53
|
-
|
|
85
|
+
If you registered a customized driver (e.g. `:customized_playwright` as above) and want that to be the default, set:
|
|
86
|
+
|
|
87
|
+
```rb
|
|
88
|
+
Capybara.default_driver = :customized_playwright
|
|
89
|
+
Capybara.javascript_driver = :customized_playwright
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Remember: choosing `:playwright` here will use Rails' built‑in driver, not the customized one from this gem.
|
|
93
|
+
|
|
94
|
+
It is not mandatory. Without changing the default driver, you can still use the customized Playwright driver by specifying `Capybara.current_driver = :customized_playwright` (or `driven_by :customized_playwright` in system spec) explicitly. Use `:playwright` only if you intend to run against Rails' built‑in Playwright driver (see issues: https://github.com/YusukeIwaki/capybara-playwright-driver/issues/93, https://github.com/rails/rails/issues/39987).
|
|
54
95
|
|
|
55
96
|
### (reference) Available driver options
|
|
56
97
|
|
|
@@ -129,10 +129,6 @@
|
|
|
129
129
|
* wait_for_element_state
|
|
130
130
|
* wait_for_selector
|
|
131
131
|
|
|
132
|
-
## Accessibility
|
|
133
|
-
|
|
134
|
-
* snapshot
|
|
135
|
-
|
|
136
132
|
## FileChooser
|
|
137
133
|
|
|
138
134
|
* element
|
|
@@ -208,6 +204,7 @@
|
|
|
208
204
|
* evaluate
|
|
209
205
|
* evaluate_handle
|
|
210
206
|
* url
|
|
207
|
+
* expect_event
|
|
211
208
|
|
|
212
209
|
## Selectors
|
|
213
210
|
|
|
@@ -231,6 +228,7 @@
|
|
|
231
228
|
* page
|
|
232
229
|
* text
|
|
233
230
|
* type
|
|
231
|
+
* worker
|
|
234
232
|
|
|
235
233
|
## Dialog
|
|
236
234
|
|
|
@@ -356,7 +354,6 @@
|
|
|
356
354
|
* workers
|
|
357
355
|
* ~~wait_for_event~~
|
|
358
356
|
* clock
|
|
359
|
-
* accessibility
|
|
360
357
|
* keyboard
|
|
361
358
|
* mouse
|
|
362
359
|
* request
|
|
@@ -459,6 +456,7 @@
|
|
|
459
456
|
* count
|
|
460
457
|
* dblclick
|
|
461
458
|
* describe
|
|
459
|
+
* description
|
|
462
460
|
* dispatch_event
|
|
463
461
|
* drag_to
|
|
464
462
|
* element_handle
|
data/documentation/package.json
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"write-heading-ids": "docusaurus write-heading-ids"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@docusaurus/core": "^3.
|
|
18
|
-
"@docusaurus/preset-classic": "^3.
|
|
17
|
+
"@docusaurus/core": "^3.9.2",
|
|
18
|
+
"@docusaurus/preset-classic": "^3.9.2",
|
|
19
19
|
"@mdx-js/react": "^3.1.1",
|
|
20
20
|
"@svgr/webpack": "^8.1.0",
|
|
21
21
|
"clsx": "^2.0.0",
|