playwright-ruby-client 0.6.0 → 0.6.1
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/README.md +33 -0
- data/documentation/babel.config.js +3 -0
- data/documentation/docs/api/accessibility.md +7 -0
- data/documentation/docs/api/browser.md +185 -0
- data/documentation/docs/api/browser_context.md +398 -0
- data/documentation/docs/api/browser_type.md +105 -0
- data/documentation/docs/api/cdp_session.md +7 -0
- data/documentation/docs/api/console_message.md +41 -0
- data/documentation/docs/api/dialog.md +74 -0
- data/documentation/docs/api/element_handle.md +640 -0
- data/documentation/docs/api/experimental/_category_.yml +3 -0
- data/documentation/docs/api/experimental/android.md +25 -0
- data/documentation/docs/api/experimental/android_device.md +91 -0
- data/documentation/docs/api/experimental/android_input.md +38 -0
- data/documentation/docs/api/experimental/android_socket.md +7 -0
- data/documentation/docs/api/experimental/android_web_view.md +7 -0
- data/documentation/docs/api/file_chooser.md +51 -0
- data/documentation/docs/api/frame.md +867 -0
- data/documentation/docs/api/js_handle.md +116 -0
- data/documentation/docs/api/keyboard.md +157 -0
- data/documentation/docs/api/mouse.md +69 -0
- data/documentation/docs/api/page.md +1469 -0
- data/documentation/docs/api/playwright.md +63 -0
- data/documentation/docs/api/request.md +188 -0
- data/documentation/docs/api/response.md +97 -0
- data/documentation/docs/api/route.md +80 -0
- data/documentation/docs/api/selectors.md +23 -0
- data/documentation/docs/api/touchscreen.md +8 -0
- data/documentation/docs/api/tracing.md +54 -0
- data/documentation/docs/api/web_socket.md +7 -0
- data/documentation/docs/api/worker.md +7 -0
- data/documentation/docs/article/api_coverage.mdx +11 -0
- data/documentation/docs/article/getting_started.md +152 -0
- data/documentation/docs/article/guides/_category_.yml +3 -0
- data/documentation/docs/article/guides/download_playwright_driver.md +49 -0
- data/documentation/docs/article/guides/launch_browser.md +119 -0
- data/documentation/docs/article/guides/rails_integration.md +51 -0
- data/{docs → documentation/docs/include}/api_coverage.md +0 -0
- data/documentation/docusaurus.config.js +107 -0
- data/documentation/package.json +39 -0
- data/documentation/sidebars.js +15 -0
- data/documentation/src/components/HomepageFeatures.js +61 -0
- data/documentation/src/components/HomepageFeatures.module.css +13 -0
- data/documentation/src/css/custom.css +44 -0
- data/documentation/src/pages/index.js +50 -0
- data/documentation/src/pages/index.module.css +41 -0
- data/documentation/src/pages/markdown-page.md +7 -0
- data/documentation/static/.nojekyll +0 -0
- data/documentation/static/img/playwright-logo.svg +9 -0
- data/documentation/static/img/undraw_dropdown_menu.svg +1 -0
- data/documentation/static/img/undraw_web_development.svg +1 -0
- data/documentation/static/img/undraw_windows.svg +1 -0
- data/documentation/yarn.lock +8805 -0
- data/lib/playwright/channel_owners/binding_call.rb +33 -0
- data/lib/playwright/channel_owners/browser_context.rb +2 -2
- data/lib/playwright/channel_owners/element_handle.rb +2 -10
- data/lib/playwright/channel_owners/frame.rb +6 -28
- data/lib/playwright/channel_owners/js_handle.rb +2 -10
- data/lib/playwright/channel_owners/page.rb +10 -1
- data/lib/playwright/input_files.rb +0 -8
- data/lib/playwright/javascript.rb +0 -10
- data/lib/playwright/javascript/expression.rb +2 -7
- data/lib/playwright/version.rb +1 -1
- data/lib/playwright_api/accessibility.rb +7 -89
- data/lib/playwright_api/android.rb +7 -64
- data/lib/playwright_api/android_device.rb +8 -8
- data/lib/playwright_api/browser.rb +15 -169
- data/lib/playwright_api/browser_context.rb +47 -609
- data/lib/playwright_api/browser_type.rb +13 -103
- data/lib/playwright_api/cdp_session.rb +2 -25
- data/lib/playwright_api/console_message.rb +6 -6
- data/lib/playwright_api/dialog.rb +11 -92
- data/lib/playwright_api/element_handle.rb +60 -362
- data/lib/playwright_api/file_chooser.rb +0 -28
- data/lib/playwright_api/frame.rb +74 -713
- data/lib/playwright_api/js_handle.rb +16 -90
- data/lib/playwright_api/keyboard.rb +21 -213
- data/lib/playwright_api/mouse.rb +1 -45
- data/lib/playwright_api/page.rb +155 -1635
- data/lib/playwright_api/playwright.rb +14 -117
- data/lib/playwright_api/request.rb +15 -121
- data/lib/playwright_api/response.rb +9 -9
- data/lib/playwright_api/route.rb +8 -105
- data/lib/playwright_api/selectors.rb +6 -97
- data/lib/playwright_api/tracing.rb +1 -61
- data/lib/playwright_api/web_socket.rb +1 -1
- data/lib/playwright_api/worker.rb +6 -42
- metadata +55 -4
- data/lib/playwright/javascript/function.rb +0 -67
data/lib/playwright_api/route.rb
CHANGED
@@ -9,43 +9,7 @@ module Playwright
|
|
9
9
|
end
|
10
10
|
|
11
11
|
# Continues route's request with optional overrides.
|
12
|
-
#
|
13
12
|
#
|
14
|
-
# ```js
|
15
|
-
# await page.route('**/*', (route, request) => {
|
16
|
-
# // Override headers
|
17
|
-
# const headers = {
|
18
|
-
# ...request.headers(),
|
19
|
-
# foo: 'bar', // set "foo" header
|
20
|
-
# origin: undefined, // remove "origin" header
|
21
|
-
# };
|
22
|
-
# route.continue({headers});
|
23
|
-
# });
|
24
|
-
# ```
|
25
|
-
#
|
26
|
-
# ```java
|
27
|
-
# page.route("**/*", route -> {
|
28
|
-
# // Override headers
|
29
|
-
# Map<String, String> headers = new HashMap<>(route.request().headers());
|
30
|
-
# headers.put("foo", "bar"); // set "foo" header
|
31
|
-
# headers.remove("origin"); // remove "origin" header
|
32
|
-
# route.resume(new Route.ResumeOptions().setHeaders(headers));
|
33
|
-
# });
|
34
|
-
# ```
|
35
|
-
#
|
36
|
-
# ```python async
|
37
|
-
# async def handle(route, request):
|
38
|
-
# # override headers
|
39
|
-
# headers = {
|
40
|
-
# **request.headers,
|
41
|
-
# "foo": "bar" # set "foo" header
|
42
|
-
# "origin": None # remove "origin" header
|
43
|
-
# }
|
44
|
-
# await route.continue_(headers=headers)
|
45
|
-
# }
|
46
|
-
# await page.route("**/*", handle)
|
47
|
-
# ```
|
48
|
-
#
|
49
13
|
# ```python sync
|
50
14
|
# def handle(route, request):
|
51
15
|
# # override headers
|
@@ -58,87 +22,26 @@ module Playwright
|
|
58
22
|
# }
|
59
23
|
# page.route("**/*", handle)
|
60
24
|
# ```
|
61
|
-
#
|
62
|
-
# ```csharp
|
63
|
-
# await page.RouteAsync("**/*", route =>
|
64
|
-
# {
|
65
|
-
# var headers = new Dictionary<string, string>(route.Request.Headers) { { "foo", "bar" } };
|
66
|
-
# headers.Remove("origin");
|
67
|
-
# route.ContinueAsync(headers);
|
68
|
-
# });
|
69
|
-
# ```
|
70
25
|
def continue(headers: nil, method: nil, postData: nil, url: nil)
|
71
26
|
wrap_impl(@impl.continue(headers: unwrap_impl(headers), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
|
72
27
|
end
|
73
28
|
|
74
29
|
# Fulfills route's request with given response.
|
75
|
-
#
|
30
|
+
#
|
76
31
|
# An example of fulfilling all requests with 404 responses:
|
77
|
-
#
|
78
32
|
#
|
79
|
-
# ```js
|
80
|
-
# await page.route('**/*', route => {
|
81
|
-
# route.fulfill({
|
82
|
-
# status: 404,
|
83
|
-
# contentType: 'text/plain',
|
84
|
-
# body: 'Not Found!'
|
85
|
-
# });
|
86
|
-
# });
|
87
|
-
# ```
|
88
|
-
#
|
89
|
-
# ```java
|
90
|
-
# page.route("**/*", route -> {
|
91
|
-
# route.fulfill(new Route.FulfillOptions()
|
92
|
-
# .setStatus(404)
|
93
|
-
# .setContentType("text/plain")
|
94
|
-
# .setBody("Not Found!"));
|
95
|
-
# });
|
96
|
-
# ```
|
97
|
-
#
|
98
|
-
# ```python async
|
99
|
-
# await page.route("**/*", lambda route: route.fulfill(
|
100
|
-
# status=404,
|
101
|
-
# content_type="text/plain",
|
102
|
-
# body="not found!"))
|
103
|
-
# ```
|
104
|
-
#
|
105
33
|
# ```python sync
|
106
34
|
# page.route("**/*", lambda route: route.fulfill(
|
107
35
|
# status=404,
|
108
36
|
# content_type="text/plain",
|
109
37
|
# body="not found!"))
|
110
38
|
# ```
|
111
|
-
#
|
112
|
-
# ```csharp
|
113
|
-
# await page.RouteAsync("**/*", route => route.FulfillAsync(
|
114
|
-
# status: 404,
|
115
|
-
# contentType: "text/plain",
|
116
|
-
# body: "Not Found!"));
|
117
|
-
# ```
|
118
|
-
#
|
39
|
+
#
|
119
40
|
# An example of serving static file:
|
120
|
-
#
|
121
41
|
#
|
122
|
-
# ```js
|
123
|
-
# await page.route('**/xhr_endpoint', route => route.fulfill({ path: 'mock_data.json' }));
|
124
|
-
# ```
|
125
|
-
#
|
126
|
-
# ```java
|
127
|
-
# page.route("**/xhr_endpoint", route -> route.fulfill(
|
128
|
-
# new Route.FulfillOptions().setPath(Paths.get("mock_data.json")));
|
129
|
-
# ```
|
130
|
-
#
|
131
|
-
# ```python async
|
132
|
-
# await page.route("**/xhr_endpoint", lambda route: route.fulfill(path="mock_data.json"))
|
133
|
-
# ```
|
134
|
-
#
|
135
42
|
# ```python sync
|
136
43
|
# page.route("**/xhr_endpoint", lambda route: route.fulfill(path="mock_data.json"))
|
137
44
|
# ```
|
138
|
-
#
|
139
|
-
# ```csharp
|
140
|
-
# await page.RouteAsync("**/xhr_endpoint", route => route.FulfillAsync(path: "mock_data.json"));
|
141
|
-
# ```
|
142
45
|
def fulfill(
|
143
46
|
body: nil,
|
144
47
|
contentType: nil,
|
@@ -155,20 +58,20 @@ module Playwright
|
|
155
58
|
|
156
59
|
# -- inherited from EventEmitter --
|
157
60
|
# @nodoc
|
158
|
-
def
|
159
|
-
event_emitter_proxy.
|
61
|
+
def on(event, callback)
|
62
|
+
event_emitter_proxy.on(event, callback)
|
160
63
|
end
|
161
64
|
|
162
65
|
# -- inherited from EventEmitter --
|
163
66
|
# @nodoc
|
164
|
-
def
|
165
|
-
event_emitter_proxy.
|
67
|
+
def off(event, callback)
|
68
|
+
event_emitter_proxy.off(event, callback)
|
166
69
|
end
|
167
70
|
|
168
71
|
# -- inherited from EventEmitter --
|
169
72
|
# @nodoc
|
170
|
-
def
|
171
|
-
event_emitter_proxy.
|
73
|
+
def once(event, callback)
|
74
|
+
event_emitter_proxy.once(event, callback)
|
172
75
|
end
|
173
76
|
|
174
77
|
private def event_emitter_proxy
|
@@ -4,121 +4,30 @@ module Playwright
|
|
4
4
|
class Selectors < PlaywrightApi
|
5
5
|
|
6
6
|
# An example of registering selector engine that queries elements based on a tag name:
|
7
|
-
#
|
8
7
|
#
|
9
|
-
# ```js
|
10
|
-
# const { selectors, firefox } = require('playwright'); // Or 'chromium' or 'webkit'.
|
11
|
-
#
|
12
|
-
# (async () => {
|
13
|
-
# // Must be a function that evaluates to a selector engine instance.
|
14
|
-
# const createTagNameEngine = () => ({
|
15
|
-
# // Returns the first element matching given selector in the root's subtree.
|
16
|
-
# query(root, selector) {
|
17
|
-
# return root.querySelector(selector);
|
18
|
-
# },
|
19
|
-
#
|
20
|
-
# // Returns all elements matching given selector in the root's subtree.
|
21
|
-
# queryAll(root, selector) {
|
22
|
-
# return Array.from(root.querySelectorAll(selector));
|
23
|
-
# }
|
24
|
-
# });
|
25
|
-
#
|
26
|
-
# // Register the engine. Selectors will be prefixed with "tag=".
|
27
|
-
# await selectors.register('tag', createTagNameEngine);
|
28
|
-
#
|
29
|
-
# const browser = await firefox.launch();
|
30
|
-
# const page = await browser.newPage();
|
31
|
-
# await page.setContent(`<div><button>Click me</button></div>`);
|
32
|
-
#
|
33
|
-
# // Use the selector prefixed with its name.
|
34
|
-
# const button = await page.$('tag=button');
|
35
|
-
# // Combine it with other selector engines.
|
36
|
-
# await page.click('tag=div >> text="Click me"');
|
37
|
-
# // Can use it in any methods supporting selectors.
|
38
|
-
# const buttonCount = await page.$$eval('tag=button', buttons => buttons.length);
|
39
|
-
#
|
40
|
-
# await browser.close();
|
41
|
-
# })();
|
42
|
-
# ```
|
43
|
-
#
|
44
|
-
# ```java
|
45
|
-
# // Script that evaluates to a selector engine instance.
|
46
|
-
# String createTagNameEngine = "{\n" +
|
47
|
-
# " // Returns the first element matching given selector in the root's subtree.\n" +
|
48
|
-
# " query(root, selector) {\n" +
|
49
|
-
# " return root.querySelector(selector);\n" +
|
50
|
-
# " },\n" +
|
51
|
-
# " // Returns all elements matching given selector in the root's subtree.\n" +
|
52
|
-
# " queryAll(root, selector) {\n" +
|
53
|
-
# " return Array.from(root.querySelectorAll(selector));\n" +
|
54
|
-
# " }\n" +
|
55
|
-
# "}";
|
56
|
-
# // Register the engine. Selectors will be prefixed with "tag=".
|
57
|
-
# playwright.selectors().register("tag", createTagNameEngine);
|
58
|
-
# Browser browser = playwright.firefox().launch();
|
59
|
-
# Page page = browser.newPage();
|
60
|
-
# page.setContent("<div><button>Click me</button></div>");
|
61
|
-
# // Use the selector prefixed with its name.
|
62
|
-
# ElementHandle button = page.querySelector("tag=button");
|
63
|
-
# // Combine it with other selector engines.
|
64
|
-
# page.click("tag=div >> text=\"Click me\"");
|
65
|
-
# // Can use it in any methods supporting selectors.
|
66
|
-
# int buttonCount = (int) page.evalOnSelectorAll("tag=button", "buttons => buttons.length");
|
67
|
-
# browser.close();
|
68
|
-
# ```
|
69
|
-
#
|
70
|
-
# ```python async
|
71
|
-
# # FIXME: add snippet
|
72
|
-
# ```
|
73
|
-
#
|
74
8
|
# ```python sync
|
75
9
|
# # FIXME: add snippet
|
76
10
|
# ```
|
77
|
-
#
|
78
|
-
# ```csharp
|
79
|
-
# using var playwright = await Playwright.CreateAsync();
|
80
|
-
# // Script that evaluates to a selector engine instance.
|
81
|
-
# await playwright.Selectors.RegisterAsync("tag", @"{
|
82
|
-
# // Returns the first element matching given selector in the root's subtree.
|
83
|
-
# query(root, selector) {
|
84
|
-
# return root.querySelector(selector);
|
85
|
-
# },
|
86
|
-
# // Returns all elements matching given selector in the root's subtree.
|
87
|
-
# queryAll(root, selector) {
|
88
|
-
# return Array.from(root.querySelectorAll(selector));
|
89
|
-
# }
|
90
|
-
# }");
|
91
|
-
#
|
92
|
-
# await using var browser = await playwright.Chromium.LaunchAsync();
|
93
|
-
# var page = await browser.NewPageAsync();
|
94
|
-
# await page.SetContentAsync("<div><button>Click me</button></div>");
|
95
|
-
# // Use the selector prefixed with its name.
|
96
|
-
# var button = await page.QuerySelectorAsync("tag=button");
|
97
|
-
# // Combine it with other selector engines.
|
98
|
-
# await page.ClickAsync("tag=div >> text=\"Click me\"");
|
99
|
-
# // Can use it in any methods supporting selectors.
|
100
|
-
# int buttonCount = await page.EvalOnSelectorAllAsync<int>("tag=button", "buttons => buttons.length");
|
101
|
-
# ```
|
102
11
|
def register(name, contentScript: nil, path: nil, script: nil)
|
103
12
|
wrap_impl(@impl.register(unwrap_impl(name), contentScript: unwrap_impl(contentScript), path: unwrap_impl(path), script: unwrap_impl(script)))
|
104
13
|
end
|
105
14
|
|
106
15
|
# -- inherited from EventEmitter --
|
107
16
|
# @nodoc
|
108
|
-
def
|
109
|
-
event_emitter_proxy.
|
17
|
+
def on(event, callback)
|
18
|
+
event_emitter_proxy.on(event, callback)
|
110
19
|
end
|
111
20
|
|
112
21
|
# -- inherited from EventEmitter --
|
113
22
|
# @nodoc
|
114
|
-
def
|
115
|
-
event_emitter_proxy.
|
23
|
+
def off(event, callback)
|
24
|
+
event_emitter_proxy.off(event, callback)
|
116
25
|
end
|
117
26
|
|
118
27
|
# -- inherited from EventEmitter --
|
119
28
|
# @nodoc
|
120
|
-
def
|
121
|
-
event_emitter_proxy.
|
29
|
+
def once(event, callback)
|
30
|
+
event_emitter_proxy.once(event, callback)
|
122
31
|
end
|
123
32
|
|
124
33
|
private def event_emitter_proxy
|
@@ -1,42 +1,9 @@
|
|
1
1
|
module Playwright
|
2
2
|
# API for collecting and saving Playwright traces. Playwright traces can be opened using the Playwright CLI after
|
3
3
|
# Playwright script runs.
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# Start with specifying the folder traces will be stored in:
|
6
|
-
#
|
7
6
|
#
|
8
|
-
# ```js
|
9
|
-
# const browser = await chromium.launch({ traceDir: 'traces' });
|
10
|
-
# const context = await browser.newContext();
|
11
|
-
# await context.tracing.start({ name: 'trace', screenshots: true, snapshots: true });
|
12
|
-
# const page = await context.newPage();
|
13
|
-
# await page.goto('https://playwright.dev');
|
14
|
-
# await context.tracing.stop();
|
15
|
-
# await context.tracing.export('trace.zip');
|
16
|
-
# ```
|
17
|
-
#
|
18
|
-
# ```java
|
19
|
-
# Browser browser = chromium.launch(new BrowserType.LaunchOptions().setTraceDir("trace"));
|
20
|
-
# BrowserContext context = browser.newContext();
|
21
|
-
# context.tracing.start(page, new Tracing.StartOptions()
|
22
|
-
# .setName("trace")
|
23
|
-
# .setScreenshots(true)
|
24
|
-
# .setSnapshots(true);
|
25
|
-
# Page page = context.newPage();
|
26
|
-
# page.goto("https://playwright.dev");
|
27
|
-
# context.tracing.stop();
|
28
|
-
# context.tracing.export(Paths.get("trace.zip")))
|
29
|
-
# ```
|
30
|
-
#
|
31
|
-
# ```python async
|
32
|
-
# browser = await chromium.launch(traceDir='traces')
|
33
|
-
# context = await browser.new_context()
|
34
|
-
# await context.tracing.start(name="trace", screenshots=True, snapshots=True)
|
35
|
-
# await page.goto("https://playwright.dev")
|
36
|
-
# await context.tracing.stop()
|
37
|
-
# await context.tracing.export("trace.zip")
|
38
|
-
# ```
|
39
|
-
#
|
40
7
|
# ```python sync
|
41
8
|
# browser = chromium.launch(traceDir='traces')
|
42
9
|
# context = browser.new_context()
|
@@ -53,34 +20,7 @@ module Playwright
|
|
53
20
|
end
|
54
21
|
|
55
22
|
# Start tracing.
|
56
|
-
#
|
57
23
|
#
|
58
|
-
# ```js
|
59
|
-
# await context.tracing.start({ name: 'trace', screenshots: true, snapshots: true });
|
60
|
-
# const page = await context.newPage();
|
61
|
-
# await page.goto('https://playwright.dev');
|
62
|
-
# await context.tracing.stop();
|
63
|
-
# await context.tracing.export('trace.zip');
|
64
|
-
# ```
|
65
|
-
#
|
66
|
-
# ```java
|
67
|
-
# context.tracing.start(page, new Tracing.StartOptions()
|
68
|
-
# .setName("trace")
|
69
|
-
# .setScreenshots(true)
|
70
|
-
# .setSnapshots(true);
|
71
|
-
# Page page = context.newPage();
|
72
|
-
# page.goto('https://playwright.dev');
|
73
|
-
# context.tracing.stop();
|
74
|
-
# context.tracing.export(Paths.get("trace.zip")))
|
75
|
-
# ```
|
76
|
-
#
|
77
|
-
# ```python async
|
78
|
-
# await context.tracing.start(name="trace", screenshots=True, snapshots=True)
|
79
|
-
# await page.goto("https://playwright.dev")
|
80
|
-
# await context.tracing.stop()
|
81
|
-
# await context.tracing.export("trace.zip")
|
82
|
-
# ```
|
83
|
-
#
|
84
24
|
# ```python sync
|
85
25
|
# context.tracing.start(name="trace", screenshots=True, snapshots=True)
|
86
26
|
# page.goto("https://playwright.dev")
|
@@ -19,7 +19,7 @@ module Playwright
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# > NOTE: In most cases, you should use [`method: WebSocket.waitForEvent`].
|
22
|
-
#
|
22
|
+
#
|
23
23
|
# Waits for given `event` to fire. If predicate is provided, it passes event's value into the `predicate` function and
|
24
24
|
# waits for `predicate(event)` to return a truthy value. Will throw an error if the socket is closed before the `event` is
|
25
25
|
# fired.
|
@@ -2,61 +2,25 @@ module Playwright
|
|
2
2
|
# The Worker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). `worker`
|
3
3
|
# event is emitted on the page object to signal a worker creation. `close` event is emitted on the worker object when the
|
4
4
|
# worker is gone.
|
5
|
-
#
|
6
5
|
#
|
7
|
-
# ```js
|
8
|
-
# page.on('worker', worker => {
|
9
|
-
# console.log('Worker created: ' + worker.url());
|
10
|
-
# worker.on('close', worker => console.log('Worker destroyed: ' + worker.url()));
|
11
|
-
# });
|
12
|
-
#
|
13
|
-
# console.log('Current workers:');
|
14
|
-
# for (const worker of page.workers())
|
15
|
-
# console.log(' ' + worker.url());
|
16
|
-
# ```
|
17
|
-
#
|
18
|
-
# ```java
|
19
|
-
# page.onWorker(worker -> {
|
20
|
-
# System.out.println("Worker created: " + worker.url());
|
21
|
-
# worker.onClose(worker1 -> System.out.println("Worker destroyed: " + worker1.url()));
|
22
|
-
# });
|
23
|
-
# System.out.println("Current workers:");
|
24
|
-
# for (Worker worker : page.workers())
|
25
|
-
# System.out.println(" " + worker.url());
|
26
|
-
# ```
|
27
|
-
#
|
28
6
|
# ```py
|
29
7
|
# def handle_worker(worker):
|
30
8
|
# print("worker created: " + worker.url)
|
31
9
|
# worker.on("close", lambda: print("worker destroyed: " + worker.url))
|
32
|
-
#
|
10
|
+
#
|
33
11
|
# page.on('worker', handle_worker)
|
34
|
-
#
|
12
|
+
#
|
35
13
|
# print("current workers:")
|
36
14
|
# for worker in page.workers:
|
37
15
|
# print(" " + worker.url)
|
38
16
|
# ```
|
39
|
-
#
|
40
|
-
# ```csharp
|
41
|
-
# page.Worker += (_, worker) =>
|
42
|
-
# {
|
43
|
-
# Console.WriteLine($"Worker created: {worker.Url}");
|
44
|
-
# worker.Close += (_, _) => Console.WriteLine($"Worker closed {worker.Url}");
|
45
|
-
# };
|
46
|
-
#
|
47
|
-
# Console.WriteLine("Current Workers:");
|
48
|
-
# foreach(var pageWorker in page.Workers)
|
49
|
-
# {
|
50
|
-
# Console.WriteLine($"\tWorker: {pageWorker.Url}");
|
51
|
-
# }
|
52
|
-
# ```
|
53
17
|
class Worker < PlaywrightApi
|
54
18
|
|
55
19
|
# Returns the return value of `expression`.
|
56
|
-
#
|
20
|
+
#
|
57
21
|
# If the function passed to the [`method: Worker.evaluate`] returns a [Promise], then [`method: Worker.evaluate`] would
|
58
22
|
# wait for the promise to resolve and return its value.
|
59
|
-
#
|
23
|
+
#
|
60
24
|
# If the function passed to the [`method: Worker.evaluate`] returns a non-[Serializable] value, then
|
61
25
|
# [`method: Worker.evaluate`] returns `undefined`. Playwright also supports transferring some additional values that are
|
62
26
|
# not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
|
@@ -65,10 +29,10 @@ module Playwright
|
|
65
29
|
end
|
66
30
|
|
67
31
|
# Returns the return value of `expression` as a `JSHandle`.
|
68
|
-
#
|
32
|
+
#
|
69
33
|
# The only difference between [`method: Worker.evaluate`] and [`method: Worker.evaluateHandle`] is that
|
70
34
|
# [`method: Worker.evaluateHandle`] returns `JSHandle`.
|
71
|
-
#
|
35
|
+
#
|
72
36
|
# If the function passed to the [`method: Worker.evaluateHandle`] returns a [Promise], then
|
73
37
|
# [`method: Worker.evaluateHandle`] would wait for the promise to resolve and return its value.
|
74
38
|
def evaluate_handle(expression, arg: nil)
|