playwright-ruby-client 1.39.0 → 1.39.1
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/browser.md +9 -13
- data/documentation/docs/api/browser_context.md +32 -51
- data/documentation/docs/api/browser_type.md +7 -12
- data/documentation/docs/api/dialog.md +15 -18
- data/documentation/docs/api/download.md +9 -10
- data/documentation/docs/api/element_handle.md +5 -6
- data/documentation/docs/api/frame.md +24 -54
- data/documentation/docs/api/locator.md +20 -22
- data/documentation/docs/api/locator_assertions.md +642 -0
- data/documentation/docs/api/page.md +48 -101
- data/documentation/docs/api/playwright.md +20 -23
- data/documentation/docs/api/selectors.md +29 -34
- data/documentation/docs/include/api_coverage.md +43 -0
- data/lib/playwright/channel.rb +1 -1
- data/lib/playwright/errors.rb +2 -0
- data/lib/playwright/javascript/value_serializer.rb +1 -1
- data/lib/playwright/locator_assertions_impl.rb +417 -0
- data/lib/playwright/locator_impl.rb +24 -5
- data/lib/playwright/test.rb +68 -0
- data/lib/playwright/version.rb +1 -1
- data/lib/playwright_api/locator.rb +5 -0
- data/lib/playwright_api/locator_assertions.rb +551 -0
- data/sig/playwright.rbs +43 -0
- metadata +6 -2
@@ -0,0 +1,551 @@
|
|
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
|
+
# To check that at least one element from the list is visible, use [`method: Locator.first`].
|
280
|
+
#
|
281
|
+
# **Usage**
|
282
|
+
#
|
283
|
+
# ```python sync
|
284
|
+
# # A specific element is visible.
|
285
|
+
# expect(page.get_by_text("Welcome")).to_be_visible()
|
286
|
+
#
|
287
|
+
# # At least one item in the list is visible.
|
288
|
+
# expect(page.get_by_test_id("todo-item").first).to_be_visible()
|
289
|
+
#
|
290
|
+
# # At least one of the two elements is visible, possibly both.
|
291
|
+
# expect(
|
292
|
+
# page.get_by_role("button", name="Sign in")
|
293
|
+
# .or_(page.get_by_role("button", name="Sign up"))
|
294
|
+
# .first
|
295
|
+
# ).to_be_visible()
|
296
|
+
# ```
|
297
|
+
def to_be_visible(timeout: nil, visible: nil)
|
298
|
+
wrap_impl(@impl.to_be_visible(timeout: unwrap_impl(timeout), visible: unwrap_impl(visible)))
|
299
|
+
end
|
300
|
+
|
301
|
+
#
|
302
|
+
# Ensures the `Locator` points to an element that contains the given text. You can use regular expressions for the value as well.
|
303
|
+
#
|
304
|
+
# **Usage**
|
305
|
+
#
|
306
|
+
# ```python sync
|
307
|
+
# import re
|
308
|
+
# from playwright.sync_api import expect
|
309
|
+
#
|
310
|
+
# locator = page.locator('.title')
|
311
|
+
# expect(locator).to_contain_text("substring")
|
312
|
+
# expect(locator).to_contain_text(re.compile(r"\d messages"))
|
313
|
+
# ```
|
314
|
+
#
|
315
|
+
# If you pass an array as an expected value, the expectations are:
|
316
|
+
# 1. Locator resolves to a list of elements.
|
317
|
+
# 1. Elements from a **subset** of this list contain text from the expected array, respectively.
|
318
|
+
# 1. The matching subset of elements has the same order as the expected array.
|
319
|
+
# 1. Each text value from the expected array is matched by some element from the list.
|
320
|
+
#
|
321
|
+
# For example, consider the following list:
|
322
|
+
#
|
323
|
+
# ```html
|
324
|
+
# <ul>
|
325
|
+
# <li>Item Text 1</li>
|
326
|
+
# <li>Item Text 2</li>
|
327
|
+
# <li>Item Text 3</li>
|
328
|
+
# </ul>
|
329
|
+
# ```
|
330
|
+
#
|
331
|
+
# Let's see how we can use the assertion:
|
332
|
+
#
|
333
|
+
# ```python sync
|
334
|
+
# from playwright.sync_api import expect
|
335
|
+
#
|
336
|
+
# # ✓ Contains the right items in the right order
|
337
|
+
# expect(page.locator("ul > li")).to_contain_text(["Text 1", "Text 3", "Text 4"])
|
338
|
+
#
|
339
|
+
# # ✖ Wrong order
|
340
|
+
# expect(page.locator("ul > li")).to_contain_text(["Text 3", "Text 2"])
|
341
|
+
#
|
342
|
+
# # ✖ No item contains this text
|
343
|
+
# expect(page.locator("ul > li")).to_contain_text(["Some 33"])
|
344
|
+
#
|
345
|
+
# # ✖ Locator points to the outer list element, not to the list items
|
346
|
+
# expect(page.locator("ul")).to_contain_text(["Text 3"])
|
347
|
+
# ```
|
348
|
+
def to_contain_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
|
349
|
+
wrap_impl(@impl.to_contain_text(unwrap_impl(expected), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout), useInnerText: unwrap_impl(useInnerText)))
|
350
|
+
end
|
351
|
+
|
352
|
+
#
|
353
|
+
# Ensures the `Locator` points to an element with given attribute.
|
354
|
+
#
|
355
|
+
# **Usage**
|
356
|
+
#
|
357
|
+
# ```python sync
|
358
|
+
# from playwright.sync_api import expect
|
359
|
+
#
|
360
|
+
# locator = page.locator("input")
|
361
|
+
# expect(locator).to_have_attribute("type", "text")
|
362
|
+
# ```
|
363
|
+
def to_have_attribute(name, value, timeout: nil)
|
364
|
+
wrap_impl(@impl.to_have_attribute(unwrap_impl(name), unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
365
|
+
end
|
366
|
+
|
367
|
+
#
|
368
|
+
# Ensures the `Locator` points to an element with given CSS classes. This needs to be a full match
|
369
|
+
# or using a relaxed regular expression.
|
370
|
+
#
|
371
|
+
# **Usage**
|
372
|
+
#
|
373
|
+
# ```html
|
374
|
+
# <div class='selected row' id='component'></div>
|
375
|
+
# ```
|
376
|
+
#
|
377
|
+
# ```python sync
|
378
|
+
# from playwright.sync_api import expect
|
379
|
+
#
|
380
|
+
# locator = page.locator("#component")
|
381
|
+
# expect(locator).to_have_class(re.compile(r"selected"))
|
382
|
+
# expect(locator).to_have_class("selected row")
|
383
|
+
# ```
|
384
|
+
#
|
385
|
+
# Note that if array is passed as an expected value, entire lists of elements can be asserted:
|
386
|
+
#
|
387
|
+
# ```python sync
|
388
|
+
# from playwright.sync_api import expect
|
389
|
+
#
|
390
|
+
# locator = page.locator("list > .component")
|
391
|
+
# expect(locator).to_have_class(["component", "component selected", "component"])
|
392
|
+
# ```
|
393
|
+
def to_have_class(expected, timeout: nil)
|
394
|
+
wrap_impl(@impl.to_have_class(unwrap_impl(expected), timeout: unwrap_impl(timeout)))
|
395
|
+
end
|
396
|
+
|
397
|
+
#
|
398
|
+
# Ensures the `Locator` resolves to an exact number of DOM nodes.
|
399
|
+
#
|
400
|
+
# **Usage**
|
401
|
+
#
|
402
|
+
# ```python sync
|
403
|
+
# from playwright.sync_api import expect
|
404
|
+
#
|
405
|
+
# locator = page.locator("list > .component")
|
406
|
+
# expect(locator).to_have_count(3)
|
407
|
+
# ```
|
408
|
+
def to_have_count(count, timeout: nil)
|
409
|
+
wrap_impl(@impl.to_have_count(unwrap_impl(count), timeout: unwrap_impl(timeout)))
|
410
|
+
end
|
411
|
+
|
412
|
+
#
|
413
|
+
# Ensures the `Locator` resolves to an element with the given computed CSS style.
|
414
|
+
#
|
415
|
+
# **Usage**
|
416
|
+
#
|
417
|
+
# ```python sync
|
418
|
+
# from playwright.sync_api import expect
|
419
|
+
#
|
420
|
+
# locator = page.get_by_role("button")
|
421
|
+
# expect(locator).to_have_css("display", "flex")
|
422
|
+
# ```
|
423
|
+
def to_have_css(name, value, timeout: nil)
|
424
|
+
wrap_impl(@impl.to_have_css(unwrap_impl(name), unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
425
|
+
end
|
426
|
+
|
427
|
+
#
|
428
|
+
# Ensures the `Locator` points to an element with the given DOM Node ID.
|
429
|
+
#
|
430
|
+
# **Usage**
|
431
|
+
#
|
432
|
+
# ```python sync
|
433
|
+
# from playwright.sync_api import expect
|
434
|
+
#
|
435
|
+
# locator = page.get_by_role("textbox")
|
436
|
+
# expect(locator).to_have_id("lastname")
|
437
|
+
# ```
|
438
|
+
def to_have_id(id, timeout: nil)
|
439
|
+
wrap_impl(@impl.to_have_id(unwrap_impl(id), timeout: unwrap_impl(timeout)))
|
440
|
+
end
|
441
|
+
|
442
|
+
#
|
443
|
+
# Ensures the `Locator` points to an element with given JavaScript property. Note that this property can be
|
444
|
+
# of a primitive type as well as a plain serializable JavaScript object.
|
445
|
+
#
|
446
|
+
# **Usage**
|
447
|
+
#
|
448
|
+
# ```python sync
|
449
|
+
# from playwright.sync_api import expect
|
450
|
+
#
|
451
|
+
# locator = page.locator(".component")
|
452
|
+
# expect(locator).to_have_js_property("loaded", True)
|
453
|
+
# ```
|
454
|
+
def to_have_js_property(name, value, timeout: nil)
|
455
|
+
wrap_impl(@impl.to_have_js_property(unwrap_impl(name), unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
456
|
+
end
|
457
|
+
|
458
|
+
#
|
459
|
+
# Ensures the `Locator` points to an element with the given text. You can use regular expressions for the value as well.
|
460
|
+
#
|
461
|
+
# **Usage**
|
462
|
+
#
|
463
|
+
# ```python sync
|
464
|
+
# import re
|
465
|
+
# from playwright.sync_api import expect
|
466
|
+
#
|
467
|
+
# locator = page.locator(".title")
|
468
|
+
# expect(locator).to_have_text(re.compile(r"Welcome, Test User"))
|
469
|
+
# expect(locator).to_have_text(re.compile(r"Welcome, .*"))
|
470
|
+
# ```
|
471
|
+
#
|
472
|
+
# If you pass an array as an expected value, the expectations are:
|
473
|
+
# 1. Locator resolves to a list of elements.
|
474
|
+
# 1. The number of elements equals the number of expected values in the array.
|
475
|
+
# 1. Elements from the list have text matching expected array values, one by one, in order.
|
476
|
+
#
|
477
|
+
# For example, consider the following list:
|
478
|
+
#
|
479
|
+
# ```html
|
480
|
+
# <ul>
|
481
|
+
# <li>Text 1</li>
|
482
|
+
# <li>Text 2</li>
|
483
|
+
# <li>Text 3</li>
|
484
|
+
# </ul>
|
485
|
+
# ```
|
486
|
+
#
|
487
|
+
# Let's see how we can use the assertion:
|
488
|
+
#
|
489
|
+
# ```python sync
|
490
|
+
# from playwright.sync_api import expect
|
491
|
+
#
|
492
|
+
# # ✓ Has the right items in the right order
|
493
|
+
# expect(page.locator("ul > li")).to_have_text(["Text 1", "Text 2", "Text 3"])
|
494
|
+
#
|
495
|
+
# # ✖ Wrong order
|
496
|
+
# expect(page.locator("ul > li")).to_have_text(["Text 3", "Text 2", "Text 1"])
|
497
|
+
#
|
498
|
+
# # ✖ Last item does not match
|
499
|
+
# expect(page.locator("ul > li")).to_have_text(["Text 1", "Text 2", "Text"])
|
500
|
+
#
|
501
|
+
# # ✖ Locator points to the outer list element, not to the list items
|
502
|
+
# expect(page.locator("ul")).to_have_text(["Text 1", "Text 2", "Text 3"])
|
503
|
+
# ```
|
504
|
+
def to_have_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
|
505
|
+
wrap_impl(@impl.to_have_text(unwrap_impl(expected), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout), useInnerText: unwrap_impl(useInnerText)))
|
506
|
+
end
|
507
|
+
|
508
|
+
#
|
509
|
+
# Ensures the `Locator` points to an element with the given input value. You can use regular expressions for the value as well.
|
510
|
+
#
|
511
|
+
# **Usage**
|
512
|
+
#
|
513
|
+
# ```python sync
|
514
|
+
# import re
|
515
|
+
# from playwright.sync_api import expect
|
516
|
+
#
|
517
|
+
# locator = page.locator("input[type=number]")
|
518
|
+
# expect(locator).to_have_value(re.compile(r"[0-9]"))
|
519
|
+
# ```
|
520
|
+
def to_have_value(value, timeout: nil)
|
521
|
+
wrap_impl(@impl.to_have_value(unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
522
|
+
end
|
523
|
+
|
524
|
+
#
|
525
|
+
# Ensures the `Locator` points to multi-select/combobox (i.e. a `select` with the `multiple` attribute) and the specified values are selected.
|
526
|
+
#
|
527
|
+
# **Usage**
|
528
|
+
#
|
529
|
+
# For example, given the following element:
|
530
|
+
#
|
531
|
+
# ```html
|
532
|
+
# <select id="favorite-colors" multiple>
|
533
|
+
# <option value="R">Red</option>
|
534
|
+
# <option value="G">Green</option>
|
535
|
+
# <option value="B">Blue</option>
|
536
|
+
# </select>
|
537
|
+
# ```
|
538
|
+
#
|
539
|
+
# ```python sync
|
540
|
+
# import re
|
541
|
+
# from playwright.sync_api import expect
|
542
|
+
#
|
543
|
+
# locator = page.locator("id=favorite-colors")
|
544
|
+
# locator.select_option(["R", "G"])
|
545
|
+
# expect(locator).to_have_values([re.compile(r"R"), re.compile(r"G")])
|
546
|
+
# ```
|
547
|
+
def to_have_values(values, timeout: nil)
|
548
|
+
wrap_impl(@impl.to_have_values(unwrap_impl(values), timeout: unwrap_impl(timeout)))
|
549
|
+
end
|
550
|
+
end
|
551
|
+
end
|
data/sig/playwright.rbs
CHANGED
@@ -538,6 +538,49 @@ module Playwright
|
|
538
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
|
539
539
|
end
|
540
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
|
+
|
541
584
|
class Android
|
542
585
|
def devices: (?host: String, ?omitDriverInstall: bool, ?port: Integer) -> Array[untyped]
|
543
586
|
end
|
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.39.
|
4
|
+
version: 1.39.1
|
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-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -233,6 +233,7 @@ files:
|
|
233
233
|
- documentation/docs/api/js_handle.md
|
234
234
|
- documentation/docs/api/keyboard.md
|
235
235
|
- documentation/docs/api/locator.md
|
236
|
+
- documentation/docs/api/locator_assertions.md
|
236
237
|
- documentation/docs/api/mouse.md
|
237
238
|
- documentation/docs/api/page.md
|
238
239
|
- documentation/docs/api/playwright.md
|
@@ -326,6 +327,7 @@ files:
|
|
326
327
|
- lib/playwright/javascript/value_serializer.rb
|
327
328
|
- lib/playwright/javascript/visitor_info.rb
|
328
329
|
- lib/playwright/keyboard_impl.rb
|
330
|
+
- lib/playwright/locator_assertions_impl.rb
|
329
331
|
- lib/playwright/locator_impl.rb
|
330
332
|
- lib/playwright/locator_utils.rb
|
331
333
|
- lib/playwright/mouse_impl.rb
|
@@ -333,6 +335,7 @@ files:
|
|
333
335
|
- lib/playwright/raw_headers.rb
|
334
336
|
- lib/playwright/route_handler.rb
|
335
337
|
- lib/playwright/select_option_values.rb
|
338
|
+
- lib/playwright/test.rb
|
336
339
|
- lib/playwright/timeout_settings.rb
|
337
340
|
- lib/playwright/touchscreen_impl.rb
|
338
341
|
- lib/playwright/transport.rb
|
@@ -366,6 +369,7 @@ files:
|
|
366
369
|
- lib/playwright_api/js_handle.rb
|
367
370
|
- lib/playwright_api/keyboard.rb
|
368
371
|
- lib/playwright_api/locator.rb
|
372
|
+
- lib/playwright_api/locator_assertions.rb
|
369
373
|
- lib/playwright_api/mouse.rb
|
370
374
|
- lib/playwright_api/page.rb
|
371
375
|
- lib/playwright_api/playwright.rb
|