playwright-ruby-client 1.39.0 → 1.40.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/documentation/docs/api/api_request_context.md +1 -2
- data/documentation/docs/api/browser.md +10 -14
- data/documentation/docs/api/browser_context.md +32 -51
- data/documentation/docs/api/browser_type.md +8 -12
- data/documentation/docs/api/dialog.md +15 -18
- data/documentation/docs/api/download.md +10 -12
- data/documentation/docs/api/element_handle.md +9 -7
- data/documentation/docs/api/frame.md +28 -55
- data/documentation/docs/api/locator.md +24 -23
- data/documentation/docs/api/locator_assertions.md +652 -0
- data/documentation/docs/api/page.md +53 -103
- data/documentation/docs/api/playwright.md +20 -23
- data/documentation/docs/api/selectors.md +29 -34
- data/documentation/docs/article/guides/rails_integration.md +80 -51
- data/documentation/docs/article/guides/rspec_integration.md +59 -0
- data/documentation/docs/include/api_coverage.md +43 -0
- data/documentation/docusaurus.config.js +1 -1
- data/documentation/package.json +7 -7
- data/documentation/yarn.lock +4641 -5023
- data/lib/playwright/api_response_impl.rb +2 -2
- data/lib/playwright/channel.rb +1 -1
- data/lib/playwright/channel_owners/api_request_context.rb +12 -3
- data/lib/playwright/channel_owners/browser.rb +11 -7
- data/lib/playwright/channel_owners/browser_context.rb +35 -15
- data/lib/playwright/channel_owners/frame.rb +38 -14
- data/lib/playwright/channel_owners/page.rb +29 -16
- data/lib/playwright/channel_owners/web_socket.rb +8 -13
- data/lib/playwright/connection.rb +18 -2
- data/lib/playwright/errors.rb +22 -2
- data/lib/playwright/input_files.rb +4 -4
- 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/utils.rb +3 -10
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright/waiter.rb +146 -0
- data/lib/playwright.rb +1 -1
- data/lib/playwright_api/api_request_context.rb +1 -2
- data/lib/playwright_api/browser.rb +2 -2
- data/lib/playwright_api/browser_context.rb +3 -3
- data/lib/playwright_api/browser_type.rb +2 -1
- data/lib/playwright_api/download.rb +1 -2
- data/lib/playwright_api/element_handle.rb +4 -1
- data/lib/playwright_api/frame.rb +4 -1
- data/lib/playwright_api/locator.rb +9 -1
- data/lib/playwright_api/locator_assertions.rb +561 -0
- data/lib/playwright_api/page.rb +16 -13
- data/lib/playwright_api/request.rb +4 -4
- data/lib/playwright_api/worker.rb +4 -4
- data/sig/playwright.rbs +48 -5
- metadata +9 -4
- data/lib/playwright/wait_helper.rb +0 -73
@@ -0,0 +1,561 @@
|
|
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
|
+
# **Details**
|
305
|
+
#
|
306
|
+
# When `expected` parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual text and
|
307
|
+
# in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
308
|
+
#
|
309
|
+
# **Usage**
|
310
|
+
#
|
311
|
+
# ```python sync
|
312
|
+
# import re
|
313
|
+
# from playwright.sync_api import expect
|
314
|
+
#
|
315
|
+
# locator = page.locator('.title')
|
316
|
+
# expect(locator).to_contain_text("substring")
|
317
|
+
# expect(locator).to_contain_text(re.compile(r"\d messages"))
|
318
|
+
# ```
|
319
|
+
#
|
320
|
+
# If you pass an array as an expected value, the expectations are:
|
321
|
+
# 1. Locator resolves to a list of elements.
|
322
|
+
# 1. Elements from a **subset** of this list contain text from the expected array, respectively.
|
323
|
+
# 1. The matching subset of elements has the same order as the expected array.
|
324
|
+
# 1. Each text value from the expected array is matched by some element from the list.
|
325
|
+
#
|
326
|
+
# For example, consider the following list:
|
327
|
+
#
|
328
|
+
# ```html
|
329
|
+
# <ul>
|
330
|
+
# <li>Item Text 1</li>
|
331
|
+
# <li>Item Text 2</li>
|
332
|
+
# <li>Item Text 3</li>
|
333
|
+
# </ul>
|
334
|
+
# ```
|
335
|
+
#
|
336
|
+
# Let's see how we can use the assertion:
|
337
|
+
#
|
338
|
+
# ```python sync
|
339
|
+
# from playwright.sync_api import expect
|
340
|
+
#
|
341
|
+
# # ✓ Contains the right items in the right order
|
342
|
+
# expect(page.locator("ul > li")).to_contain_text(["Text 1", "Text 3", "Text 4"])
|
343
|
+
#
|
344
|
+
# # ✖ Wrong order
|
345
|
+
# expect(page.locator("ul > li")).to_contain_text(["Text 3", "Text 2"])
|
346
|
+
#
|
347
|
+
# # ✖ No item contains this text
|
348
|
+
# expect(page.locator("ul > li")).to_contain_text(["Some 33"])
|
349
|
+
#
|
350
|
+
# # ✖ Locator points to the outer list element, not to the list items
|
351
|
+
# expect(page.locator("ul")).to_contain_text(["Text 3"])
|
352
|
+
# ```
|
353
|
+
def to_contain_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
|
354
|
+
wrap_impl(@impl.to_contain_text(unwrap_impl(expected), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout), useInnerText: unwrap_impl(useInnerText)))
|
355
|
+
end
|
356
|
+
|
357
|
+
#
|
358
|
+
# Ensures the `Locator` points to an element with given attribute.
|
359
|
+
#
|
360
|
+
# **Usage**
|
361
|
+
#
|
362
|
+
# ```python sync
|
363
|
+
# from playwright.sync_api import expect
|
364
|
+
#
|
365
|
+
# locator = page.locator("input")
|
366
|
+
# expect(locator).to_have_attribute("type", "text")
|
367
|
+
# ```
|
368
|
+
def to_have_attribute(name, value, ignoreCase: nil, timeout: nil)
|
369
|
+
wrap_impl(@impl.to_have_attribute(unwrap_impl(name), unwrap_impl(value), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout)))
|
370
|
+
end
|
371
|
+
|
372
|
+
#
|
373
|
+
# Ensures the `Locator` points to an element with given CSS classes. This needs to be a full match
|
374
|
+
# or using a relaxed regular expression.
|
375
|
+
#
|
376
|
+
# **Usage**
|
377
|
+
#
|
378
|
+
# ```html
|
379
|
+
# <div class='selected row' id='component'></div>
|
380
|
+
# ```
|
381
|
+
#
|
382
|
+
# ```python sync
|
383
|
+
# from playwright.sync_api import expect
|
384
|
+
#
|
385
|
+
# locator = page.locator("#component")
|
386
|
+
# expect(locator).to_have_class(re.compile(r"selected"))
|
387
|
+
# expect(locator).to_have_class("selected row")
|
388
|
+
# ```
|
389
|
+
#
|
390
|
+
# Note that if array is passed as an expected value, entire lists of elements can be asserted:
|
391
|
+
#
|
392
|
+
# ```python sync
|
393
|
+
# from playwright.sync_api import expect
|
394
|
+
#
|
395
|
+
# locator = page.locator("list > .component")
|
396
|
+
# expect(locator).to_have_class(["component", "component selected", "component"])
|
397
|
+
# ```
|
398
|
+
def to_have_class(expected, timeout: nil)
|
399
|
+
wrap_impl(@impl.to_have_class(unwrap_impl(expected), timeout: unwrap_impl(timeout)))
|
400
|
+
end
|
401
|
+
|
402
|
+
#
|
403
|
+
# Ensures the `Locator` resolves to an exact number of DOM nodes.
|
404
|
+
#
|
405
|
+
# **Usage**
|
406
|
+
#
|
407
|
+
# ```python sync
|
408
|
+
# from playwright.sync_api import expect
|
409
|
+
#
|
410
|
+
# locator = page.locator("list > .component")
|
411
|
+
# expect(locator).to_have_count(3)
|
412
|
+
# ```
|
413
|
+
def to_have_count(count, timeout: nil)
|
414
|
+
wrap_impl(@impl.to_have_count(unwrap_impl(count), timeout: unwrap_impl(timeout)))
|
415
|
+
end
|
416
|
+
|
417
|
+
#
|
418
|
+
# Ensures the `Locator` resolves to an element with the given computed CSS style.
|
419
|
+
#
|
420
|
+
# **Usage**
|
421
|
+
#
|
422
|
+
# ```python sync
|
423
|
+
# from playwright.sync_api import expect
|
424
|
+
#
|
425
|
+
# locator = page.get_by_role("button")
|
426
|
+
# expect(locator).to_have_css("display", "flex")
|
427
|
+
# ```
|
428
|
+
def to_have_css(name, value, timeout: nil)
|
429
|
+
wrap_impl(@impl.to_have_css(unwrap_impl(name), unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
430
|
+
end
|
431
|
+
|
432
|
+
#
|
433
|
+
# Ensures the `Locator` points to an element with the given DOM Node ID.
|
434
|
+
#
|
435
|
+
# **Usage**
|
436
|
+
#
|
437
|
+
# ```python sync
|
438
|
+
# from playwright.sync_api import expect
|
439
|
+
#
|
440
|
+
# locator = page.get_by_role("textbox")
|
441
|
+
# expect(locator).to_have_id("lastname")
|
442
|
+
# ```
|
443
|
+
def to_have_id(id, timeout: nil)
|
444
|
+
wrap_impl(@impl.to_have_id(unwrap_impl(id), timeout: unwrap_impl(timeout)))
|
445
|
+
end
|
446
|
+
|
447
|
+
#
|
448
|
+
# Ensures the `Locator` points to an element with given JavaScript property. Note that this property can be
|
449
|
+
# of a primitive type as well as a plain serializable JavaScript object.
|
450
|
+
#
|
451
|
+
# **Usage**
|
452
|
+
#
|
453
|
+
# ```python sync
|
454
|
+
# from playwright.sync_api import expect
|
455
|
+
#
|
456
|
+
# locator = page.locator(".component")
|
457
|
+
# expect(locator).to_have_js_property("loaded", True)
|
458
|
+
# ```
|
459
|
+
def to_have_js_property(name, value, timeout: nil)
|
460
|
+
wrap_impl(@impl.to_have_js_property(unwrap_impl(name), unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
461
|
+
end
|
462
|
+
|
463
|
+
#
|
464
|
+
# Ensures the `Locator` points to an element with the given text. You can use regular expressions for the value as well.
|
465
|
+
#
|
466
|
+
# **Details**
|
467
|
+
#
|
468
|
+
# When `expected` parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual text and
|
469
|
+
# in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
470
|
+
#
|
471
|
+
# **Usage**
|
472
|
+
#
|
473
|
+
# ```python sync
|
474
|
+
# import re
|
475
|
+
# from playwright.sync_api import expect
|
476
|
+
#
|
477
|
+
# locator = page.locator(".title")
|
478
|
+
# expect(locator).to_have_text(re.compile(r"Welcome, Test User"))
|
479
|
+
# expect(locator).to_have_text(re.compile(r"Welcome, .*"))
|
480
|
+
# ```
|
481
|
+
#
|
482
|
+
# If you pass an array as an expected value, the expectations are:
|
483
|
+
# 1. Locator resolves to a list of elements.
|
484
|
+
# 1. The number of elements equals the number of expected values in the array.
|
485
|
+
# 1. Elements from the list have text matching expected array values, one by one, in order.
|
486
|
+
#
|
487
|
+
# For example, consider the following list:
|
488
|
+
#
|
489
|
+
# ```html
|
490
|
+
# <ul>
|
491
|
+
# <li>Text 1</li>
|
492
|
+
# <li>Text 2</li>
|
493
|
+
# <li>Text 3</li>
|
494
|
+
# </ul>
|
495
|
+
# ```
|
496
|
+
#
|
497
|
+
# Let's see how we can use the assertion:
|
498
|
+
#
|
499
|
+
# ```python sync
|
500
|
+
# from playwright.sync_api import expect
|
501
|
+
#
|
502
|
+
# # ✓ Has the right items in the right order
|
503
|
+
# expect(page.locator("ul > li")).to_have_text(["Text 1", "Text 2", "Text 3"])
|
504
|
+
#
|
505
|
+
# # ✖ Wrong order
|
506
|
+
# expect(page.locator("ul > li")).to_have_text(["Text 3", "Text 2", "Text 1"])
|
507
|
+
#
|
508
|
+
# # ✖ Last item does not match
|
509
|
+
# expect(page.locator("ul > li")).to_have_text(["Text 1", "Text 2", "Text"])
|
510
|
+
#
|
511
|
+
# # ✖ Locator points to the outer list element, not to the list items
|
512
|
+
# expect(page.locator("ul")).to_have_text(["Text 1", "Text 2", "Text 3"])
|
513
|
+
# ```
|
514
|
+
def to_have_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
|
515
|
+
wrap_impl(@impl.to_have_text(unwrap_impl(expected), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout), useInnerText: unwrap_impl(useInnerText)))
|
516
|
+
end
|
517
|
+
|
518
|
+
#
|
519
|
+
# Ensures the `Locator` points to an element with the given input value. You can use regular expressions for the value as well.
|
520
|
+
#
|
521
|
+
# **Usage**
|
522
|
+
#
|
523
|
+
# ```python sync
|
524
|
+
# import re
|
525
|
+
# from playwright.sync_api import expect
|
526
|
+
#
|
527
|
+
# locator = page.locator("input[type=number]")
|
528
|
+
# expect(locator).to_have_value(re.compile(r"[0-9]"))
|
529
|
+
# ```
|
530
|
+
def to_have_value(value, timeout: nil)
|
531
|
+
wrap_impl(@impl.to_have_value(unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
532
|
+
end
|
533
|
+
|
534
|
+
#
|
535
|
+
# Ensures the `Locator` points to multi-select/combobox (i.e. a `select` with the `multiple` attribute) and the specified values are selected.
|
536
|
+
#
|
537
|
+
# **Usage**
|
538
|
+
#
|
539
|
+
# For example, given the following element:
|
540
|
+
#
|
541
|
+
# ```html
|
542
|
+
# <select id="favorite-colors" multiple>
|
543
|
+
# <option value="R">Red</option>
|
544
|
+
# <option value="G">Green</option>
|
545
|
+
# <option value="B">Blue</option>
|
546
|
+
# </select>
|
547
|
+
# ```
|
548
|
+
#
|
549
|
+
# ```python sync
|
550
|
+
# import re
|
551
|
+
# from playwright.sync_api import expect
|
552
|
+
#
|
553
|
+
# locator = page.locator("id=favorite-colors")
|
554
|
+
# locator.select_option(["R", "G"])
|
555
|
+
# expect(locator).to_have_values([re.compile(r"R"), re.compile(r"G")])
|
556
|
+
# ```
|
557
|
+
def to_have_values(values, timeout: nil)
|
558
|
+
wrap_impl(@impl.to_have_values(unwrap_impl(values), timeout: unwrap_impl(timeout)))
|
559
|
+
end
|
560
|
+
end
|
561
|
+
end
|
data/lib/playwright_api/page.rb
CHANGED
@@ -166,8 +166,8 @@ module Playwright
|
|
166
166
|
#
|
167
167
|
# **NOTE**: if `runBeforeUnload` is passed as true, a `beforeunload` dialog might be summoned and should be handled
|
168
168
|
# manually via [`event: Page.dialog`] event.
|
169
|
-
def close(runBeforeUnload: nil)
|
170
|
-
wrap_impl(@impl.close(runBeforeUnload: unwrap_impl(runBeforeUnload)))
|
169
|
+
def close(reason: nil, runBeforeUnload: nil)
|
170
|
+
wrap_impl(@impl.close(reason: unwrap_impl(reason), runBeforeUnload: unwrap_impl(runBeforeUnload)))
|
171
171
|
end
|
172
172
|
|
173
173
|
#
|
@@ -225,13 +225,16 @@ module Playwright
|
|
225
225
|
#
|
226
226
|
# Since `eventInit` is event-specific, please refer to the events documentation for the lists of initial
|
227
227
|
# properties:
|
228
|
+
# - [DeviceMotionEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent/DeviceMotionEvent)
|
229
|
+
# - [DeviceOrientationEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent/DeviceOrientationEvent)
|
228
230
|
# - [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
|
231
|
+
# - [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
|
229
232
|
# - [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
|
230
233
|
# - [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
|
231
234
|
# - [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
|
232
235
|
# - [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
|
233
236
|
# - [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
|
234
|
-
# - [
|
237
|
+
# - [WheelEvent](https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/WheelEvent)
|
235
238
|
#
|
236
239
|
# You can also specify `JSHandle` as the property value if you want live objects to be passed into the event:
|
237
240
|
#
|
@@ -442,7 +445,7 @@ module Playwright
|
|
442
445
|
#
|
443
446
|
# def run(playwright: Playwright):
|
444
447
|
# webkit = playwright.webkit
|
445
|
-
# browser = webkit.launch(headless=
|
448
|
+
# browser = webkit.launch(headless=False)
|
446
449
|
# context = browser.new_context()
|
447
450
|
# page = context.new_page()
|
448
451
|
# page.expose_binding("pageURL", lambda source: source["page"].url)
|
@@ -1671,13 +1674,13 @@ module Playwright
|
|
1671
1674
|
end
|
1672
1675
|
|
1673
1676
|
# @nodoc
|
1674
|
-
def
|
1675
|
-
wrap_impl(@impl.
|
1677
|
+
def stop_js_coverage
|
1678
|
+
wrap_impl(@impl.stop_js_coverage)
|
1676
1679
|
end
|
1677
1680
|
|
1678
1681
|
# @nodoc
|
1679
|
-
def
|
1680
|
-
wrap_impl(@impl.
|
1682
|
+
def start_js_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
|
1683
|
+
wrap_impl(@impl.start_js_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
|
1681
1684
|
end
|
1682
1685
|
|
1683
1686
|
# @nodoc
|
@@ -1685,6 +1688,11 @@ module Playwright
|
|
1685
1688
|
wrap_impl(@impl.start_css_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
|
1686
1689
|
end
|
1687
1690
|
|
1691
|
+
# @nodoc
|
1692
|
+
def stop_css_coverage
|
1693
|
+
wrap_impl(@impl.stop_css_coverage)
|
1694
|
+
end
|
1695
|
+
|
1688
1696
|
# @nodoc
|
1689
1697
|
def owned_context=(req)
|
1690
1698
|
wrap_impl(@impl.owned_context=(unwrap_impl(req)))
|
@@ -1695,11 +1703,6 @@ module Playwright
|
|
1695
1703
|
wrap_impl(@impl.guid)
|
1696
1704
|
end
|
1697
1705
|
|
1698
|
-
# @nodoc
|
1699
|
-
def start_js_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
|
1700
|
-
wrap_impl(@impl.start_js_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
|
1701
|
-
end
|
1702
|
-
|
1703
1706
|
# -- inherited from EventEmitter --
|
1704
1707
|
# @nodoc
|
1705
1708
|
def off(event, callback)
|
@@ -196,13 +196,13 @@ module Playwright
|
|
196
196
|
end
|
197
197
|
|
198
198
|
# @nodoc
|
199
|
-
def
|
200
|
-
wrap_impl(@impl.
|
199
|
+
def header_values(name)
|
200
|
+
wrap_impl(@impl.header_values(unwrap_impl(name)))
|
201
201
|
end
|
202
202
|
|
203
203
|
# @nodoc
|
204
|
-
def
|
205
|
-
wrap_impl(@impl.
|
204
|
+
def apply_fallback_overrides(overrides)
|
205
|
+
wrap_impl(@impl.apply_fallback_overrides(unwrap_impl(overrides)))
|
206
206
|
end
|
207
207
|
|
208
208
|
# -- inherited from EventEmitter --
|
@@ -47,13 +47,13 @@ module Playwright
|
|
47
47
|
end
|
48
48
|
|
49
49
|
# @nodoc
|
50
|
-
def
|
51
|
-
wrap_impl(@impl.
|
50
|
+
def page=(req)
|
51
|
+
wrap_impl(@impl.page=(unwrap_impl(req)))
|
52
52
|
end
|
53
53
|
|
54
54
|
# @nodoc
|
55
|
-
def
|
56
|
-
wrap_impl(@impl.
|
55
|
+
def context=(req)
|
56
|
+
wrap_impl(@impl.context=(unwrap_impl(req)))
|
57
57
|
end
|
58
58
|
|
59
59
|
# -- inherited from EventEmitter --
|