playwright-ruby-client 1.42.0 → 1.43.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/documentation/docs/api/browser_context.md +22 -10
- data/documentation/docs/api/frame_locator.md +26 -4
- data/documentation/docs/api/locator.md +22 -0
- data/documentation/docs/api/page.md +10 -8
- data/documentation/docs/article/guides/download_playwright_driver.md +7 -10
- data/documentation/docs/article/guides/playwright_on_alpine_linux.md +3 -1
- data/documentation/docs/include/api_coverage.md +2 -0
- data/documentation/docusaurus.config.js +6 -0
- data/documentation/package.json +2 -2
- data/documentation/yarn.lock +1732 -1815
- data/lib/playwright/channel_owners/browser_context.rb +31 -2
- data/lib/playwright/channel_owners/js_handle.rb +4 -0
- data/lib/playwright/channel_owners/request.rb +1 -1
- data/lib/playwright/connection.rb +3 -0
- data/lib/playwright/frame_locator_impl.rb +8 -0
- data/lib/playwright/locator_impl.rb +8 -0
- data/lib/playwright/transport.rb +6 -0
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright/waiter.rb +4 -6
- data/lib/playwright/web_socket_transport.rb +8 -0
- data/lib/playwright.rb +1 -1
- data/lib/playwright_api/android.rb +6 -6
- data/lib/playwright_api/android_device.rb +6 -6
- data/lib/playwright_api/api_request_context.rb +6 -6
- data/lib/playwright_api/browser.rb +6 -6
- data/lib/playwright_api/browser_context.rb +24 -14
- data/lib/playwright_api/browser_type.rb +6 -6
- data/lib/playwright_api/cdp_session.rb +6 -6
- data/lib/playwright_api/dialog.rb +6 -6
- data/lib/playwright_api/element_handle.rb +6 -6
- data/lib/playwright_api/frame.rb +6 -6
- data/lib/playwright_api/frame_locator.rb +23 -4
- data/lib/playwright_api/js_handle.rb +6 -6
- data/lib/playwright_api/locator.rb +19 -0
- data/lib/playwright_api/page.rb +26 -22
- data/lib/playwright_api/playwright.rb +6 -6
- data/lib/playwright_api/request.rb +6 -6
- data/lib/playwright_api/response.rb +6 -6
- data/lib/playwright_api/route.rb +6 -6
- data/lib/playwright_api/selectors.rb +6 -6
- data/lib/playwright_api/tracing.rb +6 -6
- data/lib/playwright_api/web_socket.rb +6 -6
- data/lib/playwright_api/worker.rb +6 -6
- data/sig/playwright.rbs +3 -1
- 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: e22c38ec1a50889adfbb6664dcb445db3635bcfd3d0240113f5b7250f5a16f91
|
4
|
+
data.tar.gz: 74f4b27cbc4d4e0b903c46621fa7dea13249d97b17bd780436fd5635d90f3e83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4201f5fa8a9353daecb78860b4a142a477c64b9634560b262faaea2c53491c0b5909ec3ada0e6ece917de08a91390b479a0aca34e7d607c0c14e9cf0999579a
|
7
|
+
data.tar.gz: 63968771197cee749d2780fa3f822f9e154088c0ea53062b86dda770f05704344a3f1f5dd696387d419252c2d1466a83e1ffbf8810ee25f069cf48c5662804ad
|
data/README.md
CHANGED
@@ -168,13 +168,13 @@ If your environment doesn't accept installing browser or creating browser proces
|
|
168
168
|
For launching Playwright server, just execute:
|
169
169
|
|
170
170
|
```
|
171
|
-
npx playwright install && npx playwright run-server --port 8080
|
171
|
+
npx playwright install && npx playwright run-server --port 8080 --path /ws
|
172
172
|
```
|
173
173
|
|
174
174
|
and we can connect to the server with the code like this:
|
175
175
|
|
176
176
|
```ruby
|
177
|
-
Playwright.connect_to_playwright_server('ws://127.0.0.1:8080') do |playwright|
|
177
|
+
Playwright.connect_to_playwright_server('ws://127.0.0.1:8080/ws?browser=chromium') do |playwright|
|
178
178
|
playwright.chromium.launch do |browser|
|
179
179
|
page = browser.new_page
|
180
180
|
page.goto('https://github.com/YusukeIwaki')
|
@@ -91,11 +91,21 @@ Returns the browser instance of the context. If it was launched as a persistent
|
|
91
91
|
## clear_cookies
|
92
92
|
|
93
93
|
```
|
94
|
-
def clear_cookies
|
94
|
+
def clear_cookies(domain: nil, name: nil, path: nil)
|
95
95
|
```
|
96
96
|
|
97
97
|
|
98
|
-
|
98
|
+
Removes cookies from context. Accepts optional filter.
|
99
|
+
|
100
|
+
**Usage**
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
context.clear_cookies()
|
104
|
+
context.clear_cookies(name: "session-id")
|
105
|
+
context.clear_cookies(domain: "my-origin.com")
|
106
|
+
context.clear_cookies(path: "/api/v1")
|
107
|
+
context.clear_cookies(name: "session-id", domain: "my-origin.com")
|
108
|
+
```
|
99
109
|
|
100
110
|
## clear_permissions
|
101
111
|
|
@@ -311,14 +321,16 @@ page.goto("https://example.com")
|
|
311
321
|
|
312
322
|
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:
|
313
323
|
|
314
|
-
```
|
315
|
-
def handle_route(route
|
316
|
-
if
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
324
|
+
```ruby
|
325
|
+
def handle_route(route, request)
|
326
|
+
if request.post_data["my-string"]
|
327
|
+
mocked_data = request.post_data.merge({ "my-string" => 'mocked-data'})
|
328
|
+
route.fulfill(postData: mocked_data)
|
329
|
+
else
|
330
|
+
route.continue
|
331
|
+
end
|
332
|
+
end
|
333
|
+
context.route("/api/**", method(:handle_route))
|
322
334
|
```
|
323
335
|
|
324
336
|
Page routes (set up with [Page#route](./page#route)) take precedence over browser context routes when request matches both
|
@@ -26,11 +26,11 @@ page.frame_locator('.result-frame').first.get_by_role('button').click
|
|
26
26
|
|
27
27
|
**Converting Locator to FrameLocator**
|
28
28
|
|
29
|
-
If you have a [Locator](./locator) object pointing to an `iframe` it can be converted to [FrameLocator](./frame_locator) using [
|
29
|
+
If you have a [Locator](./locator) object pointing to an `iframe` it can be converted to [FrameLocator](./frame_locator) using [Locator#content_frame](./locator#content_frame).
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
**Converting FrameLocator to Locator**
|
32
|
+
|
33
|
+
If you have a [FrameLocator](./frame_locator) object it can be converted to [Locator](./locator) pointing to the same `iframe` using [FrameLocator#owner](./frame_locator#owner).
|
34
34
|
|
35
35
|
## first
|
36
36
|
|
@@ -305,3 +305,25 @@ def nth(index)
|
|
305
305
|
|
306
306
|
|
307
307
|
Returns locator to the n-th matching frame. It's zero based, `nth(0)` selects the first frame.
|
308
|
+
|
309
|
+
## owner
|
310
|
+
|
311
|
+
```
|
312
|
+
def owner
|
313
|
+
```
|
314
|
+
|
315
|
+
|
316
|
+
Returns a [Locator](./locator) object pointing to the same `iframe` as this frame locator.
|
317
|
+
|
318
|
+
Useful when you have a [FrameLocator](./frame_locator) object obtained somewhere, and later on would like to interact with the `iframe` element.
|
319
|
+
|
320
|
+
For a reverse operation, use [Locator#content_frame](./locator#content_frame).
|
321
|
+
|
322
|
+
**Usage**
|
323
|
+
|
324
|
+
```ruby
|
325
|
+
frame_locator = page.frame_locator('iframe[name="embedded"]')
|
326
|
+
# ...
|
327
|
+
locator = frame_locator.owner
|
328
|
+
locator.get_attribute('src') # => frame1.html
|
329
|
+
```
|
@@ -377,6 +377,28 @@ def element_handles
|
|
377
377
|
|
378
378
|
Resolves given locator to all matching DOM elements. If there are no matching elements, returns an empty list.
|
379
379
|
|
380
|
+
## content_frame
|
381
|
+
|
382
|
+
```
|
383
|
+
def content_frame
|
384
|
+
```
|
385
|
+
|
386
|
+
|
387
|
+
Returns a [FrameLocator](./frame_locator) object pointing to the same `iframe` as this locator.
|
388
|
+
|
389
|
+
Useful when you have a [Locator](./locator) object obtained somewhere, and later on would like to interact with the content inside the frame.
|
390
|
+
|
391
|
+
For a reverse operation, use [FrameLocator#owner](./frame_locator#owner).
|
392
|
+
|
393
|
+
**Usage**
|
394
|
+
|
395
|
+
```ruby
|
396
|
+
locator = page.locator('iframe[name="embedded"]')
|
397
|
+
# ...
|
398
|
+
frame_locator = locator.content_frame
|
399
|
+
frame_locator.get_by_role("button").click
|
400
|
+
```
|
401
|
+
|
380
402
|
## evaluate
|
381
403
|
|
382
404
|
```
|
@@ -1246,14 +1246,16 @@ page.goto("https://example.com")
|
|
1246
1246
|
|
1247
1247
|
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:
|
1248
1248
|
|
1249
|
-
```
|
1250
|
-
def handle_route(route
|
1251
|
-
if
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1249
|
+
```ruby
|
1250
|
+
def handle_route(route, request)
|
1251
|
+
if request.post_data["my-string"]
|
1252
|
+
mocked_data = request.post_data.merge({ "my-string" => 'mocked-data'})
|
1253
|
+
route.fulfill(postData: mocked_data)
|
1254
|
+
else
|
1255
|
+
route.continue
|
1256
|
+
end
|
1257
|
+
end
|
1258
|
+
page.route("/api/**", method(:handle_route))
|
1257
1259
|
```
|
1258
1260
|
|
1259
1261
|
Page routes take precedence over browser context routes (set up with [BrowserContext#route](./browser_context#route)) when request
|
@@ -8,16 +8,16 @@ sidebar_position: 1
|
|
8
8
|
|
9
9
|
Choose any of the three ways as you prefer to download the driver:
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
- `npx`: suitable for playground use, and not suitable for continuous usage.
|
12
|
+
- `npm install`: the best choice for most use cases, with existing Node.js environment.
|
13
|
+
- Direct download: maybe a good choice for Docker :whale: integration.
|
14
14
|
|
15
15
|
:::note
|
16
16
|
|
17
17
|
Also the article [Playwright on Alpine Linux](./playwright_on_alpine_linux) would be helpful if you plan to
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
- Build a browser server/container like Selenium Grid
|
20
|
+
- Run automation scripts on Alpine Linux
|
21
21
|
|
22
22
|
:::
|
23
23
|
|
@@ -29,7 +29,6 @@ $ npx playwright install
|
|
29
29
|
|
30
30
|
and then set `playwright_cli_executable_path: "npx playwright"` at `Playwright.create`.
|
31
31
|
|
32
|
-
|
33
32
|
## Using `npm install`
|
34
33
|
|
35
34
|
Actually `npx playwright` is a bit slow. We can also use `npm install` to setup.
|
@@ -44,15 +43,13 @@ $ ./node_modules/.bin/playwright install
|
|
44
43
|
|
45
44
|
and then set `playwright_cli_executable_path: './node_modules/.bin/playwright'`
|
46
45
|
|
47
|
-
|
48
46
|
## Directly download driver without Node.js installation.
|
49
47
|
|
50
|
-
Instead of npm, you can also directly download playwright driver from playwright.azureedge.net.
|
51
|
-
|
48
|
+
Instead of npm, you can also directly download playwright driver from playwright.azureedge.net. (The URL can be easily detected from [here](https://github.com/microsoft/playwright-python/blob/cfc1030a69d1e934cac579687a680eac53d4b9ee/setup.py#L75))
|
52
49
|
|
53
50
|
```shell
|
54
51
|
$ export PLAYWRIGHT_CLI_VERSION=$(bundle exec ruby -e 'puts Playwright::COMPATIBLE_PLAYWRIGHT_VERSION.strip')
|
55
52
|
$ wget https://playwright.azureedge.net/builds/driver/playwright-$PLAYWRIGHT_CLI_VERSION-linux.zip
|
56
53
|
```
|
57
54
|
|
58
|
-
and then extract it, and set `playwright_cli_executable_path: '/path/to/playwright-
|
55
|
+
and then extract it, and set `playwright_cli_executable_path: '/path/to/playwright-$PLAYWRIGHT_CLI_VERSION-linux/node /path/to/playwright-$PLAYWRIGHT_CLI_VERSION-linux/package/cli.js'`
|
@@ -62,7 +62,7 @@ Many example uses `Playwright#create`, which internally uses Pipe (stdin/stdout)
|
|
62
62
|
```ruby {3}
|
63
63
|
require 'playwright'
|
64
64
|
|
65
|
-
Playwright.connect_to_playwright_server('wss://example.com:8888/ws') do |playwright|
|
65
|
+
Playwright.connect_to_playwright_server('wss://example.com:8888/ws?browser=chromium') do |playwright|
|
66
66
|
playwright.chromium.launch do |browser|
|
67
67
|
page = browser.new_page
|
68
68
|
page.goto('https://github.com/microsoft/playwright')
|
@@ -73,6 +73,8 @@ end
|
|
73
73
|
|
74
74
|
`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"`.
|
75
75
|
|
76
|
+
Note that `?browser=chromium` is important for server to determine which browser to prepare.
|
77
|
+
|
76
78
|
### Server code
|
77
79
|
|
78
80
|
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)
|
@@ -86,6 +86,12 @@ module.exports = {
|
|
86
86
|
prism: {
|
87
87
|
additionalLanguages: ['bash', 'ruby'],
|
88
88
|
},
|
89
|
+
algolia: {
|
90
|
+
appId: '00PBL1OR8R',
|
91
|
+
apiKey: '38d9bd4fef84d709547a1ca466ee8241',
|
92
|
+
indexName: 'playwright-ruby-client',
|
93
|
+
contextualSearch: false,
|
94
|
+
}
|
89
95
|
},
|
90
96
|
presets: [
|
91
97
|
[
|
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.1.1",
|
18
|
+
"@docusaurus/preset-classic": "^3.1.1",
|
19
19
|
"@mdx-js/react": "^3.0.0",
|
20
20
|
"@svgr/webpack": "^8.1.0",
|
21
21
|
"clsx": "^2.0.0",
|