playwright-browserstack 1.62.0__py3-none-win_arm64.whl

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.
Files changed (192) hide show
  1. playwright/__init__.py +19 -0
  2. playwright/__main__.py +33 -0
  3. playwright/_impl/__init__.py +0 -0
  4. playwright/_impl/__pyinstaller/__init__.py +20 -0
  5. playwright/_impl/__pyinstaller/hook-playwright.async_api.py +17 -0
  6. playwright/_impl/__pyinstaller/hook-playwright.sync_api.py +17 -0
  7. playwright/_impl/_android.py +704 -0
  8. playwright/_impl/_api_structures.py +365 -0
  9. playwright/_impl/_artifact.py +87 -0
  10. playwright/_impl/_assertions.py +1124 -0
  11. playwright/_impl/_async_base.py +105 -0
  12. playwright/_impl/_browser.py +293 -0
  13. playwright/_impl/_browser_context.py +754 -0
  14. playwright/_impl/_browser_type.py +368 -0
  15. playwright/_impl/_cdp_session.py +46 -0
  16. playwright/_impl/_clock.py +104 -0
  17. playwright/_impl/_connection.py +764 -0
  18. playwright/_impl/_console_message.py +98 -0
  19. playwright/_impl/_credentials.py +57 -0
  20. playwright/_impl/_debugger.py +54 -0
  21. playwright/_impl/_dialog.py +63 -0
  22. playwright/_impl/_disposable.py +96 -0
  23. playwright/_impl/_download.py +64 -0
  24. playwright/_impl/_driver.py +41 -0
  25. playwright/_impl/_element_handle.py +480 -0
  26. playwright/_impl/_errors.py +64 -0
  27. playwright/_impl/_event_context_manager.py +33 -0
  28. playwright/_impl/_fetch.py +626 -0
  29. playwright/_impl/_file_chooser.py +57 -0
  30. playwright/_impl/_form_data.py +34 -0
  31. playwright/_impl/_frame.py +985 -0
  32. playwright/_impl/_glob.py +65 -0
  33. playwright/_impl/_greenlets.py +49 -0
  34. playwright/_impl/_har_router.py +122 -0
  35. playwright/_impl/_helper.py +601 -0
  36. playwright/_impl/_impl_to_api_mapping.py +158 -0
  37. playwright/_impl/_input.py +111 -0
  38. playwright/_impl/_js_handle.py +336 -0
  39. playwright/_impl/_json_pipe.py +97 -0
  40. playwright/_impl/_local_utils.py +95 -0
  41. playwright/_impl/_locator.py +1024 -0
  42. playwright/_impl/_map.py +31 -0
  43. playwright/_impl/_network.py +1017 -0
  44. playwright/_impl/_object_factory.py +116 -0
  45. playwright/_impl/_page.py +1637 -0
  46. playwright/_impl/_path_utils.py +27 -0
  47. playwright/_impl/_playwright.py +68 -0
  48. playwright/_impl/_screencast.py +177 -0
  49. playwright/_impl/_selectors.py +67 -0
  50. playwright/_impl/_set_input_files_helpers.py +158 -0
  51. playwright/_impl/_str_utils.py +76 -0
  52. playwright/_impl/_stream.py +46 -0
  53. playwright/_impl/_sync_base.py +151 -0
  54. playwright/_impl/_tracing.py +281 -0
  55. playwright/_impl/_transport.py +184 -0
  56. playwright/_impl/_video.py +56 -0
  57. playwright/_impl/_waiter.py +197 -0
  58. playwright/_impl/_web_error.py +48 -0
  59. playwright/_impl/_web_storage.py +58 -0
  60. playwright/_impl/_writable_stream.py +42 -0
  61. playwright/_repo_version.py +24 -0
  62. playwright/async_api/__init__.py +275 -0
  63. playwright/async_api/_android_generated.py +462 -0
  64. playwright/async_api/_context_manager.py +57 -0
  65. playwright/async_api/_generated.py +23875 -0
  66. playwright/driver/LICENSE +2946 -0
  67. playwright/driver/README.md +1 -0
  68. playwright/driver/node.exe +0 -0
  69. playwright/driver/package/LICENSE +202 -0
  70. playwright/driver/package/NOTICE +5 -0
  71. playwright/driver/package/README.md +3 -0
  72. playwright/driver/package/ThirdPartyNotices.txt +13 -0
  73. playwright/driver/package/bin/install_media_pack.ps1 +5 -0
  74. playwright/driver/package/bin/install_webkit_wsl.ps1 +33 -0
  75. playwright/driver/package/bin/reinstall_chrome_beta_linux.sh +42 -0
  76. playwright/driver/package/bin/reinstall_chrome_beta_mac.sh +13 -0
  77. playwright/driver/package/bin/reinstall_chrome_beta_win.ps1 +24 -0
  78. playwright/driver/package/bin/reinstall_chrome_stable_linux.sh +42 -0
  79. playwright/driver/package/bin/reinstall_chrome_stable_mac.sh +12 -0
  80. playwright/driver/package/bin/reinstall_chrome_stable_win.ps1 +24 -0
  81. playwright/driver/package/bin/reinstall_msedge_beta_linux.sh +48 -0
  82. playwright/driver/package/bin/reinstall_msedge_beta_mac.sh +11 -0
  83. playwright/driver/package/bin/reinstall_msedge_beta_win.ps1 +23 -0
  84. playwright/driver/package/bin/reinstall_msedge_dev_linux.sh +48 -0
  85. playwright/driver/package/bin/reinstall_msedge_dev_mac.sh +11 -0
  86. playwright/driver/package/bin/reinstall_msedge_dev_win.ps1 +23 -0
  87. playwright/driver/package/bin/reinstall_msedge_stable_linux.sh +48 -0
  88. playwright/driver/package/bin/reinstall_msedge_stable_mac.sh +11 -0
  89. playwright/driver/package/bin/reinstall_msedge_stable_win.ps1 +24 -0
  90. playwright/driver/package/browsers.json +75 -0
  91. playwright/driver/package/cli.js +21 -0
  92. playwright/driver/package/index.d.ts +17 -0
  93. playwright/driver/package/index.js +17 -0
  94. playwright/driver/package/index.mjs +28 -0
  95. playwright/driver/package/lib/bootstrap.js +88 -0
  96. playwright/driver/package/lib/coreBundle.js +74830 -0
  97. playwright/driver/package/lib/entry/cliDaemon.js +5 -0
  98. playwright/driver/package/lib/entry/dashboardApp.js +3 -0
  99. playwright/driver/package/lib/entry/mcp.js +10 -0
  100. playwright/driver/package/lib/entry/oopBrowserDownload.js +3 -0
  101. playwright/driver/package/lib/package.js +50 -0
  102. playwright/driver/package/lib/server/chromium/appIcon.png +0 -0
  103. playwright/driver/package/lib/server/electron/loader.js +118 -0
  104. playwright/driver/package/lib/serverRegistry.js +7347 -0
  105. playwright/driver/package/lib/serverRegistry.js.LICENSE +354 -0
  106. playwright/driver/package/lib/tools/cli-client/channelSessions.js +141 -0
  107. playwright/driver/package/lib/tools/cli-client/cli.js +6 -0
  108. playwright/driver/package/lib/tools/cli-client/help.json +708 -0
  109. playwright/driver/package/lib/tools/cli-client/minimist.js +128 -0
  110. playwright/driver/package/lib/tools/cli-client/output.js +343 -0
  111. playwright/driver/package/lib/tools/cli-client/program.js +404 -0
  112. playwright/driver/package/lib/tools/cli-client/registry.js +176 -0
  113. playwright/driver/package/lib/tools/cli-client/session.js +258 -0
  114. playwright/driver/package/lib/tools/dashboard/appIcon.png +0 -0
  115. playwright/driver/package/lib/tools/skills/playwright-cli/SKILL.md +420 -0
  116. playwright/driver/package/lib/tools/skills/playwright-cli/references/element-attributes.md +23 -0
  117. playwright/driver/package/lib/tools/skills/playwright-cli/references/playwright-tests.md +39 -0
  118. playwright/driver/package/lib/tools/skills/playwright-cli/references/request-mocking.md +87 -0
  119. playwright/driver/package/lib/tools/skills/playwright-cli/references/running-code.md +241 -0
  120. playwright/driver/package/lib/tools/skills/playwright-cli/references/session-management.md +225 -0
  121. playwright/driver/package/lib/tools/skills/playwright-cli/references/storage-state.md +275 -0
  122. playwright/driver/package/lib/tools/skills/playwright-cli/references/test-generation.md +433 -0
  123. playwright/driver/package/lib/tools/skills/playwright-cli/references/tracing.md +139 -0
  124. playwright/driver/package/lib/tools/skills/playwright-cli/references/video-recording.md +143 -0
  125. playwright/driver/package/lib/tools/skills/playwright-component-testing/SKILL.md +143 -0
  126. playwright/driver/package/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +144 -0
  127. playwright/driver/package/lib/tools/skills/playwright-component-testing/references/migration.md +85 -0
  128. playwright/driver/package/lib/tools/skills/playwright-component-testing/references/react.md +67 -0
  129. playwright/driver/package/lib/tools/skills/playwright-component-testing/references/vue.md +75 -0
  130. playwright/driver/package/lib/tools/skills/playwright-trace/SKILL.md +171 -0
  131. playwright/driver/package/lib/tools/utils/extension.js +101 -0
  132. playwright/driver/package/lib/tools/utils/socketConnection.js +108 -0
  133. playwright/driver/package/lib/utilsBundle.js +90764 -0
  134. playwright/driver/package/lib/utilsBundle.js.LICENSE +2179 -0
  135. playwright/driver/package/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
  136. playwright/driver/package/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
  137. playwright/driver/package/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
  138. playwright/driver/package/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
  139. playwright/driver/package/lib/vite/dashboard/assets/index-CyWAfh-p.js +11 -0
  140. playwright/driver/package/lib/vite/dashboard/assets/index-DhC616m4.css +1 -0
  141. playwright/driver/package/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
  142. playwright/driver/package/lib/vite/dashboard/index.html +29 -0
  143. playwright/driver/package/lib/vite/dashboard/playwright-logo.svg +24 -0
  144. playwright/driver/package/lib/vite/htmlReport/index.html +16 -0
  145. playwright/driver/package/lib/vite/htmlReport/report.css +2 -0
  146. playwright/driver/package/lib/vite/htmlReport/report.js +32 -0
  147. playwright/driver/package/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
  148. playwright/driver/package/lib/vite/recorder/assets/codeMirrorModule-CwYYHbcZ.js +32 -0
  149. playwright/driver/package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
  150. playwright/driver/package/lib/vite/recorder/assets/index-DYjdXIbE.js +129 -0
  151. playwright/driver/package/lib/vite/recorder/assets/index-l_lX622x.css +1 -0
  152. playwright/driver/package/lib/vite/recorder/index.html +29 -0
  153. playwright/driver/package/lib/vite/recorder/playwright-logo.svg +9 -0
  154. playwright/driver/package/lib/vite/traceViewer/assets/codeMirrorModule-By56iMx7.js +32 -0
  155. playwright/driver/package/lib/vite/traceViewer/assets/defaultSettingsView-B34OrIms.js +181 -0
  156. playwright/driver/package/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
  157. playwright/driver/package/lib/vite/traceViewer/assets/xtermModule-COQkjINf.js +7 -0
  158. playwright/driver/package/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
  159. playwright/driver/package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
  160. playwright/driver/package/lib/vite/traceViewer/defaultSettingsView.BLFoOugd.css +1 -0
  161. playwright/driver/package/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
  162. playwright/driver/package/lib/vite/traceViewer/index.Dl36UVQT.js +1 -0
  163. playwright/driver/package/lib/vite/traceViewer/index.html +44 -0
  164. playwright/driver/package/lib/vite/traceViewer/manifest.webmanifest +16 -0
  165. playwright/driver/package/lib/vite/traceViewer/playwright-logo.svg +9 -0
  166. playwright/driver/package/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
  167. playwright/driver/package/lib/vite/traceViewer/snapshot.html +10 -0
  168. playwright/driver/package/lib/vite/traceViewer/sw.bundle.js +4 -0
  169. playwright/driver/package/lib/vite/traceViewer/uiMode.C7UW1sC9.css +1 -0
  170. playwright/driver/package/lib/vite/traceViewer/uiMode.D962mr9b.js +5 -0
  171. playwright/driver/package/lib/vite/traceViewer/uiMode.html +18 -0
  172. playwright/driver/package/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
  173. playwright/driver/package/lib/webp_codec.LICENSE +173 -0
  174. playwright/driver/package/lib/webp_codec.wasm +0 -0
  175. playwright/driver/package/lib/xdg-open +1267 -0
  176. playwright/driver/package/package.json +34 -0
  177. playwright/driver/package/types/protocol.d.ts +24842 -0
  178. playwright/driver/package/types/structs.d.ts +47 -0
  179. playwright/driver/package/types/types.d.ts +26188 -0
  180. playwright/py.typed +0 -0
  181. playwright/sync_api/__init__.py +275 -0
  182. playwright/sync_api/_android_generated.py +494 -0
  183. playwright/sync_api/_context_manager.py +98 -0
  184. playwright/sync_api/_generated.py +24045 -0
  185. playwright_browserstack-1.62.0.dist-info/METADATA +82 -0
  186. playwright_browserstack-1.62.0.dist-info/RECORD +192 -0
  187. playwright_browserstack-1.62.0.dist-info/WHEEL +5 -0
  188. playwright_browserstack-1.62.0.dist-info/entry_points.txt +5 -0
  189. playwright_browserstack-1.62.0.dist-info/licenses/LICENSE +202 -0
  190. playwright_browserstack-1.62.0.dist-info/licenses/LICENSE.txt +51 -0
  191. playwright_browserstack-1.62.0.dist-info/licenses/NOTICE +18 -0
  192. playwright_browserstack-1.62.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1124 @@
