playwright-ruby-client 1.17.1 → 1.18.2
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/api_request_context.md +24 -0
- data/documentation/docs/api/api_response.md +14 -0
- data/documentation/docs/api/download.md +1 -3
- data/documentation/docs/api/frame.md +1 -1
- data/documentation/docs/api/frame_locator.md +10 -1
- data/documentation/docs/api/locator.md +19 -47
- data/documentation/docs/api/page.md +5 -1
- data/documentation/docs/include/api_coverage.md +5 -0
- data/lib/playwright/channel_owners/browser_context.rb +5 -0
- data/lib/playwright/channel_owners/frame.rb +2 -2
- data/lib/playwright/channel_owners/local_utils.rb +14 -0
- data/lib/playwright/channel_owners/page.rb +2 -2
- data/lib/playwright/frame_locator_impl.rb +2 -1
- data/lib/playwright/locator_impl.rb +62 -3
- data/lib/playwright/tracing_impl.rb +21 -7
- data/lib/playwright/transport.rb +1 -1
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright_api/api_request.rb +3 -1
- data/lib/playwright_api/api_request_context.rb +47 -0
- data/lib/playwright_api/api_response.rb +13 -0
- data/lib/playwright_api/download.rb +0 -4
- data/lib/playwright_api/frame.rb +2 -2
- data/lib/playwright_api/frame_locator.rb +11 -2
- data/lib/playwright_api/local_utils.rb +9 -0
- data/lib/playwright_api/locator.rb +16 -46
- data/lib/playwright_api/page.rb +12 -12
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cea05a1d92148b300982f6ada4ae56aa99c9b9fff9c7a9ac40dae957682b716e
|
4
|
+
data.tar.gz: dc053db008d37c2194bbaa6f34c80e8b8a174370d0afdc9b23777063519c4318
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 560c79143101d7ad7ff31e8eda70d7300e335bd40b9a6a87824a0e6e329658a7c45d7e5ee0979822092dda8008c4e83342e1abd4332db57dbb806ccd9bff1c8e
|
7
|
+
data.tar.gz: f8c49313b8b3f5561d8e64cdbf262eb5967a8eb421d5761fa0b0182d3cef634f276b095fc4520d26957f8b6d72fb5aefd0fbc18236e94e725aeb6c0025ad1545
|
@@ -9,6 +9,30 @@ environment or the service to your e2e test. When used on [Page](./page) or a [B
|
|
9
9
|
the cookies from the corresponding [BrowserContext](./browser_context). This means that if you log in using this API, your e2e test will be
|
10
10
|
logged in and vice versa.
|
11
11
|
|
12
|
+
```ruby
|
13
|
+
playwright.chromium.launch do |browser|
|
14
|
+
# This will launch a new browser, create a context and page. When making HTTP
|
15
|
+
# requests with the internal APIRequestContext (e.g. `context.request` or `page.request`)
|
16
|
+
# it will automatically set the cookies to the browser page and vise versa.
|
17
|
+
context = browser.new_context(base_url: 'https://api.github,com')
|
18
|
+
api_request_context = context.request
|
19
|
+
|
20
|
+
|
21
|
+
# Create a repository.
|
22
|
+
response = api_request_context.post(
|
23
|
+
"/user/repos",
|
24
|
+
headers: {
|
25
|
+
"Accept": "application/vnd.github.v3+json",
|
26
|
+
"Authorization": "Bearer #{API_TOKEN}",
|
27
|
+
},
|
28
|
+
data: { name: 'test-repo-1' },
|
29
|
+
)
|
30
|
+
response.ok? # => true
|
31
|
+
response.json['name'] # => "tes≈-repo-1"
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
|
12
36
|
## delete
|
13
37
|
|
14
38
|
```
|
@@ -6,6 +6,20 @@ sidebar_position: 10
|
|
6
6
|
|
7
7
|
[APIResponse](./api_response) class represents responses returned by [APIRequestContext#get](./api_request_context#get) and similar methods.
|
8
8
|
|
9
|
+
```ruby
|
10
|
+
playwright.chromium.launch do |browser|
|
11
|
+
context = browser.new_context
|
12
|
+
response = context.request.get("https://example.com/user/repos")
|
13
|
+
|
14
|
+
response.ok? # => true
|
15
|
+
response.status # => 200
|
16
|
+
response.headers["content-type"] # => "application/json; charset=utf-8"
|
17
|
+
response.json # => { "name" => "Foo" }
|
18
|
+
response.body # => "{ \"name\" => \"Foo\" }"
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
|
9
23
|
## body
|
10
24
|
|
11
25
|
```
|
@@ -19,9 +19,7 @@ end
|
|
19
19
|
path = download.path
|
20
20
|
```
|
21
21
|
|
22
|
-
|
23
|
-
downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not
|
24
|
-
performed and user has no access to the downloaded files.
|
22
|
+
|
25
23
|
|
26
24
|
## cancel
|
27
25
|
|
@@ -26,6 +26,15 @@ page.frame_locator('.result-frame').locator('button').click
|
|
26
26
|
page.frame_locator('.result-frame').first.locator('button').click
|
27
27
|
```
|
28
28
|
|
29
|
+
**Converting Locator to FrameLocator**
|
30
|
+
|
31
|
+
If you have a [Locator](./locator) object pointing to an `iframe` it can be converted to [FrameLocator](./frame_locator) using
|
32
|
+
[`:scope`](https://developer.mozilla.org/en-US/docs/Web/CSS/:scope) CSS selector:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
frame_locator = locator.frame_locator(':scope')
|
36
|
+
```
|
37
|
+
|
29
38
|
|
30
39
|
|
31
40
|
## first
|
@@ -56,7 +65,7 @@ Returns locator to the last matching frame.
|
|
56
65
|
## locator
|
57
66
|
|
58
67
|
```
|
59
|
-
def locator(selector)
|
68
|
+
def locator(selector, hasText: nil)
|
60
69
|
```
|
61
70
|
|
62
71
|
The method finds an element matching the specified selector in the FrameLocator's subtree.
|
@@ -4,53 +4,10 @@ sidebar_position: 10
|
|
4
4
|
|
5
5
|
# Locator
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
```ruby
|
11
|
-
locator = page.locator("text=Submit")
|
12
|
-
locator.click
|
13
|
-
```
|
14
|
-
|
15
|
-
The difference between the Locator and [ElementHandle](./element_handle) is that the latter points to a particular element, while Locator
|
16
|
-
captures the logic of how to retrieve that element.
|
17
|
-
|
18
|
-
In the example below, handle points to a particular DOM element on page. If that element changes text or is used by
|
19
|
-
React to render an entirely different component, handle is still pointing to that very DOM element. This can lead to
|
20
|
-
unexpected behaviors.
|
21
|
-
|
22
|
-
```ruby
|
23
|
-
handle = page.query_selector("text=Submit")
|
24
|
-
handle.hover
|
25
|
-
handle.click
|
26
|
-
```
|
27
|
-
|
28
|
-
With the locator, every time the `element` is used, up-to-date DOM element is located in the page using the selector. So
|
29
|
-
in the snippet below, underlying DOM element is going to be located twice.
|
30
|
-
|
31
|
-
```ruby
|
32
|
-
locator = page.locator("text=Submit")
|
33
|
-
locator.hover
|
34
|
-
locator.click
|
35
|
-
```
|
36
|
-
|
37
|
-
**Strictness**
|
38
|
-
|
39
|
-
Locators are strict. This means that all operations on locators that imply some target DOM element will throw if more
|
40
|
-
than one element matches given selector.
|
41
|
-
|
42
|
-
```ruby
|
43
|
-
# Throws if there are several buttons in DOM:
|
44
|
-
page.locator('button').click
|
45
|
-
|
46
|
-
# Works because we explicitly tell locator to pick the first element:
|
47
|
-
page.locator('button').first.click
|
48
|
-
|
49
|
-
# Works because count knows what to do with multiple matches:
|
50
|
-
page.locator('button').count
|
51
|
-
```
|
52
|
-
|
7
|
+
Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent a way
|
8
|
+
to find element(s) on the page at any moment. Locator can be created with the [Page#locator](./page#locator) method.
|
53
9
|
|
10
|
+
[Learn more about locators](https://playwright.dev/python/docs/locators).
|
54
11
|
|
55
12
|
## all_inner_texts
|
56
13
|
|
@@ -220,6 +177,21 @@ element.dispatch_event("dragstart", eventInit: { dataTransfer: data_transfer })
|
|
220
177
|
|
221
178
|
|
222
179
|
|
180
|
+
## drag_to
|
181
|
+
|
182
|
+
```
|
183
|
+
def drag_to(
|
184
|
+
target,
|
185
|
+
force: nil,
|
186
|
+
noWaitAfter: nil,
|
187
|
+
sourcePosition: nil,
|
188
|
+
targetPosition: nil,
|
189
|
+
timeout: nil,
|
190
|
+
trial: nil)
|
191
|
+
```
|
192
|
+
|
193
|
+
|
194
|
+
|
223
195
|
## element_handle
|
224
196
|
|
225
197
|
```
|
@@ -458,7 +430,7 @@ Returns locator to the last matching element.
|
|
458
430
|
## locator
|
459
431
|
|
460
432
|
```
|
461
|
-
def locator(selector)
|
433
|
+
def locator(selector, hasText: nil)
|
462
434
|
```
|
463
435
|
|
464
436
|
The method finds an element matching the specified selector in the [Locator](./locator)'s subtree.
|
@@ -774,7 +774,7 @@ considered not visible.
|
|
774
774
|
## locator
|
775
775
|
|
776
776
|
```
|
777
|
-
def locator(selector)
|
777
|
+
def locator(selector, hasText: nil)
|
778
778
|
```
|
779
779
|
|
780
780
|
The method returns an element locator that can be used to perform actions on the page. Locator is resolved to the
|
@@ -1597,4 +1597,8 @@ associated with the page.
|
|
1597
1597
|
|
1598
1598
|
## mouse
|
1599
1599
|
|
1600
|
+
## request
|
1601
|
+
|
1602
|
+
API testing helper associated with this page. Requests made with this API will use page cookies.
|
1603
|
+
|
1600
1604
|
## touchscreen
|
@@ -319,6 +319,7 @@
|
|
319
319
|
* accessibility
|
320
320
|
* keyboard
|
321
321
|
* mouse
|
322
|
+
* request
|
322
323
|
* touchscreen
|
323
324
|
|
324
325
|
## BrowserContext
|
@@ -405,6 +406,7 @@
|
|
405
406
|
* count
|
406
407
|
* dblclick
|
407
408
|
* dispatch_event
|
409
|
+
* drag_to
|
408
410
|
* element_handle
|
409
411
|
* element_handles
|
410
412
|
* evaluate
|
@@ -449,6 +451,9 @@
|
|
449
451
|
* locator
|
450
452
|
* nth
|
451
453
|
|
454
|
+
## LocalUtils
|
455
|
+
|
456
|
+
|
452
457
|
## APIResponse
|
453
458
|
|
454
459
|
* body
|
@@ -400,8 +400,8 @@ module Playwright
|
|
400
400
|
nil
|
401
401
|
end
|
402
402
|
|
403
|
-
def locator(selector)
|
404
|
-
LocatorImpl.new(frame: self, timeout_settings: @page.send(:timeout_settings), selector: selector)
|
403
|
+
def locator(selector, hasText: nil)
|
404
|
+
LocatorImpl.new(frame: self, timeout_settings: @page.send(:timeout_settings), selector: selector, hasText: hasText)
|
405
405
|
end
|
406
406
|
|
407
407
|
def frame_locator(selector)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Playwright
|
2
|
+
define_channel_owner :LocalUtils do
|
3
|
+
# @param zip_file [String]
|
4
|
+
# @param name_value_array [Array<Hash<{name: string, value: string}>>]
|
5
|
+
def zip(zip_file, name_value_array)
|
6
|
+
params = {
|
7
|
+
zipFile: zip_file,
|
8
|
+
entries: name_value_array,
|
9
|
+
}
|
10
|
+
@channel.send_message_to_server('zip', params)
|
11
|
+
nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -6,11 +6,12 @@ module Playwright
|
|
6
6
|
@frame_selector = frame_selector
|
7
7
|
end
|
8
8
|
|
9
|
-
def locator(selector)
|
9
|
+
def locator(selector, hasText: nil)
|
10
10
|
LocatorImpl.new(
|
11
11
|
frame: @frame,
|
12
12
|
timeout_settings: @timeout_settings,
|
13
13
|
selector: "#{@frame_selector} >> control=enter-frame >> #{selector}",
|
14
|
+
hasText: hasText,
|
14
15
|
)
|
15
16
|
end
|
16
17
|
|
@@ -1,9 +1,46 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
module Playwright
|
4
|
+
class EscapeWithQuotes
|
5
|
+
def initialize(text, char = "'")
|
6
|
+
stringified = text.to_json
|
7
|
+
escaped_text = stringified[1...-1].gsub(/\\"/, '"')
|
8
|
+
|
9
|
+
case char
|
10
|
+
when '"'
|
11
|
+
text = escaped_text.gsub(/["]/, '\\"')
|
12
|
+
@text = "\"#{text}\""
|
13
|
+
when "'"
|
14
|
+
text = escaped_text.gsub(/[']/, '\\\'')
|
15
|
+
@text = "'#{text}'"
|
16
|
+
else
|
17
|
+
raise ArgumentError.new('Invalid escape char')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
@text
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
2
26
|
define_api_implementation :LocatorImpl do
|
3
|
-
def initialize(frame:, timeout_settings:, selector:)
|
27
|
+
def initialize(frame:, timeout_settings:, selector:, hasText: nil)
|
4
28
|
@frame = frame
|
5
29
|
@timeout_settings = timeout_settings
|
6
|
-
@selector =
|
30
|
+
@selector =
|
31
|
+
case hasText
|
32
|
+
when Regexp
|
33
|
+
source = EscapeWithQuotes.new(hasText.source, '"')
|
34
|
+
flags = []
|
35
|
+
flags << 'ms' if (hasText.options & Regexp::MULTILINE) != 0
|
36
|
+
flags << 'i' if (hasText.options & Regexp::IGNORECASE) != 0
|
37
|
+
"#{selector} >> :scope:text-matches(#{source}, \"#{flags.join('')}\")"
|
38
|
+
when String
|
39
|
+
text = EscapeWithQuotes.new(hasText, '"')
|
40
|
+
"#{selector} >> :scope:has-text(#{text})"
|
41
|
+
else
|
42
|
+
selector
|
43
|
+
end
|
7
44
|
end
|
8
45
|
|
9
46
|
def to_s
|
@@ -102,6 +139,27 @@ module Playwright
|
|
102
139
|
@frame.dispatch_event(@selector, type, strict: true, eventInit: eventInit, timeout: timeout)
|
103
140
|
end
|
104
141
|
|
142
|
+
def drag_to(target,
|
143
|
+
force: nil,
|
144
|
+
noWaitAfter: nil,
|
145
|
+
sourcePosition: nil,
|
146
|
+
targetPosition: nil,
|
147
|
+
timeout: nil,
|
148
|
+
trial: nil)
|
149
|
+
|
150
|
+
@frame.drag_and_drop(
|
151
|
+
@selector,
|
152
|
+
target.instance_variable_get(:@selector),
|
153
|
+
force: force,
|
154
|
+
noWaitAfter: noWaitAfter,
|
155
|
+
sourcePosition: sourcePosition,
|
156
|
+
targetPosition: targetPosition,
|
157
|
+
timeout: timeout,
|
158
|
+
trial: trial,
|
159
|
+
strict: true,
|
160
|
+
)
|
161
|
+
end
|
162
|
+
|
105
163
|
def evaluate(expression, arg: nil, timeout: nil)
|
106
164
|
with_element(timeout: timeout) do |handle|
|
107
165
|
handle.evaluate(expression, arg: arg)
|
@@ -122,11 +180,12 @@ module Playwright
|
|
122
180
|
@frame.fill(@selector, value, strict: true, force: force, noWaitAfter: noWaitAfter, timeout: timeout)
|
123
181
|
end
|
124
182
|
|
125
|
-
def locator(selector)
|
183
|
+
def locator(selector, hasText: nil)
|
126
184
|
LocatorImpl.new(
|
127
185
|
frame: @frame,
|
128
186
|
timeout_settings: @timeout_settings,
|
129
187
|
selector: "#{@selector} >> #{selector}",
|
188
|
+
hasText: hasText,
|
130
189
|
)
|
131
190
|
end
|
132
191
|
|
@@ -20,21 +20,35 @@ module Playwright
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def stop_chunk(path: nil)
|
23
|
-
do_stop_chunk(
|
23
|
+
do_stop_chunk(file_path: path)
|
24
24
|
end
|
25
25
|
|
26
26
|
def stop(path: nil)
|
27
|
-
do_stop_chunk(
|
27
|
+
do_stop_chunk(file_path: path)
|
28
28
|
@channel.send_message_to_server('tracingStop')
|
29
29
|
end
|
30
30
|
|
31
|
-
private def do_stop_chunk(
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
private def do_stop_chunk(file_path:)
|
32
|
+
mode = 'doNotSave'
|
33
|
+
if file_path
|
34
|
+
if @context.send(:remote_connection?)
|
35
|
+
mode = 'compressTrace'
|
36
|
+
else
|
37
|
+
mode = 'compressTraceAndSources'
|
38
|
+
end
|
39
|
+
end
|
35
40
|
|
36
|
-
|
41
|
+
result = @channel.send_message_to_server_result('tracingStopChunk', mode: mode)
|
42
|
+
return unless file_path # Not interested in artifacts.
|
43
|
+
return unless result['artifact'] # The artifact may be missing if the browser closed while stopping tracing.
|
44
|
+
|
45
|
+
artifact = ChannelOwners::Artifact.from(result['artifact'])
|
46
|
+
artifact.save_as(file_path)
|
37
47
|
artifact.delete
|
48
|
+
|
49
|
+
# // Add local sources to the remote trace if necessary.
|
50
|
+
# if (result.sourceEntries?.length)
|
51
|
+
# await this._context._localUtils.zip(filePath, result.sourceEntries);
|
38
52
|
end
|
39
53
|
end
|
40
54
|
end
|
data/lib/playwright/transport.rb
CHANGED
@@ -46,7 +46,7 @@ module Playwright
|
|
46
46
|
#
|
47
47
|
# @note This method blocks until playwright-cli exited. Consider using Thread or Future.
|
48
48
|
def async_run
|
49
|
-
@stdin, @stdout, @stderr, @thread = Open3.popen3("#{@driver_executable_path} run-driver")
|
49
|
+
@stdin, @stdout, @stderr, @thread = Open3.popen3("#{@driver_executable_path} run-driver", { pgroup: true })
|
50
50
|
@stdin.binmode # Ensure Strings are written 1:1 without encoding conversion, necessary for integer values
|
51
51
|
|
52
52
|
Thread.new { handle_stdout }
|
data/lib/playwright/version.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Playwright
|
2
|
-
# Exposes API that can be used for the Web API testing.
|
2
|
+
# Exposes API that can be used for the Web API testing. Each Playwright browser context has a APIRequestContext instance
|
3
|
+
# attached which shares cookies with the page context. Its also possible to create a new APIRequestContext instance
|
4
|
+
# manually. For more information see [here](./class-apirequestcontext).
|
3
5
|
class APIRequest < PlaywrightApi
|
4
6
|
|
5
7
|
# Creates new instances of `APIRequestContext`.
|
@@ -3,6 +3,53 @@ module Playwright
|
|
3
3
|
# environment or the service to your e2e test. When used on `Page` or a `BrowserContext`, this API will automatically use
|
4
4
|
# the cookies from the corresponding `BrowserContext`. This means that if you log in using this API, your e2e test will be
|
5
5
|
# logged in and vice versa.
|
6
|
+
#
|
7
|
+
# ```python sync
|
8
|
+
# import os
|
9
|
+
# from playwright.sync_api import sync_playwright
|
10
|
+
#
|
11
|
+
# REPO = "test-repo-1"
|
12
|
+
# USER = "github-username"
|
13
|
+
# API_TOKEN = os.getenv("GITHUB_API_TOKEN")
|
14
|
+
#
|
15
|
+
# with sync_playwright() as p:
|
16
|
+
# # This will launch a new browser, create a context and page. When making HTTP
|
17
|
+
# # requests with the internal APIRequestContext (e.g. `context.request` or `page.request`)
|
18
|
+
# # it will automatically set the cookies to the browser page and vise versa.
|
19
|
+
# browser = playwright.chromium.launch()
|
20
|
+
# context = browser.new_context(base_url="https://api.github.com")
|
21
|
+
# api_request_context = context.request
|
22
|
+
# page = context.new_page()
|
23
|
+
#
|
24
|
+
# # Alternatively you can create a APIRequestContext manually without having a browser context attached:
|
25
|
+
# # api_request_context = playwright.request.new_context(base_url="https://api.github.com")
|
26
|
+
#
|
27
|
+
#
|
28
|
+
# # Create a repository.
|
29
|
+
# response = api_request_context.post(
|
30
|
+
# "/user/repos",
|
31
|
+
# headers={
|
32
|
+
# "Accept": "application/vnd.github.v3+json",
|
33
|
+
# # Add GitHub personal access token.
|
34
|
+
# "Authorization": f"token {API_TOKEN}",
|
35
|
+
# },
|
36
|
+
# data={"name": REPO},
|
37
|
+
# )
|
38
|
+
# assert response.ok
|
39
|
+
# assert response.json()["name"] == REPO
|
40
|
+
#
|
41
|
+
# # Delete a repository.
|
42
|
+
# response = api_request_context.delete(
|
43
|
+
# f"/repos/{USER}/{REPO}",
|
44
|
+
# headers={
|
45
|
+
# "Accept": "application/vnd.github.v3+json",
|
46
|
+
# # Add GitHub personal access token.
|
47
|
+
# "Authorization": f"token {API_TOKEN}",
|
48
|
+
# },
|
49
|
+
# )
|
50
|
+
# assert response.ok
|
51
|
+
# assert await response.body() == '{"status": "ok"}'
|
52
|
+
# ```
|
6
53
|
class APIRequestContext < PlaywrightApi
|
7
54
|
|
8
55
|
# Sends HTTP(S) [DELETE](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE) request and returns its
|
@@ -1,5 +1,18 @@
|
|
1
1
|
module Playwright
|
2
2
|
# `APIResponse` class represents responses returned by [`method: APIRequestContext.get`] and similar methods.
|
3
|
+
#
|
4
|
+
# ```python sync
|
5
|
+
# from playwright.sync_api import sync_playwright
|
6
|
+
#
|
7
|
+
# with sync_playwright() as p:
|
8
|
+
# context = playwright.request.new_context()
|
9
|
+
# response = context.get("https://example.com/user/repos")
|
10
|
+
# assert response.ok
|
11
|
+
# assert response.status == 200
|
12
|
+
# assert response.headers["content-type"] == "application/json; charset=utf-8"
|
13
|
+
# assert response.json()["name"] == "foobar"
|
14
|
+
# assert response.body() == '{"status": "ok"}'
|
15
|
+
# ```
|
3
16
|
class APIResponse < PlaywrightApi
|
4
17
|
|
5
18
|
# Returns the buffer with response body.
|
@@ -12,10 +12,6 @@ module Playwright
|
|
12
12
|
# # wait for download to complete
|
13
13
|
# path = download.path()
|
14
14
|
# ```
|
15
|
-
#
|
16
|
-
# > NOTE: Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the
|
17
|
-
# downloaded content. If `acceptDownloads` is not set, download events are emitted, but the actual download is not
|
18
|
-
# performed and user has no access to the downloaded files.
|
19
15
|
class Download < PlaywrightApi
|
20
16
|
|
21
17
|
# Cancels a download. Will not fail if the download is already finished or canceled. Upon successful cancellations,
|
data/lib/playwright_api/frame.rb
CHANGED
@@ -445,8 +445,8 @@ module Playwright
|
|
445
445
|
# The method returns an element locator that can be used to perform actions in the frame. Locator is resolved to the
|
446
446
|
# element immediately before performing an action, so a series of actions on the same locator can in fact be performed on
|
447
447
|
# different DOM elements. That would happen if the DOM structure between those actions has changed.
|
448
|
-
def locator(selector)
|
449
|
-
wrap_impl(@impl.locator(unwrap_impl(selector)))
|
448
|
+
def locator(selector, hasText: nil)
|
449
|
+
wrap_impl(@impl.locator(unwrap_impl(selector), hasText: unwrap_impl(hasText)))
|
450
450
|
end
|
451
451
|
|
452
452
|
# Returns frame's name attribute as specified in the tag.
|
@@ -20,6 +20,15 @@ module Playwright
|
|
20
20
|
# # Works because we explicitly tell locator to pick the first frame:
|
21
21
|
# page.frame_locator('.result-frame').first.locator('button').click()
|
22
22
|
# ```
|
23
|
+
#
|
24
|
+
# **Converting Locator to FrameLocator**
|
25
|
+
#
|
26
|
+
# If you have a `Locator` object pointing to an `iframe` it can be converted to `FrameLocator` using
|
27
|
+
# [`:scope`](https://developer.mozilla.org/en-US/docs/Web/CSS/:scope) CSS selector:
|
28
|
+
#
|
29
|
+
# ```python sync
|
30
|
+
# frameLocator = locator.frame_locator(":scope");
|
31
|
+
# ```
|
23
32
|
class FrameLocator < PlaywrightApi
|
24
33
|
|
25
34
|
# Returns locator to the first matching frame.
|
@@ -39,8 +48,8 @@ module Playwright
|
|
39
48
|
end
|
40
49
|
|
41
50
|
# The method finds an element matching the specified selector in the FrameLocator's subtree.
|
42
|
-
def locator(selector)
|
43
|
-
wrap_impl(@impl.locator(unwrap_impl(selector)))
|
51
|
+
def locator(selector, hasText: nil)
|
52
|
+
wrap_impl(@impl.locator(unwrap_impl(selector), hasText: unwrap_impl(hasText)))
|
44
53
|
end
|
45
54
|
|
46
55
|
# Returns locator to the n-th matching frame.
|
@@ -1,49 +1,8 @@
|
|
1
1
|
module Playwright
|
2
|
-
#
|
3
|
-
#
|
2
|
+
# Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent a way
|
3
|
+
# to find element(s) on the page at any moment. Locator can be created with the [`method: Page.locator`] method.
|
4
4
|
#
|
5
|
-
#
|
6
|
-
# locator = page.locator("text=Submit")
|
7
|
-
# locator.click()
|
8
|
-
# ```
|
9
|
-
#
|
10
|
-
# The difference between the Locator and `ElementHandle` is that the latter points to a particular element, while Locator
|
11
|
-
# captures the logic of how to retrieve that element.
|
12
|
-
#
|
13
|
-
# In the example below, handle points to a particular DOM element on page. If that element changes text or is used by
|
14
|
-
# React to render an entirely different component, handle is still pointing to that very DOM element. This can lead to
|
15
|
-
# unexpected behaviors.
|
16
|
-
#
|
17
|
-
# ```python sync
|
18
|
-
# handle = page.query_selector("text=Submit")
|
19
|
-
# handle.hover()
|
20
|
-
# handle.click()
|
21
|
-
# ```
|
22
|
-
#
|
23
|
-
# With the locator, every time the `element` is used, up-to-date DOM element is located in the page using the selector. So
|
24
|
-
# in the snippet below, underlying DOM element is going to be located twice.
|
25
|
-
#
|
26
|
-
# ```python sync
|
27
|
-
# locator = page.locator("text=Submit")
|
28
|
-
# locator.hover()
|
29
|
-
# locator.click()
|
30
|
-
# ```
|
31
|
-
#
|
32
|
-
# **Strictness**
|
33
|
-
#
|
34
|
-
# Locators are strict. This means that all operations on locators that imply some target DOM element will throw if more
|
35
|
-
# than one element matches given selector.
|
36
|
-
#
|
37
|
-
# ```python sync
|
38
|
-
# # Throws if there are several buttons in DOM:
|
39
|
-
# page.locator('button').click()
|
40
|
-
#
|
41
|
-
# # Works because we explicitly tell locator to pick the first element:
|
42
|
-
# page.locator('button').first.click()
|
43
|
-
#
|
44
|
-
# # Works because count knows what to do with multiple matches:
|
45
|
-
# page.locator('button').count()
|
46
|
-
# ```
|
5
|
+
# [Learn more about locators](./locators.md).
|
47
6
|
class Locator < PlaywrightApi
|
48
7
|
|
49
8
|
# Returns an array of `node.innerText` values for all matching nodes.
|
@@ -183,6 +142,17 @@ module Playwright
|
|
183
142
|
wrap_impl(@impl.dispatch_event(unwrap_impl(type), eventInit: unwrap_impl(eventInit), timeout: unwrap_impl(timeout)))
|
184
143
|
end
|
185
144
|
|
145
|
+
def drag_to(
|
146
|
+
target,
|
147
|
+
force: nil,
|
148
|
+
noWaitAfter: nil,
|
149
|
+
sourcePosition: nil,
|
150
|
+
targetPosition: nil,
|
151
|
+
timeout: nil,
|
152
|
+
trial: nil)
|
153
|
+
wrap_impl(@impl.drag_to(unwrap_impl(target), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), sourcePosition: unwrap_impl(sourcePosition), targetPosition: unwrap_impl(targetPosition), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
154
|
+
end
|
155
|
+
|
186
156
|
# Resolves given locator to the first matching DOM element. If no elements matching the query are visible, waits for them
|
187
157
|
# up to a given timeout. If multiple elements match the selector, throws.
|
188
158
|
def element_handle(timeout: nil)
|
@@ -350,8 +320,8 @@ module Playwright
|
|
350
320
|
end
|
351
321
|
|
352
322
|
# The method finds an element matching the specified selector in the `Locator`'s subtree.
|
353
|
-
def locator(selector)
|
354
|
-
wrap_impl(@impl.locator(unwrap_impl(selector)))
|
323
|
+
def locator(selector, hasText: nil)
|
324
|
+
wrap_impl(@impl.locator(unwrap_impl(selector), hasText: unwrap_impl(hasText)))
|
355
325
|
end
|
356
326
|
|
357
327
|
# Returns locator to the n-th matching element.
|
data/lib/playwright_api/page.rb
CHANGED
@@ -56,6 +56,11 @@ module Playwright
|
|
56
56
|
wrap_impl(@impl.mouse)
|
57
57
|
end
|
58
58
|
|
59
|
+
# API testing helper associated with this page. Requests made with this API will use page cookies.
|
60
|
+
def request # property
|
61
|
+
wrap_impl(@impl.request)
|
62
|
+
end
|
63
|
+
|
59
64
|
def touchscreen # property
|
60
65
|
wrap_impl(@impl.touchscreen)
|
61
66
|
end
|
@@ -681,8 +686,8 @@ module Playwright
|
|
681
686
|
# different DOM elements. That would happen if the DOM structure between those actions has changed.
|
682
687
|
#
|
683
688
|
# Shortcut for main frame's [`method: Frame.locator`].
|
684
|
-
def locator(selector)
|
685
|
-
wrap_impl(@impl.locator(unwrap_impl(selector)))
|
689
|
+
def locator(selector, hasText: nil)
|
690
|
+
wrap_impl(@impl.locator(unwrap_impl(selector), hasText: unwrap_impl(hasText)))
|
686
691
|
end
|
687
692
|
|
688
693
|
# The page's main frame. Page is guaranteed to have a main frame which persists during navigations.
|
@@ -1381,21 +1386,11 @@ module Playwright
|
|
1381
1386
|
wrap_impl(@impl.owned_context=(unwrap_impl(req)))
|
1382
1387
|
end
|
1383
1388
|
|
1384
|
-
# @nodoc
|
1385
|
-
def request
|
1386
|
-
wrap_impl(@impl.request)
|
1387
|
-
end
|
1388
|
-
|
1389
1389
|
# @nodoc
|
1390
1390
|
def start_js_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
|
1391
1391
|
wrap_impl(@impl.start_js_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
|
1392
1392
|
end
|
1393
1393
|
|
1394
|
-
# @nodoc
|
1395
|
-
def stop_js_coverage
|
1396
|
-
wrap_impl(@impl.stop_js_coverage)
|
1397
|
-
end
|
1398
|
-
|
1399
1394
|
# @nodoc
|
1400
1395
|
def start_css_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
|
1401
1396
|
wrap_impl(@impl.start_css_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
|
@@ -1406,6 +1401,11 @@ module Playwright
|
|
1406
1401
|
wrap_impl(@impl.stop_css_coverage)
|
1407
1402
|
end
|
1408
1403
|
|
1404
|
+
# @nodoc
|
1405
|
+
def stop_js_coverage
|
1406
|
+
wrap_impl(@impl.stop_js_coverage)
|
1407
|
+
end
|
1408
|
+
|
1409
1409
|
# @nodoc
|
1410
1410
|
def guid
|
1411
1411
|
wrap_impl(@impl.guid)
|
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.18.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- YusukeIwaki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -296,6 +296,7 @@ files:
|
|
296
296
|
- lib/playwright/channel_owners/fetch_request.rb
|
297
297
|
- lib/playwright/channel_owners/frame.rb
|
298
298
|
- lib/playwright/channel_owners/js_handle.rb
|
299
|
+
- lib/playwright/channel_owners/local_utils.rb
|
299
300
|
- lib/playwright/channel_owners/page.rb
|
300
301
|
- lib/playwright/channel_owners/playwright.rb
|
301
302
|
- lib/playwright/channel_owners/request.rb
|
@@ -359,6 +360,7 @@ files:
|
|
359
360
|
- lib/playwright_api/frame_locator.rb
|
360
361
|
- lib/playwright_api/js_handle.rb
|
361
362
|
- lib/playwright_api/keyboard.rb
|
363
|
+
- lib/playwright_api/local_utils.rb
|
362
364
|
- lib/playwright_api/locator.rb
|
363
365
|
- lib/playwright_api/mouse.rb
|
364
366
|
- lib/playwright_api/page.rb
|
@@ -394,5 +396,5 @@ requirements: []
|
|
394
396
|
rubygems_version: 3.3.3
|
395
397
|
signing_key:
|
396
398
|
specification_version: 4
|
397
|
-
summary: The Ruby binding of playwright driver 1.
|
399
|
+
summary: The Ruby binding of playwright driver 1.18.1
|
398
400
|
test_files: []
|