playwright-ruby-client 1.30.0 → 1.31.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/locator.md +2 -2
- data/documentation/docs/api/page.md +1 -1
- data/documentation/docs/api/route.md +14 -1
- data/documentation/docs/api/selectors.md +4 -2
- data/documentation/docs/api/touchscreen.md +2 -0
- data/lib/playwright/channel_owners/browser_context.rb +13 -7
- data/lib/playwright/channel_owners/page.rb +13 -7
- data/lib/playwright/channel_owners/route.rb +2 -1
- data/lib/playwright/locator_utils.rb +2 -1
- data/lib/playwright/route_handler.rb +8 -0
- data/lib/playwright/url_matcher.rb +12 -0
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright_api/browser_context.rb +5 -5
- data/lib/playwright_api/locator.rb +2 -2
- data/lib/playwright_api/page.rb +1 -1
- data/lib/playwright_api/route.rb +15 -2
- data/lib/playwright_api/selectors.rb +6 -4
- data/lib/playwright_api/touchscreen.rb +2 -0
- data/sig/playwright.rbs +2 -2
- 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: a07a47674b92ceb12d46b022a3c37fddd1a637b41de72df5c3e1cb040eb22490
|
4
|
+
data.tar.gz: 6ecf932e03fe4b2b7c155913d806ccd4013c57962e530bfda6dfa52f1137ba93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06f348db3d405450347b09c7769682754cf6d2dfb14d60d1a0b15fbb092aff70e9e84dadc3376cd956a3f424f4c33e1c2839c2aaa64f8abd6cd6e14653de4a32
|
7
|
+
data.tar.gz: 5f57704d5329a591a88d3a174087ad304114860312437e440013cc16707511c614102bde3200a793480208a4d2f4f44c67f7eea624982a2c1cc28e7d762d735f
|
@@ -255,7 +255,7 @@ def dispatch_event(type, eventInit: nil, timeout: nil)
|
|
255
255
|
```
|
256
256
|
|
257
257
|
|
258
|
-
|
258
|
+
Programmatically dispatch an event on the matching element.
|
259
259
|
|
260
260
|
**Usage**
|
261
261
|
|
@@ -950,7 +950,7 @@ def press(key, delay: nil, noWaitAfter: nil, timeout: nil)
|
|
950
950
|
```
|
951
951
|
|
952
952
|
|
953
|
-
Focuses the
|
953
|
+
Focuses the matching element and presses a combination of the keys.
|
954
954
|
|
955
955
|
**Usage**
|
956
956
|
|
@@ -1464,7 +1464,7 @@ This method taps an element matching `selector` by performing the following step
|
|
1464
1464
|
When all steps combined have not finished during the specified `timeout`, this method throws a
|
1465
1465
|
`TimeoutError`. Passing zero timeout disables this.
|
1466
1466
|
|
1467
|
-
**NOTE**: [Page#tap_point](./page#tap_point)
|
1467
|
+
**NOTE**: [Page#tap_point](./page#tap_point) the method will throw if `hasTouch` option of the browser context is false.
|
1468
1468
|
|
1469
1469
|
## text_content
|
1470
1470
|
|
@@ -43,6 +43,10 @@ end
|
|
43
43
|
page.route("**/*", method(:handle))
|
44
44
|
```
|
45
45
|
|
46
|
+
**Details**
|
47
|
+
|
48
|
+
Note that any overrides such as `url` or `headers` only apply to the request being routed. If this request results in a redirect, overrides will not be applied to the new redirected request. If you want to propagate a header through redirects, use the combination of [Route#fetch](./route#fetch) and [Route#fulfill](./route#fulfill) instead.
|
49
|
+
|
46
50
|
## fallback
|
47
51
|
|
48
52
|
```
|
@@ -113,7 +117,12 @@ page.route("**/*", method(:handle))
|
|
113
117
|
## fetch
|
114
118
|
|
115
119
|
```
|
116
|
-
def fetch(
|
120
|
+
def fetch(
|
121
|
+
headers: nil,
|
122
|
+
maxRedirects: nil,
|
123
|
+
method: nil,
|
124
|
+
postData: nil,
|
125
|
+
url: nil)
|
117
126
|
```
|
118
127
|
|
119
128
|
|
@@ -133,6 +142,10 @@ end
|
|
133
142
|
page.route("https://dog.ceo/api/breeds/list/all", method(:handle))
|
134
143
|
```
|
135
144
|
|
145
|
+
**Details**
|
146
|
+
|
147
|
+
Note that `headers` option will apply to the fetched request as well as any redirects initiated by it. If you want to only apply `headers` to the original request, but not to redirects, look into [Route#continue](./route#continue) instead.
|
148
|
+
|
136
149
|
## fulfill
|
137
150
|
|
138
151
|
```
|
@@ -11,10 +11,12 @@ information.
|
|
11
11
|
## register
|
12
12
|
|
13
13
|
```
|
14
|
-
def register(name,
|
14
|
+
def register(name, script: nil, contentScript: nil, path: nil)
|
15
15
|
```
|
16
16
|
|
17
17
|
|
18
|
+
Selectors must be registered before creating the page.
|
19
|
+
|
18
20
|
**Usage**
|
19
21
|
|
20
22
|
An example of registering selector engine that queries elements based on a tag name:
|
@@ -42,7 +44,7 @@ playwright.chromium.launch do |browser|
|
|
42
44
|
# Use the selector prefixed with its name.
|
43
45
|
button = page.locator('tag=button')
|
44
46
|
# Combine it with other selector engines.
|
45
|
-
page.locator('tag=div
|
47
|
+
page.locator('tag=div').get_by_text('Click me').click
|
46
48
|
|
47
49
|
# Can use it in any methods supporting selectors.
|
48
50
|
button_count = page.locator('tag=button').count
|
@@ -104,7 +104,7 @@ module Playwright
|
|
104
104
|
|
105
105
|
@routes.reject!(&:expired?)
|
106
106
|
if @routes.count == 0
|
107
|
-
|
107
|
+
async_update_interception_patterns
|
108
108
|
end
|
109
109
|
|
110
110
|
unless handled
|
@@ -280,18 +280,14 @@ module Playwright
|
|
280
280
|
def route(url, handler, times: nil)
|
281
281
|
entry = RouteHandler.new(url, base_url, handler, times)
|
282
282
|
@routes.unshift(entry)
|
283
|
-
|
284
|
-
@channel.send_message_to_server('setNetworkInterceptionEnabled', enabled: true)
|
285
|
-
end
|
283
|
+
update_interception_patterns
|
286
284
|
end
|
287
285
|
|
288
286
|
def unroute(url, handler: nil)
|
289
287
|
@routes.reject! do |handler_entry|
|
290
288
|
handler_entry.same_value?(url: url, handler: handler)
|
291
289
|
end
|
292
|
-
|
293
|
-
@channel.send_message_to_server('setNetworkInterceptionEnabled', enabled: false)
|
294
|
-
end
|
290
|
+
update_interception_patterns
|
295
291
|
end
|
296
292
|
|
297
293
|
private def record_into_har(har, page, notFound:, url:)
|
@@ -325,6 +321,16 @@ module Playwright
|
|
325
321
|
router.add_context_route(self)
|
326
322
|
end
|
327
323
|
|
324
|
+
private def async_update_interception_patterns
|
325
|
+
patterns = RouteHandler.prepare_interception_patterns(@routes)
|
326
|
+
@channel.async_send_message_to_server('setNetworkInterceptionPatterns', patterns: patterns)
|
327
|
+
end
|
328
|
+
|
329
|
+
private def update_interception_patterns
|
330
|
+
patterns = RouteHandler.prepare_interception_patterns(@routes)
|
331
|
+
@channel.send_message_to_server('setNetworkInterceptionPatterns', patterns: patterns)
|
332
|
+
end
|
333
|
+
|
328
334
|
def expect_event(event, predicate: nil, timeout: nil, &block)
|
329
335
|
wait_helper = WaitHelper.new
|
330
336
|
wait_helper.reject_on_timeout(timeout || @timeout_settings.timeout, "Timeout while waiting for event \"#{event}\"")
|
@@ -119,7 +119,7 @@ module Playwright
|
|
119
119
|
|
120
120
|
@routes.reject!(&:expired?)
|
121
121
|
if @routes.count == 0
|
122
|
-
|
122
|
+
async_update_interception_patterns
|
123
123
|
end
|
124
124
|
|
125
125
|
unless handled
|
@@ -407,18 +407,14 @@ module Playwright
|
|
407
407
|
def route(url, handler, times: nil)
|
408
408
|
entry = RouteHandler.new(url, @browser_context.send(:base_url), handler, times)
|
409
409
|
@routes.unshift(entry)
|
410
|
-
|
411
|
-
@channel.send_message_to_server('setNetworkInterceptionEnabled', enabled: true)
|
412
|
-
end
|
410
|
+
update_interception_patterns
|
413
411
|
end
|
414
412
|
|
415
413
|
def unroute(url, handler: nil)
|
416
414
|
@routes.reject! do |handler_entry|
|
417
415
|
handler_entry.same_value?(url: url, handler: handler)
|
418
416
|
end
|
419
|
-
|
420
|
-
@channel.send_message_to_server('setNetworkInterceptionEnabled', enabled: false)
|
421
|
-
end
|
417
|
+
update_interception_patterns
|
422
418
|
end
|
423
419
|
|
424
420
|
def route_from_har(har, notFound: nil, update: nil, url: nil)
|
@@ -436,6 +432,16 @@ module Playwright
|
|
436
432
|
router.add_page_route(self)
|
437
433
|
end
|
438
434
|
|
435
|
+
private def async_update_interception_patterns
|
436
|
+
patterns = RouteHandler.prepare_interception_patterns(@routes)
|
437
|
+
@channel.async_send_message_to_server('setNetworkInterceptionPatterns', patterns: patterns)
|
438
|
+
end
|
439
|
+
|
440
|
+
private def update_interception_patterns
|
441
|
+
patterns = RouteHandler.prepare_interception_patterns(@routes)
|
442
|
+
@channel.send_message_to_server('setNetworkInterceptionPatterns', patterns: patterns)
|
443
|
+
end
|
444
|
+
|
439
445
|
def screenshot(
|
440
446
|
animations: nil,
|
441
447
|
caret: nil,
|
@@ -109,7 +109,7 @@ module Playwright
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
-
def fetch(headers: nil, method: nil, postData: nil, url: nil)
|
112
|
+
def fetch(headers: nil, method: nil, postData: nil, url: nil, maxRedirects: nil)
|
113
113
|
api_request_context = request.frame.page.context.request
|
114
114
|
api_request_context.send(:_inner_fetch,
|
115
115
|
request,
|
@@ -117,6 +117,7 @@ module Playwright
|
|
117
117
|
headers: headers,
|
118
118
|
method: method,
|
119
119
|
data: postData,
|
120
|
+
maxRedirects: maxRedirects,
|
120
121
|
)
|
121
122
|
end
|
122
123
|
|
@@ -111,6 +111,7 @@ module Playwright
|
|
111
111
|
|
112
112
|
# @param text [Regexp|String]
|
113
113
|
private def escape_for_attribute_selector_or_regex(text, exact)
|
114
|
+
puts "escape_for_attribute_selector_or_regex #{text}"
|
114
115
|
if text.is_a?(Regexp)
|
115
116
|
regex = JavaScript::Regex.new(text)
|
116
117
|
"/#{regex.source}/#{regex.flag}"
|
@@ -125,7 +126,7 @@ module Playwright
|
|
125
126
|
# cssEscape(value).replace(/\\ /g, ' ')
|
126
127
|
# However, our attribute selectors do not conform to CSS parsing spec,
|
127
128
|
# so we escape them differently.
|
128
|
-
_text = text.gsub(/["]/, '\\"')
|
129
|
+
_text = text.gsub(/\\/) { "\\\\" }.gsub(/["]/, '\\"')
|
129
130
|
if exact
|
130
131
|
"\"#{_text}\""
|
131
132
|
else
|
@@ -43,6 +43,10 @@ module Playwright
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
def as_pattern
|
47
|
+
@url_matcher.as_pattern
|
48
|
+
end
|
49
|
+
|
46
50
|
def match?(url)
|
47
51
|
@url_matcher.match?(url)
|
48
52
|
end
|
@@ -66,5 +70,9 @@ module Playwright
|
|
66
70
|
@url_value == url
|
67
71
|
end
|
68
72
|
end
|
73
|
+
|
74
|
+
def self.prepare_interception_patterns(handlers)
|
75
|
+
handlers.map(&:as_pattern).compact
|
76
|
+
end
|
69
77
|
end
|
70
78
|
end
|
@@ -7,6 +7,18 @@ module Playwright
|
|
7
7
|
@base_url = base_url
|
8
8
|
end
|
9
9
|
|
10
|
+
def as_pattern
|
11
|
+
case @url
|
12
|
+
when String
|
13
|
+
{ glob: @url }
|
14
|
+
when Regexp
|
15
|
+
regex = JavaScript::Regex.new(@url)
|
16
|
+
{ regexSource: regex.source, regexFlags: regex.flag }
|
17
|
+
else
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
10
22
|
def match?(target_url)
|
11
23
|
case @url
|
12
24
|
when String
|
data/lib/playwright/version.rb
CHANGED
@@ -428,11 +428,6 @@ module Playwright
|
|
428
428
|
wrap_impl(@impl.options=(unwrap_impl(req)))
|
429
429
|
end
|
430
430
|
|
431
|
-
# @nodoc
|
432
|
-
def enable_debug_console!
|
433
|
-
wrap_impl(@impl.enable_debug_console!)
|
434
|
-
end
|
435
|
-
|
436
431
|
# @nodoc
|
437
432
|
def browser=(req)
|
438
433
|
wrap_impl(@impl.browser=(unwrap_impl(req)))
|
@@ -443,6 +438,11 @@ module Playwright
|
|
443
438
|
wrap_impl(@impl.owner_page=(unwrap_impl(req)))
|
444
439
|
end
|
445
440
|
|
441
|
+
# @nodoc
|
442
|
+
def enable_debug_console!
|
443
|
+
wrap_impl(@impl.enable_debug_console!)
|
444
|
+
end
|
445
|
+
|
446
446
|
# -- inherited from EventEmitter --
|
447
447
|
# @nodoc
|
448
448
|
def off(event, callback)
|
@@ -212,7 +212,7 @@ module Playwright
|
|
212
212
|
end
|
213
213
|
|
214
214
|
#
|
215
|
-
#
|
215
|
+
# Programmatically dispatch an event on the matching element.
|
216
216
|
#
|
217
217
|
# **Usage**
|
218
218
|
#
|
@@ -792,7 +792,7 @@ module Playwright
|
|
792
792
|
end
|
793
793
|
|
794
794
|
#
|
795
|
-
# Focuses the
|
795
|
+
# Focuses the matching element and presses a combination of the keys.
|
796
796
|
#
|
797
797
|
# **Usage**
|
798
798
|
#
|
data/lib/playwright_api/page.rb
CHANGED
@@ -1292,7 +1292,7 @@ module Playwright
|
|
1292
1292
|
# When all steps combined have not finished during the specified `timeout`, this method throws a
|
1293
1293
|
# `TimeoutError`. Passing zero timeout disables this.
|
1294
1294
|
#
|
1295
|
-
# **NOTE**: [`method: Page.tap`]
|
1295
|
+
# **NOTE**: [`method: Page.tap`] the method will throw if `hasTouch` option of the browser context is false.
|
1296
1296
|
def tap_point(
|
1297
1297
|
selector,
|
1298
1298
|
force: nil,
|
data/lib/playwright_api/route.rb
CHANGED
@@ -29,6 +29,10 @@ module Playwright
|
|
29
29
|
#
|
30
30
|
# page.route("**/*", handle)
|
31
31
|
# ```
|
32
|
+
#
|
33
|
+
# **Details**
|
34
|
+
#
|
35
|
+
# Note that any overrides such as `url` or `headers` only apply to the request being routed. If this request results in a redirect, overrides will not be applied to the new redirected request. If you want to propagate a header through redirects, use the combination of [`method: Route.fetch`] and [`method: Route.fulfill`] instead.
|
32
36
|
def continue(headers: nil, method: nil, postData: nil, url: nil)
|
33
37
|
wrap_impl(@impl.continue(headers: unwrap_impl(headers), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
|
34
38
|
end
|
@@ -106,8 +110,17 @@ module Playwright
|
|
106
110
|
#
|
107
111
|
# page.route("https://dog.ceo/api/breeds/list/all", handle)
|
108
112
|
# ```
|
109
|
-
|
110
|
-
|
113
|
+
#
|
114
|
+
# **Details**
|
115
|
+
#
|
116
|
+
# Note that `headers` option will apply to the fetched request as well as any redirects initiated by it. If you want to only apply `headers` to the original request, but not to redirects, look into [`method: Route.continue`] instead.
|
117
|
+
def fetch(
|
118
|
+
headers: nil,
|
119
|
+
maxRedirects: nil,
|
120
|
+
method: nil,
|
121
|
+
postData: nil,
|
122
|
+
url: nil)
|
123
|
+
wrap_impl(@impl.fetch(headers: unwrap_impl(headers), maxRedirects: unwrap_impl(maxRedirects), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
|
111
124
|
end
|
112
125
|
|
113
126
|
#
|
@@ -4,6 +4,8 @@ module Playwright
|
|
4
4
|
# information.
|
5
5
|
class Selectors < PlaywrightApi
|
6
6
|
|
7
|
+
#
|
8
|
+
# Selectors must be registered before creating the page.
|
7
9
|
#
|
8
10
|
# **Usage**
|
9
11
|
#
|
@@ -33,8 +35,8 @@ module Playwright
|
|
33
35
|
#
|
34
36
|
# # Use the selector prefixed with its name.
|
35
37
|
# button = page.locator('tag=button')
|
36
|
-
# # Combine it with
|
37
|
-
# page.locator('tag=div
|
38
|
+
# # Combine it with built-in locators.
|
39
|
+
# page.locator('tag=div').get_by_text('Click me').click()
|
38
40
|
# # Can use it in any methods supporting selectors.
|
39
41
|
# button_count = page.locator('tag=button').count()
|
40
42
|
# print(button_count)
|
@@ -43,8 +45,8 @@ module Playwright
|
|
43
45
|
# with sync_playwright() as playwright:
|
44
46
|
# run(playwright)
|
45
47
|
# ```
|
46
|
-
def register(name,
|
47
|
-
wrap_impl(@impl.register(unwrap_impl(name),
|
48
|
+
def register(name, script: nil, contentScript: nil, path: nil)
|
49
|
+
wrap_impl(@impl.register(unwrap_impl(name), script: unwrap_impl(script), contentScript: unwrap_impl(contentScript), path: unwrap_impl(path)))
|
48
50
|
end
|
49
51
|
|
50
52
|
#
|
@@ -6,6 +6,8 @@ module Playwright
|
|
6
6
|
|
7
7
|
#
|
8
8
|
# Dispatches a `touchstart` and `touchend` event with a single touch at the position (`x`,`y`).
|
9
|
+
#
|
10
|
+
# **NOTE**: [`method: Page.tap`] the method will throw if `hasTouch` option of the browser context is false.
|
9
11
|
def tap_point(x, y)
|
10
12
|
wrap_impl(@impl.tap_point(unwrap_impl(x), unwrap_impl(y)))
|
11
13
|
end
|
data/sig/playwright.rbs
CHANGED
@@ -47,7 +47,7 @@ module Playwright
|
|
47
47
|
def abort: (?errorCode: String) -> void
|
48
48
|
def continue: (?headers: Hash[untyped, untyped], ?method: String, ?postData: (String | String | untyped), ?url: String) -> void
|
49
49
|
def fallback: (?headers: Hash[untyped, untyped], ?method: String, ?postData: (String | String | untyped), ?url: String) -> void
|
50
|
-
def fetch: (?headers: Hash[untyped, untyped], ?method: String, ?postData: (String | String | untyped), ?url: String) -> APIResponse
|
50
|
+
def fetch: (?headers: Hash[untyped, untyped], ?maxRedirects: Integer, ?method: String, ?postData: (String | String | untyped), ?url: String) -> APIResponse
|
51
51
|
def fulfill: (?body: (String | String), ?contentType: String, ?headers: Hash[untyped, untyped], ?json: untyped, ?path: (String | File), ?response: APIResponse, ?status: Integer) -> void
|
52
52
|
def request: -> Request
|
53
53
|
end
|
@@ -217,7 +217,7 @@ module Playwright
|
|
217
217
|
end
|
218
218
|
|
219
219
|
class Selectors
|
220
|
-
def register: (String name, ?contentScript: bool, ?path: (String | File)
|
220
|
+
def register: (String name, ?script: String, ?contentScript: bool, ?path: (String | File)) -> void
|
221
221
|
end
|
222
222
|
|
223
223
|
class ConsoleMessage
|
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.31.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-03-02 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.31.1
|
405
405
|
test_files: []
|