playwright-ruby-client 0.9.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/documentation/docs/api/accessibility.md +51 -1
- data/documentation/docs/api/browser_context.md +28 -0
- data/documentation/docs/api/element_handle.md +4 -5
- data/documentation/docs/api/experimental/android.md +15 -2
- data/documentation/docs/api/frame.md +66 -97
- data/documentation/docs/api/locator.md +28 -41
- data/documentation/docs/api/mouse.md +3 -4
- data/documentation/docs/api/page.md +41 -1
- data/documentation/docs/api/request.md +15 -19
- data/documentation/docs/api/touchscreen.md +8 -0
- data/documentation/docs/api/tracing.md +13 -12
- data/documentation/docs/api/worker.md +46 -8
- data/documentation/docs/article/guides/inspector.md +1 -1
- data/documentation/docs/article/guides/playwright_on_alpine_linux.md +1 -1
- data/documentation/docs/article/guides/semi_automation.md +1 -1
- data/documentation/docs/article/guides/use_storage_state.md +78 -0
- data/documentation/docs/include/api_coverage.md +13 -13
- data/lib/playwright/accessibility_impl.rb +50 -0
- data/lib/playwright/channel_owners/browser_context.rb +45 -0
- data/lib/playwright/channel_owners/frame.rb +9 -0
- data/lib/playwright/channel_owners/page.rb +31 -2
- data/lib/playwright/channel_owners/request.rb +8 -8
- data/lib/playwright/channel_owners/worker.rb +23 -0
- data/lib/playwright/locator_impl.rb +3 -3
- data/lib/playwright/touchscreen_impl.rb +7 -0
- data/lib/playwright/tracing_impl.rb +9 -8
- data/lib/playwright/version.rb +1 -1
- data/lib/playwright_api/accessibility.rb +1 -1
- data/lib/playwright_api/android.rb +15 -2
- data/lib/playwright_api/browser_context.rb +8 -8
- data/lib/playwright_api/element_handle.rb +1 -1
- data/lib/playwright_api/frame.rb +5 -3
- data/lib/playwright_api/locator.rb +3 -3
- data/lib/playwright_api/page.rb +8 -6
- data/lib/playwright_api/touchscreen.rb +1 -1
- data/lib/playwright_api/worker.rb +13 -3
- metadata +4 -2
@@ -1,4 +1,27 @@
|
|
1
1
|
module Playwright
|
2
2
|
define_channel_owner :Worker do
|
3
|
+
attr_writer :context, :page
|
4
|
+
|
5
|
+
private def after_initialize
|
6
|
+
@channel.once('close', ->(_) { on_close })
|
7
|
+
end
|
8
|
+
|
9
|
+
private def on_close
|
10
|
+
@page&.send(:remove_worker, self)
|
11
|
+
@context&.send(:remove_service_worker, self)
|
12
|
+
emit(Events::Worker::Close, self)
|
13
|
+
end
|
14
|
+
|
15
|
+
def url
|
16
|
+
@initializer['url']
|
17
|
+
end
|
18
|
+
|
19
|
+
def evaluate(expression, arg: nil)
|
20
|
+
JavaScript::Expression.new(expression, arg).evaluate(@channel)
|
21
|
+
end
|
22
|
+
|
23
|
+
def evaluate_handle(expression, arg: nil)
|
24
|
+
JavaScript::Expression.new(expression, arg).evaluate_handle(@channel)
|
25
|
+
end
|
3
26
|
end
|
4
27
|
end
|
@@ -142,7 +142,7 @@ module Playwright
|
|
142
142
|
LocatorImpl.new(
|
143
143
|
frame: @frame,
|
144
144
|
timeout_settings: @timeout_settings,
|
145
|
-
selector: "#{@selector} >>
|
145
|
+
selector: "#{@selector} >> nth=0",
|
146
146
|
)
|
147
147
|
end
|
148
148
|
|
@@ -150,7 +150,7 @@ module Playwright
|
|
150
150
|
LocatorImpl.new(
|
151
151
|
frame: @frame,
|
152
152
|
timeout_settings: @timeout_settings,
|
153
|
-
selector: "#{@selector} >>
|
153
|
+
selector: "#{@selector} >> nth=-1",
|
154
154
|
)
|
155
155
|
end
|
156
156
|
|
@@ -158,7 +158,7 @@ module Playwright
|
|
158
158
|
LocatorImpl.new(
|
159
159
|
frame: @frame,
|
160
160
|
timeout_settings: @timeout_settings,
|
161
|
-
selector: "#{@selector} >>
|
161
|
+
selector: "#{@selector} >> nth=#{index}",
|
162
162
|
)
|
163
163
|
end
|
164
164
|
|
@@ -16,16 +16,17 @@ module Playwright
|
|
16
16
|
|
17
17
|
# Stop tracing.
|
18
18
|
def stop(path: nil)
|
19
|
+
export(path: path) if path
|
19
20
|
@channel.send_message_to_server('tracingStop')
|
21
|
+
end
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
23
|
+
private def export(path:)
|
24
|
+
resp = @channel.send_message_to_server('tracingExport')
|
25
|
+
artifact = ChannelOwners::Artifact.from(resp)
|
26
|
+
# if self._context._browser:
|
27
|
+
# artifact._is_remote = self._context._browser._is_remote
|
28
|
+
artifact.save_as(path)
|
29
|
+
artifact.delete
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
data/lib/playwright/version.rb
CHANGED
@@ -44,7 +44,7 @@ module Playwright
|
|
44
44
|
# print(node["name"])
|
45
45
|
# ```
|
46
46
|
def snapshot(interestingOnly: nil, root: nil)
|
47
|
-
|
47
|
+
wrap_impl(@impl.snapshot(interestingOnly: unwrap_impl(interestingOnly), root: unwrap_impl(root)))
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -1,6 +1,19 @@
|
|
1
1
|
module Playwright
|
2
|
-
# Playwright has **experimental** support for Android automation.
|
3
|
-
#
|
2
|
+
# Playwright has **experimental** support for Android automation. This includes Chrome for Android and Android WebView.
|
3
|
+
#
|
4
|
+
# *Requirements*
|
5
|
+
# - Android device or AVD Emulator.
|
6
|
+
# - [ADB daemon](https://developer.android.com/studio/command-line/adb) running and authenticated with your device.
|
7
|
+
# Typically running `adb devices` is all you need to do.
|
8
|
+
# - [`Chrome 87`](https://play.google.com/store/apps/details?id=com.android.chrome) or newer installed on the device
|
9
|
+
# - "Enable command line on non-rooted devices" enabled in `chrome://flags`.
|
10
|
+
#
|
11
|
+
# *Known limitations*
|
12
|
+
# - Raw USB operation is not yet supported, so you need ADB.
|
13
|
+
# - Device needs to be awake to produce screenshots. Enabling "Stay awake" developer mode will help.
|
14
|
+
# - We didn't run all the tests against the device, so not everything works.
|
15
|
+
#
|
16
|
+
# *How to run*
|
4
17
|
#
|
5
18
|
# An example of the Android automation script would be:
|
6
19
|
#
|
@@ -59,7 +59,7 @@ module Playwright
|
|
59
59
|
#
|
60
60
|
# All existing background pages in the context.
|
61
61
|
def background_pages
|
62
|
-
|
62
|
+
wrap_impl(@impl.background_pages)
|
63
63
|
end
|
64
64
|
|
65
65
|
# Returns the browser instance of the context. If it was launched as a persistent context null gets returned.
|
@@ -268,7 +268,7 @@ module Playwright
|
|
268
268
|
#
|
269
269
|
# All existing service workers in the context.
|
270
270
|
def service_workers
|
271
|
-
|
271
|
+
wrap_impl(@impl.service_workers)
|
272
272
|
end
|
273
273
|
|
274
274
|
# This setting will change the default maximum navigation time for the following methods and related shortcuts:
|
@@ -325,7 +325,7 @@ module Playwright
|
|
325
325
|
|
326
326
|
# Returns storage state for this browser context, contains current cookies and local storage snapshot.
|
327
327
|
def storage_state(path: nil)
|
328
|
-
|
328
|
+
wrap_impl(@impl.storage_state(path: unwrap_impl(path)))
|
329
329
|
end
|
330
330
|
|
331
331
|
# Removes a route created with [`method: BrowserContext.route`]. When `handler` is not specified, removes all routes for
|
@@ -367,11 +367,6 @@ module Playwright
|
|
367
367
|
wrap_impl(@impl.enable_debug_console!)
|
368
368
|
end
|
369
369
|
|
370
|
-
# @nodoc
|
371
|
-
def pause
|
372
|
-
wrap_impl(@impl.pause)
|
373
|
-
end
|
374
|
-
|
375
370
|
# @nodoc
|
376
371
|
def browser=(req)
|
377
372
|
wrap_impl(@impl.browser=(unwrap_impl(req)))
|
@@ -382,6 +377,11 @@ module Playwright
|
|
382
377
|
wrap_impl(@impl.owner_page=(unwrap_impl(req)))
|
383
378
|
end
|
384
379
|
|
380
|
+
# @nodoc
|
381
|
+
def pause
|
382
|
+
wrap_impl(@impl.pause)
|
383
|
+
end
|
384
|
+
|
385
385
|
# @nodoc
|
386
386
|
def options=(req)
|
387
387
|
wrap_impl(@impl.options=(unwrap_impl(req)))
|
@@ -268,7 +268,7 @@ module Playwright
|
|
268
268
|
wrap_impl(@impl.inner_text)
|
269
269
|
end
|
270
270
|
|
271
|
-
# Returns `input.value` for `<input>` or `<textarea>` element. Throws for non-input elements.
|
271
|
+
# Returns `input.value` for `<input>` or `<textarea>` or `<select>` element. Throws for non-input elements.
|
272
272
|
def input_value(timeout: nil)
|
273
273
|
wrap_impl(@impl.input_value(timeout: unwrap_impl(timeout)))
|
274
274
|
end
|
data/lib/playwright_api/frame.rb
CHANGED
@@ -173,10 +173,12 @@ module Playwright
|
|
173
173
|
target,
|
174
174
|
force: nil,
|
175
175
|
noWaitAfter: nil,
|
176
|
+
sourcePosition: nil,
|
176
177
|
strict: nil,
|
178
|
+
targetPosition: nil,
|
177
179
|
timeout: nil,
|
178
180
|
trial: nil)
|
179
|
-
wrap_impl(@impl.drag_and_drop(unwrap_impl(source), unwrap_impl(target), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
181
|
+
wrap_impl(@impl.drag_and_drop(unwrap_impl(source), unwrap_impl(target), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), sourcePosition: unwrap_impl(sourcePosition), strict: unwrap_impl(strict), targetPosition: unwrap_impl(targetPosition), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
180
182
|
end
|
181
183
|
|
182
184
|
# Returns the return value of `expression`.
|
@@ -380,7 +382,7 @@ module Playwright
|
|
380
382
|
wrap_impl(@impl.inner_text(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
381
383
|
end
|
382
384
|
|
383
|
-
# Returns `input.value` for the selected `<input>` or `<textarea>` element. Throws for non-input elements.
|
385
|
+
# Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element. Throws for non-input elements.
|
384
386
|
def input_value(selector, strict: nil, timeout: nil)
|
385
387
|
wrap_impl(@impl.input_value(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
386
388
|
end
|
@@ -720,7 +722,7 @@ module Playwright
|
|
720
722
|
# Note that `frame.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to
|
721
723
|
# be flaky. Use signals such as network events, selectors becoming visible and others instead.
|
722
724
|
def wait_for_timeout(timeout)
|
723
|
-
|
725
|
+
wrap_impl(@impl.wait_for_timeout(unwrap_impl(timeout)))
|
724
726
|
end
|
725
727
|
|
726
728
|
# Waits for the frame to navigate to the given URL.
|
@@ -197,8 +197,8 @@ module Playwright
|
|
197
197
|
# The method finds all elements matching the specified locator and passes an array of matched elements as a first argument
|
198
198
|
# to `expression`. Returns the result of `expression` invocation.
|
199
199
|
#
|
200
|
-
# If `expression` returns a [Promise], then [`Locator.evaluateAll`] would wait for the promise to resolve and
|
201
|
-
# value.
|
200
|
+
# If `expression` returns a [Promise], then [`method: Locator.evaluateAll`] would wait for the promise to resolve and
|
201
|
+
# return its value.
|
202
202
|
#
|
203
203
|
# Examples:
|
204
204
|
#
|
@@ -282,7 +282,7 @@ module Playwright
|
|
282
282
|
wrap_impl(@impl.inner_text(timeout: unwrap_impl(timeout)))
|
283
283
|
end
|
284
284
|
|
285
|
-
# Returns `input.value` for `<input>` or `<textarea>` element. Throws for non-input elements.
|
285
|
+
# Returns `input.value` for `<input>` or `<textarea>` or `<select>` element. Throws for non-input elements.
|
286
286
|
def input_value(timeout: nil)
|
287
287
|
wrap_impl(@impl.input_value(timeout: unwrap_impl(timeout)))
|
288
288
|
end
|
data/lib/playwright_api/page.rb
CHANGED
@@ -246,10 +246,12 @@ module Playwright
|
|
246
246
|
target,
|
247
247
|
force: nil,
|
248
248
|
noWaitAfter: nil,
|
249
|
+
sourcePosition: nil,
|
249
250
|
strict: nil,
|
251
|
+
targetPosition: nil,
|
250
252
|
timeout: nil,
|
251
253
|
trial: nil)
|
252
|
-
wrap_impl(@impl.drag_and_drop(unwrap_impl(source), unwrap_impl(target), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
254
|
+
wrap_impl(@impl.drag_and_drop(unwrap_impl(source), unwrap_impl(target), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), sourcePosition: unwrap_impl(sourcePosition), strict: unwrap_impl(strict), targetPosition: unwrap_impl(targetPosition), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
253
255
|
end
|
254
256
|
|
255
257
|
# This method changes the `CSS media type` through the `media` argument, and/or the `'prefers-colors-scheme'` media
|
@@ -614,7 +616,7 @@ module Playwright
|
|
614
616
|
wrap_impl(@impl.inner_text(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
615
617
|
end
|
616
618
|
|
617
|
-
# Returns `input.value` for the selected `<input>` or `<textarea>` element. Throws for non-input elements.
|
619
|
+
# Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element. Throws for non-input elements.
|
618
620
|
def input_value(selector, strict: nil, timeout: nil)
|
619
621
|
wrap_impl(@impl.input_value(unwrap_impl(selector), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
|
620
622
|
end
|
@@ -1274,7 +1276,7 @@ module Playwright
|
|
1274
1276
|
#
|
1275
1277
|
# Shortcut for main frame's [`method: Frame.waitForTimeout`].
|
1276
1278
|
def wait_for_timeout(timeout)
|
1277
|
-
|
1279
|
+
wrap_impl(@impl.wait_for_timeout(unwrap_impl(timeout)))
|
1278
1280
|
end
|
1279
1281
|
|
1280
1282
|
# Waits for the main frame to navigate to the given URL.
|
@@ -1299,8 +1301,8 @@ module Playwright
|
|
1299
1301
|
# Performs action and waits for a new `Worker`. If predicate is provided, it passes `Worker` value into the `predicate`
|
1300
1302
|
# function and waits for `predicate(worker)` to return a truthy value. Will throw an error if the page is closed before
|
1301
1303
|
# the worker event is fired.
|
1302
|
-
def expect_worker(predicate: nil, timeout: nil)
|
1303
|
-
|
1304
|
+
def expect_worker(predicate: nil, timeout: nil, &block)
|
1305
|
+
wrap_impl(@impl.expect_worker(predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
|
1304
1306
|
end
|
1305
1307
|
|
1306
1308
|
# This method returns all of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API)
|
@@ -1308,7 +1310,7 @@ module Playwright
|
|
1308
1310
|
#
|
1309
1311
|
# > NOTE: This does not contain ServiceWorkers
|
1310
1312
|
def workers
|
1311
|
-
|
1313
|
+
wrap_impl(@impl.workers)
|
1312
1314
|
end
|
1313
1315
|
|
1314
1316
|
# > NOTE: In most cases, you should use [`method: Page.waitForEvent`].
|
@@ -5,7 +5,7 @@ module Playwright
|
|
5
5
|
|
6
6
|
# Dispatches a `touchstart` and `touchend` event with a single touch at the position (`x`,`y`).
|
7
7
|
def tap_point(x, y)
|
8
|
-
|
8
|
+
wrap_impl(@impl.tap_point(unwrap_impl(x), unwrap_impl(y)))
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -25,7 +25,7 @@ module Playwright
|
|
25
25
|
# [`method: Worker.evaluate`] returns `undefined`. Playwright also supports transferring some additional values that are
|
26
26
|
# not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
|
27
27
|
def evaluate(expression, arg: nil)
|
28
|
-
|
28
|
+
wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
29
29
|
end
|
30
30
|
|
31
31
|
# Returns the return value of `expression` as a `JSHandle`.
|
@@ -36,11 +36,21 @@ module Playwright
|
|
36
36
|
# If the function passed to the [`method: Worker.evaluateHandle`] returns a [Promise], then
|
37
37
|
# [`method: Worker.evaluateHandle`] would wait for the promise to resolve and return its value.
|
38
38
|
def evaluate_handle(expression, arg: nil)
|
39
|
-
|
39
|
+
wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg)))
|
40
40
|
end
|
41
41
|
|
42
42
|
def url
|
43
|
-
|
43
|
+
wrap_impl(@impl.url)
|
44
|
+
end
|
45
|
+
|
46
|
+
# @nodoc
|
47
|
+
def context=(req)
|
48
|
+
wrap_impl(@impl.context=(unwrap_impl(req)))
|
49
|
+
end
|
50
|
+
|
51
|
+
# @nodoc
|
52
|
+
def page=(req)
|
53
|
+
wrap_impl(@impl.page=(unwrap_impl(req)))
|
44
54
|
end
|
45
55
|
|
46
56
|
# -- inherited from EventEmitter --
|
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:
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- YusukeIwaki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -250,6 +250,7 @@ files:
|
|
250
250
|
- documentation/docs/article/guides/rails_integration.md
|
251
251
|
- documentation/docs/article/guides/recording_video.md
|
252
252
|
- documentation/docs/article/guides/semi_automation.md
|
253
|
+
- documentation/docs/article/guides/use_storage_state.md
|
253
254
|
- documentation/docs/include/api_coverage.md
|
254
255
|
- documentation/docusaurus.config.js
|
255
256
|
- documentation/package.json
|
@@ -267,6 +268,7 @@ files:
|
|
267
268
|
- documentation/static/img/undraw_windows.svg
|
268
269
|
- documentation/yarn.lock
|
269
270
|
- lib/playwright.rb
|
271
|
+
- lib/playwright/accessibility_impl.rb
|
270
272
|
- lib/playwright/android_input_impl.rb
|
271
273
|
- lib/playwright/api_implementation.rb
|
272
274
|
- lib/playwright/channel.rb
|