playwright-ruby-client 1.33.0 → 1.35.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/browser_context.md +12 -1
- data/documentation/docs/api/console_message.md +9 -0
- data/documentation/docs/api/dialog.md +9 -0
- data/documentation/docs/api/element_handle.md +1 -0
- data/documentation/docs/api/locator.md +18 -0
- data/documentation/docs/api/page.md +1 -0
- data/documentation/docs/api/route.md +1 -1
- data/documentation/docs/article/guides/playwright_on_alpine_linux.md +28 -21
- data/documentation/docs/include/api_coverage.md +4 -0
- data/lib/playwright/channel_owners/browser_context.rb +41 -3
- data/lib/playwright/channel_owners/console_message.rb +4 -0
- data/lib/playwright/channel_owners/dialog.rb +4 -0
- data/lib/playwright/channel_owners/element_handle.rb +2 -0
- data/lib/playwright/channel_owners/page.rb +5 -13
- data/lib/playwright/channel_owners/playwright.rb +0 -1
- data/lib/playwright/channel_owners/route.rb +2 -1
- data/lib/playwright/events.rb +2 -0
- data/lib/playwright/locator_impl.rb +14 -1
- data/lib/playwright/locator_utils.rb +1 -1
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright.rb +3 -2
- data/lib/playwright_api/browser_context.rb +10 -2
- data/lib/playwright_api/console_message.rb +6 -0
- data/lib/playwright_api/dialog.rb +6 -0
- data/lib/playwright_api/element_handle.rb +2 -1
- data/lib/playwright_api/frame.rb +4 -4
- data/lib/playwright_api/locator.rb +17 -2
- data/lib/playwright_api/page.rb +7 -6
- data/lib/playwright_api/playwright.rb +1 -1
- data/lib/playwright_api/response.rb +4 -4
- data/lib/playwright_api/route.rb +1 -1
- data/lib/playwright_api/worker.rb +4 -4
- data/sig/playwright.rbs +8 -4
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3bd6b36250957e5968a5314944dc9327980d93e225a9aea86d3958268f8e089c
|
|
4
|
+
data.tar.gz: e787bb96692cb1d47b1f56d359d3ed63559f477993f1d14250398403a08359e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5a9e9da2b00c688fb256a770cacb32e9762ccd1df1965f30653d30c62810e6c3fae54c9838006461d02427520a071bec13000c754c4790fe85f1f9086592436c
|
|
7
|
+
data.tar.gz: e9e74a9558c418ce736ccbc0aa61ba6cac55b484ba961255de8dc8e22bdbf67db90f3c00de470b3cd94846c9fb5b76afcf3773f2680e9f8ba5d317f2cf318474
|
|
@@ -451,6 +451,17 @@ def unroute(url, handler: nil)
|
|
|
451
451
|
Removes a route created with [BrowserContext#route](./browser_context#route). When `handler` is not specified, removes all
|
|
452
452
|
routes for the `url`.
|
|
453
453
|
|
|
454
|
+
## expect_console_message
|
|
455
|
+
|
|
456
|
+
```
|
|
457
|
+
def expect_console_message(predicate: nil, timeout: nil, &block)
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
Performs action and waits for a [ConsoleMessage](./console_message) to be logged by in the pages in the context. If predicate is provided, it passes
|
|
462
|
+
[ConsoleMessage](./console_message) value into the `predicate` function and waits for `predicate(message)` to return a truthy value.
|
|
463
|
+
Will throw an error if the page is closed before the [`event: BrowserContext.console`] event is fired.
|
|
464
|
+
|
|
454
465
|
## expect_event
|
|
455
466
|
|
|
456
467
|
```
|
|
@@ -472,7 +483,7 @@ end
|
|
|
472
483
|
## expect_page
|
|
473
484
|
|
|
474
485
|
```
|
|
475
|
-
def expect_page(predicate: nil, timeout: nil)
|
|
486
|
+
def expect_page(predicate: nil, timeout: nil, &block)
|
|
476
487
|
```
|
|
477
488
|
|
|
478
489
|
|
|
@@ -64,6 +64,23 @@ Returns an array of `node.textContent` values for all matching nodes.
|
|
|
64
64
|
texts = page.get_by_role("link").all_text_contents
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
+
## and
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
def and(locator)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
Creates a locator that matches both this locator and the argument locator.
|
|
75
|
+
|
|
76
|
+
**Usage**
|
|
77
|
+
|
|
78
|
+
The following example finds a button with a specific title.
|
|
79
|
+
|
|
80
|
+
```ruby
|
|
81
|
+
button = page.get_by_role("button").and(page.get_by_title("Subscribe"))
|
|
82
|
+
```
|
|
83
|
+
|
|
67
84
|
## blur
|
|
68
85
|
|
|
69
86
|
```
|
|
@@ -1023,6 +1040,7 @@ def screenshot(
|
|
|
1023
1040
|
animations: nil,
|
|
1024
1041
|
caret: nil,
|
|
1025
1042
|
mask: nil,
|
|
1043
|
+
maskColor: nil,
|
|
1026
1044
|
omitBackground: nil,
|
|
1027
1045
|
path: nil,
|
|
1028
1046
|
quality: nil,
|
|
@@ -14,14 +14,14 @@ This all-in-one architecture is reasonable for browser automation in our own com
|
|
|
14
14
|
|
|
15
15
|
However we may have trouble with bringing Playwright into:
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
- Docker
|
|
18
|
+
- Alpine Linux
|
|
19
|
+
- Serverless computing
|
|
20
|
+
- AWS Lambda
|
|
21
|
+
- Google Cloud Functions
|
|
22
|
+
- PaaS
|
|
23
|
+
- Heroku
|
|
24
|
+
- Google App Engine
|
|
25
25
|
|
|
26
26
|
This article introduces a way to separate environments into client (for executing Playwright script) and server (for working with browsers). The main use-case assumes Docker (using Alpine Linux), however the way can be applied also into other use-cases.
|
|
27
27
|
|
|
@@ -39,16 +39,22 @@ Playwright provides two kind of methods to share the browser environments for cl
|
|
|
39
39
|
|
|
40
40
|
When you want to share only one browser environment, Browser server is suitable. This feature is officially supported in Playwright.
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
- Server can be launched with [BrowserType#launchServer](https://playwright.dev/docs/api/class-browsertype#browser-type-launch-server) instead of `BrowserType#launch`.
|
|
43
|
+
- Client can connect to server with [BrowserType#connect](https://playwright.dev/docs/api/class-browsertype#browser-type-connect). In playwright-ruby-client, `BrowserType#connect` and not implemented yet and use `Playwright#connect_to_browser_server()` instead.
|
|
44
44
|
|
|
45
45
|
Another method is sharing all browser environment. This method is very simple, but not an official feature, and can be changed in future.
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
- Server can be launched with `playwright run-server` (CLI command).
|
|
48
|
+
- Client can connect to server with `Playwright.connect_to_playwright_server` instead of `Playwright.create`
|
|
49
49
|
|
|
50
50
|
## Playwright server/client
|
|
51
51
|
|
|
52
|
+
:::caution
|
|
53
|
+
|
|
54
|
+
This method is no longer supported on Playwright driver >= 1.35. See [this issue](https://github.com/YusukeIwaki/playwright-ruby-client/issues/254) for detail, and use Browser server/client method instead.
|
|
55
|
+
|
|
56
|
+
:::
|
|
57
|
+
|
|
52
58
|
### Client code
|
|
53
59
|
|
|
54
60
|
Many example uses `Playwright#create`, which internally uses Pipe (stdin/stdout) transport for Playwright-protocol messaging. Instead, **just use `Playwright#connect_to_playwright_server(endpoint)`** for WebSocket transport.
|
|
@@ -74,10 +80,10 @@ With the [official Docker image](https://hub.docker.com/_/microsoft-playwright)
|
|
|
74
80
|
If custom Docker image is preferred, build it as follows:
|
|
75
81
|
|
|
76
82
|
```Dockerfile
|
|
77
|
-
FROM mcr.microsoft.com/playwright
|
|
83
|
+
FROM mcr.microsoft.com/playwright
|
|
78
84
|
|
|
79
85
|
WORKDIR /root
|
|
80
|
-
RUN npm install playwright
|
|
86
|
+
RUN npm install playwright && ./node_modules/.bin/playwright install
|
|
81
87
|
|
|
82
88
|
ENV PORT 8888
|
|
83
89
|
CMD ["./node_modules/.bin/playwright", "run-server", "--port", "$PORT", "--path", "/ws"]
|
|
@@ -105,15 +111,17 @@ For instant use, `npx playwright launch-server --browser chromium` generates a W
|
|
|
105
111
|
More customization can be done by implementing JavaScript server like below:
|
|
106
112
|
|
|
107
113
|
```js
|
|
108
|
-
const playwright = require(
|
|
114
|
+
const playwright = require("playwright");
|
|
109
115
|
|
|
110
116
|
option = {
|
|
111
|
-
channel:
|
|
117
|
+
channel: "chrome-canary",
|
|
112
118
|
headless: false,
|
|
113
119
|
port: 8080,
|
|
114
|
-
wsPath:
|
|
115
|
-
}
|
|
116
|
-
playwright.chromium.launchServer(option).then((server) => {
|
|
120
|
+
wsPath: "ws",
|
|
121
|
+
};
|
|
122
|
+
playwright.chromium.launchServer(option).then((server) => {
|
|
123
|
+
console.log(server.wsEndpoint());
|
|
124
|
+
});
|
|
117
125
|
```
|
|
118
126
|
|
|
119
127
|
`port` and `wsPath` would be useful for generating static WebSocket endpoint URL.
|
|
@@ -132,13 +140,12 @@ Just set an environment variable `DEBUG=1`.
|
|
|
132
140
|
DEBUG=1 bundle exec ruby some-automation-with-playwright.rb
|
|
133
141
|
```
|
|
134
142
|
|
|
135
|
-
|
|
136
143
|
### Enable verbose logging on server
|
|
137
144
|
|
|
138
145
|
Just set an environment variable `DEBUG=pw:*` or `DEBUG=pw:server`
|
|
139
146
|
|
|
140
147
|
```
|
|
141
|
-
DEBUG=pw:* npx playwright
|
|
148
|
+
DEBUG=pw:* npx playwright launch-server --browser chromium
|
|
142
149
|
```
|
|
143
150
|
|
|
144
151
|
See [the official documentation](https://playwright.dev/docs/debug/#verbose-api-logs) for details.
|
|
@@ -218,6 +218,7 @@
|
|
|
218
218
|
|
|
219
219
|
* args
|
|
220
220
|
* location
|
|
221
|
+
* page
|
|
221
222
|
* text
|
|
222
223
|
* type
|
|
223
224
|
|
|
@@ -227,6 +228,7 @@
|
|
|
227
228
|
* default_value
|
|
228
229
|
* dismiss
|
|
229
230
|
* message
|
|
231
|
+
* page
|
|
230
232
|
* type
|
|
231
233
|
|
|
232
234
|
## Download
|
|
@@ -367,6 +369,7 @@
|
|
|
367
369
|
* set_offline
|
|
368
370
|
* storage_state
|
|
369
371
|
* unroute
|
|
372
|
+
* expect_console_message
|
|
370
373
|
* expect_event
|
|
371
374
|
* expect_page
|
|
372
375
|
* ~~wait_for_event~~
|
|
@@ -422,6 +425,7 @@
|
|
|
422
425
|
* all
|
|
423
426
|
* all_inner_texts
|
|
424
427
|
* all_text_contents
|
|
428
|
+
* and
|
|
425
429
|
* blur
|
|
426
430
|
* bounding_box
|
|
427
431
|
* check
|
|
@@ -35,6 +35,12 @@ module Playwright
|
|
|
35
35
|
@channel.on('serviceWorker', ->(params) {
|
|
36
36
|
on_service_worker(ChannelOwners::Worker.from(params['worker']))
|
|
37
37
|
})
|
|
38
|
+
@channel.on('console', ->(params) {
|
|
39
|
+
on_console_message(ChannelOwners::ConsoleMessage.from(params['message']))
|
|
40
|
+
})
|
|
41
|
+
@channel.on('dialog', ->(params) {
|
|
42
|
+
on_dialog(ChannelOwners::Dialog.from(params['dialog']))
|
|
43
|
+
})
|
|
38
44
|
@channel.on('request', ->(params) {
|
|
39
45
|
on_request(
|
|
40
46
|
ChannelOwners::Request.from(params['request']),
|
|
@@ -57,6 +63,8 @@ module Playwright
|
|
|
57
63
|
)
|
|
58
64
|
})
|
|
59
65
|
set_event_to_subscription_mapping({
|
|
66
|
+
Events::BrowserContext::Console => 'console',
|
|
67
|
+
Events::BrowserContext::Dialog => 'dialog',
|
|
60
68
|
Events::BrowserContext::Request => "request",
|
|
61
69
|
Events::BrowserContext::Response => "response",
|
|
62
70
|
Events::BrowserContext::RequestFinished => "requestFinished",
|
|
@@ -113,7 +121,7 @@ module Playwright
|
|
|
113
121
|
end
|
|
114
122
|
|
|
115
123
|
unless handled
|
|
116
|
-
route.send(:async_continue_route).rescue do |err|
|
|
124
|
+
route.send(:async_continue_route, internal: true).rescue do |err|
|
|
117
125
|
puts err, err.backtrace
|
|
118
126
|
end
|
|
119
127
|
end
|
|
@@ -147,6 +155,28 @@ module Playwright
|
|
|
147
155
|
response&.send(:mark_as_finished)
|
|
148
156
|
end
|
|
149
157
|
|
|
158
|
+
private def on_console_message(message)
|
|
159
|
+
emit(Events::BrowserContext::Console, message)
|
|
160
|
+
if (page = message.page)
|
|
161
|
+
page.emit(Events::Page::Console, message)
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
private def on_dialog(dialog)
|
|
166
|
+
consumed_by_context = emit(Events::BrowserContext::Dialog, dialog)
|
|
167
|
+
if (page = dialog.page)
|
|
168
|
+
consumed_by_page = page.emit(Events::Page::Dialog, dialog)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
if !consumed_by_context && !consumed_by_page
|
|
172
|
+
if dialog.type == 'beforeunload'
|
|
173
|
+
dialog.accept_async
|
|
174
|
+
else
|
|
175
|
+
dialog.dismiss
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
150
180
|
private def on_request(request, page)
|
|
151
181
|
emit(Events::BrowserContext::Request, request)
|
|
152
182
|
page&.emit(Events::Page::Request, request)
|
|
@@ -414,12 +444,20 @@ module Playwright
|
|
|
414
444
|
end
|
|
415
445
|
end
|
|
416
446
|
|
|
417
|
-
def
|
|
447
|
+
def expect_console_message(predicate: nil, timeout: nil, &block)
|
|
448
|
+
params = {
|
|
449
|
+
predicate: predicate,
|
|
450
|
+
timeout: timeout,
|
|
451
|
+
}.compact
|
|
452
|
+
expect_event(Events::BrowserContext::Console, params, &block)
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
def expect_page(predicate: nil, timeout: nil, &block)
|
|
418
456
|
params = {
|
|
419
457
|
predicate: predicate,
|
|
420
458
|
timeout: timeout,
|
|
421
459
|
}.compact
|
|
422
|
-
expect_event(Events::BrowserContext::Page, params)
|
|
460
|
+
expect_event(Events::BrowserContext::Page, params, &block)
|
|
423
461
|
end
|
|
424
462
|
|
|
425
463
|
# called from Page#on_close with send(:remove_page, page), so keep private
|
|
@@ -296,6 +296,7 @@ module Playwright
|
|
|
296
296
|
animations: nil,
|
|
297
297
|
caret: nil,
|
|
298
298
|
mask: nil,
|
|
299
|
+
maskColor: nil,
|
|
299
300
|
omitBackground: nil,
|
|
300
301
|
path: nil,
|
|
301
302
|
quality: nil,
|
|
@@ -306,6 +307,7 @@ module Playwright
|
|
|
306
307
|
params = {
|
|
307
308
|
animations: animations,
|
|
308
309
|
caret: caret,
|
|
310
|
+
maskColor: maskColor,
|
|
309
311
|
omitBackground: omitBackground,
|
|
310
312
|
path: path,
|
|
311
313
|
quality: quality,
|
|
@@ -36,12 +36,7 @@ module Playwright
|
|
|
36
36
|
|
|
37
37
|
@channel.on('bindingCall', ->(params) { on_binding(ChannelOwners::BindingCall.from(params['binding'])) })
|
|
38
38
|
@channel.once('close', ->(_) { on_close })
|
|
39
|
-
@channel.on('console', ->(params) {
|
|
40
|
-
console_message = ChannelOwners::ConsoleMessage.from(params['message'])
|
|
41
|
-
emit(Events::Page::Console, console_message)
|
|
42
|
-
})
|
|
43
39
|
@channel.on('crash', ->(_) { emit(Events::Page::Crash) })
|
|
44
|
-
@channel.on('dialog', method(:on_dialog))
|
|
45
40
|
@channel.on('download', method(:on_download))
|
|
46
41
|
@channel.on('fileChooser', ->(params) {
|
|
47
42
|
chooser = FileChooserImpl.new(
|
|
@@ -70,6 +65,8 @@ module Playwright
|
|
|
70
65
|
})
|
|
71
66
|
|
|
72
67
|
set_event_to_subscription_mapping({
|
|
68
|
+
Events::Page::Console => "console",
|
|
69
|
+
Events::Page::Dialog => "dialog",
|
|
73
70
|
Events::Page::Request => "request",
|
|
74
71
|
Events::Page::Response => "response",
|
|
75
72
|
Events::Page::RequestFinished => "requestFinished",
|
|
@@ -151,13 +148,6 @@ module Playwright
|
|
|
151
148
|
emit(Events::Page::Close)
|
|
152
149
|
end
|
|
153
150
|
|
|
154
|
-
private def on_dialog(params)
|
|
155
|
-
dialog = ChannelOwners::Dialog.from(params['dialog'])
|
|
156
|
-
unless emit(Events::Page::Dialog, dialog)
|
|
157
|
-
dialog.dismiss
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
|
|
161
151
|
private def on_download(params)
|
|
162
152
|
artifact = ChannelOwners::Artifact.from(params['artifact'])
|
|
163
153
|
download = DownloadImpl.new(
|
|
@@ -448,6 +438,7 @@ module Playwright
|
|
|
448
438
|
clip: nil,
|
|
449
439
|
fullPage: nil,
|
|
450
440
|
mask: nil,
|
|
441
|
+
maskColor: nil,
|
|
451
442
|
omitBackground: nil,
|
|
452
443
|
path: nil,
|
|
453
444
|
quality: nil,
|
|
@@ -460,6 +451,7 @@ module Playwright
|
|
|
460
451
|
quality: quality,
|
|
461
452
|
fullPage: fullPage,
|
|
462
453
|
clip: clip,
|
|
454
|
+
maskColor: maskColor,
|
|
463
455
|
omitBackground: omitBackground,
|
|
464
456
|
animations: animations,
|
|
465
457
|
caret: caret,
|
|
@@ -494,7 +486,7 @@ module Playwright
|
|
|
494
486
|
end
|
|
495
487
|
nil
|
|
496
488
|
rescue => err
|
|
497
|
-
raise
|
|
489
|
+
raise if !safe_close_error?(err) || !runBeforeUnload
|
|
498
490
|
end
|
|
499
491
|
|
|
500
492
|
def closed?
|
|
@@ -137,7 +137,7 @@ module Playwright
|
|
|
137
137
|
end
|
|
138
138
|
end
|
|
139
139
|
|
|
140
|
-
private def async_continue_route
|
|
140
|
+
private def async_continue_route(internal: false)
|
|
141
141
|
post_data_for_wire =
|
|
142
142
|
if (post_data_from_overrides = request.send(:fallback_overrides)[:postData])
|
|
143
143
|
post_data_for_wire = Base64.strict_encode64(post_data_from_overrides)
|
|
@@ -155,6 +155,7 @@ module Playwright
|
|
|
155
155
|
params[:postData] = post_data_for_wire
|
|
156
156
|
end
|
|
157
157
|
params[:requestUrl] = request.send(:internal_url)
|
|
158
|
+
params[:isFallback] = internal
|
|
158
159
|
|
|
159
160
|
# TODO _race_with_page_close
|
|
160
161
|
@channel.async_send_message_to_server('continue', params)
|
data/lib/playwright/events.rb
CHANGED
|
@@ -268,9 +268,20 @@ module Playwright
|
|
|
268
268
|
)
|
|
269
269
|
end
|
|
270
270
|
|
|
271
|
+
def and(locator)
|
|
272
|
+
unless same_frame?(locator)
|
|
273
|
+
raise DifferentFrameError.new('and')
|
|
274
|
+
end
|
|
275
|
+
LocatorImpl.new(
|
|
276
|
+
frame: @frame,
|
|
277
|
+
timeout_settings: @timeout_settings,
|
|
278
|
+
selector: "#{@selector} >> internal:and=#{locator.send(:selector_json)}",
|
|
279
|
+
)
|
|
280
|
+
end
|
|
281
|
+
|
|
271
282
|
def or(locator)
|
|
272
283
|
unless same_frame?(locator)
|
|
273
|
-
raise DifferentFrameError.new('
|
|
284
|
+
raise DifferentFrameError.new('or')
|
|
274
285
|
end
|
|
275
286
|
LocatorImpl.new(
|
|
276
287
|
frame: @frame,
|
|
@@ -351,6 +362,7 @@ module Playwright
|
|
|
351
362
|
animations: nil,
|
|
352
363
|
caret: nil,
|
|
353
364
|
mask: nil,
|
|
365
|
+
maskColor: nil,
|
|
354
366
|
omitBackground: nil,
|
|
355
367
|
path: nil,
|
|
356
368
|
quality: nil,
|
|
@@ -363,6 +375,7 @@ module Playwright
|
|
|
363
375
|
animations: animations,
|
|
364
376
|
caret: caret,
|
|
365
377
|
mask: mask,
|
|
378
|
+
maskColor: maskColor,
|
|
366
379
|
omitBackground: omitBackground,
|
|
367
380
|
path: path,
|
|
368
381
|
quality: quality,
|
|
@@ -39,7 +39,7 @@ module Playwright
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
private def get_by_test_id_selector(test_id_attribute_name, test_id)
|
|
42
|
-
"internal:testid=[#{test_id_attribute_name}=#{
|
|
42
|
+
"internal:testid=[#{test_id_attribute_name}=#{escape_for_attribute_selector_or_regex(test_id, true)}]"
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
private def get_by_label_selector(text, exact:)
|
data/lib/playwright/version.rb
CHANGED
data/lib/playwright.rb
CHANGED
|
@@ -74,7 +74,7 @@ module Playwright
|
|
|
74
74
|
# ...
|
|
75
75
|
# end
|
|
76
76
|
#
|
|
77
|
-
# When we use this method without block, an instance of
|
|
77
|
+
# When we use this method without block, an instance of Playwright::Execution is returned
|
|
78
78
|
# and we *must* call execution.stop on the end.
|
|
79
79
|
# The instance of playwright is available by calling execution.playwright
|
|
80
80
|
module_function def create(playwright_cli_executable_path:, &block)
|
|
@@ -159,8 +159,9 @@ module Playwright
|
|
|
159
159
|
begin
|
|
160
160
|
playwright = connection.initialize_playwright
|
|
161
161
|
browser = playwright.send(:pre_launched_browser)
|
|
162
|
+
browser.send(:update_browser_type, playwright.chromium) # Just workaround for nil reference error.
|
|
162
163
|
browser.browser_type.send(:did_launch_browser, browser)
|
|
163
|
-
browser.should_close_connection_on_close!
|
|
164
|
+
browser.send(:should_close_connection_on_close!)
|
|
164
165
|
Execution.new(connection, PlaywrightApi.wrap(playwright), PlaywrightApi.wrap(browser))
|
|
165
166
|
rescue
|
|
166
167
|
connection.stop
|
|
@@ -391,6 +391,14 @@ module Playwright
|
|
|
391
391
|
wrap_impl(@impl.unroute(unwrap_impl(url), handler: unwrap_impl(handler)))
|
|
392
392
|
end
|
|
393
393
|
|
|
394
|
+
#
|
|
395
|
+
# Performs action and waits for a `ConsoleMessage` to be logged by in the pages in the context. If predicate is provided, it passes
|
|
396
|
+
# `ConsoleMessage` value into the `predicate` function and waits for `predicate(message)` to return a truthy value.
|
|
397
|
+
# Will throw an error if the page is closed before the [`event: BrowserContext.console`] event is fired.
|
|
398
|
+
def expect_console_message(predicate: nil, timeout: nil, &block)
|
|
399
|
+
wrap_impl(@impl.expect_console_message(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
|
|
400
|
+
end
|
|
401
|
+
|
|
394
402
|
#
|
|
395
403
|
# Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
|
|
396
404
|
# value. Will throw an error if the context closes before the event is fired. Returns the event data value.
|
|
@@ -410,8 +418,8 @@ module Playwright
|
|
|
410
418
|
# Performs action and waits for a new `Page` to be created in the context. If predicate is provided, it passes
|
|
411
419
|
# `Page` value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
|
|
412
420
|
# Will throw an error if the context closes before new `Page` is created.
|
|
413
|
-
def expect_page(predicate: nil, timeout: nil)
|
|
414
|
-
wrap_impl(@impl.expect_page(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout)))
|
|
421
|
+
def expect_page(predicate: nil, timeout: nil, &block)
|
|
422
|
+
wrap_impl(@impl.expect_page(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
|
|
415
423
|
end
|
|
416
424
|
|
|
417
425
|
#
|
|
@@ -51,6 +51,12 @@ module Playwright
|
|
|
51
51
|
wrap_impl(@impl.message)
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
+
#
|
|
55
|
+
# The page that initiated this dialog, if available.
|
|
56
|
+
def page
|
|
57
|
+
wrap_impl(@impl.page)
|
|
58
|
+
end
|
|
59
|
+
|
|
54
60
|
#
|
|
55
61
|
# Returns dialog's type, can be one of `alert`, `beforeunload`, `confirm` or `prompt`.
|
|
56
62
|
def type
|
|
@@ -374,13 +374,14 @@ module Playwright
|
|
|
374
374
|
animations: nil,
|
|
375
375
|
caret: nil,
|
|
376
376
|
mask: nil,
|
|
377
|
+
maskColor: nil,
|
|
377
378
|
omitBackground: nil,
|
|
378
379
|
path: nil,
|
|
379
380
|
quality: nil,
|
|
380
381
|
scale: nil,
|
|
381
382
|
timeout: nil,
|
|
382
383
|
type: nil)
|
|
383
|
-
wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), caret: unwrap_impl(caret), mask: unwrap_impl(mask), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), scale: unwrap_impl(scale), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
|
|
384
|
+
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)))
|
|
384
385
|
end
|
|
385
386
|
|
|
386
387
|
#
|
data/lib/playwright_api/frame.rb
CHANGED
|
@@ -1038,13 +1038,13 @@ module Playwright
|
|
|
1038
1038
|
end
|
|
1039
1039
|
|
|
1040
1040
|
# @nodoc
|
|
1041
|
-
def
|
|
1042
|
-
wrap_impl(@impl.
|
|
1041
|
+
def detached=(req)
|
|
1042
|
+
wrap_impl(@impl.detached=(unwrap_impl(req)))
|
|
1043
1043
|
end
|
|
1044
1044
|
|
|
1045
1045
|
# @nodoc
|
|
1046
|
-
def
|
|
1047
|
-
wrap_impl(@impl.
|
|
1046
|
+
def highlight(selector)
|
|
1047
|
+
wrap_impl(@impl.highlight(unwrap_impl(selector)))
|
|
1048
1048
|
end
|
|
1049
1049
|
|
|
1050
1050
|
# -- inherited from EventEmitter --
|
|
@@ -50,6 +50,20 @@ module Playwright
|
|
|
50
50
|
wrap_impl(@impl.all_text_contents)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
+
#
|
|
54
|
+
# Creates a locator that matches both this locator and the argument locator.
|
|
55
|
+
#
|
|
56
|
+
# **Usage**
|
|
57
|
+
#
|
|
58
|
+
# The following example finds a button with a specific title.
|
|
59
|
+
#
|
|
60
|
+
# ```python sync
|
|
61
|
+
# button = page.get_by_role("button").and_(page.getByTitle("Subscribe"))
|
|
62
|
+
# ```
|
|
63
|
+
def and(locator)
|
|
64
|
+
wrap_impl(@impl.and(unwrap_impl(locator)))
|
|
65
|
+
end
|
|
66
|
+
|
|
53
67
|
#
|
|
54
68
|
# Calls [blur](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur) on the element.
|
|
55
69
|
def blur(timeout: nil)
|
|
@@ -767,7 +781,7 @@ module Playwright
|
|
|
767
781
|
# **Usage**
|
|
768
782
|
#
|
|
769
783
|
# ```python sync
|
|
770
|
-
# banana = page.get_by_role("listitem").last
|
|
784
|
+
# banana = page.get_by_role("listitem").last
|
|
771
785
|
# ```
|
|
772
786
|
def last
|
|
773
787
|
wrap_impl(@impl.last)
|
|
@@ -884,13 +898,14 @@ module Playwright
|
|
|
884
898
|
animations: nil,
|
|
885
899
|
caret: nil,
|
|
886
900
|
mask: nil,
|
|
901
|
+
maskColor: nil,
|
|
887
902
|
omitBackground: nil,
|
|
888
903
|
path: nil,
|
|
889
904
|
quality: nil,
|
|
890
905
|
scale: nil,
|
|
891
906
|
timeout: nil,
|
|
892
907
|
type: nil)
|
|
893
|
-
wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), caret: unwrap_impl(caret), mask: unwrap_impl(mask), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), scale: unwrap_impl(scale), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
|
|
908
|
+
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)))
|
|
894
909
|
end
|
|
895
910
|
|
|
896
911
|
#
|
data/lib/playwright_api/page.rb
CHANGED
|
@@ -1154,13 +1154,14 @@ module Playwright
|
|
|
1154
1154
|
clip: nil,
|
|
1155
1155
|
fullPage: nil,
|
|
1156
1156
|
mask: nil,
|
|
1157
|
+
maskColor: nil,
|
|
1157
1158
|
omitBackground: nil,
|
|
1158
1159
|
path: nil,
|
|
1159
1160
|
quality: nil,
|
|
1160
1161
|
scale: nil,
|
|
1161
1162
|
timeout: nil,
|
|
1162
1163
|
type: nil)
|
|
1163
|
-
wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), caret: unwrap_impl(caret), clip: unwrap_impl(clip), fullPage: unwrap_impl(fullPage), mask: unwrap_impl(mask), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), scale: unwrap_impl(scale), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
|
|
1164
|
+
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)))
|
|
1164
1165
|
end
|
|
1165
1166
|
|
|
1166
1167
|
#
|
|
@@ -1672,11 +1673,6 @@ module Playwright
|
|
|
1672
1673
|
raise NotImplementedError.new('wait_for_event is not implemented yet.')
|
|
1673
1674
|
end
|
|
1674
1675
|
|
|
1675
|
-
# @nodoc
|
|
1676
|
-
def stop_css_coverage
|
|
1677
|
-
wrap_impl(@impl.stop_css_coverage)
|
|
1678
|
-
end
|
|
1679
|
-
|
|
1680
1676
|
# @nodoc
|
|
1681
1677
|
def owned_context=(req)
|
|
1682
1678
|
wrap_impl(@impl.owned_context=(unwrap_impl(req)))
|
|
@@ -1702,6 +1698,11 @@ module Playwright
|
|
|
1702
1698
|
wrap_impl(@impl.start_css_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
|
|
1703
1699
|
end
|
|
1704
1700
|
|
|
1701
|
+
# @nodoc
|
|
1702
|
+
def stop_css_coverage
|
|
1703
|
+
wrap_impl(@impl.stop_css_coverage)
|
|
1704
|
+
end
|
|
1705
|
+
|
|
1705
1706
|
# -- inherited from EventEmitter --
|
|
1706
1707
|
# @nodoc
|
|
1707
1708
|
def off(event, callback)
|
|
@@ -83,7 +83,7 @@ module Playwright
|
|
|
83
83
|
#
|
|
84
84
|
# >>> browser = playwright.chromium.launch()
|
|
85
85
|
# >>> page = browser.new_page()
|
|
86
|
-
# >>> page.goto("
|
|
86
|
+
# >>> page.goto("https://playwright.dev/")
|
|
87
87
|
# >>> page.screenshot(path="example.png")
|
|
88
88
|
# >>> browser.close()
|
|
89
89
|
#
|
|
@@ -118,13 +118,13 @@ module Playwright
|
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
# @nodoc
|
|
121
|
-
def
|
|
122
|
-
wrap_impl(@impl.
|
|
121
|
+
def from_service_worker?
|
|
122
|
+
wrap_impl(@impl.from_service_worker?)
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
# @nodoc
|
|
126
|
-
def
|
|
127
|
-
wrap_impl(@impl.
|
|
126
|
+
def ok?
|
|
127
|
+
wrap_impl(@impl.ok?)
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
# -- inherited from EventEmitter --
|
data/lib/playwright_api/route.rb
CHANGED
|
@@ -47,13 +47,13 @@ module Playwright
|
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
# @nodoc
|
|
50
|
-
def
|
|
51
|
-
wrap_impl(@impl.
|
|
50
|
+
def context=(req)
|
|
51
|
+
wrap_impl(@impl.context=(unwrap_impl(req)))
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
# @nodoc
|
|
55
|
-
def
|
|
56
|
-
wrap_impl(@impl.
|
|
55
|
+
def page=(req)
|
|
56
|
+
wrap_impl(@impl.page=(unwrap_impl(req)))
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
# -- inherited from EventEmitter --
|
data/sig/playwright.rbs
CHANGED
|
@@ -118,7 +118,7 @@ module Playwright
|
|
|
118
118
|
def press: (String key, ?delay: Float, ?noWaitAfter: bool, ?timeout: Float) -> void
|
|
119
119
|
def query_selector: (String selector) -> (nil | ElementHandle)
|
|
120
120
|
def query_selector_all: (String selector) -> Array[untyped]
|
|
121
|
-
def screenshot: (?animations: ("disabled" | "allow"), ?caret: ("hide" | "initial"), ?mask: Array[untyped], ?omitBackground: bool, ?path: (String | File), ?quality: Integer, ?scale: ("css" | "device"), ?timeout: Float, ?type: ("png" | "jpeg")) -> String
|
|
121
|
+
def screenshot: (?animations: ("disabled" | "allow"), ?caret: ("hide" | "initial"), ?mask: Array[untyped], ?maskColor: String, ?omitBackground: bool, ?path: (String | File), ?quality: Integer, ?scale: ("css" | "device"), ?timeout: Float, ?type: ("png" | "jpeg")) -> String
|
|
122
122
|
def scroll_into_view_if_needed: (?timeout: Float) -> void
|
|
123
123
|
def select_option: (?element: (ElementHandle | Array[untyped]), ?index: (Integer | Array[untyped]), ?value: (String | Array[untyped]), ?label: (String | Array[untyped]), ?force: bool, ?noWaitAfter: bool, ?timeout: Float) -> Array[untyped]
|
|
124
124
|
def select_text: (?force: bool, ?timeout: Float) -> void
|
|
@@ -223,6 +223,7 @@ module Playwright
|
|
|
223
223
|
class ConsoleMessage
|
|
224
224
|
def args: -> Array[untyped]
|
|
225
225
|
def location: -> Hash[untyped, untyped]
|
|
226
|
+
def page: -> (nil | Page)
|
|
226
227
|
def text: -> String
|
|
227
228
|
def type: -> String
|
|
228
229
|
end
|
|
@@ -232,6 +233,7 @@ module Playwright
|
|
|
232
233
|
def default_value: -> String
|
|
233
234
|
def dismiss: -> void
|
|
234
235
|
def message: -> String
|
|
236
|
+
def page: -> (nil | Page)
|
|
235
237
|
def type: -> String
|
|
236
238
|
end
|
|
237
239
|
|
|
@@ -304,7 +306,7 @@ module Playwright
|
|
|
304
306
|
def reload: (?timeout: Float, ?waitUntil: ("load" | "domcontentloaded" | "networkidle" | "commit")) -> (nil | Response)
|
|
305
307
|
def route: ((String | Regexp | function) url, function handler, ?times: Integer) -> void
|
|
306
308
|
def route_from_har: ((String | File) har, ?notFound: ("abort" | "fallback"), ?update: bool, ?updateContent: ("embed" | "attach"), ?updateMode: ("full" | "minimal"), ?url: (String | Regexp)) -> void
|
|
307
|
-
def screenshot: (?animations: ("disabled" | "allow"), ?caret: ("hide" | "initial"), ?clip: Hash[untyped, untyped], ?fullPage: bool, ?mask: Array[untyped], ?omitBackground: bool, ?path: (String | File), ?quality: Integer, ?scale: ("css" | "device"), ?timeout: Float, ?type: ("png" | "jpeg")) -> String
|
|
309
|
+
def screenshot: (?animations: ("disabled" | "allow"), ?caret: ("hide" | "initial"), ?clip: Hash[untyped, untyped], ?fullPage: bool, ?mask: Array[untyped], ?maskColor: String, ?omitBackground: bool, ?path: (String | File), ?quality: Integer, ?scale: ("css" | "device"), ?timeout: Float, ?type: ("png" | "jpeg")) -> String
|
|
308
310
|
def select_option: (String selector, ?element: (ElementHandle | Array[untyped]), ?index: (Integer | Array[untyped]), ?value: (String | Array[untyped]), ?label: (String | Array[untyped]), ?force: bool, ?noWaitAfter: bool, ?strict: bool, ?timeout: Float) -> Array[untyped]
|
|
309
311
|
def set_checked: (String selector, bool checked, ?force: bool, ?noWaitAfter: bool, ?position: Hash[untyped, untyped], ?strict: bool, ?timeout: Float, ?trial: bool) -> void
|
|
310
312
|
def set_content: (String html, ?timeout: Float, ?waitUntil: ("load" | "domcontentloaded" | "networkidle" | "commit")) -> void
|
|
@@ -382,8 +384,9 @@ module Playwright
|
|
|
382
384
|
def offline=: (bool offline) -> void
|
|
383
385
|
def storage_state: (?path: (String | File)) -> Hash[untyped, untyped]
|
|
384
386
|
def unroute: ((String | Regexp | function) url, ?handler: function) -> void
|
|
387
|
+
def expect_console_message: (?predicate: function, ?timeout: Float) { () -> void } -> ConsoleMessage
|
|
385
388
|
def expect_event: (String event, ?predicate: function, ?timeout: Float) { () -> void } -> untyped
|
|
386
|
-
def expect_page: (?predicate: function, ?timeout: Float) -> Page
|
|
389
|
+
def expect_page: (?predicate: function, ?timeout: Float) { () -> void } -> Page
|
|
387
390
|
|
|
388
391
|
attr_reader request: APIRequestContext
|
|
389
392
|
attr_reader tracing: Tracing
|
|
@@ -434,6 +437,7 @@ module Playwright
|
|
|
434
437
|
def all: -> Array[untyped]
|
|
435
438
|
def all_inner_texts: -> Array[untyped]
|
|
436
439
|
def all_text_contents: -> Array[untyped]
|
|
440
|
+
def and: (Locator locator) -> Locator
|
|
437
441
|
def blur: (?timeout: Float) -> void
|
|
438
442
|
def bounding_box: (?timeout: Float) -> (nil | Hash[untyped, untyped])
|
|
439
443
|
def check: (?force: bool, ?noWaitAfter: bool, ?position: Hash[untyped, untyped], ?timeout: Float, ?trial: bool) -> void
|
|
@@ -479,7 +483,7 @@ module Playwright
|
|
|
479
483
|
def or: (Locator locator) -> Locator
|
|
480
484
|
def page: -> Page
|
|
481
485
|
def press: (String key, ?delay: Float, ?noWaitAfter: bool, ?timeout: Float) -> void
|
|
482
|
-
def screenshot: (?animations: ("disabled" | "allow"), ?caret: ("hide" | "initial"), ?mask: Array[untyped], ?omitBackground: bool, ?path: (String | File), ?quality: Integer, ?scale: ("css" | "device"), ?timeout: Float, ?type: ("png" | "jpeg")) -> String
|
|
486
|
+
def screenshot: (?animations: ("disabled" | "allow"), ?caret: ("hide" | "initial"), ?mask: Array[untyped], ?maskColor: String, ?omitBackground: bool, ?path: (String | File), ?quality: Integer, ?scale: ("css" | "device"), ?timeout: Float, ?type: ("png" | "jpeg")) -> String
|
|
483
487
|
def scroll_into_view_if_needed: (?timeout: Float) -> void
|
|
484
488
|
def select_option: (?element: (ElementHandle | Array[untyped]), ?index: (Integer | Array[untyped]), ?value: (String | Array[untyped]), ?label: (String | Array[untyped]), ?force: bool, ?noWaitAfter: bool, ?timeout: Float) -> Array[untyped]
|
|
485
489
|
def select_text: (?force: bool, ?timeout: Float) -> void
|
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.
|
|
4
|
+
version: 1.35.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- YusukeIwaki
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-
|
|
11
|
+
date: 2023-06-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|
|
@@ -401,5 +401,5 @@ requirements: []
|
|
|
401
401
|
rubygems_version: 3.3.26
|
|
402
402
|
signing_key:
|
|
403
403
|
specification_version: 4
|
|
404
|
-
summary: The Ruby binding of playwright driver 1.
|
|
404
|
+
summary: The Ruby binding of playwright driver 1.35.0
|
|
405
405
|
test_files: []
|