playwright-ruby-client 1.37.1 → 1.39.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/README.md +13 -7
- data/documentation/docs/api/browser.md +13 -9
- data/documentation/docs/api/browser_context.md +51 -32
- data/documentation/docs/api/browser_type.md +12 -7
- data/documentation/docs/api/dialog.md +18 -15
- data/documentation/docs/api/download.md +17 -7
- data/documentation/docs/api/element_handle.md +7 -19
- data/documentation/docs/api/frame.md +55 -30
- data/documentation/docs/api/keyboard.md +4 -0
- data/documentation/docs/api/locator.md +57 -16
- data/documentation/docs/api/page.md +102 -54
- data/documentation/docs/api/playwright.md +23 -20
- data/documentation/docs/api/request.md +17 -0
- data/documentation/docs/api/selectors.md +34 -29
- data/documentation/docs/include/api_coverage.md +1 -0
- data/lib/playwright/channel.rb +8 -0
- data/lib/playwright/channel_owner.rb +7 -2
- data/lib/playwright/channel_owners/browser_context.rb +16 -1
- data/lib/playwright/channel_owners/local_utils.rb +27 -0
- data/lib/playwright/channel_owners/page.rb +2 -0
- data/lib/playwright/channel_owners/playwright.rb +1 -24
- data/lib/playwright/channel_owners/request.rb +17 -1
- data/lib/playwright/channel_owners/route.rb +5 -1
- data/lib/playwright/connection.rb +1 -1
- data/lib/playwright/console_message_impl.rb +29 -0
- data/lib/playwright/errors.rb +13 -2
- data/lib/playwright/events.rb +1 -0
- data/lib/playwright/javascript/value_parser.rb +8 -0
- data/lib/playwright/javascript/value_serializer.rb +10 -4
- data/lib/playwright/locator_impl.rb +4 -0
- data/lib/playwright/utils.rb +4 -0
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright_api/browser.rb +2 -2
- data/lib/playwright_api/browser_context.rb +4 -4
- data/lib/playwright_api/browser_type.rb +2 -2
- data/lib/playwright_api/console_message.rb +0 -22
- data/lib/playwright_api/dialog.rb +2 -2
- data/lib/playwright_api/download.rb +12 -3
- data/lib/playwright_api/element_handle.rb +2 -15
- data/lib/playwright_api/frame.rb +8 -13
- data/lib/playwright_api/keyboard.rb +4 -0
- data/lib/playwright_api/locator.rb +52 -16
- data/lib/playwright_api/page.rb +24 -29
- data/lib/playwright_api/playwright.rb +4 -4
- data/lib/playwright_api/request.rb +17 -0
- data/lib/playwright_api/selectors.rb +2 -2
- data/lib/playwright_api/worker.rb +4 -4
- data/sig/playwright.rbs +1 -0
- metadata +4 -4
- data/lib/playwright/channel_owners/console_message.rb +0 -25
data/lib/playwright/errors.rb
CHANGED
@@ -5,13 +5,13 @@ module Playwright
|
|
5
5
|
if error_payload['name'] == 'TimeoutError'
|
6
6
|
TimeoutError.new(
|
7
7
|
message: error_payload['message'],
|
8
|
-
stack: error_payload['stack']
|
8
|
+
stack: error_payload['stack'],
|
9
9
|
)
|
10
10
|
else
|
11
11
|
new(
|
12
12
|
name: error_payload['name'],
|
13
13
|
message: error_payload['message'],
|
14
|
-
stack: error_payload['stack']
|
14
|
+
stack: error_payload['stack'],
|
15
15
|
)
|
16
16
|
end
|
17
17
|
end
|
@@ -25,6 +25,8 @@ module Playwright
|
|
25
25
|
@message = message
|
26
26
|
@stack = stack
|
27
27
|
end
|
28
|
+
|
29
|
+
attr_reader :name, :message, :stack
|
28
30
|
end
|
29
31
|
|
30
32
|
class DriverCrashedError < StandardError
|
@@ -38,4 +40,13 @@ module Playwright
|
|
38
40
|
super(name: 'TimeoutError', message: message, stack: stack)
|
39
41
|
end
|
40
42
|
end
|
43
|
+
|
44
|
+
class WebError
|
45
|
+
def initialize(error, page)
|
46
|
+
@error = error
|
47
|
+
@page = PlaywrightApi.wrap(page)
|
48
|
+
end
|
49
|
+
|
50
|
+
attr_reader :error, :page
|
51
|
+
end
|
41
52
|
end
|
data/lib/playwright/events.rb
CHANGED
@@ -56,6 +56,14 @@ module Playwright
|
|
56
56
|
return hash['bi'].to_i
|
57
57
|
end
|
58
58
|
|
59
|
+
if hash.key?('m')
|
60
|
+
return parse_hash(hash['m']).to_h
|
61
|
+
end
|
62
|
+
|
63
|
+
if hash.key?('se')
|
64
|
+
return Set.new(parse_hash(hash['se']))
|
65
|
+
end
|
66
|
+
|
59
67
|
if hash.key?('r')
|
60
68
|
# @see https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/RegExp
|
61
69
|
# @see https://docs.ruby-lang.org/ja/latest/class/Regexp.html
|
@@ -56,11 +56,17 @@ module Playwright
|
|
56
56
|
result = []
|
57
57
|
value.each { |v| result << serialize_value(v) }
|
58
58
|
{ a: result, id: id }
|
59
|
+
when Set
|
60
|
+
{ se: serialize_value(value.to_a) }
|
59
61
|
when Hash
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
if value.any? { |k, v| !k.is_a?(String) && !k.is_a?(Symbol) } # Map
|
63
|
+
{ m: serialize_value(value.to_a) }
|
64
|
+
else
|
65
|
+
id = @visited.log(value)
|
66
|
+
result = []
|
67
|
+
value.each { |key, v| result << { k: key, v: serialize_value(v) } }
|
68
|
+
{ o: result, id: id }
|
69
|
+
end
|
64
70
|
else
|
65
71
|
raise ArgumentError.new("Unexpected value: #{value}")
|
66
72
|
end
|
@@ -446,6 +446,10 @@ module Playwright
|
|
446
446
|
@frame.type(@selector, text, strict: true, delay: delay, noWaitAfter: noWaitAfter, timeout: timeout)
|
447
447
|
end
|
448
448
|
|
449
|
+
def press_sequentially(text, delay: nil, noWaitAfter: nil, timeout: nil)
|
450
|
+
type(text, delay: delay, noWaitAfter: noWaitAfter, timeout: timeout)
|
451
|
+
end
|
452
|
+
|
449
453
|
def uncheck(
|
450
454
|
force: nil,
|
451
455
|
noWaitAfter: nil,
|
data/lib/playwright/utils.rb
CHANGED
data/lib/playwright/version.rb
CHANGED
@@ -4,9 +4,9 @@ module Playwright
|
|
4
4
|
# A Browser is created via [`method: BrowserType.launch`]. An example of using a `Browser` to create a `Page`:
|
5
5
|
#
|
6
6
|
# ```python sync
|
7
|
-
# from playwright.sync_api import sync_playwright
|
7
|
+
# from playwright.sync_api import sync_playwright, Playwright
|
8
8
|
#
|
9
|
-
# def run(playwright):
|
9
|
+
# def run(playwright: Playwright):
|
10
10
|
# firefox = playwright.firefox
|
11
11
|
# browser = firefox.launch()
|
12
12
|
# page = browser.new_page()
|
@@ -131,9 +131,9 @@ module Playwright
|
|
131
131
|
# An example of exposing page URL to all frames in all pages in the context:
|
132
132
|
#
|
133
133
|
# ```python sync
|
134
|
-
# from playwright.sync_api import sync_playwright
|
134
|
+
# from playwright.sync_api import sync_playwright, Playwright
|
135
135
|
#
|
136
|
-
# def run(playwright):
|
136
|
+
# def run(playwright: Playwright):
|
137
137
|
# webkit = playwright.webkit
|
138
138
|
# browser = webkit.launch(headless=false)
|
139
139
|
# context = browser.new_context()
|
@@ -190,13 +190,13 @@ module Playwright
|
|
190
190
|
# import hashlib
|
191
191
|
# from playwright.sync_api import sync_playwright
|
192
192
|
#
|
193
|
-
# def sha256(text):
|
193
|
+
# def sha256(text: str) -> str:
|
194
194
|
# m = hashlib.sha256()
|
195
195
|
# m.update(bytes(text, "utf8"))
|
196
196
|
# return m.hexdigest()
|
197
197
|
#
|
198
198
|
#
|
199
|
-
# def run(playwright):
|
199
|
+
# def run(playwright: Playwright):
|
200
200
|
# webkit = playwright.webkit
|
201
201
|
# browser = webkit.launch(headless=False)
|
202
202
|
# context = browser.new_context()
|
@@ -4,9 +4,9 @@ module Playwright
|
|
4
4
|
# typical example of using Playwright to drive automation:
|
5
5
|
#
|
6
6
|
# ```python sync
|
7
|
-
# from playwright.sync_api import sync_playwright
|
7
|
+
# from playwright.sync_api import sync_playwright, Playwright
|
8
8
|
#
|
9
|
-
# def run(playwright):
|
9
|
+
# def run(playwright: Playwright):
|
10
10
|
# chromium = playwright.chromium
|
11
11
|
# browser = chromium.launch()
|
12
12
|
# page = browser.new_page()
|
@@ -52,27 +52,5 @@ module Playwright
|
|
52
52
|
def type
|
53
53
|
wrap_impl(@impl.type)
|
54
54
|
end
|
55
|
-
|
56
|
-
# -- inherited from EventEmitter --
|
57
|
-
# @nodoc
|
58
|
-
def off(event, callback)
|
59
|
-
event_emitter_proxy.off(event, callback)
|
60
|
-
end
|
61
|
-
|
62
|
-
# -- inherited from EventEmitter --
|
63
|
-
# @nodoc
|
64
|
-
def once(event, callback)
|
65
|
-
event_emitter_proxy.once(event, callback)
|
66
|
-
end
|
67
|
-
|
68
|
-
# -- inherited from EventEmitter --
|
69
|
-
# @nodoc
|
70
|
-
def on(event, callback)
|
71
|
-
event_emitter_proxy.on(event, callback)
|
72
|
-
end
|
73
|
-
|
74
|
-
private def event_emitter_proxy
|
75
|
-
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
76
|
-
end
|
77
55
|
end
|
78
56
|
end
|
@@ -5,13 +5,13 @@ module Playwright
|
|
5
5
|
# An example of using `Dialog` class:
|
6
6
|
#
|
7
7
|
# ```python sync
|
8
|
-
# from playwright.sync_api import sync_playwright
|
8
|
+
# from playwright.sync_api import sync_playwright, Playwright
|
9
9
|
#
|
10
10
|
# def handle_dialog(dialog):
|
11
11
|
# print(dialog.message)
|
12
12
|
# dialog.dismiss()
|
13
13
|
#
|
14
|
-
# def run(playwright):
|
14
|
+
# def run(playwright: Playwright):
|
15
15
|
# chromium = playwright.chromium
|
16
16
|
# browser = chromium.launch()
|
17
17
|
# page = browser.new_page()
|
@@ -5,14 +5,17 @@ module Playwright
|
|
5
5
|
# All the downloaded files belonging to the browser context are deleted when the
|
6
6
|
# browser context is closed.
|
7
7
|
#
|
8
|
-
# Download event is emitted once the download starts. Download path becomes available once download completes
|
8
|
+
# Download event is emitted once the download starts. Download path becomes available once download completes.
|
9
9
|
#
|
10
10
|
# ```python sync
|
11
|
+
# # Start waiting for the download
|
11
12
|
# with page.expect_download() as download_info:
|
13
|
+
# # Perform the action that initiates download
|
12
14
|
# page.get_by_text("Download file").click()
|
13
15
|
# download = download_info.value
|
14
|
-
#
|
15
|
-
#
|
16
|
+
#
|
17
|
+
# # Wait for the download process to complete and save the downloaded file somewhere
|
18
|
+
# download.save_as("/path/to/save/at/" + download.suggested_filename)
|
16
19
|
# ```
|
17
20
|
class Download < PlaywrightApi
|
18
21
|
|
@@ -54,6 +57,12 @@ module Playwright
|
|
54
57
|
#
|
55
58
|
# Copy the download to a user-specified path. It is safe to call this method while the download
|
56
59
|
# is still in progress. Will wait for the download to finish if necessary.
|
60
|
+
#
|
61
|
+
# **Usage**
|
62
|
+
#
|
63
|
+
# ```python sync
|
64
|
+
# download.save_as("/path/to/save/at/" + download.suggested_filename)
|
65
|
+
# ```
|
57
66
|
def save_as(path)
|
58
67
|
wrap_impl(@impl.save_as(unwrap_impl(path)))
|
59
68
|
end
|
@@ -224,7 +224,7 @@ module Playwright
|
|
224
224
|
#
|
225
225
|
# If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled instead.
|
226
226
|
#
|
227
|
-
# To send fine-grained keyboard events, use [`method:
|
227
|
+
# To send fine-grained keyboard events, use [`method: Locator.pressSequentially`].
|
228
228
|
def fill(value, force: nil, noWaitAfter: nil, timeout: nil)
|
229
229
|
wrap_impl(@impl.fill(unwrap_impl(value), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
230
230
|
end
|
@@ -407,7 +407,7 @@ module Playwright
|
|
407
407
|
# **Usage**
|
408
408
|
#
|
409
409
|
# ```python sync
|
410
|
-
# #
|
410
|
+
# # Single selection matching the value or label
|
411
411
|
# handle.select_option("blue")
|
412
412
|
# # single selection matching both the label
|
413
413
|
# handle.select_option(label="blue")
|
@@ -503,19 +503,6 @@ module Playwright
|
|
503
503
|
# To press a special key, like `Control` or `ArrowDown`, use [`method: ElementHandle.press`].
|
504
504
|
#
|
505
505
|
# **Usage**
|
506
|
-
#
|
507
|
-
# ```python sync
|
508
|
-
# element_handle.type("hello") # types instantly
|
509
|
-
# element_handle.type("world", delay=100) # types slower, like a user
|
510
|
-
# ```
|
511
|
-
#
|
512
|
-
# An example of typing into a text field and then submitting the form:
|
513
|
-
#
|
514
|
-
# ```python sync
|
515
|
-
# element_handle = page.query_selector("input")
|
516
|
-
# element_handle.type("some text")
|
517
|
-
# element_handle.press("Enter")
|
518
|
-
# ```
|
519
506
|
def type(text, delay: nil, noWaitAfter: nil, timeout: nil)
|
520
507
|
wrap_impl(@impl.type(unwrap_impl(text), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
521
508
|
end
|
data/lib/playwright_api/frame.rb
CHANGED
@@ -11,9 +11,9 @@ module Playwright
|
|
11
11
|
# An example of dumping frame tree:
|
12
12
|
#
|
13
13
|
# ```python sync
|
14
|
-
# from playwright.sync_api import sync_playwright
|
14
|
+
# from playwright.sync_api import sync_playwright, Playwright
|
15
15
|
#
|
16
|
-
# def run(playwright):
|
16
|
+
# def run(playwright: Playwright):
|
17
17
|
# firefox = playwright.firefox
|
18
18
|
# browser = firefox.launch()
|
19
19
|
# page = browser.new_page()
|
@@ -300,7 +300,7 @@ module Playwright
|
|
300
300
|
#
|
301
301
|
# If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled instead.
|
302
302
|
#
|
303
|
-
# To send fine-grained keyboard events, use [`method:
|
303
|
+
# To send fine-grained keyboard events, use [`method: Locator.pressSequentially`].
|
304
304
|
def fill(
|
305
305
|
selector,
|
306
306
|
value,
|
@@ -757,7 +757,7 @@ module Playwright
|
|
757
757
|
# **Usage**
|
758
758
|
#
|
759
759
|
# ```python sync
|
760
|
-
# #
|
760
|
+
# # Single selection matching the value or label
|
761
761
|
# frame.select_option("select#colors", "blue")
|
762
762
|
# # single selection matching both the label
|
763
763
|
# frame.select_option("select#colors", label="blue")
|
@@ -867,11 +867,6 @@ module Playwright
|
|
867
867
|
# To press a special key, like `Control` or `ArrowDown`, use [`method: Keyboard.press`].
|
868
868
|
#
|
869
869
|
# **Usage**
|
870
|
-
#
|
871
|
-
# ```python sync
|
872
|
-
# frame.type("#mytextarea", "hello") # types instantly
|
873
|
-
# frame.type("#mytextarea", "world", delay=100) # types slower, like a user
|
874
|
-
# ```
|
875
870
|
def type(
|
876
871
|
selector,
|
877
872
|
text,
|
@@ -919,9 +914,9 @@ module Playwright
|
|
919
914
|
# The [`method: Frame.waitForFunction`] can be used to observe viewport size change:
|
920
915
|
#
|
921
916
|
# ```python sync
|
922
|
-
# from playwright.sync_api import sync_playwright
|
917
|
+
# from playwright.sync_api import sync_playwright, Playwright
|
923
918
|
#
|
924
|
-
# def run(playwright):
|
919
|
+
# def run(playwright: Playwright):
|
925
920
|
# webkit = playwright.webkit
|
926
921
|
# browser = webkit.launch()
|
927
922
|
# page = browser.new_page()
|
@@ -998,9 +993,9 @@ module Playwright
|
|
998
993
|
# This method works across navigations:
|
999
994
|
#
|
1000
995
|
# ```python sync
|
1001
|
-
# from playwright.sync_api import sync_playwright
|
996
|
+
# from playwright.sync_api import sync_playwright, Playwright
|
1002
997
|
#
|
1003
|
-
# def run(playwright):
|
998
|
+
# def run(playwright: Playwright):
|
1004
999
|
# chromium = playwright.chromium
|
1005
1000
|
# browser = chromium.launch()
|
1006
1001
|
# page = browser.new_page()
|
@@ -81,6 +81,8 @@ module Playwright
|
|
81
81
|
wrap_impl(@impl.insert_text(unwrap_impl(text)))
|
82
82
|
end
|
83
83
|
|
84
|
+
#
|
85
|
+
# **NOTE**: In most cases, you should use [`method: Locator.press`] instead.
|
84
86
|
#
|
85
87
|
# `key` can specify the intended
|
86
88
|
# [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
|
@@ -119,6 +121,8 @@ module Playwright
|
|
119
121
|
wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay)))
|
120
122
|
end
|
121
123
|
|
124
|
+
#
|
125
|
+
# **NOTE**: In most cases, you should use [`method: Locator.fill`] instead. You only need to press keys one by one if there is special keyboard handling on the page - in this case use [`method: Locator.pressSequentially`].
|
122
126
|
#
|
123
127
|
# Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
|
124
128
|
#
|
@@ -28,6 +28,8 @@ module Playwright
|
|
28
28
|
#
|
29
29
|
# Returns an array of `node.innerText` values for all matching nodes.
|
30
30
|
#
|
31
|
+
# **NOTE**: If you need to assert text on the page, prefer [`method: LocatorAssertions.toHaveText`] with `useInnerText` option to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.
|
32
|
+
#
|
31
33
|
# **Usage**
|
32
34
|
#
|
33
35
|
# ```python sync
|
@@ -40,6 +42,8 @@ module Playwright
|
|
40
42
|
#
|
41
43
|
# Returns an array of `node.textContent` values for all matching nodes.
|
42
44
|
#
|
45
|
+
# **NOTE**: If you need to assert text on the page, prefer [`method: LocatorAssertions.toHaveText`] to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.
|
46
|
+
#
|
43
47
|
# **Usage**
|
44
48
|
#
|
45
49
|
# ```python sync
|
@@ -192,6 +196,8 @@ module Playwright
|
|
192
196
|
#
|
193
197
|
# Returns the number of elements matching the locator.
|
194
198
|
#
|
199
|
+
# **NOTE**: If you need to assert the number of elements on the page, prefer [`method: LocatorAssertions.toHaveCount`] to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.
|
200
|
+
#
|
195
201
|
# **Usage**
|
196
202
|
#
|
197
203
|
# ```python sync
|
@@ -391,7 +397,7 @@ module Playwright
|
|
391
397
|
#
|
392
398
|
# If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled instead.
|
393
399
|
#
|
394
|
-
# To send fine-grained keyboard events, use [`method: Locator.
|
400
|
+
# To send fine-grained keyboard events, use [`method: Locator.pressSequentially`].
|
395
401
|
def fill(value, force: nil, noWaitAfter: nil, timeout: nil)
|
396
402
|
wrap_impl(@impl.fill(unwrap_impl(value), force: unwrap_impl(force), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
397
403
|
end
|
@@ -441,6 +447,8 @@ module Playwright
|
|
441
447
|
|
442
448
|
#
|
443
449
|
# Returns the matching element's attribute value.
|
450
|
+
#
|
451
|
+
# **NOTE**: If you need to assert an element's attribute, prefer [`method: LocatorAssertions.toHaveAttribute`] to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.
|
444
452
|
def get_attribute(name, timeout: nil)
|
445
453
|
wrap_impl(@impl.get_attribute(unwrap_impl(name), timeout: unwrap_impl(timeout)))
|
446
454
|
end
|
@@ -681,6 +689,8 @@ module Playwright
|
|
681
689
|
|
682
690
|
#
|
683
691
|
# Returns the [`element.innerText`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText).
|
692
|
+
#
|
693
|
+
# **NOTE**: If you need to assert text on the page, prefer [`method: LocatorAssertions.toHaveText`] with `useInnerText` option to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.
|
684
694
|
def inner_text(timeout: nil)
|
685
695
|
wrap_impl(@impl.inner_text(timeout: unwrap_impl(timeout)))
|
686
696
|
end
|
@@ -688,6 +698,8 @@ module Playwright
|
|
688
698
|
#
|
689
699
|
# Returns the value for the matching `<input>` or `<textarea>` or `<select>` element.
|
690
700
|
#
|
701
|
+
# **NOTE**: If you need to assert input value, prefer [`method: LocatorAssertions.toHaveValue`] to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.
|
702
|
+
#
|
691
703
|
# **Usage**
|
692
704
|
#
|
693
705
|
# ```python sync
|
@@ -704,6 +716,8 @@ module Playwright
|
|
704
716
|
#
|
705
717
|
# Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
|
706
718
|
#
|
719
|
+
# **NOTE**: If you need to assert that checkbox is checked, prefer [`method: LocatorAssertions.toBeChecked`] to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.
|
720
|
+
#
|
707
721
|
# **Usage**
|
708
722
|
#
|
709
723
|
# ```python sync
|
@@ -716,6 +730,8 @@ module Playwright
|
|
716
730
|
#
|
717
731
|
# Returns whether the element is disabled, the opposite of [enabled](../actionability.md#enabled).
|
718
732
|
#
|
733
|
+
# **NOTE**: If you need to assert that an element is disabled, prefer [`method: LocatorAssertions.toBeDisabled`] to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.
|
734
|
+
#
|
719
735
|
# **Usage**
|
720
736
|
#
|
721
737
|
# ```python sync
|
@@ -728,6 +744,8 @@ module Playwright
|
|
728
744
|
#
|
729
745
|
# Returns whether the element is [editable](../actionability.md#editable).
|
730
746
|
#
|
747
|
+
# **NOTE**: If you need to assert that an element is editable, prefer [`method: LocatorAssertions.toBeEditable`] to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.
|
748
|
+
#
|
731
749
|
# **Usage**
|
732
750
|
#
|
733
751
|
# ```python sync
|
@@ -740,6 +758,8 @@ module Playwright
|
|
740
758
|
#
|
741
759
|
# Returns whether the element is [enabled](../actionability.md#enabled).
|
742
760
|
#
|
761
|
+
# **NOTE**: If you need to assert that an element is enabled, prefer [`method: LocatorAssertions.toBeEnabled`] to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.
|
762
|
+
#
|
743
763
|
# **Usage**
|
744
764
|
#
|
745
765
|
# ```python sync
|
@@ -752,6 +772,8 @@ module Playwright
|
|
752
772
|
#
|
753
773
|
# Returns whether the element is hidden, the opposite of [visible](../actionability.md#visible).
|
754
774
|
#
|
775
|
+
# **NOTE**: If you need to assert that element is hidden, prefer [`method: LocatorAssertions.toBeHidden`] to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.
|
776
|
+
#
|
755
777
|
# **Usage**
|
756
778
|
#
|
757
779
|
# ```python sync
|
@@ -764,6 +786,8 @@ module Playwright
|
|
764
786
|
#
|
765
787
|
# Returns whether the element is [visible](../actionability.md#visible).
|
766
788
|
#
|
789
|
+
# **NOTE**: If you need to assert that element is visible, prefer [`method: LocatorAssertions.toBeVisible`] to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.
|
790
|
+
#
|
767
791
|
# **Usage**
|
768
792
|
#
|
769
793
|
# ```python sync
|
@@ -869,6 +893,31 @@ module Playwright
|
|
869
893
|
wrap_impl(@impl.press(unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
870
894
|
end
|
871
895
|
|
896
|
+
#
|
897
|
+
# **NOTE**: In most cases, you should use [`method: Locator.fill`] instead. You only need to press keys one by one if there is special keyboard handling on the page.
|
898
|
+
#
|
899
|
+
# Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
|
900
|
+
#
|
901
|
+
# To press a special key, like `Control` or `ArrowDown`, use [`method: Locator.press`].
|
902
|
+
#
|
903
|
+
# **Usage**
|
904
|
+
#
|
905
|
+
# ```python sync
|
906
|
+
# locator.press_sequentially("hello") # types instantly
|
907
|
+
# locator.press_sequentially("world", delay=100) # types slower, like a user
|
908
|
+
# ```
|
909
|
+
#
|
910
|
+
# An example of typing into a text field and then submitting the form:
|
911
|
+
#
|
912
|
+
# ```python sync
|
913
|
+
# locator = page.get_by_label("Password")
|
914
|
+
# locator.press_sequentially("my password")
|
915
|
+
# locator.press("Enter")
|
916
|
+
# ```
|
917
|
+
def press_sequentially(text, delay: nil, noWaitAfter: nil, timeout: nil)
|
918
|
+
wrap_impl(@impl.press_sequentially(unwrap_impl(text), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
919
|
+
end
|
920
|
+
|
872
921
|
#
|
873
922
|
# Take a screenshot of the element matching the locator.
|
874
923
|
#
|
@@ -1062,31 +1111,18 @@ module Playwright
|
|
1062
1111
|
|
1063
1112
|
#
|
1064
1113
|
# Returns the [`node.textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent).
|
1114
|
+
#
|
1115
|
+
# **NOTE**: If you need to assert text on the page, prefer [`method: LocatorAssertions.toHaveText`] to avoid flakiness. See [assertions guide](../test-assertions.md) for more details.
|
1065
1116
|
def text_content(timeout: nil)
|
1066
1117
|
wrap_impl(@impl.text_content(timeout: unwrap_impl(timeout)))
|
1067
1118
|
end
|
1068
1119
|
|
1069
|
-
#
|
1070
|
-
# **NOTE**: In most cases, you should use [`method: Locator.fill`] instead. You only need to type characters if there is special keyboard handling on the page.
|
1071
1120
|
#
|
1072
1121
|
# Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
|
1073
1122
|
#
|
1074
1123
|
# To press a special key, like `Control` or `ArrowDown`, use [`method: Locator.press`].
|
1075
1124
|
#
|
1076
1125
|
# **Usage**
|
1077
|
-
#
|
1078
|
-
# ```python sync
|
1079
|
-
# element.type("hello") # types instantly
|
1080
|
-
# element.type("world", delay=100) # types slower, like a user
|
1081
|
-
# ```
|
1082
|
-
#
|
1083
|
-
# An example of typing into a text field and then submitting the form:
|
1084
|
-
#
|
1085
|
-
# ```python sync
|
1086
|
-
# element = page.get_by_label("Password")
|
1087
|
-
# element.type("my password")
|
1088
|
-
# element.press("Enter")
|
1089
|
-
# ```
|
1090
1126
|
def type(text, delay: nil, noWaitAfter: nil, timeout: nil)
|
1091
1127
|
wrap_impl(@impl.type(unwrap_impl(text), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), timeout: unwrap_impl(timeout)))
|
1092
1128
|
end
|