1
+ # Copyright (c) Microsoft Corporation.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import collections.abc
16
+ from contextlib import contextmanager
17
+ from typing import Any, Iterator, List, Literal, Optional, Pattern, Sequence, Union
18
+ from urllib.parse import urljoin
19
+
20
+ from playwright._impl._api_structures import (
21
+ AriaRole,
22
+ ExpectedTextValue,
23
+ FrameExpectOptions,
24
+ FrameExpectResult,
25
+ )
26
+ from playwright._impl._connection import format_call_log
27
+ from playwright._impl._errors import Error
28
+ from playwright._impl._fetch import APIResponse
29
+ from playwright._impl._helper import is_textual_mime_type
30
+ from playwright._impl._js_handle import parse_value
31
+ from playwright._impl._locator import Locator
32
+ from playwright._impl._page import Page
33
+ from playwright._impl._str_utils import escape_regex_flags
34
+
35
+ _soft_errors: Optional[List[AssertionError]] = None
36
+
37
+
38
+ @contextmanager
39
+ def _soft_scope() -> Iterator[List[AssertionError]]:
40
+ global _soft_errors
41
+ assert _soft_errors is None, "nested soft assertion scopes are not supported"
42
+ _soft_errors = []
43
+ try:
44
+ yield _soft_errors
45
+ finally:
46
+ _soft_errors = None
47
+
48
+
49
+ def _record_soft_or_raise(error: AssertionError, is_soft: bool) -> None:
50
+ __tracebackhide__ = True
51
+ if is_soft:
52
+ if _soft_errors is None:
53
+ raise RuntimeError(
54
+ "expect.soft(...) requires pytest-playwright>=0.7.3 "
55
+ "(or pytest-playwright-asyncio>=0.7.3). Upgrade the plugin, "
56
+ "or use a regular expect(...) assertion."
57
+ )
58
+ _soft_errors.append(error)
59
+ return
60
+ raise error
61
+
62
+
63
+ class AssertionsBase:
64
+ def __init__(
65
+ self,
66
+ locator: Locator,
67
+ timeout: float = None,
68
+ is_not: bool = False,
69
+ message: Optional[str] = None,
70
+ is_soft: bool = False,
71
+ ) -> None:
72
+ self._actual_locator = locator
73
+ self._loop = locator._loop
74
+ self._dispatcher_fiber = locator._dispatcher_fiber
75
+ self._timeout = timeout
76
+ self._is_not = is_not
77
+ self._custom_message = message
78
+ self._is_soft = is_soft
79
+
80
+ async def _call_expect(
81
+ self, expression: str, expect_options: FrameExpectOptions, title: Optional[str]
82
+ ) -> FrameExpectResult:
83
+ raise NotImplementedError(
84
+ "_call_expect must be implemented in a derived class."
85
+ )
86
+
87
+ async def _expect_impl(
88
+ self,
89
+ expression: str,
90
+ expect_options: FrameExpectOptions,
91
+ expected: Any,
92
+ message: str,
93
+ title: str = None,
94
+ ) -> None:
95
+ __tracebackhide__ = True
96
+ expect_options["isNot"] = self._is_not
97
+ if expect_options.get("timeout") is None:
98
+ expect_options["timeout"] = self._timeout or 5_000
99
+ if expect_options["isNot"]:
100
+ message = message.replace("expected to", "expected not to")
101
+ if title:
102
+ title = title.replace('"to_', '"not_to_')
103
+ if "useInnerText" in expect_options and expect_options["useInnerText"] is None:
104
+ del expect_options["useInnerText"]
105
+ result = await self._call_expect(expression, expect_options, title)
106
+ if result["matches"] == self._is_not:
107
+ received = result.get("received") or {}
108
+ aria_snapshot = None
109
+ if isinstance(received, dict):
110
+ aria_snapshot = received.get("ariaSnapshot")
111
+ value = received.get("value")
112
+ actual = parse_value(value) if value is not None else None
113
+ else:
114
+ actual = received
115
+ if self._custom_message:
116
+ out_message = self._custom_message
117
+ if expected is not None:
118
+ out_message += f"\nExpected value: '{expected or '<None>'}'"
119
+ else:
120
+ out_message = (
121
+ f"{message} '{expected}'" if expected is not None else f"{message}"
122
+ )
123
+ error_message = result.get("errorMessage")
124
+ error_message = f"\n{error_message}" if error_message else ""
125
+ aria_snapshot_message = (
126
+ f"\nAria snapshot:\n{aria_snapshot}" if aria_snapshot else ""
127
+ )
128
+ _record_soft_or_raise(
129
+ AssertionError(
130
+ f"{out_message}\nActual value: {actual}{error_message} {format_call_log(result.get('log'))}{aria_snapshot_message}"
131
+ ),
132
+ self._is_soft,
133
+ )
134
+
135
+
136
+ class PageAssertions(AssertionsBase):
137
+ def __init__(
138
+ self,
139
+ page: Page,
140
+ timeout: float = None,
141
+ is_not: bool = False,
142
+ message: Optional[str] = None,
143
+ is_soft: bool = False,
144
+ ) -> None:
145
+ super().__init__(page.locator(":root"), timeout, is_not, message, is_soft)
146
+ self._actual_page = page
147
+
148
+ async def _call_expect(
149
+ self, expression: str, expect_options: FrameExpectOptions, title: Optional[str]
150
+ ) -> FrameExpectResult:
151
+ __tracebackhide__ = True
152
+ return await self._actual_page.main_frame._expect(
153
+ None, expression, expect_options, title
154
+ )
155
+
156
+ @property
157
+ def _not(self) -> "PageAssertions":
158
+ return PageAssertions(
159
+ self._actual_page,
160
+ self._timeout,
161
+ not self._is_not,
162
+ self._custom_message,
163
+ self._is_soft,
164
+ )
165
+
166
+ async def to_have_title(
167
+ self, titleOrRegExp: Union[Pattern[str], str], timeout: float = None
168
+ ) -> None:
169
+ __tracebackhide__ = True
170
+ expected_values = to_expected_text_values(
171
+ [titleOrRegExp], normalize_white_space=True
172
+ )
173
+ await self._expect_impl(
174
+ "to.have.title",
175
+ FrameExpectOptions(expectedText=expected_values, timeout=timeout),
176
+ titleOrRegExp,
177
+ "Page title expected to be",
178
+ 'Expect "to_have_title"',
179
+ )
180
+
181
+ async def not_to_have_title(
182
+ self, titleOrRegExp: Union[Pattern[str], str], timeout: float = None
183
+ ) -> None:
184
+ __tracebackhide__ = True
185
+ await self._not.to_have_title(titleOrRegExp, timeout)
186
+
187
+ async def to_have_url(
188
+ self,
189
+ urlOrRegExp: Union[str, Pattern[str]],
190
+ timeout: float = None,
191
+ ignoreCase: bool = None,
192
+ ) -> None:
193
+ __tracebackhide__ = True
194
+ base_url = self._actual_page.context._base_url
195
+ if isinstance(urlOrRegExp, str) and base_url:
196
+ urlOrRegExp = urljoin(base_url, urlOrRegExp)
197
+ expected_text = to_expected_text_values([urlOrRegExp], ignoreCase=ignoreCase)
198
+ await self._expect_impl(
199
+ "to.have.url",
200
+ FrameExpectOptions(expectedText=expected_text, timeout=timeout),
201
+ urlOrRegExp,
202
+ "Page URL expected to be",
203
+ 'Expect "to_have_url"',
204
+ )
205
+
206
+ async def not_to_have_url(
207
+ self,
208
+ urlOrRegExp: Union[Pattern[str], str],
209
+ timeout: float = None,
210
+ ignoreCase: bool = None,
211
+ ) -> None:
212
+ __tracebackhide__ = True
213
+ await self._not.to_have_url(urlOrRegExp, timeout, ignoreCase)
214
+
215
+ async def to_match_aria_snapshot(
216
+ self, expected: str, timeout: float = None
217
+ ) -> None:
218
+ __tracebackhide__ = True
219
+ await self._expect_impl(
220
+ "to.match.aria",
221
+ FrameExpectOptions(expectedValue=expected, timeout=timeout),
222
+ expected,
223
+ "Page expected to match Aria snapshot",
224
+ 'Expect "to_match_aria_snapshot"',
225
+ )
226
+
227
+ async def not_to_match_aria_snapshot(
228
+ self, expected: str, timeout: float = None
229
+ ) -> None:
230
+ __tracebackhide__ = True
231
+ await self._not.to_match_aria_snapshot(expected, timeout)
232
+
233
+
234
+ class LocatorAssertions(AssertionsBase):
235
+ def __init__(
236
+ self,
237
+ locator: Locator,
238
+ timeout: float = None,
239
+ is_not: bool = False,
240
+ message: Optional[str] = None,
241
+ is_soft: bool = False,
242
+ ) -> None:
243
+ super().__init__(locator, timeout, is_not, message, is_soft)
244
+ self._actual_locator = locator
245
+
246
+ async def _call_expect(
247
+ self, expression: str, expect_options: FrameExpectOptions, title: Optional[str]
248
+ ) -> FrameExpectResult:
249
+ __tracebackhide__ = True
250
+ return await self._actual_locator._expect(expression, expect_options, title)
251
+
252
+ @property
253
+ def _not(self) -> "LocatorAssertions":
254
+ return LocatorAssertions(
255
+ self._actual_locator,
256
+ self._timeout,
257
+ not self._is_not,
258
+ self._custom_message,
259
+ self._is_soft,
260
+ )
261
+
262
+ async def to_contain_text(
263
+ self,
264
+ expected: Union[
265
+ Sequence[str],
266
+ Sequence[Pattern[str]],
267
+ Sequence[Union[Pattern[str], str]],
268
+ Pattern[str],
269
+ str,
270
+ ],
271
+ useInnerText: bool = None,
272
+ timeout: float = None,
273
+ ignoreCase: bool = None,
274
+ ) -> None:
275
+ __tracebackhide__ = True
276
+ if isinstance(expected, collections.abc.Sequence) and not isinstance(
277
+ expected, str
278
+ ):
279
+ expected_text = to_expected_text_values(
280
+ expected,
281
+ match_substring=True,
282
+ normalize_white_space=True,
283
+ ignoreCase=ignoreCase,
284
+ )
285
+ await self._expect_impl(
286
+ "to.contain.text.array",
287
+ FrameExpectOptions(
288
+ expectedText=expected_text,
289
+ useInnerText=useInnerText,
290
+ timeout=timeout,
291
+ ),
292
+ expected,
293
+ "Locator expected to contain text",
294
+ 'Expect "to_contain_text"',
295
+ )
296
+ else:
297
+ expected_text = to_expected_text_values(
298
+ [expected],
299
+ match_substring=True,
300
+ normalize_white_space=True,
301
+ ignoreCase=ignoreCase,
302
+ )
303
+ await self._expect_impl(
304
+ "to.have.text",
305
+ FrameExpectOptions(
306
+ expectedText=expected_text,
307
+ useInnerText=useInnerText,
308
+ timeout=timeout,
309
+ ),
310
+ expected,
311
+ "Locator expected to contain text",
312
+ 'Expect "to_contain_text"',
313
+ )
314
+
315
+ async def not_to_contain_text(
316
+ self,
317
+ expected: Union[
318
+ Sequence[str],
319
+ Sequence[Pattern[str]],
320
+ Sequence[Union[Pattern[str], str]],
321
+ Pattern[str],
322
+ str,
323
+ ],
324
+ useInnerText: bool = None,
325
+ timeout: float = None,
326
+ ignoreCase: bool = None,
327
+ ) -> None:
328
+ __tracebackhide__ = True
329
+ await self._not.to_contain_text(expected, useInnerText, timeout, ignoreCase)
330
+
331
+ async def to_have_attribute(
332
+ self,
333
+ name: str,
334
+ value: Union[Pattern[str], str] = None,
335
+ ignoreCase: bool = None,
336
+ timeout: float = None,
337
+ ) -> None:
338
+ __tracebackhide__ = True
339
+ if value is None:
340
+ await self._expect_impl(
341
+ "to.have.attribute",
342
+ FrameExpectOptions(expressionArg=name, timeout=timeout),
343
+ None,
344
+ "Locator expected to have attribute",
345
+ 'Expect "to_have_attribute"',
346
+ )
347
+ return
348
+ expected_text = to_expected_text_values([value], ignoreCase=ignoreCase)
349
+ await self._expect_impl(
350
+ "to.have.attribute.value",
351
+ FrameExpectOptions(
352
+ expressionArg=name, expectedText=expected_text, timeout=timeout
353
+ ),
354
+ value,
355
+ "Locator expected to have attribute",
356
+ 'Expect "to_have_attribute"',
357
+ )
358
+
359
+ async def not_to_have_attribute(
360
+ self,
361
+ name: str,
362
+ value: Union[Pattern[str], str] = None,
363
+ ignoreCase: bool = None,
364
+ timeout: float = None,
365
+ ) -> None:
366
+ __tracebackhide__ = True
367
+ await self._not.to_have_attribute(
368
+ name, value, ignoreCase=ignoreCase, timeout=timeout
369
+ )
370
+
371
+ async def to_have_class(
372
+ self,
373
+ expected: Union[
374
+ Sequence[str],
375
+ Sequence[Pattern[str]],
376
+ Sequence[Union[Pattern[str], str]],
377
+ Pattern[str],
378
+ str,
379
+ ],
380
+ timeout: float = None,
381
+ ) -> None:
382
+ __tracebackhide__ = True
383
+ if isinstance(expected, collections.abc.Sequence) and not isinstance(
384
+ expected, str
385
+ ):
386
+ expected_text = to_expected_text_values(expected)
387
+ await self._expect_impl(
388
+ "to.have.class.array",
389
+ FrameExpectOptions(expectedText=expected_text, timeout=timeout),
390
+ expected,
391
+ "Locator expected to have class",
392
+ 'Expect "to_have_class"',
393
+ )
394
+ else:
395
+ expected_text = to_expected_text_values([expected])
396
+ await self._expect_impl(
397
+ "to.have.class",
398
+ FrameExpectOptions(expectedText=expected_text, timeout=timeout),
399
+ expected,
400
+ "Locator expected to have class",
401
+ 'Expect "to_have_class"',
402
+ )
403
+
404
+ async def not_to_have_class(
405
+ self,
406
+ expected: Union[
407
+ Sequence[str],
408
+ Sequence[Pattern[str]],
409
+ Sequence[Union[Pattern[str], str]],
410
+ Pattern[str],
411
+ str,
412
+ ],
413
+ timeout: float = None,
414
+ ) -> None:
415
+ __tracebackhide__ = True
416
+ await self._not.to_have_class(expected, timeout)
417
+
418
+ async def to_contain_class(
419
+ self,
420
+ expected: Union[
421
+ Sequence[str],
422
+ str,
423
+ ],
424
+ timeout: float = None,
425
+ ) -> None:
426
+ __tracebackhide__ = True
427
+ if isinstance(expected, collections.abc.Sequence) and not isinstance(
428
+ expected, str
429
+ ):
430
+ expected_text = to_expected_text_values(expected)
431
+ await self._expect_impl(
432
+ "to.contain.class.array",
433
+ FrameExpectOptions(expectedText=expected_text, timeout=timeout),
434
+ expected,
435
+ "Locator expected to contain class names",
436
+ 'Expect "to_contain_class"',
437
+ )
438
+ else:
439
+ expected_text = to_expected_text_values([expected])
440
+ await self._expect_impl(
441
+ "to.contain.class",
442
+ FrameExpectOptions(expectedText=expected_text, timeout=timeout),
443
+ expected,
444
+ "Locator expected to contain class",
445
+ 'Expect "to_contain_class"',
446
+ )
447
+
448
+ async def not_to_contain_class(
449
+ self,
450
+ expected: Union[
451
+ Sequence[str],
452
+ str,
453
+ ],
454
+ timeout: float = None,
455
+ ) -> None:
456
+ __tracebackhide__ = True
457
+ await self._not.to_contain_class(expected, timeout)
458
+
459
+ async def to_have_count(
460
+ self,
461
+ count: int,
462
+ timeout: float = None,
463
+ ) -> None:
464
+ __tracebackhide__ = True
465
+ await self._expect_impl(
466
+ "to.have.count",
467
+ FrameExpectOptions(expectedNumber=count, timeout=timeout),
468
+ count,
469
+ "Locator expected to have count",
470
+ 'Expect "to_have_count"',
471
+ )
472
+
473
+ async def not_to_have_count(
474
+ self,
475
+ count: int,
476
+ timeout: float = None,
477
+ ) -> None:
478
+ __tracebackhide__ = True
479
+ await self._not.to_have_count(count, timeout)
480
+
481
+ async def to_have_css(
482
+ self,
483
+ name: str,
484
+ value: Union[str, Pattern[str]],
485
+ timeout: float = None,
486
+ pseudo: Literal["after", "before"] = None,
487
+ ) -> None:
488
+ __tracebackhide__ = True
489
+ expected_text = to_expected_text_values([value])
490
+ await self._expect_impl(
491
+ "to.have.css",
492
+ FrameExpectOptions(
493
+ expressionArg=name,
494
+ expectedText=expected_text,
495
+ timeout=timeout,
496
+ pseudo=pseudo,
497
+ ),
498
+ value,
499
+ "Locator expected to have CSS",
500
+ 'Expect "to_have_css"',
501
+ )
502
+
503
+ async def not_to_have_css(
504
+ self,
505
+ name: str,
506
+ value: Union[str, Pattern[str]],
507
+ timeout: float = None,
508
+ ) -> None:
509
+ __tracebackhide__ = True
510
+ await self._not.to_have_css(name, value, timeout)
511
+
512
+ async def to_have_id(
513
+ self,
514
+ id: Union[str, Pattern[str]],
515
+ timeout: float = None,
516
+ ) -> None:
517
+ __tracebackhide__ = True
518
+ expected_text = to_expected_text_values([id])
519
+ await self._expect_impl(
520
+ "to.have.id",
521
+ FrameExpectOptions(expectedText=expected_text, timeout=timeout),
522
+ id,
523
+ "Locator expected to have ID",
524
+ 'Expect "to_have_id"',
525
+ )
526
+
527
+ async def not_to_have_id(
528
+ self,
529
+ id: Union[str, Pattern[str]],
530
+ timeout: float = None,
531
+ ) -> None:
532
+ __tracebackhide__ = True
533
+ await self._not.to_have_id(id, timeout)
534
+
535
+ async def to_have_js_property(
536
+ self,
537
+ name: str,
538
+ value: Any,
539
+ timeout: float = None,
540
+ ) -> None:
541
+ __tracebackhide__ = True
542
+ await self._expect_impl(
543
+ "to.have.property",
544
+ FrameExpectOptions(
545
+ expressionArg=name, expectedValue=value, timeout=timeout
546
+ ),
547
+ value,
548
+ "Locator expected to have JS Property",
549
+ 'Expect "to_have_property"',
550
+ )
551
+
552
+ async def not_to_have_js_property(
553
+ self,
554
+ name: str,
555
+ value: Any,
556
+ timeout: float = None,
557
+ ) -> None:
558
+ __tracebackhide__ = True
559
+ await self._not.to_have_js_property(name, value, timeout)
560
+
561
+ async def to_have_value(
562
+ self,
563
+ value: Union[str, Pattern[str]],
564
+ timeout: float = None,
565
+ ) -> None:
566
+ __tracebackhide__ = True
567
+ expected_text = to_expected_text_values([value])
568
+ await self._expect_impl(
569
+ "to.have.value",
570
+ FrameExpectOptions(expectedText=expected_text, timeout=timeout),
571
+ value,
572
+ "Locator expected to have Value",
573
+ 'Expect "to_have_value"',
574
+ )
575
+
576
+ async def not_to_have_value(
577
+ self,
578
+ value: Union[str, Pattern[str]],
579
+ timeout: float = None,
580
+ ) -> None:
581
+ __tracebackhide__ = True
582
+ await self._not.to_have_value(value, timeout)
583
+
584
+ async def to_have_values(
585
+ self,
586
+ values: Union[
587
+ Sequence[str], Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]]
588
+ ],
589
+ timeout: float = None,
590
+ ) -> None:
591
+ __tracebackhide__ = True
592
+ expected_text = to_expected_text_values(values)
593
+ await self._expect_impl(
594
+ "to.have.values",
595
+ FrameExpectOptions(expectedText=expected_text, timeout=timeout),
596
+ values,
597
+ "Locator expected to have Values",
598
+ 'Expect "to_have_values"',
599
+ )
600
+
601
+ async def not_to_have_values(
602
+ self,
603
+ values: Union[
604
+ Sequence[str], Sequence[Pattern[str]], Sequence[Union[Pattern[str], str]]
605
+ ],
606
+ timeout: float = None,
607
+ ) -> None:
608
+ __tracebackhide__ = True
609
+ await self._not.to_have_values(values, timeout)
610
+
611
+ async def to_have_text(
612
+ self,
613
+ expected: Union[
614
+ Sequence[str],
615
+ Sequence[Pattern[str]],
616
+ Sequence[Union[Pattern[str], str]],
617
+ Pattern[str],
618
+ str,
619
+ ],
620
+ useInnerText: bool = None,
621
+ timeout: float = None,
622
+ ignoreCase: bool = None,
623
+ ) -> None:
624
+ __tracebackhide__ = True
625
+ if isinstance(expected, collections.abc.Sequence) and not isinstance(
626
+ expected, str
627
+ ):
628
+ expected_text = to_expected_text_values(
629
+ expected,
630
+ normalize_white_space=True,
631
+ ignoreCase=ignoreCase,
632
+ )
633
+ await self._expect_impl(
634
+ "to.have.text.array",
635
+ FrameExpectOptions(
636
+ expectedText=expected_text,
637
+ useInnerText=useInnerText,
638
+ timeout=timeout,
639
+ ),
640
+ expected,
641
+ "Locator expected to have text",
642
+ 'Expect "to_have_text"',
643
+ )
644
+ else:
645
+ expected_text = to_expected_text_values(
646
+ [expected], normalize_white_space=True, ignoreCase=ignoreCase
647
+ )
648
+ await self._expect_impl(
649
+ "to.have.text",
650
+ FrameExpectOptions(
651
+ expectedText=expected_text,
652
+ useInnerText=useInnerText,
653
+ timeout=timeout,
654
+ ),
655
+ expected,
656
+ "Locator expected to have text",
657
+ 'Expect "to_have_text"',
658
+ )
659
+
660
+ async def not_to_have_text(
661
+ self,
662
+ expected: Union[
663
+ Sequence[str],
664
+ Sequence[Pattern[str]],
665
+ Sequence[Union[Pattern[str], str]],
666
+ Pattern[str],
667
+ str,
668
+ ],
669
+ useInnerText: bool = None,
670
+ timeout: float = None,
671
+ ignoreCase: bool = None,
672
+ ) -> None:
673
+ __tracebackhide__ = True
674
+ await self._not.to_have_text(expected, useInnerText, timeout, ignoreCase)
675
+
676
+ async def to_be_attached(
677
+ self,
678
+ attached: bool = None,
679
+ timeout: float = None,
680
+ ) -> None:
681
+ __tracebackhide__ = True
682
+ if attached is None:
683
+ attached = True
684
+ attached_string = "attached" if attached else "detached"
685
+ await self._expect_impl(
686
+ ("to.be.attached" if attached else "to.be.detached"),
687
+ FrameExpectOptions(timeout=timeout),
688
+ None,
689
+ f"Locator expected to be {attached_string}",
690
+ 'Expect "to_be_attached"',
691
+ )
692
+
693
+ async def to_be_checked(
694
+ self,
695
+ timeout: float = None,
696
+ checked: bool = None,
697
+ indeterminate: bool = None,
698
+ ) -> None:
699
+ __tracebackhide__ = True
700
+ expected_value = {}
701
+ if indeterminate is not None:
702
+ expected_value["indeterminate"] = indeterminate
703
+ if checked is not None:
704
+ expected_value["checked"] = checked
705
+ checked_string: str
706
+ if indeterminate:
707
+ checked_string = "indeterminate"
708
+ else:
709
+ checked_string = "unchecked" if checked is False else "checked"
710
+ await self._expect_impl(
711
+ "to.be.checked",
712
+ FrameExpectOptions(timeout=timeout, expectedValue=expected_value),
713
+ None,
714
+ f"Locator expected to be {checked_string}",
715
+ 'Expect "to_be_checked"',
716
+ )
717
+
718
+ async def not_to_be_attached(
719
+ self,
720
+ attached: bool = None,
721
+ timeout: float = None,
722
+ ) -> None:
723
+ __tracebackhide__ = True
724
+ await self._not.to_be_attached(attached=attached, timeout=timeout)
725
+
726
+ async def not_to_be_checked(
727
+ self,
728
+ timeout: float = None,
729
+ ) -> None:
730
+ __tracebackhide__ = True
731
+ await self._not.to_be_checked(timeout)
732
+
733
+ async def to_be_disabled(
734
+ self,
735
+ timeout: float = None,
736
+ ) -> None:
737
+ __tracebackhide__ = True
738
+ await self._expect_impl(
739
+ "to.be.disabled",
740
+ FrameExpectOptions(timeout=timeout),
741
+ None,
742
+ "Locator expected to be disabled",
743
+ 'Expect "to_be_disabled"',
744
+ )
745
+
746
+ async def not_to_be_disabled(
747
+ self,
748
+ timeout: float = None,
749
+ ) -> None:
750
+ __tracebackhide__ = True
751
+ await self._not.to_be_disabled(timeout)
752
+
753
+ async def to_be_editable(
754
+ self,
755
+ editable: bool = None,
756
+ timeout: float = None,
757
+ ) -> None:
758
+ __tracebackhide__ = True
759
+ if editable is None:
760
+ editable = True
761
+ editable_string = "editable" if editable else "readonly"
762
+ await self._expect_impl(
763
+ "to.be.editable" if editable else "to.be.readonly",
764
+ FrameExpectOptions(timeout=timeout),
765
+ None,
766
+ f"Locator expected to be {editable_string}",
767
+ 'Expect "to_be_editable"',
768
+ )
769
+
770
+ async def not_to_be_editable(
771
+ self,
772
+ editable: bool = None,
773
+ timeout: float = None,
774
+ ) -> None:
775
+ __tracebackhide__ = True
776
+ await self._not.to_be_editable(editable, timeout)
777
+
778
+ async def to_be_empty(
779
+ self,
780
+ timeout: float = None,
781
+ ) -> None:
782
+ __tracebackhide__ = True
783
+ await self._expect_impl(
784
+ "to.be.empty",
785
+ FrameExpectOptions(timeout=timeout),
786
+ None,
787
+ "Locator expected to be empty",
788
+ 'Expect "to_be_empty"',
789
+ )
790
+
791
+ async def not_to_be_empty(
792
+ self,
793
+ timeout: float = None,
794
+ ) -> None:
795
+ __tracebackhide__ = True
796
+ await self._not.to_be_empty(timeout)
797
+
798
+ async def to_be_enabled(
799
+ self,
800
+ enabled: bool = None,
801
+ timeout: float = None,
802
+ ) -> None:
803
+ __tracebackhide__ = True
804
+ if enabled is None:
805
+ enabled = True
806
+ enabled_string = "enabled" if enabled else "disabled"
807
+ await self._expect_impl(
808
+ "to.be.enabled" if enabled else "to.be.disabled",
809
+ FrameExpectOptions(timeout=timeout),
810
+ None,
811
+ f"Locator expected to be {enabled_string}",
812
+ 'Expect "to_be_enabled"',
813
+ )
814
+
815
+ async def not_to_be_enabled(
816
+ self,
817
+ enabled: bool = None,
818
+ timeout: float = None,
819
+ ) -> None:
820
+ __tracebackhide__ = True
821
+ await self._not.to_be_enabled(enabled, timeout)
822
+
823
+ async def to_be_hidden(
824
+ self,
825
+ timeout: float = None,
826
+ ) -> None:
827
+ __tracebackhide__ = True
828
+ await self._expect_impl(
829
+ "to.be.hidden",
830
+ FrameExpectOptions(timeout=timeout),
831
+ None,
832
+ "Locator expected to be hidden",
833
+ 'Expect "to_be_hidden"',
834
+ )
835
+
836
+ async def not_to_be_hidden(
837
+ self,
838
+ timeout: float = None,
839
+ ) -> None:
840
+ __tracebackhide__ = True
841
+ await self._not.to_be_hidden(timeout)
842
+
843
+ async def to_be_visible(
844
+ self,
845
+ visible: bool = None,
846
+ timeout: float = None,
847
+ ) -> None:
848
+ __tracebackhide__ = True
849
+ if visible is None:
850
+ visible = True
851
+ visible_string = "visible" if visible else "hidden"
852
+ await self._expect_impl(
853
+ "to.be.visible" if visible else "to.be.hidden",
854
+ FrameExpectOptions(timeout=timeout),
855
+ None,
856
+ f"Locator expected to be {visible_string}",
857
+ 'Expect "to_be_visible"',
858
+ )
859
+
860
+ async def not_to_be_visible(
861
+ self,
862
+ visible: bool = None,
863
+ timeout: float = None,
864
+ ) -> None:
865
+ __tracebackhide__ = True
866
+ await self._not.to_be_visible(visible, timeout)
867
+
868
+ async def to_be_focused(
869
+ self,
870
+ timeout: float = None,
871
+ ) -> None:
872
+ __tracebackhide__ = True
873
+ await self._expect_impl(
874
+ "to.be.focused",
875
+ FrameExpectOptions(timeout=timeout),
876
+ None,
877
+ "Locator expected to be focused",
878
+ 'Expect "to_be_focused"',
879
+ )
880
+
881
+ async def not_to_be_focused(
882
+ self,
883
+ timeout: float = None,
884
+ ) -> None:
885
+ __tracebackhide__ = True
886
+ await self._not.to_be_focused(timeout)
887
+
888
+ async def to_be_in_viewport(
889
+ self,
890
+ ratio: float = None,
891
+ timeout: float = None,
892
+ ) -> None:
893
+ __tracebackhide__ = True
894
+ await self._expect_impl(
895
+ "to.be.in.viewport",
896
+ FrameExpectOptions(timeout=timeout, expectedNumber=ratio),
897
+ None,
898
+ "Locator expected to be in viewport",
899
+ 'Expect "to_be_in_viewport"',
900
+ )
901
+
902
+ async def not_to_be_in_viewport(
903
+ self, ratio: float = None, timeout: float = None
904
+ ) -> None:
905
+ __tracebackhide__ = True
906
+ await self._not.to_be_in_viewport(ratio=ratio, timeout=timeout)
907
+
908
+ async def to_have_accessible_description(
909
+ self,
910
+ description: Union[str, Pattern[str]],
911
+ ignoreCase: bool = None,
912
+ timeout: float = None,
913
+ ) -> None:
914
+ __tracebackhide__ = True
915
+ expected_values = to_expected_text_values(
916
+ [description], ignoreCase=ignoreCase, normalize_white_space=True
917
+ )
918
+ await self._expect_impl(
919
+ "to.have.accessible.description",
920
+ FrameExpectOptions(expectedText=expected_values, timeout=timeout),
921
+ None,
922
+ "Locator expected to have accessible description",
923
+ 'Expect "to_have_accessible_description"',
924
+ )
925
+
926
+ async def not_to_have_accessible_description(
927
+ self,
928
+ name: Union[str, Pattern[str]],
929
+ ignoreCase: bool = None,
930
+ timeout: float = None,
931
+ ) -> None:
932
+ __tracebackhide__ = True
933
+ await self._not.to_have_accessible_description(name, ignoreCase, timeout)
934
+
935
+ async def to_have_accessible_name(
936
+ self,
937
+ name: Union[str, Pattern[str]],
938
+ ignoreCase: bool = None,
939
+ timeout: float = None,
940
+ ) -> None:
941
+ __tracebackhide__ = True
942
+ expected_values = to_expected_text_values(
943
+ [name], ignoreCase=ignoreCase, normalize_white_space=True
944
+ )
945
+ await self._expect_impl(
946
+ "to.have.accessible.name",
947
+ FrameExpectOptions(expectedText=expected_values, timeout=timeout),
948
+ None,
949
+ "Locator expected to have accessible name",
950
+ 'Expect "to_have_accessible_name"',
951
+ )
952
+
953
+ async def not_to_have_accessible_name(
954
+ self,
955
+ name: Union[str, Pattern[str]],
956
+ ignoreCase: bool = None,
957
+ timeout: float = None,
958
+ ) -> None:
959
+ __tracebackhide__ = True
960
+ await self._not.to_have_accessible_name(name, ignoreCase, timeout)
961
+
962
+ async def to_have_role(self, role: AriaRole, timeout: float = None) -> None:
963
+ __tracebackhide__ = True
964
+ if isinstance(role, Pattern):
965
+ raise Error('"role" argument in to_have_role must be a string')
966
+ expected_values = to_expected_text_values([role])
967
+ await self._expect_impl(
968
+ "to.have.role",
969
+ FrameExpectOptions(expectedText=expected_values, timeout=timeout),
970
+ None,
971
+ "Locator expected to have accessible role",
972
+ 'Expect "to_have_role"',
973
+ )
974
+
975
+ async def to_have_accessible_error_message(
976
+ self,
977
+ errorMessage: Union[str, Pattern[str]],
978
+ ignoreCase: bool = None,
979
+ timeout: float = None,
980
+ ) -> None:
981
+ __tracebackhide__ = True
982
+ expected_values = to_expected_text_values(
983
+ [errorMessage], ignoreCase=ignoreCase, normalize_white_space=True
984
+ )
985
+ await self._expect_impl(
986
+ "to.have.accessible.error.message",
987
+ FrameExpectOptions(expectedText=expected_values, timeout=timeout),
988
+ None,
989
+ "Locator expected to have accessible error message",
990
+ 'Expect "to_have_accessible_error_message"',
991
+ )
992
+
993
+ async def not_to_have_accessible_error_message(
994
+ self,
995
+ errorMessage: Union[str, Pattern[str]],
996
+ ignoreCase: bool = None,
997
+ timeout: float = None,
998
+ ) -> None:
999
+ __tracebackhide__ = True
1000
+ await self._not.to_have_accessible_error_message(
1001
+ errorMessage=errorMessage, ignoreCase=ignoreCase, timeout=timeout
1002
+ )
1003
+
1004
+ async def not_to_have_role(self, role: AriaRole, timeout: float = None) -> None:
1005
+ __tracebackhide__ = True
1006
+ await self._not.to_have_role(role, timeout)
1007
+
1008
+ async def to_match_aria_snapshot(
1009
+ self, expected: str, timeout: float = None
1010
+ ) -> None:
1011
+ __tracebackhide__ = True
1012
+ await self._expect_impl(
1013
+ "to.match.aria",
1014
+ FrameExpectOptions(expectedValue=expected, timeout=timeout),
1015
+ expected,
1016
+ "Locator expected to match Aria snapshot",
1017
+ 'Expect "to_match_aria_snapshot"',
1018
+ )
1019
+
1020
+ async def not_to_match_aria_snapshot(
1021
+ self, expected: str, timeout: float = None
1022
+ ) -> None:
1023
+ __tracebackhide__ = True
1024
+ await self._not.to_match_aria_snapshot(expected, timeout)
1025
+
1026
+
1027
+ class APIResponseAssertions:
1028
+ def __init__(
1029
+ self,
1030
+ response: APIResponse,
1031
+ timeout: float = None,
1032
+ is_not: bool = False,
1033
+ message: Optional[str] = None,
1034
+ is_soft: bool = False,
1035
+ ) -> None:
1036
+ self._loop = response._loop
1037
+ self._dispatcher_fiber = response._dispatcher_fiber
1038
+ self._timeout = timeout
1039
+ self._is_not = is_not
1040
+ self._actual = response
1041
+ self._custom_message = message
1042
+ self._is_soft = is_soft
1043
+
1044
+ @property
1045
+ def _not(self) -> "APIResponseAssertions":
1046
+ return APIResponseAssertions(
1047
+ self._actual,
1048
+ self._timeout,
1049
+ not self._is_not,
1050
+ self._custom_message,
1051
+ self._is_soft,
1052
+ )
1053
+
1054
+ async def to_be_ok(
1055
+ self,
1056
+ ) -> None:
1057
+ __tracebackhide__ = True
1058
+ if self._is_not is not self._actual.ok:
1059
+ return
1060
+ message = f"Response status expected to be within [200..299] range, was '{self._actual.status}'"
1061
+ if self._is_not:
1062
+ message = message.replace("expected to", "expected not to")
1063
+ out_message = self._custom_message or message
1064
+ out_message += format_call_log(await self._actual._fetch_log())
1065
+
1066
+ content_type = self._actual.headers.get("content-type")
1067
+ is_text_encoding = content_type and is_textual_mime_type(content_type)
1068
+ text = await self._actual.text() if is_text_encoding else None
1069
+ if text is not None:
1070
+ out_message += f"\n Response Text:\n{text[:1000]}"
1071
+
1072
+ _record_soft_or_raise(AssertionError(out_message), self._is_soft)
1073
+
1074
+ async def not_to_be_ok(self) -> None:
1075
+ __tracebackhide__ = True
1076
+ await self._not.to_be_ok()
1077
+
1078
+
1079
+ def expected_regex(
1080
+ pattern: Pattern[str],
1081
+ match_substring: bool,
1082
+ normalize_white_space: bool,
1083
+ ignoreCase: Optional[bool] = None,
1084
+ ) -> ExpectedTextValue:
1085
+ expected = ExpectedTextValue(
1086
+ regexSource=pattern.pattern,
1087
+ regexFlags=escape_regex_flags(pattern),
1088
+ matchSubstring=match_substring,
1089
+ normalizeWhiteSpace=normalize_white_space,
1090
+ ignoreCase=ignoreCase,
1091
+ )
1092
+ if expected["ignoreCase"] is None:
1093
+ del expected["ignoreCase"]
1094
+ return expected
1095
+
1096
+
1097
+ def to_expected_text_values(
1098
+ items: Union[
1099
+ Sequence[Pattern[str]], Sequence[str], Sequence[Union[str, Pattern[str]]]
1100
+ ],
1101
+ match_substring: bool = False,
1102
+ normalize_white_space: bool = False,
1103
+ ignoreCase: Optional[bool] = None,
1104
+ ) -> Sequence[ExpectedTextValue]:
1105
+ out: List[ExpectedTextValue] = []
1106
+ assert isinstance(items, (list, tuple))
1107
+ for item in items:
1108
+ if isinstance(item, str):
1109
+ o = ExpectedTextValue(
1110
+ string=item,
1111
+ matchSubstring=match_substring,
1112
+ normalizeWhiteSpace=normalize_white_space,
1113
+ ignoreCase=ignoreCase,
1114
+ )
1115
+ if o["ignoreCase"] is None:
1116
+ del o["ignoreCase"]
1117
+ out.append(o)
1118
+ elif isinstance(item, Pattern):
1119
+ out.append(
1120
+ expected_regex(item, match_substring, normalize_white_space, ignoreCase)
1121
+ )
1122
+ else:
1123
+ raise Error("value must be a string or regular expression")
1124
+ return out