playwright-ruby-client 0.0.8 → 1.58.1.alpha1
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/AGENTS.md +4 -0
- data/CLAUDE/api_generation.md +28 -0
- data/CLAUDE/ci_expectations.md +23 -0
- data/CLAUDE/gem_release_flow.md +39 -0
- data/CLAUDE/past_upgrade_pr_patterns.md +42 -0
- data/CLAUDE/playwright_upgrade_workflow.md +35 -0
- data/CLAUDE/rspec_debugging.md +30 -0
- data/CLAUDE/unimplemented_examples.md +18 -0
- data/CLAUDE.md +32 -0
- data/CONTRIBUTING.md +5 -0
- data/README.md +60 -16
- data/documentation/README.md +33 -0
- data/documentation/babel.config.js +3 -0
- data/documentation/docs/api/api_request.md +7 -0
- data/documentation/docs/api/api_request_context.md +298 -0
- data/documentation/docs/api/api_response.md +114 -0
- data/documentation/docs/api/browser.md +237 -0
- data/documentation/docs/api/browser_context.md +503 -0
- data/documentation/docs/api/browser_type.md +184 -0
- data/documentation/docs/api/cdp_session.md +44 -0
- data/documentation/docs/api/clock.md +154 -0
- data/documentation/docs/api/console_message.md +85 -0
- data/documentation/docs/api/dialog.md +84 -0
- data/documentation/docs/api/download.md +111 -0
- data/documentation/docs/api/element_handle.md +694 -0
- data/documentation/docs/api/experimental/_category_.yml +3 -0
- data/documentation/docs/api/experimental/android.md +42 -0
- data/documentation/docs/api/experimental/android_device.md +109 -0
- data/documentation/docs/api/experimental/android_input.md +43 -0
- data/documentation/docs/api/experimental/android_socket.md +7 -0
- data/documentation/docs/api/experimental/android_web_view.md +7 -0
- data/documentation/docs/api/file_chooser.md +53 -0
- data/documentation/docs/api/frame.md +1218 -0
- data/documentation/docs/api/frame_locator.md +348 -0
- data/documentation/docs/api/js_handle.md +121 -0
- data/documentation/docs/api/keyboard.md +170 -0
- data/documentation/docs/api/locator.md +1495 -0
- data/documentation/docs/api/locator_assertions.md +827 -0
- data/documentation/docs/api/mouse.md +86 -0
- data/documentation/docs/api/page.md +1946 -0
- data/documentation/docs/api/page_assertions.md +65 -0
- data/documentation/docs/api/playwright.md +66 -0
- data/documentation/docs/api/request.md +255 -0
- data/documentation/docs/api/response.md +176 -0
- data/documentation/docs/api/route.md +205 -0
- data/documentation/docs/api/selectors.md +63 -0
- data/documentation/docs/api/touchscreen.md +22 -0
- data/documentation/docs/api/tracing.md +129 -0
- data/documentation/docs/api/web_socket.md +51 -0
- data/documentation/docs/api/worker.md +83 -0
- data/documentation/docs/article/api_coverage.mdx +11 -0
- data/documentation/docs/article/getting_started.md +161 -0
- data/documentation/docs/article/guides/_category_.yml +3 -0
- data/documentation/docs/article/guides/download_playwright_driver.md +55 -0
- data/documentation/docs/article/guides/inspector.md +31 -0
- data/documentation/docs/article/guides/launch_browser.md +121 -0
- data/documentation/docs/article/guides/playwright_on_alpine_linux.md +112 -0
- data/documentation/docs/article/guides/rails_integration.md +278 -0
- data/documentation/docs/article/guides/rails_integration_with_null_driver.md +145 -0
- data/documentation/docs/article/guides/recording_video.md +79 -0
- data/documentation/docs/article/guides/rspec_integration.md +59 -0
- data/documentation/docs/article/guides/semi_automation.md +71 -0
- data/documentation/docs/article/guides/use_storage_state.md +78 -0
- data/documentation/docs/include/api_coverage.md +671 -0
- data/documentation/docusaurus.config.js +114 -0
- data/documentation/package.json +39 -0
- data/documentation/sidebars.js +15 -0
- data/documentation/src/components/HomepageFeatures.js +61 -0
- data/documentation/src/components/HomepageFeatures.module.css +13 -0
- data/documentation/src/css/custom.css +44 -0
- data/documentation/src/pages/index.js +49 -0
- data/documentation/src/pages/index.module.css +41 -0
- data/documentation/src/pages/markdown-page.md +7 -0
- data/documentation/static/.nojekyll +0 -0
- data/documentation/static/img/playwright-logo.svg +9 -0
- data/documentation/static/img/playwright-ruby-client.png +0 -0
- data/documentation/static/img/undraw_dropdown_menu.svg +1 -0
- data/documentation/static/img/undraw_web_development.svg +1 -0
- data/documentation/static/img/undraw_windows.svg +1 -0
- data/documentation/yarn.lock +9005 -0
- data/lib/playwright/{input_types/android_input.rb → android_input_impl.rb} +5 -1
- data/lib/playwright/api_implementation.rb +18 -0
- data/lib/playwright/api_response_impl.rb +77 -0
- data/lib/playwright/channel.rb +62 -1
- data/lib/playwright/channel_owner.rb +70 -7
- data/lib/playwright/channel_owners/android.rb +16 -3
- data/lib/playwright/channel_owners/android_device.rb +22 -66
- data/lib/playwright/channel_owners/api_request_context.rb +247 -0
- data/lib/playwright/channel_owners/artifact.rb +40 -0
- data/lib/playwright/channel_owners/binding_call.rb +70 -0
- data/lib/playwright/channel_owners/browser.rb +114 -22
- data/lib/playwright/channel_owners/browser_context.rb +589 -15
- data/lib/playwright/channel_owners/browser_type.rb +90 -1
- data/lib/playwright/channel_owners/cdp_session.rb +19 -0
- data/lib/playwright/channel_owners/dialog.rb +32 -0
- data/lib/playwright/channel_owners/element_handle.rb +107 -43
- data/lib/playwright/channel_owners/fetch_request.rb +8 -0
- data/lib/playwright/channel_owners/frame.rb +334 -104
- data/lib/playwright/channel_owners/js_handle.rb +9 -13
- data/lib/playwright/channel_owners/local_utils.rb +82 -0
- data/lib/playwright/channel_owners/page.rb +778 -95
- data/lib/playwright/channel_owners/playwright.rb +25 -30
- data/lib/playwright/channel_owners/request.rb +120 -18
- data/lib/playwright/channel_owners/response.rb +113 -0
- data/lib/playwright/channel_owners/route.rb +181 -0
- data/lib/playwright/channel_owners/stream.rb +30 -0
- data/lib/playwright/channel_owners/tracing.rb +117 -0
- data/lib/playwright/channel_owners/web_socket.rb +96 -0
- data/lib/playwright/channel_owners/worker.rb +46 -0
- data/lib/playwright/channel_owners/writable_stream.rb +14 -0
- data/lib/playwright/clock_impl.rb +67 -0
- data/lib/playwright/connection.rb +111 -63
- data/lib/playwright/console_message_impl.rb +29 -0
- data/lib/playwright/download_impl.rb +32 -0
- data/lib/playwright/errors.rb +42 -5
- data/lib/playwright/event_emitter.rb +17 -3
- data/lib/playwright/event_emitter_proxy.rb +49 -0
- data/lib/playwright/events.rb +10 -5
- data/lib/playwright/file_chooser_impl.rb +24 -0
- data/lib/playwright/frame_locator_impl.rb +66 -0
- data/lib/playwright/har_router.rb +89 -0
- data/lib/playwright/http_headers.rb +14 -0
- data/lib/playwright/input_files.rb +102 -15
- data/lib/playwright/javascript/expression.rb +7 -11
- data/lib/playwright/javascript/regex.rb +23 -0
- data/lib/playwright/javascript/source_url.rb +16 -0
- data/lib/playwright/javascript/value_parser.rb +108 -19
- data/lib/playwright/javascript/value_serializer.rb +47 -8
- data/lib/playwright/javascript/visitor_info.rb +26 -0
- data/lib/playwright/javascript.rb +2 -10
- data/lib/playwright/{input_types/keyboard.rb → keyboard_impl.rb} +6 -2
- data/lib/playwright/locator_assertions_impl.rb +571 -0
- data/lib/playwright/locator_impl.rb +544 -0
- data/lib/playwright/locator_utils.rb +136 -0
- data/lib/playwright/mouse_impl.rb +57 -0
- data/lib/playwright/page_assertions_impl.rb +154 -0
- data/lib/playwright/playwright_api.rb +102 -30
- data/lib/playwright/raw_headers.rb +61 -0
- data/lib/playwright/route_handler.rb +78 -0
- data/lib/playwright/select_option_values.rb +34 -13
- data/lib/playwright/selectors_impl.rb +45 -0
- data/lib/playwright/test.rb +102 -0
- data/lib/playwright/timeout_settings.rb +9 -4
- data/lib/playwright/touchscreen_impl.rb +14 -0
- data/lib/playwright/transport.rb +61 -10
- data/lib/playwright/url_matcher.rb +24 -2
- data/lib/playwright/utils.rb +48 -13
- data/lib/playwright/version.rb +2 -1
- data/lib/playwright/video.rb +54 -0
- data/lib/playwright/waiter.rb +166 -0
- data/lib/playwright/web_socket_client.rb +167 -0
- data/lib/playwright/web_socket_transport.rb +116 -0
- data/lib/playwright.rb +188 -11
- data/lib/playwright_api/android.rb +46 -11
- data/lib/playwright_api/android_device.rb +182 -31
- data/lib/playwright_api/android_input.rb +22 -13
- data/lib/playwright_api/android_socket.rb +18 -0
- data/lib/playwright_api/android_web_view.rb +24 -0
- data/lib/playwright_api/api_request.rb +26 -0
- data/lib/playwright_api/api_request_context.rb +311 -0
- data/lib/playwright_api/api_response.rb +92 -0
- data/lib/playwright_api/browser.rb +116 -103
- data/lib/playwright_api/browser_context.rb +290 -389
- data/lib/playwright_api/browser_type.rb +96 -118
- data/lib/playwright_api/cdp_session.rb +36 -39
- data/lib/playwright_api/clock.rb +121 -0
- data/lib/playwright_api/console_message.rb +35 -19
- data/lib/playwright_api/dialog.rb +53 -50
- data/lib/playwright_api/download.rb +49 -43
- data/lib/playwright_api/element_handle.rb +354 -402
- data/lib/playwright_api/file_chooser.rb +15 -18
- data/lib/playwright_api/frame.rb +703 -603
- data/lib/playwright_api/frame_locator.rb +285 -0
- data/lib/playwright_api/js_handle.rb +50 -76
- data/lib/playwright_api/keyboard.rb +67 -146
- data/lib/playwright_api/locator.rb +1304 -0
- data/lib/playwright_api/locator_assertions.rb +704 -0
- data/lib/playwright_api/mouse.rb +23 -29
- data/lib/playwright_api/page.rb +1196 -1176
- data/lib/playwright_api/page_assertions.rb +60 -0
- data/lib/playwright_api/playwright.rb +54 -122
- data/lib/playwright_api/request.rb +112 -74
- data/lib/playwright_api/response.rb +92 -20
- data/lib/playwright_api/route.rb +152 -62
- data/lib/playwright_api/selectors.rb +47 -61
- data/lib/playwright_api/touchscreen.rb +8 -2
- data/lib/playwright_api/tracing.rb +128 -0
- data/lib/playwright_api/web_socket.rb +43 -5
- data/lib/playwright_api/worker.rb +74 -34
- data/playwright.gemspec +14 -9
- data/sig/playwright.rbs +658 -0
- metadata +216 -50
- data/docs/api_coverage.md +0 -354
- data/lib/playwright/channel_owners/chromium_browser.rb +0 -8
- data/lib/playwright/channel_owners/chromium_browser_context.rb +0 -8
- data/lib/playwright/channel_owners/console_message.rb +0 -21
- data/lib/playwright/channel_owners/firefox_browser.rb +0 -8
- data/lib/playwright/channel_owners/selectors.rb +0 -4
- data/lib/playwright/channel_owners/webkit_browser.rb +0 -8
- data/lib/playwright/input_type.rb +0 -19
- data/lib/playwright/input_types/mouse.rb +0 -4
- data/lib/playwright/input_types/touchscreen.rb +0 -4
- data/lib/playwright/javascript/function.rb +0 -67
- data/lib/playwright/wait_helper.rb +0 -73
- data/lib/playwright_api/accessibility.rb +0 -93
- data/lib/playwright_api/binding_call.rb +0 -23
- data/lib/playwright_api/chromium_browser_context.rb +0 -57
- data/lib/playwright_api/video.rb +0 -24
|
@@ -0,0 +1,704 @@
|
|
|
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.toContainClass`].
|
|
77
|
+
def not_to_contain_class(expected, timeout: nil)
|
|
78
|
+
wrap_impl(@impl.not_to_contain_class(unwrap_impl(expected), timeout: unwrap_impl(timeout)))
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
#
|
|
82
|
+
# The opposite of [`method: LocatorAssertions.toContainText`].
|
|
83
|
+
def not_to_contain_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
|
|
84
|
+
wrap_impl(@impl.not_to_contain_text(unwrap_impl(expected), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout), useInnerText: unwrap_impl(useInnerText)))
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
#
|
|
88
|
+
# The opposite of [`method: LocatorAssertions.toHaveAccessibleDescription`].
|
|
89
|
+
def not_to_have_accessible_description(name, ignoreCase: nil, timeout: nil)
|
|
90
|
+
wrap_impl(@impl.not_to_have_accessible_description(unwrap_impl(name), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout)))
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
#
|
|
94
|
+
# The opposite of [`method: LocatorAssertions.toHaveAccessibleErrorMessage`].
|
|
95
|
+
def not_to_have_accessible_error_message(errorMessage, ignoreCase: nil, timeout: nil)
|
|
96
|
+
wrap_impl(@impl.not_to_have_accessible_error_message(unwrap_impl(errorMessage), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout)))
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
#
|
|
100
|
+
# The opposite of [`method: LocatorAssertions.toHaveAccessibleName`].
|
|
101
|
+
def not_to_have_accessible_name(name, ignoreCase: nil, timeout: nil)
|
|
102
|
+
wrap_impl(@impl.not_to_have_accessible_name(unwrap_impl(name), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout)))
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
#
|
|
106
|
+
# The opposite of [`method: LocatorAssertions.toHaveAttribute`].
|
|
107
|
+
def not_to_have_attribute(name, value, ignoreCase: nil, timeout: nil)
|
|
108
|
+
wrap_impl(@impl.not_to_have_attribute(unwrap_impl(name), unwrap_impl(value), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout)))
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
#
|
|
112
|
+
# The opposite of [`method: LocatorAssertions.toHaveClass`].
|
|
113
|
+
def not_to_have_class(expected, timeout: nil)
|
|
114
|
+
wrap_impl(@impl.not_to_have_class(unwrap_impl(expected), timeout: unwrap_impl(timeout)))
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
#
|
|
118
|
+
# The opposite of [`method: LocatorAssertions.toHaveCount`].
|
|
119
|
+
def not_to_have_count(count, timeout: nil)
|
|
120
|
+
wrap_impl(@impl.not_to_have_count(unwrap_impl(count), timeout: unwrap_impl(timeout)))
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
#
|
|
124
|
+
# The opposite of [`method: LocatorAssertions.toHaveCSS`].
|
|
125
|
+
def not_to_have_css(name, value, timeout: nil)
|
|
126
|
+
wrap_impl(@impl.not_to_have_css(unwrap_impl(name), unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
#
|
|
130
|
+
# The opposite of [`method: LocatorAssertions.toHaveId`].
|
|
131
|
+
def not_to_have_id(id, timeout: nil)
|
|
132
|
+
wrap_impl(@impl.not_to_have_id(unwrap_impl(id), timeout: unwrap_impl(timeout)))
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
#
|
|
136
|
+
# The opposite of [`method: LocatorAssertions.toHaveJSProperty`].
|
|
137
|
+
def not_to_have_js_property(name, value, timeout: nil)
|
|
138
|
+
wrap_impl(@impl.not_to_have_js_property(unwrap_impl(name), unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
#
|
|
142
|
+
# The opposite of [`method: LocatorAssertions.toHaveRole`].
|
|
143
|
+
def not_to_have_role(role, timeout: nil)
|
|
144
|
+
wrap_impl(@impl.not_to_have_role(unwrap_impl(role), timeout: unwrap_impl(timeout)))
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
#
|
|
148
|
+
# The opposite of [`method: LocatorAssertions.toHaveText`].
|
|
149
|
+
def not_to_have_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
|
|
150
|
+
wrap_impl(@impl.not_to_have_text(unwrap_impl(expected), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout), useInnerText: unwrap_impl(useInnerText)))
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
#
|
|
154
|
+
# The opposite of [`method: LocatorAssertions.toHaveValue`].
|
|
155
|
+
def not_to_have_value(value, timeout: nil)
|
|
156
|
+
wrap_impl(@impl.not_to_have_value(unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
#
|
|
160
|
+
# The opposite of [`method: LocatorAssertions.toHaveValues`].
|
|
161
|
+
def not_to_have_values(values, timeout: nil)
|
|
162
|
+
wrap_impl(@impl.not_to_have_values(unwrap_impl(values), timeout: unwrap_impl(timeout)))
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
#
|
|
166
|
+
# The opposite of [`method: LocatorAssertions.toMatchAriaSnapshot`].
|
|
167
|
+
def not_to_match_aria_snapshot(expected, timeout: nil)
|
|
168
|
+
wrap_impl(@impl.not_to_match_aria_snapshot(unwrap_impl(expected), timeout: unwrap_impl(timeout)))
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
#
|
|
172
|
+
# Ensures that `Locator` points to an element that is [connected](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected) to a Document or a ShadowRoot.
|
|
173
|
+
#
|
|
174
|
+
# **Usage**
|
|
175
|
+
#
|
|
176
|
+
# ```python sync
|
|
177
|
+
# expect(page.get_by_text("Hidden text")).to_be_attached()
|
|
178
|
+
# ```
|
|
179
|
+
def to_be_attached(attached: nil, timeout: nil)
|
|
180
|
+
wrap_impl(@impl.to_be_attached(attached: unwrap_impl(attached), timeout: unwrap_impl(timeout)))
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
#
|
|
184
|
+
# Ensures the `Locator` points to a checked input.
|
|
185
|
+
#
|
|
186
|
+
# **Usage**
|
|
187
|
+
#
|
|
188
|
+
# ```python sync
|
|
189
|
+
# from playwright.sync_api import expect
|
|
190
|
+
#
|
|
191
|
+
# locator = page.get_by_label("Subscribe to newsletter")
|
|
192
|
+
# expect(locator).to_be_checked()
|
|
193
|
+
# ```
|
|
194
|
+
def to_be_checked(checked: nil, indeterminate: nil, timeout: nil)
|
|
195
|
+
wrap_impl(@impl.to_be_checked(checked: unwrap_impl(checked), indeterminate: unwrap_impl(indeterminate), timeout: unwrap_impl(timeout)))
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
#
|
|
199
|
+
# Ensures the `Locator` points to a disabled element. Element is disabled if it has "disabled" attribute
|
|
200
|
+
# or is disabled via ['aria-disabled'](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled).
|
|
201
|
+
# Note that only native control elements such as HTML `button`, `input`, `select`, `textarea`, `option`, `optgroup`
|
|
202
|
+
# can be disabled by setting "disabled" attribute. "disabled" attribute on other elements is ignored
|
|
203
|
+
# by the browser.
|
|
204
|
+
#
|
|
205
|
+
# **Usage**
|
|
206
|
+
#
|
|
207
|
+
# ```python sync
|
|
208
|
+
# from playwright.sync_api import expect
|
|
209
|
+
#
|
|
210
|
+
# locator = page.locator("button.submit")
|
|
211
|
+
# expect(locator).to_be_disabled()
|
|
212
|
+
# ```
|
|
213
|
+
def to_be_disabled(timeout: nil)
|
|
214
|
+
wrap_impl(@impl.to_be_disabled(timeout: unwrap_impl(timeout)))
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
#
|
|
218
|
+
# Ensures the `Locator` points to an editable element.
|
|
219
|
+
#
|
|
220
|
+
# **Usage**
|
|
221
|
+
#
|
|
222
|
+
# ```python sync
|
|
223
|
+
# from playwright.sync_api import expect
|
|
224
|
+
#
|
|
225
|
+
# locator = page.get_by_role("textbox")
|
|
226
|
+
# expect(locator).to_be_editable()
|
|
227
|
+
# ```
|
|
228
|
+
def to_be_editable(editable: nil, timeout: nil)
|
|
229
|
+
wrap_impl(@impl.to_be_editable(editable: unwrap_impl(editable), timeout: unwrap_impl(timeout)))
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
#
|
|
233
|
+
# Ensures the `Locator` points to an empty editable element or to a DOM node that has no text.
|
|
234
|
+
#
|
|
235
|
+
# **Usage**
|
|
236
|
+
#
|
|
237
|
+
# ```python sync
|
|
238
|
+
# from playwright.sync_api import expect
|
|
239
|
+
#
|
|
240
|
+
# locator = page.locator("div.warning")
|
|
241
|
+
# expect(locator).to_be_empty()
|
|
242
|
+
# ```
|
|
243
|
+
def to_be_empty(timeout: nil)
|
|
244
|
+
wrap_impl(@impl.to_be_empty(timeout: unwrap_impl(timeout)))
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
#
|
|
248
|
+
# Ensures the `Locator` points to an enabled element.
|
|
249
|
+
#
|
|
250
|
+
# **Usage**
|
|
251
|
+
#
|
|
252
|
+
# ```python sync
|
|
253
|
+
# from playwright.sync_api import expect
|
|
254
|
+
#
|
|
255
|
+
# locator = page.locator("button.submit")
|
|
256
|
+
# expect(locator).to_be_enabled()
|
|
257
|
+
# ```
|
|
258
|
+
def to_be_enabled(enabled: nil, timeout: nil)
|
|
259
|
+
wrap_impl(@impl.to_be_enabled(enabled: unwrap_impl(enabled), timeout: unwrap_impl(timeout)))
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
#
|
|
263
|
+
# Ensures the `Locator` points to a focused DOM node.
|
|
264
|
+
#
|
|
265
|
+
# **Usage**
|
|
266
|
+
#
|
|
267
|
+
# ```python sync
|
|
268
|
+
# from playwright.sync_api import expect
|
|
269
|
+
#
|
|
270
|
+
# locator = page.get_by_role("textbox")
|
|
271
|
+
# expect(locator).to_be_focused()
|
|
272
|
+
# ```
|
|
273
|
+
def to_be_focused(timeout: nil)
|
|
274
|
+
wrap_impl(@impl.to_be_focused(timeout: unwrap_impl(timeout)))
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
#
|
|
278
|
+
# Ensures that `Locator` either does not resolve to any DOM node, or resolves to a [non-visible](../actionability.md#visible) one.
|
|
279
|
+
#
|
|
280
|
+
# **Usage**
|
|
281
|
+
#
|
|
282
|
+
# ```python sync
|
|
283
|
+
# from playwright.sync_api import expect
|
|
284
|
+
#
|
|
285
|
+
# locator = page.locator('.my-element')
|
|
286
|
+
# expect(locator).to_be_hidden()
|
|
287
|
+
# ```
|
|
288
|
+
def to_be_hidden(timeout: nil)
|
|
289
|
+
wrap_impl(@impl.to_be_hidden(timeout: unwrap_impl(timeout)))
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
#
|
|
293
|
+
# 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).
|
|
294
|
+
#
|
|
295
|
+
# **Usage**
|
|
296
|
+
#
|
|
297
|
+
# ```python sync
|
|
298
|
+
# from playwright.sync_api import expect
|
|
299
|
+
#
|
|
300
|
+
# locator = page.get_by_role("button")
|
|
301
|
+
# # Make sure at least some part of element intersects viewport.
|
|
302
|
+
# expect(locator).to_be_in_viewport()
|
|
303
|
+
# # Make sure element is fully outside of viewport.
|
|
304
|
+
# expect(locator).not_to_be_in_viewport()
|
|
305
|
+
# # Make sure that at least half of the element intersects viewport.
|
|
306
|
+
# expect(locator).to_be_in_viewport(ratio=0.5)
|
|
307
|
+
# ```
|
|
308
|
+
def to_be_in_viewport(ratio: nil, timeout: nil)
|
|
309
|
+
wrap_impl(@impl.to_be_in_viewport(ratio: unwrap_impl(ratio), timeout: unwrap_impl(timeout)))
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
#
|
|
313
|
+
# Ensures that `Locator` points to an attached and [visible](../actionability.md#visible) DOM node.
|
|
314
|
+
#
|
|
315
|
+
# To check that at least one element from the list is visible, use [`method: Locator.first`].
|
|
316
|
+
#
|
|
317
|
+
# **Usage**
|
|
318
|
+
#
|
|
319
|
+
# ```python sync
|
|
320
|
+
# # A specific element is visible.
|
|
321
|
+
# expect(page.get_by_text("Welcome")).to_be_visible()
|
|
322
|
+
#
|
|
323
|
+
# # At least one item in the list is visible.
|
|
324
|
+
# expect(page.get_by_test_id("todo-item").first).to_be_visible()
|
|
325
|
+
#
|
|
326
|
+
# # At least one of the two elements is visible, possibly both.
|
|
327
|
+
# expect(
|
|
328
|
+
# page.get_by_role("button", name="Sign in")
|
|
329
|
+
# .or_(page.get_by_role("button", name="Sign up"))
|
|
330
|
+
# .first
|
|
331
|
+
# ).to_be_visible()
|
|
332
|
+
# ```
|
|
333
|
+
def to_be_visible(timeout: nil, visible: nil)
|
|
334
|
+
wrap_impl(@impl.to_be_visible(timeout: unwrap_impl(timeout), visible: unwrap_impl(visible)))
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
#
|
|
338
|
+
# Ensures the `Locator` points to an element with given CSS classes. All classes from the asserted value, separated by spaces, must be present in the [Element.classList](https://developer.mozilla.org/en-US/docs/Web/API/Element/classList) in any order.
|
|
339
|
+
#
|
|
340
|
+
# **Usage**
|
|
341
|
+
#
|
|
342
|
+
# ```html
|
|
343
|
+
# <div class='middle selected row' id='component'></div>
|
|
344
|
+
# ```
|
|
345
|
+
#
|
|
346
|
+
# ```python sync
|
|
347
|
+
# from playwright.sync_api import expect
|
|
348
|
+
#
|
|
349
|
+
# locator = page.locator("#component")
|
|
350
|
+
# expect(locator).to_contain_class("middle selected row")
|
|
351
|
+
# expect(locator).to_contain_class("selected")
|
|
352
|
+
# expect(locator).to_contain_class("row middle")
|
|
353
|
+
# ```
|
|
354
|
+
#
|
|
355
|
+
# When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected class lists. Each element's class attribute is matched against the corresponding class in the array:
|
|
356
|
+
#
|
|
357
|
+
# ```html
|
|
358
|
+
# <div class='list'>
|
|
359
|
+
# <div class='component inactive'></div>
|
|
360
|
+
# <div class='component active'></div>
|
|
361
|
+
# <div class='component inactive'></div>
|
|
362
|
+
# </div>
|
|
363
|
+
# ```
|
|
364
|
+
#
|
|
365
|
+
# ```python sync
|
|
366
|
+
# from playwright.sync_api import expect
|
|
367
|
+
#
|
|
368
|
+
# locator = page.locator(".list > .component")
|
|
369
|
+
# await expect(locator).to_contain_class(["inactive", "active", "inactive"])
|
|
370
|
+
# ```
|
|
371
|
+
def to_contain_class(expected, timeout: nil)
|
|
372
|
+
wrap_impl(@impl.to_contain_class(unwrap_impl(expected), timeout: unwrap_impl(timeout)))
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
#
|
|
376
|
+
# Ensures the `Locator` points to an element that contains the given text. All nested elements will be considered when computing the text content of the element. You can use regular expressions for the value as well.
|
|
377
|
+
#
|
|
378
|
+
# **Details**
|
|
379
|
+
#
|
|
380
|
+
# When `expected` parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual text and
|
|
381
|
+
# in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
|
382
|
+
#
|
|
383
|
+
# **Usage**
|
|
384
|
+
#
|
|
385
|
+
# ```python sync
|
|
386
|
+
# import re
|
|
387
|
+
# from playwright.sync_api import expect
|
|
388
|
+
#
|
|
389
|
+
# locator = page.locator('.title')
|
|
390
|
+
# expect(locator).to_contain_text("substring")
|
|
391
|
+
# expect(locator).to_contain_text(re.compile(r"\d messages"))
|
|
392
|
+
# ```
|
|
393
|
+
#
|
|
394
|
+
# If you pass an array as an expected value, the expectations are:
|
|
395
|
+
# 1. Locator resolves to a list of elements.
|
|
396
|
+
# 1. Elements from a **subset** of this list contain text from the expected array, respectively.
|
|
397
|
+
# 1. The matching subset of elements has the same order as the expected array.
|
|
398
|
+
# 1. Each text value from the expected array is matched by some element from the list.
|
|
399
|
+
#
|
|
400
|
+
# For example, consider the following list:
|
|
401
|
+
#
|
|
402
|
+
# ```html
|
|
403
|
+
# <ul>
|
|
404
|
+
# <li>Item Text 1</li>
|
|
405
|
+
# <li>Item Text 2</li>
|
|
406
|
+
# <li>Item Text 3</li>
|
|
407
|
+
# </ul>
|
|
408
|
+
# ```
|
|
409
|
+
#
|
|
410
|
+
# Let's see how we can use the assertion:
|
|
411
|
+
#
|
|
412
|
+
# ```python sync
|
|
413
|
+
# from playwright.sync_api import expect
|
|
414
|
+
#
|
|
415
|
+
# # ✓ Contains the right items in the right order
|
|
416
|
+
# expect(page.locator("ul > li")).to_contain_text(["Text 1", "Text 3"])
|
|
417
|
+
#
|
|
418
|
+
# # ✖ Wrong order
|
|
419
|
+
# expect(page.locator("ul > li")).to_contain_text(["Text 3", "Text 2"])
|
|
420
|
+
#
|
|
421
|
+
# # ✖ No item contains this text
|
|
422
|
+
# expect(page.locator("ul > li")).to_contain_text(["Some 33"])
|
|
423
|
+
#
|
|
424
|
+
# # ✖ Locator points to the outer list element, not to the list items
|
|
425
|
+
# expect(page.locator("ul")).to_contain_text(["Text 3"])
|
|
426
|
+
# ```
|
|
427
|
+
def to_contain_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
|
|
428
|
+
wrap_impl(@impl.to_contain_text(unwrap_impl(expected), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout), useInnerText: unwrap_impl(useInnerText)))
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
#
|
|
432
|
+
# Ensures the `Locator` points to an element with a given [accessible description](https://w3c.github.io/accname/#dfn-accessible-description).
|
|
433
|
+
#
|
|
434
|
+
# **Usage**
|
|
435
|
+
#
|
|
436
|
+
# ```python sync
|
|
437
|
+
# locator = page.get_by_test_id("save-button")
|
|
438
|
+
# expect(locator).to_have_accessible_description("Save results to disk")
|
|
439
|
+
# ```
|
|
440
|
+
def to_have_accessible_description(description, ignoreCase: nil, timeout: nil)
|
|
441
|
+
wrap_impl(@impl.to_have_accessible_description(unwrap_impl(description), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout)))
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
#
|
|
445
|
+
# Ensures the `Locator` points to an element with a given [aria errormessage](https://w3c.github.io/aria/#aria-errormessage).
|
|
446
|
+
#
|
|
447
|
+
# **Usage**
|
|
448
|
+
#
|
|
449
|
+
# ```python sync
|
|
450
|
+
# locator = page.get_by_test_id("username-input")
|
|
451
|
+
# expect(locator).to_have_accessible_error_message("Username is required.")
|
|
452
|
+
# ```
|
|
453
|
+
def to_have_accessible_error_message(errorMessage, ignoreCase: nil, timeout: nil)
|
|
454
|
+
wrap_impl(@impl.to_have_accessible_error_message(unwrap_impl(errorMessage), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout)))
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
#
|
|
458
|
+
# Ensures the `Locator` points to an element with a given [accessible name](https://w3c.github.io/accname/#dfn-accessible-name).
|
|
459
|
+
#
|
|
460
|
+
# **Usage**
|
|
461
|
+
#
|
|
462
|
+
# ```python sync
|
|
463
|
+
# locator = page.get_by_test_id("save-button")
|
|
464
|
+
# expect(locator).to_have_accessible_name("Save to disk")
|
|
465
|
+
# ```
|
|
466
|
+
def to_have_accessible_name(name, ignoreCase: nil, timeout: nil)
|
|
467
|
+
wrap_impl(@impl.to_have_accessible_name(unwrap_impl(name), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout)))
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
#
|
|
471
|
+
# Ensures the `Locator` points to an element with given attribute.
|
|
472
|
+
#
|
|
473
|
+
# **Usage**
|
|
474
|
+
#
|
|
475
|
+
# ```python sync
|
|
476
|
+
# from playwright.sync_api import expect
|
|
477
|
+
#
|
|
478
|
+
# locator = page.locator("input")
|
|
479
|
+
# expect(locator).to_have_attribute("type", "text")
|
|
480
|
+
# ```
|
|
481
|
+
def to_have_attribute(name, value, ignoreCase: nil, timeout: nil)
|
|
482
|
+
wrap_impl(@impl.to_have_attribute(unwrap_impl(name), unwrap_impl(value), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout)))
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
#
|
|
486
|
+
# Ensures the `Locator` points to an element with given CSS classes. When a string is provided, it must fully match the element's `class` attribute. To match individual classes use [`method: LocatorAssertions.toContainClass`].
|
|
487
|
+
#
|
|
488
|
+
# **Usage**
|
|
489
|
+
#
|
|
490
|
+
# ```html
|
|
491
|
+
# <div class='middle selected row' id='component'></div>
|
|
492
|
+
# ```
|
|
493
|
+
#
|
|
494
|
+
# ```python sync
|
|
495
|
+
# from playwright.sync_api import expect
|
|
496
|
+
#
|
|
497
|
+
# locator = page.locator("#component")
|
|
498
|
+
# expect(locator).to_have_class("middle selected row")
|
|
499
|
+
# expect(locator).to_have_class(re.compile(r"(^|\\s)selected(\\s|$)"))
|
|
500
|
+
# ```
|
|
501
|
+
#
|
|
502
|
+
# When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected class values. Each element's class attribute is matched against the corresponding string or regular expression in the array:
|
|
503
|
+
#
|
|
504
|
+
# ```python sync
|
|
505
|
+
# from playwright.sync_api import expect
|
|
506
|
+
#
|
|
507
|
+
# locator = page.locator(".list > .component")
|
|
508
|
+
# expect(locator).to_have_class(["component", "component selected", "component"])
|
|
509
|
+
# ```
|
|
510
|
+
def to_have_class(expected, timeout: nil)
|
|
511
|
+
wrap_impl(@impl.to_have_class(unwrap_impl(expected), timeout: unwrap_impl(timeout)))
|
|
512
|
+
end
|
|
513
|
+
|
|
514
|
+
#
|
|
515
|
+
# Ensures the `Locator` resolves to an exact number of DOM nodes.
|
|
516
|
+
#
|
|
517
|
+
# **Usage**
|
|
518
|
+
#
|
|
519
|
+
# ```python sync
|
|
520
|
+
# from playwright.sync_api import expect
|
|
521
|
+
#
|
|
522
|
+
# locator = page.locator("list > .component")
|
|
523
|
+
# expect(locator).to_have_count(3)
|
|
524
|
+
# ```
|
|
525
|
+
def to_have_count(count, timeout: nil)
|
|
526
|
+
wrap_impl(@impl.to_have_count(unwrap_impl(count), timeout: unwrap_impl(timeout)))
|
|
527
|
+
end
|
|
528
|
+
|
|
529
|
+
#
|
|
530
|
+
# Ensures the `Locator` resolves to an element with the given computed CSS style.
|
|
531
|
+
#
|
|
532
|
+
# **Usage**
|
|
533
|
+
#
|
|
534
|
+
# ```python sync
|
|
535
|
+
# from playwright.sync_api import expect
|
|
536
|
+
#
|
|
537
|
+
# locator = page.get_by_role("button")
|
|
538
|
+
# expect(locator).to_have_css("display", "flex")
|
|
539
|
+
# ```
|
|
540
|
+
def to_have_css(name, value, timeout: nil)
|
|
541
|
+
wrap_impl(@impl.to_have_css(unwrap_impl(name), unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
|
542
|
+
end
|
|
543
|
+
|
|
544
|
+
#
|
|
545
|
+
# Ensures the `Locator` points to an element with the given DOM Node ID.
|
|
546
|
+
#
|
|
547
|
+
# **Usage**
|
|
548
|
+
#
|
|
549
|
+
# ```python sync
|
|
550
|
+
# from playwright.sync_api import expect
|
|
551
|
+
#
|
|
552
|
+
# locator = page.get_by_role("textbox")
|
|
553
|
+
# expect(locator).to_have_id("lastname")
|
|
554
|
+
# ```
|
|
555
|
+
def to_have_id(id, timeout: nil)
|
|
556
|
+
wrap_impl(@impl.to_have_id(unwrap_impl(id), timeout: unwrap_impl(timeout)))
|
|
557
|
+
end
|
|
558
|
+
|
|
559
|
+
#
|
|
560
|
+
# Ensures the `Locator` points to an element with given JavaScript property. Note that this property can be
|
|
561
|
+
# of a primitive type as well as a plain serializable JavaScript object.
|
|
562
|
+
#
|
|
563
|
+
# **Usage**
|
|
564
|
+
#
|
|
565
|
+
# ```python sync
|
|
566
|
+
# from playwright.sync_api import expect
|
|
567
|
+
#
|
|
568
|
+
# locator = page.locator(".component")
|
|
569
|
+
# expect(locator).to_have_js_property("loaded", True)
|
|
570
|
+
# ```
|
|
571
|
+
def to_have_js_property(name, value, timeout: nil)
|
|
572
|
+
wrap_impl(@impl.to_have_js_property(unwrap_impl(name), unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
|
573
|
+
end
|
|
574
|
+
|
|
575
|
+
#
|
|
576
|
+
# Ensures the `Locator` points to an element with a given [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles).
|
|
577
|
+
#
|
|
578
|
+
# Note that role is matched as a string, disregarding the ARIA role hierarchy. For example, asserting a superclass role `"checkbox"` on an element with a subclass role `"switch"` will fail.
|
|
579
|
+
#
|
|
580
|
+
# **Usage**
|
|
581
|
+
#
|
|
582
|
+
# ```python sync
|
|
583
|
+
# locator = page.get_by_test_id("save-button")
|
|
584
|
+
# expect(locator).to_have_role("button")
|
|
585
|
+
# ```
|
|
586
|
+
def to_have_role(role, timeout: nil)
|
|
587
|
+
wrap_impl(@impl.to_have_role(unwrap_impl(role), timeout: unwrap_impl(timeout)))
|
|
588
|
+
end
|
|
589
|
+
|
|
590
|
+
#
|
|
591
|
+
# Ensures the `Locator` points to an element with the given text. All nested elements will be considered when computing the text content of the element. You can use regular expressions for the value as well.
|
|
592
|
+
#
|
|
593
|
+
# **Details**
|
|
594
|
+
#
|
|
595
|
+
# When `expected` parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual text and
|
|
596
|
+
# in the expected string before matching. When regular expression is used, the actual text is matched as is.
|
|
597
|
+
#
|
|
598
|
+
# **Usage**
|
|
599
|
+
#
|
|
600
|
+
# ```python sync
|
|
601
|
+
# import re
|
|
602
|
+
# from playwright.sync_api import expect
|
|
603
|
+
#
|
|
604
|
+
# locator = page.locator(".title")
|
|
605
|
+
# expect(locator).to_have_text(re.compile(r"Welcome, Test User"))
|
|
606
|
+
# expect(locator).to_have_text(re.compile(r"Welcome, .*"))
|
|
607
|
+
# ```
|
|
608
|
+
#
|
|
609
|
+
# If you pass an array as an expected value, the expectations are:
|
|
610
|
+
# 1. Locator resolves to a list of elements.
|
|
611
|
+
# 1. The number of elements equals the number of expected values in the array.
|
|
612
|
+
# 1. Elements from the list have text matching expected array values, one by one, in order.
|
|
613
|
+
#
|
|
614
|
+
# For example, consider the following list:
|
|
615
|
+
#
|
|
616
|
+
# ```html
|
|
617
|
+
# <ul>
|
|
618
|
+
# <li>Text 1</li>
|
|
619
|
+
# <li>Text 2</li>
|
|
620
|
+
# <li>Text 3</li>
|
|
621
|
+
# </ul>
|
|
622
|
+
# ```
|
|
623
|
+
#
|
|
624
|
+
# Let's see how we can use the assertion:
|
|
625
|
+
#
|
|
626
|
+
# ```python sync
|
|
627
|
+
# from playwright.sync_api import expect
|
|
628
|
+
#
|
|
629
|
+
# # ✓ Has the right items in the right order
|
|
630
|
+
# expect(page.locator("ul > li")).to_have_text(["Text 1", "Text 2", "Text 3"])
|
|
631
|
+
#
|
|
632
|
+
# # ✖ Wrong order
|
|
633
|
+
# expect(page.locator("ul > li")).to_have_text(["Text 3", "Text 2", "Text 1"])
|
|
634
|
+
#
|
|
635
|
+
# # ✖ Last item does not match
|
|
636
|
+
# expect(page.locator("ul > li")).to_have_text(["Text 1", "Text 2", "Text"])
|
|
637
|
+
#
|
|
638
|
+
# # ✖ Locator points to the outer list element, not to the list items
|
|
639
|
+
# expect(page.locator("ul")).to_have_text(["Text 1", "Text 2", "Text 3"])
|
|
640
|
+
# ```
|
|
641
|
+
def to_have_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
|
|
642
|
+
wrap_impl(@impl.to_have_text(unwrap_impl(expected), ignoreCase: unwrap_impl(ignoreCase), timeout: unwrap_impl(timeout), useInnerText: unwrap_impl(useInnerText)))
|
|
643
|
+
end
|
|
644
|
+
|
|
645
|
+
#
|
|
646
|
+
# Ensures the `Locator` points to an element with the given input value. You can use regular expressions for the value as well.
|
|
647
|
+
#
|
|
648
|
+
# **Usage**
|
|
649
|
+
#
|
|
650
|
+
# ```python sync
|
|
651
|
+
# import re
|
|
652
|
+
# from playwright.sync_api import expect
|
|
653
|
+
#
|
|
654
|
+
# locator = page.locator("input[type=number]")
|
|
655
|
+
# expect(locator).to_have_value(re.compile(r"[0-9]"))
|
|
656
|
+
# ```
|
|
657
|
+
def to_have_value(value, timeout: nil)
|
|
658
|
+
wrap_impl(@impl.to_have_value(unwrap_impl(value), timeout: unwrap_impl(timeout)))
|
|
659
|
+
end
|
|
660
|
+
|
|
661
|
+
#
|
|
662
|
+
# Ensures the `Locator` points to multi-select/combobox (i.e. a `select` with the `multiple` attribute) and the specified values are selected.
|
|
663
|
+
#
|
|
664
|
+
# **Usage**
|
|
665
|
+
#
|
|
666
|
+
# For example, given the following element:
|
|
667
|
+
#
|
|
668
|
+
# ```html
|
|
669
|
+
# <select id="favorite-colors" multiple>
|
|
670
|
+
# <option value="R">Red</option>
|
|
671
|
+
# <option value="G">Green</option>
|
|
672
|
+
# <option value="B">Blue</option>
|
|
673
|
+
# </select>
|
|
674
|
+
# ```
|
|
675
|
+
#
|
|
676
|
+
# ```python sync
|
|
677
|
+
# import re
|
|
678
|
+
# from playwright.sync_api import expect
|
|
679
|
+
#
|
|
680
|
+
# locator = page.locator("id=favorite-colors")
|
|
681
|
+
# locator.select_option(["R", "G"])
|
|
682
|
+
# expect(locator).to_have_values([re.compile(r"R"), re.compile(r"G")])
|
|
683
|
+
# ```
|
|
684
|
+
def to_have_values(values, timeout: nil)
|
|
685
|
+
wrap_impl(@impl.to_have_values(unwrap_impl(values), timeout: unwrap_impl(timeout)))
|
|
686
|
+
end
|
|
687
|
+
|
|
688
|
+
#
|
|
689
|
+
# Asserts that the target element matches the given [accessibility snapshot](../aria-snapshots.md).
|
|
690
|
+
#
|
|
691
|
+
# **Usage**
|
|
692
|
+
#
|
|
693
|
+
# ```python sync
|
|
694
|
+
# page.goto("https://demo.playwright.dev/todomvc/")
|
|
695
|
+
# expect(page.locator('body')).to_match_aria_snapshot('''
|
|
696
|
+
# - heading "todos"
|
|
697
|
+
# - textbox "What needs to be done?"
|
|
698
|
+
# ''')
|
|
699
|
+
# ```
|
|
700
|
+
def to_match_aria_snapshot(expected, timeout: nil)
|
|
701
|
+
wrap_impl(@impl.to_match_aria_snapshot(unwrap_impl(expected), timeout: unwrap_impl(timeout)))
|
|
702
|
+
end
|
|
703
|
+
end
|
|
704
|
+
end
|