playwright-ruby-client 1.38.0 → 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/documentation/docs/api/locator_assertions.md +684 -0
- 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 +2 -2
- data/lib/playwright_api/locator.rb +5 -0
- data/lib/playwright_api/locator_assertions.rb +538 -0
- data/sig/playwright.rbs +43 -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/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.38.
|
4
|
+
version: 1.38.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
|
@@ -401,5 +405,5 @@ requirements: []
|
|
401
405
|
rubygems_version: 3.3.26
|
402
406
|
signing_key:
|
403
407
|
specification_version: 4
|
404
|
-
summary: The Ruby binding of playwright driver 1.38.
|
408
|
+
summary: The Ruby binding of playwright driver 1.38.1
|
405
409
|
test_files: []
|