playwright-ruby-client 1.37.1 → 1.38.1
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/download.md +17 -7
- data/documentation/docs/api/element_handle.md +1 -14
- data/documentation/docs/api/frame.md +1 -6
- data/documentation/docs/api/keyboard.md +4 -0
- data/documentation/docs/api/locator.md +31 -16
- data/documentation/docs/api/locator_assertions.md +684 -0
- data/documentation/docs/api/page.md +1 -6
- data/documentation/docs/api/request.md +17 -0
- data/documentation/docs/include/api_coverage.md +44 -0
- data/lib/playwright/channel.rb +1 -1
- data/lib/playwright/channel_owners/browser_context.rb +15 -0
- data/lib/playwright/channel_owners/page.rb +2 -0
- data/lib/playwright/channel_owners/request.rb +17 -1
- data/lib/playwright/channel_owners/route.rb +5 -1
- data/lib/playwright/errors.rb +15 -2
- data/lib/playwright/events.rb +1 -0
- data/lib/playwright/javascript/value_parser.rb +8 -0
- data/lib/playwright/javascript/value_serializer.rb +11 -5
- data/lib/playwright/locator_assertions_impl.rb +417 -0
- data/lib/playwright/locator_impl.rb +28 -5
- data/lib/playwright/test.rb +68 -0
- data/lib/playwright/utils.rb +4 -0
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright_api/download.rb +12 -3
- data/lib/playwright_api/element_handle.rb +1 -14
- data/lib/playwright_api/frame.rb +1 -6
- data/lib/playwright_api/keyboard.rb +4 -0
- data/lib/playwright_api/locator.rb +31 -16
- data/lib/playwright_api/locator_assertions.rb +538 -0
- data/lib/playwright_api/page.rb +1 -6
- data/lib/playwright_api/request.rb +17 -0
- data/lib/playwright_api/worker.rb +4 -4
- data/sig/playwright.rbs +44 -0
- metadata +7 -3
@@ -0,0 +1,538 @@
|
|
1
|
+
module Playwright
|
2
|
+
#
|
3
|
+
# The `LocatorAssertions` class provides assertion methods that can be used to make assertions about the `Locator` state in the tests.
|
4
|
+
#
|
5
|
+
# ```python sync
|
6
|
+
# from playwright.sync_api import Page, expect
|
7
|
+
#
|
8
|
+
# def test_status_becomes_submitted(page: Page) -> None:
|
9
|
+
# # ..
|
10
|
+
# page.get_by_role("button").click()
|
11
|
+
# expect(page.locator(".status")).to_have_text("Submitted")
|
12
|
+
# ```
|
13
|
+
class LocatorAssertions < PlaywrightApi
|
14
|
+
|
15
|
+
#
|
16
|
+
# The opposite of [`method: LocatorAssertions.toBeAttached`].
|
17
|
+
def not_to_be_attached(attached: nil, timeout: nil)
|
18
|
+
wrap_impl(@impl.not_to_be_attached(attached: unwrap_impl(attached), timeout: unwrap_impl(timeout)))
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# The opposite of [`method: LocatorAssertions.toBeChecked`].
|
23
|
+
def not_to_be_checked(timeout: nil)
|
24
|
+
wrap_impl(@impl.not_to_be_checked(timeout: unwrap_impl(timeout)))
|
25
|
+
end
|
26
|
+
|
27
|
+
#
|
28
|
+
# The opposite of [`method: LocatorAssertions.toBeDisabled`].
|
29
|
+
def not_to_be_disabled(timeout: nil)
|
30
|
+
wrap_impl(@impl.not_to_be_disabled(timeout: unwrap_impl(timeout)))
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# The opposite of [`method: LocatorAssertions.toBeEditable`].
|
35
|
+
def not_to_be_editable(editable: nil, timeout: nil)
|
36
|
+
wrap_impl(@impl.not_to_be_editable(editable: unwrap_impl(editable), timeout: unwrap_impl(timeout)))
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# The opposite of [`method: LocatorAssertions.toBeEmpty`].
|
41
|
+
def not_to_be_empty(timeout: nil)
|
42
|
+
wrap_impl(@impl.not_to_be_empty(timeout: unwrap_impl(timeout)))
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# The opposite of [`method: LocatorAssertions.toBeEnabled`].
|
47
|
+
def not_to_be_enabled(enabled: nil, timeout: nil)
|
48
|
+
wrap_impl(@impl.not_to_be_enabled(enabled: unwrap_impl(enabled), timeout: unwrap_impl(timeout)))
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# The opposite of [`method: LocatorAssertions.toBeFocused`].
|
53
|
+
def not_to_be_focused(timeout: nil)
|
54
|
+
wrap_impl(@impl.not_to_be_focused(timeout: unwrap_impl(timeout)))
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# The opposite of [`method: LocatorAssertions.toBeHidden`].
|
59
|
+
def not_to_be_hidden(timeout: nil)
|
60
|
+
wrap_impl(@impl.not_to_be_hidden(timeout: unwrap_impl(timeout)))
|
61
|
+
end
|
62
|
+
|
63
|
+
#
|
64
|
+
# The opposite of [`method: LocatorAssertions.toBeInViewport`].
|
65
|
+
def not_to_be_in_viewport(ratio: nil, timeout: nil)
|
66
|
+
wrap_impl(@impl.not_to_be_in_viewport(ratio: unwrap_impl(ratio), timeout: unwrap_impl(timeout)))
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# The opposite of [`method: LocatorAssertions.toBeVisible`].
|
71
|
+
def not_to_be_visible(timeout: nil, visible: nil)
|
72
|
+
wrap_impl(@impl.not_to_be_visible(timeout: unwrap_impl(timeout), visible: unwrap_impl(visible)))
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# The opposite of [`method: LocatorAssertions.toContainText`].
|
77
|
+
def not_to_contain_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
|
78
|
+
wrap_impl(@impl.not_to_contain_text(unwrap_impl(expected), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout), useInnerText: unwrap_impl(useInnerText)))
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# The opposite of [`method: LocatorAssertions.toHaveAttribute`].
|
83
|
+
def not_to_have_attribute(name, value, timeout: nil)
|
84
|
+
wrap_impl(@impl.not_to_have_attribute(unwrap_impl(name), unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
85
|
+
end
|
86
|
+
|
87
|
+
#
|
88
|
+
# The opposite of [`method: LocatorAssertions.toHaveClass`].
|
89
|
+
def not_to_have_class(expected, timeout: nil)
|
90
|
+
wrap_impl(@impl.not_to_have_class(unwrap_impl(expected), timeout: unwrap_impl(timeout)))
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# The opposite of [`method: LocatorAssertions.toHaveCount`].
|
95
|
+
def not_to_have_count(count, timeout: nil)
|
96
|
+
wrap_impl(@impl.not_to_have_count(unwrap_impl(count), timeout: unwrap_impl(timeout)))
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# The opposite of [`method: LocatorAssertions.toHaveCSS`].
|
101
|
+
def not_to_have_css(name, value, timeout: nil)
|
102
|
+
wrap_impl(@impl.not_to_have_css(unwrap_impl(name), unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
103
|
+
end
|
104
|
+
|
105
|
+
#
|
106
|
+
# The opposite of [`method: LocatorAssertions.toHaveId`].
|
107
|
+
def not_to_have_id(id, timeout: nil)
|
108
|
+
wrap_impl(@impl.not_to_have_id(unwrap_impl(id), timeout: unwrap_impl(timeout)))
|
109
|
+
end
|
110
|
+
|
111
|
+
#
|
112
|
+
# The opposite of [`method: LocatorAssertions.toHaveJSProperty`].
|
113
|
+
def not_to_have_js_property(name, value, timeout: nil)
|
114
|
+
wrap_impl(@impl.not_to_have_js_property(unwrap_impl(name), unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
115
|
+
end
|
116
|
+
|
117
|
+
#
|
118
|
+
# The opposite of [`method: LocatorAssertions.toHaveText`].
|
119
|
+
def not_to_have_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
|
120
|
+
wrap_impl(@impl.not_to_have_text(unwrap_impl(expected), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout), useInnerText: unwrap_impl(useInnerText)))
|
121
|
+
end
|
122
|
+
|
123
|
+
#
|
124
|
+
# The opposite of [`method: LocatorAssertions.toHaveValue`].
|
125
|
+
def not_to_have_value(value, timeout: nil)
|
126
|
+
wrap_impl(@impl.not_to_have_value(unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
127
|
+
end
|
128
|
+
|
129
|
+
#
|
130
|
+
# The opposite of [`method: LocatorAssertions.toHaveValues`].
|
131
|
+
def not_to_have_values(values, timeout: nil)
|
132
|
+
wrap_impl(@impl.not_to_have_values(unwrap_impl(values), timeout: unwrap_impl(timeout)))
|
133
|
+
end
|
134
|
+
|
135
|
+
#
|
136
|
+
# Ensures that `Locator` points to an [attached](../actionability.md#attached) DOM node.
|
137
|
+
#
|
138
|
+
# **Usage**
|
139
|
+
#
|
140
|
+
# ```python sync
|
141
|
+
# expect(page.get_by_text("Hidden text")).to_be_attached()
|
142
|
+
# ```
|
143
|
+
def to_be_attached(attached: nil, timeout: nil)
|
144
|
+
wrap_impl(@impl.to_be_attached(attached: unwrap_impl(attached), timeout: unwrap_impl(timeout)))
|
145
|
+
end
|
146
|
+
|
147
|
+
#
|
148
|
+
# Ensures the `Locator` points to a checked input.
|
149
|
+
#
|
150
|
+
# **Usage**
|
151
|
+
#
|
152
|
+
# ```python sync
|
153
|
+
# from playwright.sync_api import expect
|
154
|
+
#
|
155
|
+
# locator = page.get_by_label("Subscribe to newsletter")
|
156
|
+
# expect(locator).to_be_checked()
|
157
|
+
# ```
|
158
|
+
def to_be_checked(checked: nil, timeout: nil)
|
159
|
+
wrap_impl(@impl.to_be_checked(checked: unwrap_impl(checked), timeout: unwrap_impl(timeout)))
|
160
|
+
end
|
161
|
+
|
162
|
+
#
|
163
|
+
# Ensures the `Locator` points to a disabled element. Element is disabled if it has "disabled" attribute
|
164
|
+
# or is disabled via ['aria-disabled'](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled).
|
165
|
+
# Note that only native control elements such as HTML `button`, `input`, `select`, `textarea`, `option`, `optgroup`
|
166
|
+
# can be disabled by setting "disabled" attribute. "disabled" attribute on other elements is ignored
|
167
|
+
# by the browser.
|
168
|
+
#
|
169
|
+
# **Usage**
|
170
|
+
#
|
171
|
+
# ```python sync
|
172
|
+
# from playwright.sync_api import expect
|
173
|
+
#
|
174
|
+
# locator = page.locator("button.submit")
|
175
|
+
# expect(locator).to_be_disabled()
|
176
|
+
# ```
|
177
|
+
def to_be_disabled(timeout: nil)
|
178
|
+
wrap_impl(@impl.to_be_disabled(timeout: unwrap_impl(timeout)))
|
179
|
+
end
|
180
|
+
|
181
|
+
#
|
182
|
+
# Ensures the `Locator` points to an editable element.
|
183
|
+
#
|
184
|
+
# **Usage**
|
185
|
+
#
|
186
|
+
# ```python sync
|
187
|
+
# from playwright.sync_api import expect
|
188
|
+
#
|
189
|
+
# locator = page.get_by_role("textbox")
|
190
|
+
# expect(locator).to_be_editable()
|
191
|
+
# ```
|
192
|
+
def to_be_editable(editable: nil, timeout: nil)
|
193
|
+
wrap_impl(@impl.to_be_editable(editable: unwrap_impl(editable), timeout: unwrap_impl(timeout)))
|
194
|
+
end
|
195
|
+
|
196
|
+
#
|
197
|
+
# Ensures the `Locator` points to an empty editable element or to a DOM node that has no text.
|
198
|
+
#
|
199
|
+
# **Usage**
|
200
|
+
#
|
201
|
+
# ```python sync
|
202
|
+
# from playwright.sync_api import expect
|
203
|
+
#
|
204
|
+
# locator = page.locator("div.warning")
|
205
|
+
# expect(locator).to_be_empty()
|
206
|
+
# ```
|
207
|
+
def to_be_empty(timeout: nil)
|
208
|
+
wrap_impl(@impl.to_be_empty(timeout: unwrap_impl(timeout)))
|
209
|
+
end
|
210
|
+
|
211
|
+
#
|
212
|
+
# Ensures the `Locator` points to an enabled element.
|
213
|
+
#
|
214
|
+
# **Usage**
|
215
|
+
#
|
216
|
+
# ```python sync
|
217
|
+
# from playwright.sync_api import expect
|
218
|
+
#
|
219
|
+
# locator = page.locator("button.submit")
|
220
|
+
# expect(locator).to_be_enabled()
|
221
|
+
# ```
|
222
|
+
def to_be_enabled(enabled: nil, timeout: nil)
|
223
|
+
wrap_impl(@impl.to_be_enabled(enabled: unwrap_impl(enabled), timeout: unwrap_impl(timeout)))
|
224
|
+
end
|
225
|
+
|
226
|
+
#
|
227
|
+
# Ensures the `Locator` points to a focused DOM node.
|
228
|
+
#
|
229
|
+
# **Usage**
|
230
|
+
#
|
231
|
+
# ```python sync
|
232
|
+
# from playwright.sync_api import expect
|
233
|
+
#
|
234
|
+
# locator = page.get_by_role("textbox")
|
235
|
+
# expect(locator).to_be_focused()
|
236
|
+
# ```
|
237
|
+
def to_be_focused(timeout: nil)
|
238
|
+
wrap_impl(@impl.to_be_focused(timeout: unwrap_impl(timeout)))
|
239
|
+
end
|
240
|
+
|
241
|
+
#
|
242
|
+
# Ensures that `Locator` either does not resolve to any DOM node, or resolves to a [non-visible](../actionability.md#visible) one.
|
243
|
+
#
|
244
|
+
# **Usage**
|
245
|
+
#
|
246
|
+
# ```python sync
|
247
|
+
# from playwright.sync_api import expect
|
248
|
+
#
|
249
|
+
# locator = page.locator('.my-element')
|
250
|
+
# expect(locator).to_be_hidden()
|
251
|
+
# ```
|
252
|
+
def to_be_hidden(timeout: nil)
|
253
|
+
wrap_impl(@impl.to_be_hidden(timeout: unwrap_impl(timeout)))
|
254
|
+
end
|
255
|
+
|
256
|
+
#
|
257
|
+
# Ensures the `Locator` points to an element that intersects viewport, according to the [intersection observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).
|
258
|
+
#
|
259
|
+
# **Usage**
|
260
|
+
#
|
261
|
+
# ```python sync
|
262
|
+
# from playwright.sync_api import expect
|
263
|
+
#
|
264
|
+
# locator = page.get_by_role("button")
|
265
|
+
# # Make sure at least some part of element intersects viewport.
|
266
|
+
# expect(locator).to_be_in_viewport()
|
267
|
+
# # Make sure element is fully outside of viewport.
|
268
|
+
# expect(locator).not_to_be_in_viewport()
|
269
|
+
# # Make sure that at least half of the element intersects viewport.
|
270
|
+
# expect(locator).to_be_in_viewport(ratio=0.5)
|
271
|
+
# ```
|
272
|
+
def to_be_in_viewport(ratio: nil, timeout: nil)
|
273
|
+
wrap_impl(@impl.to_be_in_viewport(ratio: unwrap_impl(ratio), timeout: unwrap_impl(timeout)))
|
274
|
+
end
|
275
|
+
|
276
|
+
#
|
277
|
+
# Ensures that `Locator` points to an [attached](../actionability.md#attached) and [visible](../actionability.md#visible) DOM node.
|
278
|
+
#
|
279
|
+
# **Usage**
|
280
|
+
#
|
281
|
+
# ```python sync
|
282
|
+
# expect(page.get_by_text("Welcome")).to_be_visible()
|
283
|
+
# ```
|
284
|
+
def to_be_visible(timeout: nil, visible: nil)
|
285
|
+
wrap_impl(@impl.to_be_visible(timeout: unwrap_impl(timeout), visible: unwrap_impl(visible)))
|
286
|
+
end
|
287
|
+
|
288
|
+
#
|
289
|
+
# Ensures the `Locator` points to an element that contains the given text. You can use regular expressions for the value as well.
|
290
|
+
#
|
291
|
+
# **Usage**
|
292
|
+
#
|
293
|
+
# ```python sync
|
294
|
+
# import re
|
295
|
+
# from playwright.sync_api import expect
|
296
|
+
#
|
297
|
+
# locator = page.locator('.title')
|
298
|
+
# expect(locator).to_contain_text("substring")
|
299
|
+
# expect(locator).to_contain_text(re.compile(r"\d messages"))
|
300
|
+
# ```
|
301
|
+
#
|
302
|
+
# If you pass an array as an expected value, the expectations are:
|
303
|
+
# 1. Locator resolves to a list of elements.
|
304
|
+
# 1. Elements from a **subset** of this list contain text from the expected array, respectively.
|
305
|
+
# 1. The matching subset of elements has the same order as the expected array.
|
306
|
+
# 1. Each text value from the expected array is matched by some element from the list.
|
307
|
+
#
|
308
|
+
# For example, consider the following list:
|
309
|
+
#
|
310
|
+
# ```html
|
311
|
+
# <ul>
|
312
|
+
# <li>Item Text 1</li>
|
313
|
+
# <li>Item Text 2</li>
|
314
|
+
# <li>Item Text 3</li>
|
315
|
+
# </ul>
|
316
|
+
# ```
|
317
|
+
#
|
318
|
+
# Let's see how we can use the assertion:
|
319
|
+
#
|
320
|
+
# ```python sync
|
321
|
+
# from playwright.sync_api import expect
|
322
|
+
#
|
323
|
+
# # ✓ Contains the right items in the right order
|
324
|
+
# expect(page.locator("ul > li")).to_contain_text(["Text 1", "Text 3", "Text 4"])
|
325
|
+
#
|
326
|
+
# # ✖ Wrong order
|
327
|
+
# expect(page.locator("ul > li")).to_contain_text(["Text 3", "Text 2"])
|
328
|
+
#
|
329
|
+
# # ✖ No item contains this text
|
330
|
+
# expect(page.locator("ul > li")).to_contain_text(["Some 33"])
|
331
|
+
#
|
332
|
+
# # ✖ Locator points to the outer list element, not to the list items
|
333
|
+
# expect(page.locator("ul")).to_contain_text(["Text 3"])
|
334
|
+
# ```
|
335
|
+
def to_contain_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
|
336
|
+
wrap_impl(@impl.to_contain_text(unwrap_impl(expected), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout), useInnerText: unwrap_impl(useInnerText)))
|
337
|
+
end
|
338
|
+
|
339
|
+
#
|
340
|
+
# Ensures the `Locator` points to an element with given attribute.
|
341
|
+
#
|
342
|
+
# **Usage**
|
343
|
+
#
|
344
|
+
# ```python sync
|
345
|
+
# from playwright.sync_api import expect
|
346
|
+
#
|
347
|
+
# locator = page.locator("input")
|
348
|
+
# expect(locator).to_have_attribute("type", "text")
|
349
|
+
# ```
|
350
|
+
def to_have_attribute(name, value, timeout: nil)
|
351
|
+
wrap_impl(@impl.to_have_attribute(unwrap_impl(name), unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
352
|
+
end
|
353
|
+
|
354
|
+
#
|
355
|
+
# Ensures the `Locator` points to an element with given CSS classes. This needs to be a full match
|
356
|
+
# or using a relaxed regular expression.
|
357
|
+
#
|
358
|
+
# **Usage**
|
359
|
+
#
|
360
|
+
# ```html
|
361
|
+
# <div class='selected row' id='component'></div>
|
362
|
+
# ```
|
363
|
+
#
|
364
|
+
# ```python sync
|
365
|
+
# from playwright.sync_api import expect
|
366
|
+
#
|
367
|
+
# locator = page.locator("#component")
|
368
|
+
# expect(locator).to_have_class(re.compile(r"selected"))
|
369
|
+
# expect(locator).to_have_class("selected row")
|
370
|
+
# ```
|
371
|
+
#
|
372
|
+
# Note that if array is passed as an expected value, entire lists of elements can be asserted:
|
373
|
+
#
|
374
|
+
# ```python sync
|
375
|
+
# from playwright.sync_api import expect
|
376
|
+
#
|
377
|
+
# locator = page.locator("list > .component")
|
378
|
+
# expect(locator).to_have_class(["component", "component selected", "component"])
|
379
|
+
# ```
|
380
|
+
def to_have_class(expected, timeout: nil)
|
381
|
+
wrap_impl(@impl.to_have_class(unwrap_impl(expected), timeout: unwrap_impl(timeout)))
|
382
|
+
end
|
383
|
+
|
384
|
+
#
|
385
|
+
# Ensures the `Locator` resolves to an exact number of DOM nodes.
|
386
|
+
#
|
387
|
+
# **Usage**
|
388
|
+
#
|
389
|
+
# ```python sync
|
390
|
+
# from playwright.sync_api import expect
|
391
|
+
#
|
392
|
+
# locator = page.locator("list > .component")
|
393
|
+
# expect(locator).to_have_count(3)
|
394
|
+
# ```
|
395
|
+
def to_have_count(count, timeout: nil)
|
396
|
+
wrap_impl(@impl.to_have_count(unwrap_impl(count), timeout: unwrap_impl(timeout)))
|
397
|
+
end
|
398
|
+
|
399
|
+
#
|
400
|
+
# Ensures the `Locator` resolves to an element with the given computed CSS style.
|
401
|
+
#
|
402
|
+
# **Usage**
|
403
|
+
#
|
404
|
+
# ```python sync
|
405
|
+
# from playwright.sync_api import expect
|
406
|
+
#
|
407
|
+
# locator = page.get_by_role("button")
|
408
|
+
# expect(locator).to_have_css("display", "flex")
|
409
|
+
# ```
|
410
|
+
def to_have_css(name, value, timeout: nil)
|
411
|
+
wrap_impl(@impl.to_have_css(unwrap_impl(name), unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
412
|
+
end
|
413
|
+
|
414
|
+
#
|
415
|
+
# Ensures the `Locator` points to an element with the given DOM Node ID.
|
416
|
+
#
|
417
|
+
# **Usage**
|
418
|
+
#
|
419
|
+
# ```python sync
|
420
|
+
# from playwright.sync_api import expect
|
421
|
+
#
|
422
|
+
# locator = page.get_by_role("textbox")
|
423
|
+
# expect(locator).to_have_id("lastname")
|
424
|
+
# ```
|
425
|
+
def to_have_id(id, timeout: nil)
|
426
|
+
wrap_impl(@impl.to_have_id(unwrap_impl(id), timeout: unwrap_impl(timeout)))
|
427
|
+
end
|
428
|
+
|
429
|
+
#
|
430
|
+
# Ensures the `Locator` points to an element with given JavaScript property. Note that this property can be
|
431
|
+
# of a primitive type as well as a plain serializable JavaScript object.
|
432
|
+
#
|
433
|
+
# **Usage**
|
434
|
+
#
|
435
|
+
# ```python sync
|
436
|
+
# from playwright.sync_api import expect
|
437
|
+
#
|
438
|
+
# locator = page.locator(".component")
|
439
|
+
# expect(locator).to_have_js_property("loaded", True)
|
440
|
+
# ```
|
441
|
+
def to_have_js_property(name, value, timeout: nil)
|
442
|
+
wrap_impl(@impl.to_have_js_property(unwrap_impl(name), unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
443
|
+
end
|
444
|
+
|
445
|
+
#
|
446
|
+
# Ensures the `Locator` points to an element with the given text. You can use regular expressions for the value as well.
|
447
|
+
#
|
448
|
+
# **Usage**
|
449
|
+
#
|
450
|
+
# ```python sync
|
451
|
+
# import re
|
452
|
+
# from playwright.sync_api import expect
|
453
|
+
#
|
454
|
+
# locator = page.locator(".title")
|
455
|
+
# expect(locator).to_have_text(re.compile(r"Welcome, Test User"))
|
456
|
+
# expect(locator).to_have_text(re.compile(r"Welcome, .*"))
|
457
|
+
# ```
|
458
|
+
#
|
459
|
+
# If you pass an array as an expected value, the expectations are:
|
460
|
+
# 1. Locator resolves to a list of elements.
|
461
|
+
# 1. The number of elements equals the number of expected values in the array.
|
462
|
+
# 1. Elements from the list have text matching expected array values, one by one, in order.
|
463
|
+
#
|
464
|
+
# For example, consider the following list:
|
465
|
+
#
|
466
|
+
# ```html
|
467
|
+
# <ul>
|
468
|
+
# <li>Text 1</li>
|
469
|
+
# <li>Text 2</li>
|
470
|
+
# <li>Text 3</li>
|
471
|
+
# </ul>
|
472
|
+
# ```
|
473
|
+
#
|
474
|
+
# Let's see how we can use the assertion:
|
475
|
+
#
|
476
|
+
# ```python sync
|
477
|
+
# from playwright.sync_api import expect
|
478
|
+
#
|
479
|
+
# # ✓ Has the right items in the right order
|
480
|
+
# expect(page.locator("ul > li")).to_have_text(["Text 1", "Text 2", "Text 3"])
|
481
|
+
#
|
482
|
+
# # ✖ Wrong order
|
483
|
+
# expect(page.locator("ul > li")).to_have_text(["Text 3", "Text 2", "Text 1"])
|
484
|
+
#
|
485
|
+
# # ✖ Last item does not match
|
486
|
+
# expect(page.locator("ul > li")).to_have_text(["Text 1", "Text 2", "Text"])
|
487
|
+
#
|
488
|
+
# # ✖ Locator points to the outer list element, not to the list items
|
489
|
+
# expect(page.locator("ul")).to_have_text(["Text 1", "Text 2", "Text 3"])
|
490
|
+
# ```
|
491
|
+
def to_have_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
|
492
|
+
wrap_impl(@impl.to_have_text(unwrap_impl(expected), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout), useInnerText: unwrap_impl(useInnerText)))
|
493
|
+
end
|
494
|
+
|
495
|
+
#
|
496
|
+
# Ensures the `Locator` points to an element with the given input value. You can use regular expressions for the value as well.
|
497
|
+
#
|
498
|
+
# **Usage**
|
499
|
+
#
|
500
|
+
# ```python sync
|
501
|
+
# import re
|
502
|
+
# from playwright.sync_api import expect
|
503
|
+
#
|
504
|
+
# locator = page.locator("input[type=number]")
|
505
|
+
# expect(locator).to_have_value(re.compile(r"[0-9]"))
|
506
|
+
# ```
|
507
|
+
def to_have_value(value, timeout: nil)
|
508
|
+
wrap_impl(@impl.to_have_value(unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
509
|
+
end
|
510
|
+
|
511
|
+
#
|
512
|
+
# Ensures the `Locator` points to multi-select/combobox (i.e. a `select` with the `multiple` attribute) and the specified values are selected.
|
513
|
+
#
|
514
|
+
# **Usage**
|
515
|
+
#
|
516
|
+
# For example, given the following element:
|
517
|
+
#
|
518
|
+
# ```html
|
519
|
+
# <select id="favorite-colors" multiple>
|
520
|
+
# <option value="R">Red</option>
|
521
|
+
# <option value="G">Green</option>
|
522
|
+
# <option value="B">Blue</option>
|
523
|
+
# </select>
|
524
|
+
# ```
|
525
|
+
#
|
526
|
+
# ```python sync
|
527
|
+
# import re
|
528
|
+
# from playwright.sync_api import expect
|
529
|
+
#
|
530
|
+
# locator = page.locator("id=favorite-colors")
|
531
|
+
# locator.select_option(["R", "G"])
|
532
|
+
# expect(locator).to_have_values([re.compile(r"R"), re.compile(r"G")])
|
533
|
+
# ```
|
534
|
+
def to_have_values(values, timeout: nil)
|
535
|
+
wrap_impl(@impl.to_have_values(unwrap_impl(values), timeout: unwrap_impl(timeout)))
|
536
|
+
end
|
537
|
+
end
|
538
|
+
end
|
data/lib/playwright_api/page.rb
CHANGED
@@ -532,7 +532,7 @@ module Playwright
|
|
532
532
|
#
|
533
533
|
# 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.
|
534
534
|
#
|
535
|
-
# To send fine-grained keyboard events, use [`method:
|
535
|
+
# To send fine-grained keyboard events, use [`method: Locator.pressSequentially`].
|
536
536
|
def fill(
|
537
537
|
selector,
|
538
538
|
value,
|
@@ -1340,11 +1340,6 @@ module Playwright
|
|
1340
1340
|
# To press a special key, like `Control` or `ArrowDown`, use [`method: Keyboard.press`].
|
1341
1341
|
#
|
1342
1342
|
# **Usage**
|
1343
|
-
#
|
1344
|
-
# ```python sync
|
1345
|
-
# page.type("#mytextarea", "hello") # types instantly
|
1346
|
-
# page.type("#mytextarea", "world", delay=100) # types slower, like a user
|
1347
|
-
# ```
|
1348
1343
|
def type(
|
1349
1344
|
selector,
|
1350
1345
|
text,
|
@@ -37,6 +37,20 @@ module Playwright
|
|
37
37
|
|
38
38
|
#
|
39
39
|
# Returns the `Frame` that initiated this request.
|
40
|
+
#
|
41
|
+
# **Usage**
|
42
|
+
#
|
43
|
+
# ```py
|
44
|
+
# frame_url = request.frame.url
|
45
|
+
# ```
|
46
|
+
#
|
47
|
+
# **Details**
|
48
|
+
#
|
49
|
+
# Note that in some cases the frame is not available, and this method will throw.
|
50
|
+
# - When request originates in the Service Worker. You can use `request.serviceWorker()` to check that.
|
51
|
+
# - When navigation request is issued before the corresponding frame is created. You can use [`method: Request.isNavigationRequest`] to check that.
|
52
|
+
#
|
53
|
+
# Here is an example that handles all the cases:
|
40
54
|
def frame
|
41
55
|
wrap_impl(@impl.frame)
|
42
56
|
end
|
@@ -64,6 +78,9 @@ module Playwright
|
|
64
78
|
|
65
79
|
#
|
66
80
|
# Whether this request is driving frame's navigation.
|
81
|
+
#
|
82
|
+
# Some navigation requests are issued before the corresponding frame is created, and therefore
|
83
|
+
# do not have [`method: Request.frame`] available.
|
67
84
|
def navigation_request?
|
68
85
|
wrap_impl(@impl.navigation_request?)
|
69
86
|
end
|
@@ -47,13 +47,13 @@ module Playwright
|
|
47
47
|
end
|
48
48
|
|
49
49
|
# @nodoc
|
50
|
-
def
|
51
|
-
wrap_impl(@impl.
|
50
|
+
def context=(req)
|
51
|
+
wrap_impl(@impl.context=(unwrap_impl(req)))
|
52
52
|
end
|
53
53
|
|
54
54
|
# @nodoc
|
55
|
-
def
|
56
|
-
wrap_impl(@impl.
|
55
|
+
def page=(req)
|
56
|
+
wrap_impl(@impl.page=(unwrap_impl(req)))
|
57
57
|
end
|
58
58
|
|
59
59
|
# -- inherited from EventEmitter --
|
data/sig/playwright.rbs
CHANGED
@@ -483,6 +483,7 @@ module Playwright
|
|
483
483
|
def or: (Locator locator) -> Locator
|
484
484
|
def page: -> Page
|
485
485
|
def press: (String key, ?delay: Float, ?noWaitAfter: bool, ?timeout: Float) -> void
|
486
|
+
def press_sequentially: (String text, ?delay: Float, ?noWaitAfter: bool, ?timeout: Float) -> void
|
486
487
|
def screenshot: (?animations: ("disabled" | "allow"), ?caret: ("hide" | "initial"), ?mask: Array[untyped], ?maskColor: String, ?omitBackground: bool, ?path: (String | File), ?quality: Integer, ?scale: ("css" | "device"), ?timeout: Float, ?type: ("png" | "jpeg")) -> String
|
487
488
|
def scroll_into_view_if_needed: (?timeout: Float) -> void
|
488
489
|
def select_option: (?element: (ElementHandle | Array[untyped]), ?index: (Integer | Array[untyped]), ?value: (String | Array[untyped]), ?label: (String | Array[untyped]), ?force: bool, ?noWaitAfter: bool, ?timeout: Float) -> Array[untyped]
|
@@ -537,6 +538,49 @@ module Playwright
|
|
537
538
|
def put: (String url, ?data: (String | String | untyped), ?failOnStatusCode: bool, ?form: Hash[untyped, untyped], ?headers: Hash[untyped, untyped], ?ignoreHTTPSErrors: bool, ?maxRedirects: Integer, ?multipart: Hash[untyped, untyped], ?params: Hash[untyped, untyped], ?timeout: Float) -> APIResponse
|
538
539
|
end
|
539
540
|
|
541
|
+
class LocatorAssertions
|
542
|
+
def not_to_be_attached: (?attached: bool, ?timeout: Float) -> void
|
543
|
+
def not_to_be_checked: (?timeout: Float) -> void
|
544
|
+
def not_to_be_disabled: (?timeout: Float) -> void
|
545
|
+
def not_to_be_editable: (?editable: bool, ?timeout: Float) -> void
|
546
|
+
def not_to_be_empty: (?timeout: Float) -> void
|
547
|
+
def not_to_be_enabled: (?enabled: bool, ?timeout: Float) -> void
|
548
|
+
def not_to_be_focused: (?timeout: Float) -> void
|
549
|
+
def not_to_be_hidden: (?timeout: Float) -> void
|
550
|
+
def not_to_be_in_viewport: (?ratio: Float, ?timeout: Float) -> void
|
551
|
+
def not_to_be_visible: (?timeout: Float, ?visible: bool) -> void
|
552
|
+
def not_to_contain_text: ((String | Regexp | Array[untyped] | Array[untyped] | Array[untyped]) expected, ?ignoreCase: bool, ?timeout: Float, ?useInnerText: bool) -> void
|
553
|
+
def not_to_have_attribute: (String name, (String | Regexp) value, ?timeout: Float) -> void
|
554
|
+
def not_to_have_class: ((String | Regexp | Array[untyped] | Array[untyped] | Array[untyped]) expected, ?timeout: Float) -> void
|
555
|
+
def not_to_have_count: (Integer count, ?timeout: Float) -> void
|
556
|
+
def not_to_have_css: (String name, (String | Regexp) value, ?timeout: Float) -> void
|
557
|
+
def not_to_have_id: ((String | Regexp) id, ?timeout: Float) -> void
|
558
|
+
def not_to_have_js_property: (String name, untyped value, ?timeout: Float) -> void
|
559
|
+
def not_to_have_text: ((String | Regexp | Array[untyped] | Array[untyped] | Array[untyped]) expected, ?ignoreCase: bool, ?timeout: Float, ?useInnerText: bool) -> void
|
560
|
+
def not_to_have_value: ((String | Regexp) value, ?timeout: Float) -> void
|
561
|
+
def not_to_have_values: ((Array[untyped] | Array[untyped] | Array[untyped]) values, ?timeout: Float) -> void
|
562
|
+
def to_be_attached: (?attached: bool, ?timeout: Float) -> void
|
563
|
+
def to_be_checked: (?checked: bool, ?timeout: Float) -> void
|
564
|
+
def to_be_disabled: (?timeout: Float) -> void
|
565
|
+
def to_be_editable: (?editable: bool, ?timeout: Float) -> void
|
566
|
+
def to_be_empty: (?timeout: Float) -> void
|
567
|
+
def to_be_enabled: (?enabled: bool, ?timeout: Float) -> void
|
568
|
+
def to_be_focused: (?timeout: Float) -> void
|
569
|
+
def to_be_hidden: (?timeout: Float) -> void
|
570
|
+
def to_be_in_viewport: (?ratio: Float, ?timeout: Float) -> void
|
571
|
+
def to_be_visible: (?timeout: Float, ?visible: bool) -> void
|
572
|
+
def to_contain_text: ((String | Regexp | Array[untyped] | Array[untyped] | Array[untyped]) expected, ?ignoreCase: bool, ?timeout: Float, ?useInnerText: bool) -> void
|
573
|
+
def to_have_attribute: (String name, (String | Regexp) value, ?timeout: Float) -> void
|
574
|
+
def to_have_class: ((String | Regexp | Array[untyped] | Array[untyped] | Array[untyped]) expected, ?timeout: Float) -> void
|
575
|
+
def to_have_count: (Integer count, ?timeout: Float) -> void
|
576
|
+
def to_have_css: (String name, (String | Regexp) value, ?timeout: Float) -> void
|
577
|
+
def to_have_id: ((String | Regexp) id, ?timeout: Float) -> void
|
578
|
+
def to_have_js_property: (String name, untyped value, ?timeout: Float) -> void
|
579
|
+
def to_have_text: ((String | Regexp | Array[untyped] | Array[untyped] | Array[untyped]) expected, ?ignoreCase: bool, ?timeout: Float, ?useInnerText: bool) -> void
|
580
|
+
def to_have_value: ((String | Regexp) value, ?timeout: Float) -> void
|
581
|
+
def to_have_values: ((Array[untyped] | Array[untyped] | Array[untyped]) values, ?timeout: Float) -> void
|
582
|
+
end
|
583
|
+
|
540
584
|
class Android
|
541
585
|
def devices: (?host: String, ?omitDriverInstall: bool, ?port: Integer) -> Array[untyped]
|
542
586
|
end
|