playwright-ruby-client 0.0.8 → 1.58.1.alpha1
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/AGENTS.md +4 -0
- data/CLAUDE/api_generation.md +28 -0
- data/CLAUDE/ci_expectations.md +23 -0
- data/CLAUDE/gem_release_flow.md +39 -0
- data/CLAUDE/past_upgrade_pr_patterns.md +42 -0
- data/CLAUDE/playwright_upgrade_workflow.md +35 -0
- data/CLAUDE/rspec_debugging.md +30 -0
- data/CLAUDE/unimplemented_examples.md +18 -0
- data/CLAUDE.md +32 -0
- data/CONTRIBUTING.md +5 -0
- data/README.md +60 -16
- data/documentation/README.md +33 -0
- data/documentation/babel.config.js +3 -0
- data/documentation/docs/api/api_request.md +7 -0
- data/documentation/docs/api/api_request_context.md +298 -0
- data/documentation/docs/api/api_response.md +114 -0
- data/documentation/docs/api/browser.md +237 -0
- data/documentation/docs/api/browser_context.md +503 -0
- data/documentation/docs/api/browser_type.md +184 -0
- data/documentation/docs/api/cdp_session.md +44 -0
- data/documentation/docs/api/clock.md +154 -0
- data/documentation/docs/api/console_message.md +85 -0
- data/documentation/docs/api/dialog.md +84 -0
- data/documentation/docs/api/download.md +111 -0
- data/documentation/docs/api/element_handle.md +694 -0
- data/documentation/docs/api/experimental/_category_.yml +3 -0
- data/documentation/docs/api/experimental/android.md +42 -0
- data/documentation/docs/api/experimental/android_device.md +109 -0
- data/documentation/docs/api/experimental/android_input.md +43 -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 +53 -0
- data/documentation/docs/api/frame.md +1218 -0
- data/documentation/docs/api/frame_locator.md +348 -0
- data/documentation/docs/api/js_handle.md +121 -0
- data/documentation/docs/api/keyboard.md +170 -0
- data/documentation/docs/api/locator.md +1495 -0
- data/documentation/docs/api/locator_assertions.md +827 -0
- data/documentation/docs/api/mouse.md +86 -0
- data/documentation/docs/api/page.md +1946 -0
- data/documentation/docs/api/page_assertions.md +65 -0
- data/documentation/docs/api/playwright.md +66 -0
- data/documentation/docs/api/request.md +255 -0
- data/documentation/docs/api/response.md +176 -0
- data/documentation/docs/api/route.md +205 -0
- data/documentation/docs/api/selectors.md +63 -0
- data/documentation/docs/api/touchscreen.md +22 -0
- data/documentation/docs/api/tracing.md +129 -0
- data/documentation/docs/api/web_socket.md +51 -0
- data/documentation/docs/api/worker.md +83 -0
- data/documentation/docs/article/api_coverage.mdx +11 -0
- data/documentation/docs/article/getting_started.md +161 -0
- data/documentation/docs/article/guides/_category_.yml +3 -0
- data/documentation/docs/article/guides/download_playwright_driver.md +55 -0
- data/documentation/docs/article/guides/inspector.md +31 -0
- data/documentation/docs/article/guides/launch_browser.md +121 -0
- data/documentation/docs/article/guides/playwright_on_alpine_linux.md +112 -0
- data/documentation/docs/article/guides/rails_integration.md +278 -0
- data/documentation/docs/article/guides/rails_integration_with_null_driver.md +145 -0
- data/documentation/docs/article/guides/recording_video.md +79 -0
- data/documentation/docs/article/guides/rspec_integration.md +59 -0
- data/documentation/docs/article/guides/semi_automation.md +71 -0
- data/documentation/docs/article/guides/use_storage_state.md +78 -0
- data/documentation/docs/include/api_coverage.md +671 -0
- data/documentation/docusaurus.config.js +114 -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 +49 -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/playwright-ruby-client.png +0 -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 +9005 -0
- data/lib/playwright/{input_types/android_input.rb → android_input_impl.rb} +5 -1
- data/lib/playwright/api_implementation.rb +18 -0
- data/lib/playwright/api_response_impl.rb +77 -0
- data/lib/playwright/channel.rb +62 -1
- data/lib/playwright/channel_owner.rb +70 -7
- data/lib/playwright/channel_owners/android.rb +16 -3
- data/lib/playwright/channel_owners/android_device.rb +22 -66
- data/lib/playwright/channel_owners/api_request_context.rb +247 -0
- data/lib/playwright/channel_owners/artifact.rb +40 -0
- data/lib/playwright/channel_owners/binding_call.rb +70 -0
- data/lib/playwright/channel_owners/browser.rb +114 -22
- data/lib/playwright/channel_owners/browser_context.rb +589 -15
- data/lib/playwright/channel_owners/browser_type.rb +90 -1
- data/lib/playwright/channel_owners/cdp_session.rb +19 -0
- data/lib/playwright/channel_owners/dialog.rb +32 -0
- data/lib/playwright/channel_owners/element_handle.rb +107 -43
- data/lib/playwright/channel_owners/fetch_request.rb +8 -0
- data/lib/playwright/channel_owners/frame.rb +334 -104
- data/lib/playwright/channel_owners/js_handle.rb +9 -13
- data/lib/playwright/channel_owners/local_utils.rb +82 -0
- data/lib/playwright/channel_owners/page.rb +778 -95
- data/lib/playwright/channel_owners/playwright.rb +25 -30
- data/lib/playwright/channel_owners/request.rb +120 -18
- data/lib/playwright/channel_owners/response.rb +113 -0
- data/lib/playwright/channel_owners/route.rb +181 -0
- data/lib/playwright/channel_owners/stream.rb +30 -0
- data/lib/playwright/channel_owners/tracing.rb +117 -0
- data/lib/playwright/channel_owners/web_socket.rb +96 -0
- data/lib/playwright/channel_owners/worker.rb +46 -0
- data/lib/playwright/channel_owners/writable_stream.rb +14 -0
- data/lib/playwright/clock_impl.rb +67 -0
- data/lib/playwright/connection.rb +111 -63
- data/lib/playwright/console_message_impl.rb +29 -0
- data/lib/playwright/download_impl.rb +32 -0
- data/lib/playwright/errors.rb +42 -5
- data/lib/playwright/event_emitter.rb +17 -3
- data/lib/playwright/event_emitter_proxy.rb +49 -0
- data/lib/playwright/events.rb +10 -5
- data/lib/playwright/file_chooser_impl.rb +24 -0
- data/lib/playwright/frame_locator_impl.rb +66 -0
- data/lib/playwright/har_router.rb +89 -0
- data/lib/playwright/http_headers.rb +14 -0
- data/lib/playwright/input_files.rb +102 -15
- data/lib/playwright/javascript/expression.rb +7 -11
- data/lib/playwright/javascript/regex.rb +23 -0
- data/lib/playwright/javascript/source_url.rb +16 -0
- data/lib/playwright/javascript/value_parser.rb +108 -19
- data/lib/playwright/javascript/value_serializer.rb +47 -8
- data/lib/playwright/javascript/visitor_info.rb +26 -0
- data/lib/playwright/javascript.rb +2 -10
- data/lib/playwright/{input_types/keyboard.rb → keyboard_impl.rb} +6 -2
- data/lib/playwright/locator_assertions_impl.rb +571 -0
- data/lib/playwright/locator_impl.rb +544 -0
- data/lib/playwright/locator_utils.rb +136 -0
- data/lib/playwright/mouse_impl.rb +57 -0
- data/lib/playwright/page_assertions_impl.rb +154 -0
- data/lib/playwright/playwright_api.rb +102 -30
- data/lib/playwright/raw_headers.rb +61 -0
- data/lib/playwright/route_handler.rb +78 -0
- data/lib/playwright/select_option_values.rb +34 -13
- data/lib/playwright/selectors_impl.rb +45 -0
- data/lib/playwright/test.rb +102 -0
- data/lib/playwright/timeout_settings.rb +9 -4
- data/lib/playwright/touchscreen_impl.rb +14 -0
- data/lib/playwright/transport.rb +61 -10
- data/lib/playwright/url_matcher.rb +24 -2
- data/lib/playwright/utils.rb +48 -13
- data/lib/playwright/version.rb +2 -1
- data/lib/playwright/video.rb +54 -0
- data/lib/playwright/waiter.rb +166 -0
- data/lib/playwright/web_socket_client.rb +167 -0
- data/lib/playwright/web_socket_transport.rb +116 -0
- data/lib/playwright.rb +188 -11
- data/lib/playwright_api/android.rb +46 -11
- data/lib/playwright_api/android_device.rb +182 -31
- data/lib/playwright_api/android_input.rb +22 -13
- data/lib/playwright_api/android_socket.rb +18 -0
- data/lib/playwright_api/android_web_view.rb +24 -0
- data/lib/playwright_api/api_request.rb +26 -0
- data/lib/playwright_api/api_request_context.rb +311 -0
- data/lib/playwright_api/api_response.rb +92 -0
- data/lib/playwright_api/browser.rb +116 -103
- data/lib/playwright_api/browser_context.rb +290 -389
- data/lib/playwright_api/browser_type.rb +96 -118
- data/lib/playwright_api/cdp_session.rb +36 -39
- data/lib/playwright_api/clock.rb +121 -0
- data/lib/playwright_api/console_message.rb +35 -19
- data/lib/playwright_api/dialog.rb +53 -50
- data/lib/playwright_api/download.rb +49 -43
- data/lib/playwright_api/element_handle.rb +354 -402
- data/lib/playwright_api/file_chooser.rb +15 -18
- data/lib/playwright_api/frame.rb +703 -603
- data/lib/playwright_api/frame_locator.rb +285 -0
- data/lib/playwright_api/js_handle.rb +50 -76
- data/lib/playwright_api/keyboard.rb +67 -146
- data/lib/playwright_api/locator.rb +1304 -0
- data/lib/playwright_api/locator_assertions.rb +704 -0
- data/lib/playwright_api/mouse.rb +23 -29
- data/lib/playwright_api/page.rb +1196 -1176
- data/lib/playwright_api/page_assertions.rb +60 -0
- data/lib/playwright_api/playwright.rb +54 -122
- data/lib/playwright_api/request.rb +112 -74
- data/lib/playwright_api/response.rb +92 -20
- data/lib/playwright_api/route.rb +152 -62
- data/lib/playwright_api/selectors.rb +47 -61
- data/lib/playwright_api/touchscreen.rb +8 -2
- data/lib/playwright_api/tracing.rb +128 -0
- data/lib/playwright_api/web_socket.rb +43 -5
- data/lib/playwright_api/worker.rb +74 -34
- data/playwright.gemspec +14 -9
- data/sig/playwright.rbs +658 -0
- metadata +216 -50
- data/docs/api_coverage.md +0 -354
- data/lib/playwright/channel_owners/chromium_browser.rb +0 -8
- data/lib/playwright/channel_owners/chromium_browser_context.rb +0 -8
- data/lib/playwright/channel_owners/console_message.rb +0 -21
- data/lib/playwright/channel_owners/firefox_browser.rb +0 -8
- data/lib/playwright/channel_owners/selectors.rb +0 -4
- data/lib/playwright/channel_owners/webkit_browser.rb +0 -8
- data/lib/playwright/input_type.rb +0 -19
- data/lib/playwright/input_types/mouse.rb +0 -4
- data/lib/playwright/input_types/touchscreen.rb +0 -4
- data/lib/playwright/javascript/function.rb +0 -67
- data/lib/playwright/wait_helper.rb +0 -73
- data/lib/playwright_api/accessibility.rb +0 -93
- data/lib/playwright_api/binding_call.rb +0 -23
- data/lib/playwright_api/chromium_browser_context.rb +0 -57
- data/lib/playwright_api/video.rb +0 -24
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
module Playwright
|
|
2
|
+
#
|
|
3
|
+
# API for collecting and saving Playwright traces. Playwright traces can be opened in [Trace Viewer](../trace-viewer.md) after Playwright script runs.
|
|
4
|
+
#
|
|
5
|
+
# **NOTE**: You probably want to [enable tracing in your config file](https://playwright.dev/docs/api/class-testoptions#test-options-trace) instead of using `context.tracing`.
|
|
6
|
+
#
|
|
7
|
+
# The `context.tracing` API captures browser operations and network activity, but it doesn't record test assertions (like `expect` calls). We recommend [enabling tracing through Playwright Test configuration](https://playwright.dev/docs/api/class-testoptions#test-options-trace), which includes those assertions and provides a more complete trace for debugging test failures.
|
|
8
|
+
#
|
|
9
|
+
# Start recording a trace before performing actions. At the end, stop tracing and save it to a file.
|
|
10
|
+
#
|
|
11
|
+
# ```python sync
|
|
12
|
+
# browser = chromium.launch()
|
|
13
|
+
# context = browser.new_context()
|
|
14
|
+
# context.tracing.start(screenshots=True, snapshots=True)
|
|
15
|
+
# page = context.new_page()
|
|
16
|
+
# page.goto("https://playwright.dev")
|
|
17
|
+
# context.tracing.stop(path = "trace.zip")
|
|
18
|
+
# ```
|
|
19
|
+
class Tracing < PlaywrightApi
|
|
20
|
+
|
|
21
|
+
#
|
|
22
|
+
# Start tracing.
|
|
23
|
+
#
|
|
24
|
+
# **NOTE**: You probably want to [enable tracing in your config file](https://playwright.dev/docs/api/class-testoptions#test-options-trace) instead of using `Tracing.start`.
|
|
25
|
+
#
|
|
26
|
+
# The `context.tracing` API captures browser operations and network activity, but it doesn't record test assertions (like `expect` calls). We recommend [enabling tracing through Playwright Test configuration](https://playwright.dev/docs/api/class-testoptions#test-options-trace), which includes those assertions and provides a more complete trace for debugging test failures.
|
|
27
|
+
#
|
|
28
|
+
# **Usage**
|
|
29
|
+
#
|
|
30
|
+
# ```python sync
|
|
31
|
+
# context.tracing.start(screenshots=True, snapshots=True)
|
|
32
|
+
# page = context.new_page()
|
|
33
|
+
# page.goto("https://playwright.dev")
|
|
34
|
+
# context.tracing.stop(path = "trace.zip")
|
|
35
|
+
# ```
|
|
36
|
+
def start(
|
|
37
|
+
name: nil,
|
|
38
|
+
screenshots: nil,
|
|
39
|
+
snapshots: nil,
|
|
40
|
+
sources: nil,
|
|
41
|
+
title: nil)
|
|
42
|
+
wrap_impl(@impl.start(name: unwrap_impl(name), screenshots: unwrap_impl(screenshots), snapshots: unwrap_impl(snapshots), sources: unwrap_impl(sources), title: unwrap_impl(title)))
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
#
|
|
46
|
+
# Start a new trace chunk. If you'd like to record multiple traces on the same `BrowserContext`, use [`method: Tracing.start`] once, and then create multiple trace chunks with [`method: Tracing.startChunk`] and [`method: Tracing.stopChunk`].
|
|
47
|
+
#
|
|
48
|
+
# **Usage**
|
|
49
|
+
#
|
|
50
|
+
# ```python sync
|
|
51
|
+
# context.tracing.start(screenshots=True, snapshots=True)
|
|
52
|
+
# page = context.new_page()
|
|
53
|
+
# page.goto("https://playwright.dev")
|
|
54
|
+
#
|
|
55
|
+
# context.tracing.start_chunk()
|
|
56
|
+
# page.get_by_text("Get Started").click()
|
|
57
|
+
# # Everything between start_chunk and stop_chunk will be recorded in the trace.
|
|
58
|
+
# context.tracing.stop_chunk(path = "trace1.zip")
|
|
59
|
+
#
|
|
60
|
+
# context.tracing.start_chunk()
|
|
61
|
+
# page.goto("http://example.com")
|
|
62
|
+
# # Save a second trace file with different actions.
|
|
63
|
+
# context.tracing.stop_chunk(path = "trace2.zip")
|
|
64
|
+
# ```
|
|
65
|
+
def start_chunk(name: nil, title: nil)
|
|
66
|
+
wrap_impl(@impl.start_chunk(name: unwrap_impl(name), title: unwrap_impl(title)))
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
#
|
|
70
|
+
# **NOTE**: Use `test.step` instead when available.
|
|
71
|
+
#
|
|
72
|
+
# Creates a new group within the trace, assigning any subsequent API calls to this group, until [`method: Tracing.groupEnd`] is called. Groups can be nested and will be visible in the trace viewer.
|
|
73
|
+
#
|
|
74
|
+
# **Usage**
|
|
75
|
+
#
|
|
76
|
+
# ```python sync
|
|
77
|
+
# # All actions between group and group_end
|
|
78
|
+
# # will be shown in the trace viewer as a group.
|
|
79
|
+
# page.context.tracing.group("Open Playwright.dev > API")
|
|
80
|
+
# page.goto("https://playwright.dev/")
|
|
81
|
+
# page.get_by_role("link", name="API").click()
|
|
82
|
+
# page.context.tracing.group_end()
|
|
83
|
+
# ```
|
|
84
|
+
def group(name, location: nil)
|
|
85
|
+
wrap_impl(@impl.group(unwrap_impl(name), location: unwrap_impl(location)))
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
#
|
|
89
|
+
# Closes the last group created by [`method: Tracing.group`].
|
|
90
|
+
def group_end
|
|
91
|
+
wrap_impl(@impl.group_end)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
#
|
|
95
|
+
# Stop tracing.
|
|
96
|
+
def stop(path: nil)
|
|
97
|
+
wrap_impl(@impl.stop(path: unwrap_impl(path)))
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
#
|
|
101
|
+
# Stop the trace chunk. See [`method: Tracing.startChunk`] for more details about multiple trace chunks.
|
|
102
|
+
def stop_chunk(path: nil)
|
|
103
|
+
wrap_impl(@impl.stop_chunk(path: unwrap_impl(path)))
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# -- inherited from EventEmitter --
|
|
107
|
+
# @nodoc
|
|
108
|
+
def once(event, callback)
|
|
109
|
+
event_emitter_proxy.once(event, callback)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# -- inherited from EventEmitter --
|
|
113
|
+
# @nodoc
|
|
114
|
+
def on(event, callback)
|
|
115
|
+
event_emitter_proxy.on(event, callback)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# -- inherited from EventEmitter --
|
|
119
|
+
# @nodoc
|
|
120
|
+
def off(event, callback)
|
|
121
|
+
event_emitter_proxy.off(event, callback)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
private def event_emitter_proxy
|
|
125
|
+
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -1,21 +1,59 @@
|
|
|
1
1
|
module Playwright
|
|
2
|
-
#
|
|
2
|
+
#
|
|
3
|
+
# The `WebSocket` class represents WebSocket connections within a page. It provides the ability to inspect and manipulate the data being transmitted and received.
|
|
4
|
+
#
|
|
5
|
+
# If you want to intercept or modify WebSocket frames, consider using `WebSocketRoute`.
|
|
3
6
|
class WebSocket < PlaywrightApi
|
|
4
7
|
|
|
8
|
+
#
|
|
5
9
|
# Indicates that the web socket has been closed.
|
|
6
10
|
def closed?
|
|
7
|
-
|
|
11
|
+
wrap_impl(@impl.closed?)
|
|
8
12
|
end
|
|
9
13
|
|
|
14
|
+
#
|
|
10
15
|
# Contains the URL of the WebSocket.
|
|
11
16
|
def url
|
|
12
|
-
|
|
17
|
+
wrap_impl(@impl.url)
|
|
13
18
|
end
|
|
14
19
|
|
|
20
|
+
#
|
|
15
21
|
# Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
|
|
16
22
|
# value. Will throw an error if the webSocket is closed before the event is fired. Returns the event data value.
|
|
17
|
-
def expect_event(event,
|
|
18
|
-
|
|
23
|
+
def expect_event(event, predicate: nil, timeout: nil, &block)
|
|
24
|
+
wrap_impl(@impl.expect_event(unwrap_impl(event), predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
#
|
|
28
|
+
# **NOTE**: In most cases, you should use [`method: WebSocket.waitForEvent`].
|
|
29
|
+
#
|
|
30
|
+
# Waits for given `event` to fire. If predicate is provided, it passes
|
|
31
|
+
# event's value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
|
|
32
|
+
# Will throw an error if the socket is closed before the `event` is fired.
|
|
33
|
+
def wait_for_event(event, predicate: nil, timeout: nil, &block)
|
|
34
|
+
wrap_impl(@impl.wait_for_event(unwrap_impl(event), predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# -- inherited from EventEmitter --
|
|
38
|
+
# @nodoc
|
|
39
|
+
def once(event, callback)
|
|
40
|
+
event_emitter_proxy.once(event, callback)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# -- inherited from EventEmitter --
|
|
44
|
+
# @nodoc
|
|
45
|
+
def on(event, callback)
|
|
46
|
+
event_emitter_proxy.on(event, callback)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# -- inherited from EventEmitter --
|
|
50
|
+
# @nodoc
|
|
51
|
+
def off(event, callback)
|
|
52
|
+
event_emitter_proxy.off(event, callback)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private def event_emitter_proxy
|
|
56
|
+
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
|
19
57
|
end
|
|
20
58
|
end
|
|
21
59
|
end
|
|
@@ -1,58 +1,98 @@
|
|
|
1
1
|
module Playwright
|
|
2
|
+
#
|
|
2
3
|
# The Worker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). `worker`
|
|
3
4
|
# event is emitted on the page object to signal a worker creation. `close` event is emitted on the worker object when the
|
|
4
5
|
# worker is gone.
|
|
5
|
-
#
|
|
6
6
|
#
|
|
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
7
|
# ```py
|
|
19
8
|
# def handle_worker(worker):
|
|
20
9
|
# print("worker created: " + worker.url)
|
|
21
10
|
# worker.on("close", lambda: print("worker destroyed: " + worker.url))
|
|
22
|
-
#
|
|
11
|
+
#
|
|
23
12
|
# page.on('worker', handle_worker)
|
|
24
|
-
#
|
|
13
|
+
#
|
|
25
14
|
# print("current workers:")
|
|
26
15
|
# for worker in page.workers:
|
|
27
16
|
# print(" " + worker.url)
|
|
28
17
|
# ```
|
|
29
18
|
class Worker < PlaywrightApi
|
|
30
19
|
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
20
|
+
#
|
|
21
|
+
# Returns the return value of `expression`.
|
|
22
|
+
#
|
|
23
|
+
# If the function passed to the [`method: Worker.evaluate`] returns a [Promise], then [`method: Worker.evaluate`] would wait for the promise
|
|
34
24
|
# to resolve and return its value.
|
|
35
|
-
#
|
|
36
|
-
# If the function passed to the `
|
|
37
|
-
#
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
# Returns the return value of `
|
|
44
|
-
#
|
|
45
|
-
# The only difference between `
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
#
|
|
25
|
+
#
|
|
26
|
+
# If the function passed to the [`method: Worker.evaluate`] returns a non-[Serializable] value, then [`method: Worker.evaluate`] returns `undefined`. Playwright also supports transferring some
|
|
27
|
+
# additional values that are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
|
|
28
|
+
def evaluate(expression, arg: nil)
|
|
29
|
+
wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
#
|
|
33
|
+
# Returns the return value of `expression` as a `JSHandle`.
|
|
34
|
+
#
|
|
35
|
+
# The only difference between [`method: Worker.evaluate`] and
|
|
36
|
+
# [`method: Worker.evaluateHandle`] is that [`method: Worker.evaluateHandle`]
|
|
37
|
+
# returns `JSHandle`.
|
|
38
|
+
#
|
|
39
|
+
# If the function passed to the [`method: Worker.evaluateHandle`] returns a [Promise], then [`method: Worker.evaluateHandle`] would wait for
|
|
49
40
|
# the promise to resolve and return its value.
|
|
50
|
-
def evaluate_handle(
|
|
51
|
-
|
|
41
|
+
def evaluate_handle(expression, arg: nil)
|
|
42
|
+
wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
|
52
43
|
end
|
|
53
44
|
|
|
54
45
|
def url
|
|
55
|
-
|
|
46
|
+
wrap_impl(@impl.url)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
#
|
|
50
|
+
# Waits for event to fire and passes its value into the predicate function.
|
|
51
|
+
# Returns when the predicate returns truthy value.
|
|
52
|
+
# Will throw an error if the page is closed before the event is fired.
|
|
53
|
+
# Returns the event data value.
|
|
54
|
+
#
|
|
55
|
+
# **Usage**
|
|
56
|
+
#
|
|
57
|
+
# ```python sync
|
|
58
|
+
# with worker.expect_event("console") as event_info:
|
|
59
|
+
# worker.evaluate("console.log(42)")
|
|
60
|
+
# message = event_info.value
|
|
61
|
+
# ```
|
|
62
|
+
def expect_event(event, predicate: nil, timeout: nil, &block)
|
|
63
|
+
wrap_impl(@impl.expect_event(unwrap_impl(event), predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# @nodoc
|
|
67
|
+
def page=(req)
|
|
68
|
+
wrap_impl(@impl.page=(unwrap_impl(req)))
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# @nodoc
|
|
72
|
+
def context=(req)
|
|
73
|
+
wrap_impl(@impl.context=(unwrap_impl(req)))
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# -- inherited from EventEmitter --
|
|
77
|
+
# @nodoc
|
|
78
|
+
def once(event, callback)
|
|
79
|
+
event_emitter_proxy.once(event, callback)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# -- inherited from EventEmitter --
|
|
83
|
+
# @nodoc
|
|
84
|
+
def on(event, callback)
|
|
85
|
+
event_emitter_proxy.on(event, callback)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# -- inherited from EventEmitter --
|
|
89
|
+
# @nodoc
|
|
90
|
+
def off(event, callback)
|
|
91
|
+
event_emitter_proxy.off(event, callback)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
private def event_emitter_proxy
|
|
95
|
+
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
|
56
96
|
end
|
|
57
97
|
end
|
|
58
98
|
end
|
data/playwright.gemspec
CHANGED
|
@@ -11,28 +11,33 @@ Gem::Specification.new do |spec|
|
|
|
11
11
|
spec.authors = ['YusukeIwaki']
|
|
12
12
|
spec.email = ['q7w8e9w8q7w8e9@yahoo.co.jp']
|
|
13
13
|
|
|
14
|
-
spec.summary =
|
|
14
|
+
spec.summary = "The Ruby binding of playwright driver #{Playwright::COMPATIBLE_PLAYWRIGHT_VERSION}"
|
|
15
15
|
spec.homepage = 'https://github.com/YusukeIwaki/playwright-ruby-client'
|
|
16
16
|
spec.license = 'MIT'
|
|
17
17
|
|
|
18
18
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
19
19
|
`git ls-files -z`.split("\x0").reject do |f|
|
|
20
|
-
f.match(%r{^(test|spec|features)/}) || f.include?(".git") || f.start_with?("development/")
|
|
20
|
+
f.match(%r{^(test|spec|features)/}) || f.include?(".git") || f.include?(".circleci") || f.start_with?("development/")
|
|
21
21
|
end
|
|
22
|
-
end + `find lib/playwright_api -name *.rb -type f`.split("\n")
|
|
22
|
+
end + `find lib/playwright_api -name *.rb -type f`.split("\n") + `find sig -name *.rbs -type f`.split("\n")
|
|
23
23
|
spec.bindir = 'exe'
|
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
25
25
|
spec.require_paths = ['lib']
|
|
26
26
|
|
|
27
|
-
spec.
|
|
27
|
+
spec.required_ruby_version = '>= 2.4'
|
|
28
|
+
spec.add_dependency 'base64'
|
|
29
|
+
spec.add_dependency 'concurrent-ruby', '>= 1.1.6'
|
|
28
30
|
spec.add_dependency 'mime-types', '>= 3.0'
|
|
29
|
-
spec.add_development_dependency 'bundler'
|
|
31
|
+
spec.add_development_dependency 'bundler'
|
|
32
|
+
spec.add_development_dependency 'chunky_png'
|
|
30
33
|
spec.add_development_dependency 'dry-inflector'
|
|
34
|
+
spec.add_development_dependency 'faye-websocket'
|
|
31
35
|
spec.add_development_dependency 'pry-byebug'
|
|
32
|
-
spec.add_development_dependency '
|
|
33
|
-
spec.add_development_dependency '
|
|
34
|
-
spec.add_development_dependency '
|
|
36
|
+
spec.add_development_dependency 'ostruct'
|
|
37
|
+
spec.add_development_dependency 'puma'
|
|
38
|
+
spec.add_development_dependency 'rack', '< 3'
|
|
39
|
+
spec.add_development_dependency 'rake'
|
|
40
|
+
spec.add_development_dependency 'rspec'
|
|
35
41
|
spec.add_development_dependency 'rubocop-rspec'
|
|
36
42
|
spec.add_development_dependency 'sinatra'
|
|
37
|
-
spec.add_development_dependency 'webrick'
|
|
38
43
|
end
|