playwright-browserstack 1.62.0__py3-none-win32.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.
- playwright/__init__.py +19 -0
- playwright/__main__.py +33 -0
- playwright/_impl/__init__.py +0 -0
- playwright/_impl/__pyinstaller/__init__.py +20 -0
- playwright/_impl/__pyinstaller/hook-playwright.async_api.py +17 -0
- playwright/_impl/__pyinstaller/hook-playwright.sync_api.py +17 -0
- playwright/_impl/_android.py +704 -0
- playwright/_impl/_api_structures.py +365 -0
- playwright/_impl/_artifact.py +87 -0
- playwright/_impl/_assertions.py +1124 -0
- playwright/_impl/_async_base.py +105 -0
- playwright/_impl/_browser.py +293 -0
- playwright/_impl/_browser_context.py +754 -0
- playwright/_impl/_browser_type.py +368 -0
- playwright/_impl/_cdp_session.py +46 -0
- playwright/_impl/_clock.py +104 -0
- playwright/_impl/_connection.py +764 -0
- playwright/_impl/_console_message.py +98 -0
- playwright/_impl/_credentials.py +57 -0
- playwright/_impl/_debugger.py +54 -0
- playwright/_impl/_dialog.py +63 -0
- playwright/_impl/_disposable.py +96 -0
- playwright/_impl/_download.py +64 -0
- playwright/_impl/_driver.py +41 -0
- playwright/_impl/_element_handle.py +480 -0
- playwright/_impl/_errors.py +64 -0
- playwright/_impl/_event_context_manager.py +33 -0
- playwright/_impl/_fetch.py +626 -0
- playwright/_impl/_file_chooser.py +57 -0
- playwright/_impl/_form_data.py +34 -0
- playwright/_impl/_frame.py +985 -0
- playwright/_impl/_glob.py +65 -0
- playwright/_impl/_greenlets.py +49 -0
- playwright/_impl/_har_router.py +122 -0
- playwright/_impl/_helper.py +601 -0
- playwright/_impl/_impl_to_api_mapping.py +158 -0
- playwright/_impl/_input.py +111 -0
- playwright/_impl/_js_handle.py +336 -0
- playwright/_impl/_json_pipe.py +97 -0
- playwright/_impl/_local_utils.py +95 -0
- playwright/_impl/_locator.py +1024 -0
- playwright/_impl/_map.py +31 -0
- playwright/_impl/_network.py +1017 -0
- playwright/_impl/_object_factory.py +116 -0
- playwright/_impl/_page.py +1637 -0
- playwright/_impl/_path_utils.py +27 -0
- playwright/_impl/_playwright.py +68 -0
- playwright/_impl/_screencast.py +177 -0
- playwright/_impl/_selectors.py +67 -0
- playwright/_impl/_set_input_files_helpers.py +158 -0
- playwright/_impl/_str_utils.py +76 -0
- playwright/_impl/_stream.py +46 -0
- playwright/_impl/_sync_base.py +151 -0
- playwright/_impl/_tracing.py +281 -0
- playwright/_impl/_transport.py +184 -0
- playwright/_impl/_video.py +56 -0
- playwright/_impl/_waiter.py +197 -0
- playwright/_impl/_web_error.py +48 -0
- playwright/_impl/_web_storage.py +58 -0
- playwright/_impl/_writable_stream.py +42 -0
- playwright/_repo_version.py +24 -0
- playwright/async_api/__init__.py +275 -0
- playwright/async_api/_android_generated.py +462 -0
- playwright/async_api/_context_manager.py +57 -0
- playwright/async_api/_generated.py +23875 -0
- playwright/driver/LICENSE +2946 -0
- playwright/driver/README.md +1 -0
- playwright/driver/node.exe +0 -0
- playwright/driver/package/LICENSE +202 -0
- playwright/driver/package/NOTICE +5 -0
- playwright/driver/package/README.md +3 -0
- playwright/driver/package/ThirdPartyNotices.txt +13 -0
- playwright/driver/package/bin/install_media_pack.ps1 +5 -0
- playwright/driver/package/bin/install_webkit_wsl.ps1 +33 -0
- playwright/driver/package/bin/reinstall_chrome_beta_linux.sh +42 -0
- playwright/driver/package/bin/reinstall_chrome_beta_mac.sh +13 -0
- playwright/driver/package/bin/reinstall_chrome_beta_win.ps1 +24 -0
- playwright/driver/package/bin/reinstall_chrome_stable_linux.sh +42 -0
- playwright/driver/package/bin/reinstall_chrome_stable_mac.sh +12 -0
- playwright/driver/package/bin/reinstall_chrome_stable_win.ps1 +24 -0
- playwright/driver/package/bin/reinstall_msedge_beta_linux.sh +48 -0
- playwright/driver/package/bin/reinstall_msedge_beta_mac.sh +11 -0
- playwright/driver/package/bin/reinstall_msedge_beta_win.ps1 +23 -0
- playwright/driver/package/bin/reinstall_msedge_dev_linux.sh +48 -0
- playwright/driver/package/bin/reinstall_msedge_dev_mac.sh +11 -0
- playwright/driver/package/bin/reinstall_msedge_dev_win.ps1 +23 -0
- playwright/driver/package/bin/reinstall_msedge_stable_linux.sh +48 -0
- playwright/driver/package/bin/reinstall_msedge_stable_mac.sh +11 -0
- playwright/driver/package/bin/reinstall_msedge_stable_win.ps1 +24 -0
- playwright/driver/package/browsers.json +75 -0
- playwright/driver/package/cli.js +21 -0
- playwright/driver/package/index.d.ts +17 -0
- playwright/driver/package/index.js +17 -0
- playwright/driver/package/index.mjs +28 -0
- playwright/driver/package/lib/bootstrap.js +88 -0
- playwright/driver/package/lib/coreBundle.js +74830 -0
- playwright/driver/package/lib/entry/cliDaemon.js +5 -0
- playwright/driver/package/lib/entry/dashboardApp.js +3 -0
- playwright/driver/package/lib/entry/mcp.js +10 -0
- playwright/driver/package/lib/entry/oopBrowserDownload.js +3 -0
- playwright/driver/package/lib/package.js +50 -0
- playwright/driver/package/lib/server/chromium/appIcon.png +0 -0
- playwright/driver/package/lib/server/electron/loader.js +118 -0
- playwright/driver/package/lib/serverRegistry.js +7347 -0
- playwright/driver/package/lib/serverRegistry.js.LICENSE +354 -0
- playwright/driver/package/lib/tools/cli-client/channelSessions.js +141 -0
- playwright/driver/package/lib/tools/cli-client/cli.js +6 -0
- playwright/driver/package/lib/tools/cli-client/help.json +708 -0
- playwright/driver/package/lib/tools/cli-client/minimist.js +128 -0
- playwright/driver/package/lib/tools/cli-client/output.js +343 -0
- playwright/driver/package/lib/tools/cli-client/program.js +404 -0
- playwright/driver/package/lib/tools/cli-client/registry.js +176 -0
- playwright/driver/package/lib/tools/cli-client/session.js +258 -0
- playwright/driver/package/lib/tools/dashboard/appIcon.png +0 -0
- playwright/driver/package/lib/tools/skills/playwright-cli/SKILL.md +420 -0
- playwright/driver/package/lib/tools/skills/playwright-cli/references/element-attributes.md +23 -0
- playwright/driver/package/lib/tools/skills/playwright-cli/references/playwright-tests.md +39 -0
- playwright/driver/package/lib/tools/skills/playwright-cli/references/request-mocking.md +87 -0
- playwright/driver/package/lib/tools/skills/playwright-cli/references/running-code.md +241 -0
- playwright/driver/package/lib/tools/skills/playwright-cli/references/session-management.md +225 -0
- playwright/driver/package/lib/tools/skills/playwright-cli/references/storage-state.md +275 -0
- playwright/driver/package/lib/tools/skills/playwright-cli/references/test-generation.md +433 -0
- playwright/driver/package/lib/tools/skills/playwright-cli/references/tracing.md +139 -0
- playwright/driver/package/lib/tools/skills/playwright-cli/references/video-recording.md +143 -0
- playwright/driver/package/lib/tools/skills/playwright-component-testing/SKILL.md +143 -0
- playwright/driver/package/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +144 -0
- playwright/driver/package/lib/tools/skills/playwright-component-testing/references/migration.md +85 -0
- playwright/driver/package/lib/tools/skills/playwright-component-testing/references/react.md +67 -0
- playwright/driver/package/lib/tools/skills/playwright-component-testing/references/vue.md +75 -0
- playwright/driver/package/lib/tools/skills/playwright-trace/SKILL.md +171 -0
- playwright/driver/package/lib/tools/utils/extension.js +101 -0
- playwright/driver/package/lib/tools/utils/socketConnection.js +108 -0
- playwright/driver/package/lib/utilsBundle.js +90764 -0
- playwright/driver/package/lib/utilsBundle.js.LICENSE +2179 -0
- playwright/driver/package/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
- playwright/driver/package/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
- playwright/driver/package/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
- playwright/driver/package/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
- playwright/driver/package/lib/vite/dashboard/assets/index-CyWAfh-p.js +11 -0
- playwright/driver/package/lib/vite/dashboard/assets/index-DhC616m4.css +1 -0
- playwright/driver/package/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
- playwright/driver/package/lib/vite/dashboard/index.html +29 -0
- playwright/driver/package/lib/vite/dashboard/playwright-logo.svg +24 -0
- playwright/driver/package/lib/vite/htmlReport/index.html +16 -0
- playwright/driver/package/lib/vite/htmlReport/report.css +2 -0
- playwright/driver/package/lib/vite/htmlReport/report.js +32 -0
- playwright/driver/package/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
- playwright/driver/package/lib/vite/recorder/assets/codeMirrorModule-CwYYHbcZ.js +32 -0
- playwright/driver/package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- playwright/driver/package/lib/vite/recorder/assets/index-DYjdXIbE.js +129 -0
- playwright/driver/package/lib/vite/recorder/assets/index-l_lX622x.css +1 -0
- playwright/driver/package/lib/vite/recorder/index.html +29 -0
- playwright/driver/package/lib/vite/recorder/playwright-logo.svg +9 -0
- playwright/driver/package/lib/vite/traceViewer/assets/codeMirrorModule-By56iMx7.js +32 -0
- playwright/driver/package/lib/vite/traceViewer/assets/defaultSettingsView-B34OrIms.js +181 -0
- playwright/driver/package/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
- playwright/driver/package/lib/vite/traceViewer/assets/xtermModule-COQkjINf.js +7 -0
- playwright/driver/package/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
- playwright/driver/package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- playwright/driver/package/lib/vite/traceViewer/defaultSettingsView.BLFoOugd.css +1 -0
- playwright/driver/package/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
- playwright/driver/package/lib/vite/traceViewer/index.Dl36UVQT.js +1 -0
- playwright/driver/package/lib/vite/traceViewer/index.html +44 -0
- playwright/driver/package/lib/vite/traceViewer/manifest.webmanifest +16 -0
- playwright/driver/package/lib/vite/traceViewer/playwright-logo.svg +9 -0
- playwright/driver/package/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
- playwright/driver/package/lib/vite/traceViewer/snapshot.html +10 -0
- playwright/driver/package/lib/vite/traceViewer/sw.bundle.js +4 -0
- playwright/driver/package/lib/vite/traceViewer/uiMode.C7UW1sC9.css +1 -0
- playwright/driver/package/lib/vite/traceViewer/uiMode.D962mr9b.js +5 -0
- playwright/driver/package/lib/vite/traceViewer/uiMode.html +18 -0
- playwright/driver/package/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
- playwright/driver/package/lib/webp_codec.LICENSE +173 -0
- playwright/driver/package/lib/webp_codec.wasm +0 -0
- playwright/driver/package/lib/xdg-open +1267 -0
- playwright/driver/package/package.json +34 -0
- playwright/driver/package/types/protocol.d.ts +24842 -0
- playwright/driver/package/types/structs.d.ts +47 -0
- playwright/driver/package/types/types.d.ts +26188 -0
- playwright/py.typed +0 -0
- playwright/sync_api/__init__.py +275 -0
- playwright/sync_api/_android_generated.py +494 -0
- playwright/sync_api/_context_manager.py +98 -0
- playwright/sync_api/_generated.py +24045 -0
- playwright_browserstack-1.62.0.dist-info/METADATA +82 -0
- playwright_browserstack-1.62.0.dist-info/RECORD +192 -0
- playwright_browserstack-1.62.0.dist-info/WHEEL +5 -0
- playwright_browserstack-1.62.0.dist-info/entry_points.txt +5 -0
- playwright_browserstack-1.62.0.dist-info/licenses/LICENSE +202 -0
- playwright_browserstack-1.62.0.dist-info/licenses/LICENSE.txt +51 -0
- playwright_browserstack-1.62.0.dist-info/licenses/NOTICE +18 -0
- playwright_browserstack-1.62.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,985 @@
|
|
|
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 asyncio
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
from typing import (
|
|
18
|
+
TYPE_CHECKING,
|
|
19
|
+
Any,
|
|
20
|
+
Dict,
|
|
21
|
+
List,
|
|
22
|
+
Literal,
|
|
23
|
+
Optional,
|
|
24
|
+
Pattern,
|
|
25
|
+
Sequence,
|
|
26
|
+
Set,
|
|
27
|
+
Union,
|
|
28
|
+
cast,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
from pyee import EventEmitter
|
|
32
|
+
|
|
33
|
+
from playwright._impl._api_structures import (
|
|
34
|
+
AriaRole,
|
|
35
|
+
DropPayload,
|
|
36
|
+
FilePayload,
|
|
37
|
+
FrameExpectOptions,
|
|
38
|
+
FrameExpectResult,
|
|
39
|
+
Position,
|
|
40
|
+
)
|
|
41
|
+
from playwright._impl._connection import (
|
|
42
|
+
ChannelOwner,
|
|
43
|
+
from_channel,
|
|
44
|
+
from_nullable_channel,
|
|
45
|
+
)
|
|
46
|
+
from playwright._impl._element_handle import ElementHandle, convert_select_option_values
|
|
47
|
+
from playwright._impl._errors import Error
|
|
48
|
+
from playwright._impl._event_context_manager import EventContextManagerImpl
|
|
49
|
+
from playwright._impl._helper import (
|
|
50
|
+
DocumentLoadState,
|
|
51
|
+
FrameNavigatedEvent,
|
|
52
|
+
KeyboardModifier,
|
|
53
|
+
MouseButton,
|
|
54
|
+
TimeoutSettings,
|
|
55
|
+
URLMatch,
|
|
56
|
+
async_readfile,
|
|
57
|
+
locals_to_params,
|
|
58
|
+
monotonic_time,
|
|
59
|
+
url_matches,
|
|
60
|
+
)
|
|
61
|
+
from playwright._impl._js_handle import (
|
|
62
|
+
JSHandle,
|
|
63
|
+
Serializable,
|
|
64
|
+
add_source_url_to_script,
|
|
65
|
+
parse_result,
|
|
66
|
+
parse_value,
|
|
67
|
+
serialize_argument,
|
|
68
|
+
)
|
|
69
|
+
from playwright._impl._locator import (
|
|
70
|
+
FrameLocator,
|
|
71
|
+
Locator,
|
|
72
|
+
get_by_alt_text_selector,
|
|
73
|
+
get_by_label_selector,
|
|
74
|
+
get_by_placeholder_selector,
|
|
75
|
+
get_by_role_selector,
|
|
76
|
+
get_by_test_id_selector,
|
|
77
|
+
get_by_text_selector,
|
|
78
|
+
get_by_title_selector,
|
|
79
|
+
test_id_attribute_name,
|
|
80
|
+
)
|
|
81
|
+
from playwright._impl._network import Response
|
|
82
|
+
from playwright._impl._set_input_files_helpers import convert_input_files
|
|
83
|
+
from playwright._impl._waiter import Waiter
|
|
84
|
+
|
|
85
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
86
|
+
from playwright._impl._page import Page
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class Frame(ChannelOwner):
|
|
90
|
+
def __init__(
|
|
91
|
+
self, parent: ChannelOwner, type: str, guid: str, initializer: Dict
|
|
92
|
+
) -> None:
|
|
93
|
+
super().__init__(parent, type, guid, initializer)
|
|
94
|
+
self._parent_frame = from_nullable_channel(initializer.get("parentFrame"))
|
|
95
|
+
if self._parent_frame:
|
|
96
|
+
self._parent_frame._child_frames.append(self)
|
|
97
|
+
self._name = initializer["name"]
|
|
98
|
+
self._url = initializer["url"]
|
|
99
|
+
self._detached = False
|
|
100
|
+
self._child_frames: List[Frame] = []
|
|
101
|
+
self._page: Optional[Page] = None
|
|
102
|
+
self._load_states: Set[str] = set(initializer["loadStates"])
|
|
103
|
+
self._event_emitter = EventEmitter()
|
|
104
|
+
self._channel.on(
|
|
105
|
+
"loadstate",
|
|
106
|
+
lambda params: self._on_load_state(params.get("add"), params.get("remove")),
|
|
107
|
+
)
|
|
108
|
+
self._channel.on(
|
|
109
|
+
"navigated",
|
|
110
|
+
lambda params: self._on_frame_navigated(params),
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
def __repr__(self) -> str:
|
|
114
|
+
return f"<Frame name={self.name} url={self.url!r}>"
|
|
115
|
+
|
|
116
|
+
def _on_load_state(
|
|
117
|
+
self, add: DocumentLoadState = None, remove: DocumentLoadState = None
|
|
118
|
+
) -> None:
|
|
119
|
+
if add:
|
|
120
|
+
self._load_states.add(add)
|
|
121
|
+
self._event_emitter.emit("loadstate", add)
|
|
122
|
+
elif remove and remove in self._load_states:
|
|
123
|
+
self._load_states.remove(remove)
|
|
124
|
+
if not self._parent_frame and add == "load" and self._page:
|
|
125
|
+
self._page.emit("load", self._page)
|
|
126
|
+
self._page.context.emit("pageload", self._page)
|
|
127
|
+
if not self._parent_frame and add == "domcontentloaded" and self._page:
|
|
128
|
+
self._page.emit("domcontentloaded", self._page)
|
|
129
|
+
|
|
130
|
+
def _on_frame_navigated(self, event: FrameNavigatedEvent) -> None:
|
|
131
|
+
self._url = event["url"]
|
|
132
|
+
self._name = event["name"]
|
|
133
|
+
self._event_emitter.emit("navigated", event)
|
|
134
|
+
if "error" not in event and self._page:
|
|
135
|
+
self._page.emit("framenavigated", self)
|
|
136
|
+
self._page.context.emit("framenavigated", self)
|
|
137
|
+
|
|
138
|
+
async def _query_count(self, selector: str) -> int:
|
|
139
|
+
return await self._channel.send("queryCount", None, {"selector": selector})
|
|
140
|
+
|
|
141
|
+
@property
|
|
142
|
+
def page(self) -> "Page":
|
|
143
|
+
assert self._page
|
|
144
|
+
return self._page
|
|
145
|
+
|
|
146
|
+
async def goto(
|
|
147
|
+
self,
|
|
148
|
+
url: str,
|
|
149
|
+
timeout: float = None,
|
|
150
|
+
waitUntil: DocumentLoadState = None,
|
|
151
|
+
referer: str = None,
|
|
152
|
+
) -> Optional[Response]:
|
|
153
|
+
return cast(
|
|
154
|
+
Optional[Response],
|
|
155
|
+
from_nullable_channel(
|
|
156
|
+
await self._channel.send(
|
|
157
|
+
"goto", self._navigation_timeout, locals_to_params(locals())
|
|
158
|
+
)
|
|
159
|
+
),
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
def _setup_navigation_waiter(self, wait_name: str, timeout: float = None) -> Waiter:
|
|
163
|
+
assert self._page
|
|
164
|
+
waiter = Waiter(self._page, f"frame.{wait_name}")
|
|
165
|
+
waiter.reject_on_event(
|
|
166
|
+
self._page,
|
|
167
|
+
"close",
|
|
168
|
+
lambda: cast("Page", self._page)._close_error_with_reason(),
|
|
169
|
+
)
|
|
170
|
+
waiter.reject_on_event(
|
|
171
|
+
self._page, "crash", Error("Navigation failed because page crashed!")
|
|
172
|
+
)
|
|
173
|
+
waiter.reject_on_event(
|
|
174
|
+
self._page,
|
|
175
|
+
"framedetached",
|
|
176
|
+
Error("Navigating frame was detached!"),
|
|
177
|
+
lambda frame: frame == self,
|
|
178
|
+
)
|
|
179
|
+
timeout = self._page._timeout_settings.navigation_timeout(timeout)
|
|
180
|
+
waiter.reject_on_timeout(timeout, f"Timeout {timeout}ms exceeded.")
|
|
181
|
+
return waiter
|
|
182
|
+
|
|
183
|
+
async def _expect(
|
|
184
|
+
self,
|
|
185
|
+
selector: Optional[str],
|
|
186
|
+
expression: str,
|
|
187
|
+
options: FrameExpectOptions,
|
|
188
|
+
title: str = None,
|
|
189
|
+
) -> FrameExpectResult:
|
|
190
|
+
if "expectedValue" in options:
|
|
191
|
+
options["expectedValue"] = serialize_argument(options["expectedValue"])
|
|
192
|
+
try:
|
|
193
|
+
await self._channel.send(
|
|
194
|
+
"expect",
|
|
195
|
+
self._timeout,
|
|
196
|
+
{
|
|
197
|
+
"selector": selector,
|
|
198
|
+
"expression": expression,
|
|
199
|
+
**options,
|
|
200
|
+
},
|
|
201
|
+
title=title,
|
|
202
|
+
)
|
|
203
|
+
return {"matches": not options.get("isNot")}
|
|
204
|
+
except Error as e:
|
|
205
|
+
if not e._details:
|
|
206
|
+
raise e
|
|
207
|
+
details = cast(Dict[str, Any], e._details)
|
|
208
|
+
received = details.get("received")
|
|
209
|
+
if received:
|
|
210
|
+
received = {
|
|
211
|
+
"value": (
|
|
212
|
+
parse_value(received["value"]) if "value" in received else None
|
|
213
|
+
),
|
|
214
|
+
"ariaSnapshot": received.get("ariaSnapshot"),
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
"matches": bool(options.get("isNot")),
|
|
218
|
+
"received": received,
|
|
219
|
+
"timedOut": details.get("timedOut"),
|
|
220
|
+
"errorMessage": (
|
|
221
|
+
"Error: " + details["customErrorMessage"]
|
|
222
|
+
if details.get("customErrorMessage")
|
|
223
|
+
else None
|
|
224
|
+
),
|
|
225
|
+
"log": e._log,
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
def expect_navigation(
|
|
229
|
+
self,
|
|
230
|
+
url: URLMatch = None,
|
|
231
|
+
waitUntil: DocumentLoadState = None,
|
|
232
|
+
timeout: float = None,
|
|
233
|
+
) -> EventContextManagerImpl[Response]:
|
|
234
|
+
assert self._page
|
|
235
|
+
if not waitUntil:
|
|
236
|
+
waitUntil = "load"
|
|
237
|
+
|
|
238
|
+
if timeout is None:
|
|
239
|
+
timeout = self._page._timeout_settings.navigation_timeout()
|
|
240
|
+
deadline = monotonic_time() + timeout
|
|
241
|
+
waiter = self._setup_navigation_waiter("expect_navigation", timeout)
|
|
242
|
+
|
|
243
|
+
to_url = f' to "{url}"' if url else ""
|
|
244
|
+
waiter.log(f"waiting for navigation{to_url} until '{waitUntil}'")
|
|
245
|
+
|
|
246
|
+
def predicate(event: Any) -> bool:
|
|
247
|
+
# Any failed navigation results in a rejection.
|
|
248
|
+
if event.get("error"):
|
|
249
|
+
return True
|
|
250
|
+
waiter.log(f' navigated to "{event["url"]}"')
|
|
251
|
+
return url_matches(
|
|
252
|
+
cast("Page", self._page)._browser_context._base_url,
|
|
253
|
+
event["url"],
|
|
254
|
+
url,
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
waiter.wait_for_event(
|
|
258
|
+
self._event_emitter,
|
|
259
|
+
"navigated",
|
|
260
|
+
predicate=predicate,
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
async def continuation() -> Optional[Response]:
|
|
264
|
+
event = await waiter.result()
|
|
265
|
+
if "error" in event:
|
|
266
|
+
raise Error(event["error"])
|
|
267
|
+
if waitUntil not in self._load_states:
|
|
268
|
+
t = deadline - monotonic_time()
|
|
269
|
+
if t > 0:
|
|
270
|
+
await self._wait_for_load_state_impl(state=waitUntil, timeout=t)
|
|
271
|
+
if "newDocument" in event and "request" in event["newDocument"]:
|
|
272
|
+
request = from_channel(event["newDocument"]["request"])
|
|
273
|
+
return await request.response()
|
|
274
|
+
return None
|
|
275
|
+
|
|
276
|
+
return EventContextManagerImpl(asyncio.create_task(continuation()))
|
|
277
|
+
|
|
278
|
+
async def wait_for_url(
|
|
279
|
+
self,
|
|
280
|
+
url: URLMatch,
|
|
281
|
+
waitUntil: DocumentLoadState = None,
|
|
282
|
+
timeout: float = None,
|
|
283
|
+
) -> None:
|
|
284
|
+
assert self._page
|
|
285
|
+
if url_matches(self._page._browser_context._base_url, self.url, url):
|
|
286
|
+
await self._wait_for_load_state_impl(state=waitUntil, timeout=timeout)
|
|
287
|
+
return
|
|
288
|
+
async with self.expect_navigation(
|
|
289
|
+
url=url, waitUntil=waitUntil, timeout=timeout
|
|
290
|
+
):
|
|
291
|
+
pass
|
|
292
|
+
|
|
293
|
+
async def wait_for_load_state(
|
|
294
|
+
self,
|
|
295
|
+
state: Literal["domcontentloaded", "load", "networkidle"] = None,
|
|
296
|
+
timeout: float = None,
|
|
297
|
+
) -> None:
|
|
298
|
+
return await self._wait_for_load_state_impl(state, timeout)
|
|
299
|
+
|
|
300
|
+
async def _wait_for_load_state_impl(
|
|
301
|
+
self, state: DocumentLoadState = None, timeout: float = None
|
|
302
|
+
) -> None:
|
|
303
|
+
if not state:
|
|
304
|
+
state = "load"
|
|
305
|
+
if state not in ("load", "domcontentloaded", "networkidle", "commit"):
|
|
306
|
+
raise Error(
|
|
307
|
+
"state: expected one of (load|domcontentloaded|networkidle|commit)"
|
|
308
|
+
)
|
|
309
|
+
waiter = self._setup_navigation_waiter("wait_for_load_state", timeout)
|
|
310
|
+
|
|
311
|
+
if state in self._load_states:
|
|
312
|
+
waiter.log(f' not waiting, "{state}" event already fired')
|
|
313
|
+
# TODO: align with upstream
|
|
314
|
+
waiter._fulfill(None)
|
|
315
|
+
else:
|
|
316
|
+
|
|
317
|
+
def handle_load_state_event(actual_state: str) -> bool:
|
|
318
|
+
waiter.log(f'"{actual_state}" event fired')
|
|
319
|
+
return actual_state == state
|
|
320
|
+
|
|
321
|
+
waiter.wait_for_event(
|
|
322
|
+
self._event_emitter,
|
|
323
|
+
"loadstate",
|
|
324
|
+
handle_load_state_event,
|
|
325
|
+
)
|
|
326
|
+
await waiter.result()
|
|
327
|
+
|
|
328
|
+
def _timeout(self, timeout: Optional[float]) -> float:
|
|
329
|
+
timeout_settings = (
|
|
330
|
+
self._page._timeout_settings if self._page else TimeoutSettings(None)
|
|
331
|
+
)
|
|
332
|
+
return timeout_settings.timeout(timeout)
|
|
333
|
+
|
|
334
|
+
def _navigation_timeout(self, timeout: Optional[float]) -> float:
|
|
335
|
+
timeout_settings = (
|
|
336
|
+
self._page._timeout_settings if self._page else TimeoutSettings(None)
|
|
337
|
+
)
|
|
338
|
+
return timeout_settings.navigation_timeout(timeout)
|
|
339
|
+
|
|
340
|
+
async def frame_element(self) -> ElementHandle:
|
|
341
|
+
return from_channel(await self._channel.send("frameElement", None))
|
|
342
|
+
|
|
343
|
+
async def evaluate(self, expression: str, arg: Serializable = None) -> Any:
|
|
344
|
+
return parse_result(
|
|
345
|
+
await self._channel.send(
|
|
346
|
+
"evaluateExpression",
|
|
347
|
+
None,
|
|
348
|
+
dict(
|
|
349
|
+
expression=expression,
|
|
350
|
+
arg=serialize_argument(arg),
|
|
351
|
+
),
|
|
352
|
+
)
|
|
353
|
+
)
|
|
354
|
+
|
|
355
|
+
async def evaluate_handle(
|
|
356
|
+
self, expression: str, arg: Serializable = None
|
|
357
|
+
) -> JSHandle:
|
|
358
|
+
return from_channel(
|
|
359
|
+
await self._channel.send(
|
|
360
|
+
"evaluateExpressionHandle",
|
|
361
|
+
None,
|
|
362
|
+
dict(
|
|
363
|
+
expression=expression,
|
|
364
|
+
arg=serialize_argument(arg),
|
|
365
|
+
),
|
|
366
|
+
)
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
async def query_selector(
|
|
370
|
+
self, selector: str, strict: bool = None
|
|
371
|
+
) -> Optional[ElementHandle]:
|
|
372
|
+
return from_nullable_channel(
|
|
373
|
+
await self._channel.send("querySelector", None, locals_to_params(locals()))
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
async def query_selector_all(self, selector: str) -> List[ElementHandle]:
|
|
377
|
+
return list(
|
|
378
|
+
map(
|
|
379
|
+
from_channel,
|
|
380
|
+
await self._channel.send(
|
|
381
|
+
"querySelectorAll", None, dict(selector=selector)
|
|
382
|
+
),
|
|
383
|
+
)
|
|
384
|
+
)
|
|
385
|
+
|
|
386
|
+
async def wait_for_selector(
|
|
387
|
+
self,
|
|
388
|
+
selector: str,
|
|
389
|
+
strict: bool = None,
|
|
390
|
+
timeout: float = None,
|
|
391
|
+
state: Literal["attached", "detached", "hidden", "visible"] = None,
|
|
392
|
+
) -> Optional[ElementHandle]:
|
|
393
|
+
return from_nullable_channel(
|
|
394
|
+
await self._channel.send(
|
|
395
|
+
"waitForSelector", self._timeout, locals_to_params(locals())
|
|
396
|
+
)
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
async def is_checked(
|
|
400
|
+
self, selector: str, strict: bool = None, timeout: float = None
|
|
401
|
+
) -> bool:
|
|
402
|
+
return await self._channel.send(
|
|
403
|
+
"isChecked", self._timeout, locals_to_params(locals())
|
|
404
|
+
)
|
|
405
|
+
|
|
406
|
+
async def is_disabled(
|
|
407
|
+
self, selector: str, strict: bool = None, timeout: float = None
|
|
408
|
+
) -> bool:
|
|
409
|
+
return await self._channel.send(
|
|
410
|
+
"isDisabled", self._timeout, locals_to_params(locals())
|
|
411
|
+
)
|
|
412
|
+
|
|
413
|
+
async def is_editable(
|
|
414
|
+
self, selector: str, strict: bool = None, timeout: float = None
|
|
415
|
+
) -> bool:
|
|
416
|
+
return await self._channel.send(
|
|
417
|
+
"isEditable", self._timeout, locals_to_params(locals())
|
|
418
|
+
)
|
|
419
|
+
|
|
420
|
+
async def is_enabled(
|
|
421
|
+
self, selector: str, strict: bool = None, timeout: float = None
|
|
422
|
+
) -> bool:
|
|
423
|
+
return await self._channel.send(
|
|
424
|
+
"isEnabled", self._timeout, locals_to_params(locals())
|
|
425
|
+
)
|
|
426
|
+
|
|
427
|
+
async def is_hidden(self, selector: str, strict: bool = None) -> bool:
|
|
428
|
+
return await self._channel.send(
|
|
429
|
+
"isHidden", self._timeout, locals_to_params(locals())
|
|
430
|
+
)
|
|
431
|
+
|
|
432
|
+
async def is_visible(self, selector: str, strict: bool = None) -> bool:
|
|
433
|
+
return await self._channel.send(
|
|
434
|
+
"isVisible", self._timeout, locals_to_params(locals())
|
|
435
|
+
)
|
|
436
|
+
|
|
437
|
+
async def dispatch_event(
|
|
438
|
+
self,
|
|
439
|
+
selector: str,
|
|
440
|
+
type: str,
|
|
441
|
+
eventInit: Dict = None,
|
|
442
|
+
strict: bool = None,
|
|
443
|
+
timeout: float = None,
|
|
444
|
+
) -> None:
|
|
445
|
+
await self._channel.send(
|
|
446
|
+
"dispatchEvent",
|
|
447
|
+
self._timeout,
|
|
448
|
+
locals_to_params(
|
|
449
|
+
dict(
|
|
450
|
+
selector=selector,
|
|
451
|
+
type=type,
|
|
452
|
+
eventInit=serialize_argument(eventInit),
|
|
453
|
+
strict=strict,
|
|
454
|
+
timeout=timeout,
|
|
455
|
+
),
|
|
456
|
+
),
|
|
457
|
+
)
|
|
458
|
+
|
|
459
|
+
async def eval_on_selector(
|
|
460
|
+
self,
|
|
461
|
+
selector: str,
|
|
462
|
+
expression: str,
|
|
463
|
+
arg: Serializable = None,
|
|
464
|
+
strict: bool = None,
|
|
465
|
+
) -> Any:
|
|
466
|
+
return parse_result(
|
|
467
|
+
await self._channel.send(
|
|
468
|
+
"evalOnSelector",
|
|
469
|
+
None,
|
|
470
|
+
locals_to_params(
|
|
471
|
+
dict(
|
|
472
|
+
selector=selector,
|
|
473
|
+
expression=expression,
|
|
474
|
+
arg=serialize_argument(arg),
|
|
475
|
+
strict=strict,
|
|
476
|
+
)
|
|
477
|
+
),
|
|
478
|
+
)
|
|
479
|
+
)
|
|
480
|
+
|
|
481
|
+
async def eval_on_selector_all(
|
|
482
|
+
self,
|
|
483
|
+
selector: str,
|
|
484
|
+
expression: str,
|
|
485
|
+
arg: Serializable = None,
|
|
486
|
+
) -> Any:
|
|
487
|
+
return parse_result(
|
|
488
|
+
await self._channel.send(
|
|
489
|
+
"evalOnSelectorAll",
|
|
490
|
+
None,
|
|
491
|
+
dict(
|
|
492
|
+
selector=selector,
|
|
493
|
+
expression=expression,
|
|
494
|
+
arg=serialize_argument(arg),
|
|
495
|
+
),
|
|
496
|
+
)
|
|
497
|
+
)
|
|
498
|
+
|
|
499
|
+
async def content(self) -> str:
|
|
500
|
+
return await self._channel.send("content", None)
|
|
501
|
+
|
|
502
|
+
async def set_content(
|
|
503
|
+
self,
|
|
504
|
+
html: str,
|
|
505
|
+
timeout: float = None,
|
|
506
|
+
waitUntil: DocumentLoadState = None,
|
|
507
|
+
) -> None:
|
|
508
|
+
await self._channel.send(
|
|
509
|
+
"setContent", self._navigation_timeout, locals_to_params(locals())
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
@property
|
|
513
|
+
def name(self) -> str:
|
|
514
|
+
return self._name or ""
|
|
515
|
+
|
|
516
|
+
@property
|
|
517
|
+
def url(self) -> str:
|
|
518
|
+
return self._url or ""
|
|
519
|
+
|
|
520
|
+
@property
|
|
521
|
+
def parent_frame(self) -> Optional["Frame"]:
|
|
522
|
+
return self._parent_frame
|
|
523
|
+
|
|
524
|
+
@property
|
|
525
|
+
def child_frames(self) -> List["Frame"]:
|
|
526
|
+
return self._child_frames.copy()
|
|
527
|
+
|
|
528
|
+
def is_detached(self) -> bool:
|
|
529
|
+
return self._detached
|
|
530
|
+
|
|
531
|
+
async def add_script_tag(
|
|
532
|
+
self,
|
|
533
|
+
url: str = None,
|
|
534
|
+
path: Union[str, Path] = None,
|
|
535
|
+
content: str = None,
|
|
536
|
+
type: str = None,
|
|
537
|
+
) -> ElementHandle:
|
|
538
|
+
params = locals_to_params(locals())
|
|
539
|
+
if path:
|
|
540
|
+
params["content"] = add_source_url_to_script(
|
|
541
|
+
(await async_readfile(path)).decode(), path
|
|
542
|
+
)
|
|
543
|
+
del params["path"]
|
|
544
|
+
return from_channel(await self._channel.send("addScriptTag", None, params))
|
|
545
|
+
|
|
546
|
+
async def add_style_tag(
|
|
547
|
+
self, url: str = None, path: Union[str, Path] = None, content: str = None
|
|
548
|
+
) -> ElementHandle:
|
|
549
|
+
params = locals_to_params(locals())
|
|
550
|
+
if path:
|
|
551
|
+
params["content"] = (
|
|
552
|
+
(await async_readfile(path)).decode()
|
|
553
|
+
+ "\n/*# sourceURL="
|
|
554
|
+
+ str(Path(path))
|
|
555
|
+
+ "*/"
|
|
556
|
+
)
|
|
557
|
+
del params["path"]
|
|
558
|
+
return from_channel(await self._channel.send("addStyleTag", None, params))
|
|
559
|
+
|
|
560
|
+
async def click(
|
|
561
|
+
self,
|
|
562
|
+
selector: str,
|
|
563
|
+
modifiers: Sequence[KeyboardModifier] = None,
|
|
564
|
+
position: Position = None,
|
|
565
|
+
delay: float = None,
|
|
566
|
+
button: MouseButton = None,
|
|
567
|
+
clickCount: int = None,
|
|
568
|
+
timeout: float = None,
|
|
569
|
+
force: bool = None,
|
|
570
|
+
noWaitAfter: bool = None,
|
|
571
|
+
strict: bool = None,
|
|
572
|
+
trial: bool = None,
|
|
573
|
+
scroll: Literal["auto", "none"] = None,
|
|
574
|
+
) -> None:
|
|
575
|
+
await self._click(**locals_to_params(locals()))
|
|
576
|
+
|
|
577
|
+
async def _click(
|
|
578
|
+
self,
|
|
579
|
+
selector: str,
|
|
580
|
+
modifiers: Sequence[KeyboardModifier] = None,
|
|
581
|
+
position: Position = None,
|
|
582
|
+
delay: float = None,
|
|
583
|
+
button: MouseButton = None,
|
|
584
|
+
clickCount: int = None,
|
|
585
|
+
timeout: float = None,
|
|
586
|
+
force: bool = None,
|
|
587
|
+
noWaitAfter: bool = None,
|
|
588
|
+
strict: bool = None,
|
|
589
|
+
trial: bool = None,
|
|
590
|
+
steps: int = None,
|
|
591
|
+
scroll: Literal["auto", "none"] = None,
|
|
592
|
+
) -> None:
|
|
593
|
+
await self._channel.send("click", self._timeout, locals_to_params(locals()))
|
|
594
|
+
|
|
595
|
+
async def dblclick(
|
|
596
|
+
self,
|
|
597
|
+
selector: str,
|
|
598
|
+
modifiers: Sequence[KeyboardModifier] = None,
|
|
599
|
+
position: Position = None,
|
|
600
|
+
delay: float = None,
|
|
601
|
+
button: MouseButton = None,
|
|
602
|
+
timeout: float = None,
|
|
603
|
+
force: bool = None,
|
|
604
|
+
noWaitAfter: bool = None,
|
|
605
|
+
strict: bool = None,
|
|
606
|
+
trial: bool = None,
|
|
607
|
+
scroll: Literal["auto", "none"] = None,
|
|
608
|
+
) -> None:
|
|
609
|
+
await self._channel.send(
|
|
610
|
+
"dblclick", self._timeout, locals_to_params(locals()), title="Double click"
|
|
611
|
+
)
|
|
612
|
+
|
|
613
|
+
async def tap(
|
|
614
|
+
self,
|
|
615
|
+
selector: str,
|
|
616
|
+
modifiers: Sequence[KeyboardModifier] = None,
|
|
617
|
+
position: Position = None,
|
|
618
|
+
timeout: float = None,
|
|
619
|
+
force: bool = None,
|
|
620
|
+
noWaitAfter: bool = None,
|
|
621
|
+
strict: bool = None,
|
|
622
|
+
trial: bool = None,
|
|
623
|
+
scroll: Literal["auto", "none"] = None,
|
|
624
|
+
) -> None:
|
|
625
|
+
await self._channel.send("tap", self._timeout, locals_to_params(locals()))
|
|
626
|
+
|
|
627
|
+
async def fill(
|
|
628
|
+
self,
|
|
629
|
+
selector: str,
|
|
630
|
+
value: str,
|
|
631
|
+
timeout: float = None,
|
|
632
|
+
noWaitAfter: bool = None,
|
|
633
|
+
strict: bool = None,
|
|
634
|
+
force: bool = None,
|
|
635
|
+
) -> None:
|
|
636
|
+
await self._fill(**locals_to_params(locals()))
|
|
637
|
+
|
|
638
|
+
async def _fill(
|
|
639
|
+
self,
|
|
640
|
+
selector: str,
|
|
641
|
+
value: str,
|
|
642
|
+
timeout: float = None,
|
|
643
|
+
noWaitAfter: bool = None,
|
|
644
|
+
strict: bool = None,
|
|
645
|
+
force: bool = None,
|
|
646
|
+
title: str = None,
|
|
647
|
+
) -> None:
|
|
648
|
+
await self._channel.send("fill", self._timeout, locals_to_params(locals()))
|
|
649
|
+
|
|
650
|
+
def locator(
|
|
651
|
+
self,
|
|
652
|
+
selector: str,
|
|
653
|
+
hasText: Union[str, Pattern[str]] = None,
|
|
654
|
+
hasNotText: Union[str, Pattern[str]] = None,
|
|
655
|
+
has: Locator = None,
|
|
656
|
+
hasNot: Locator = None,
|
|
657
|
+
) -> Locator:
|
|
658
|
+
return Locator(
|
|
659
|
+
self,
|
|
660
|
+
selector,
|
|
661
|
+
has_text=hasText,
|
|
662
|
+
has_not_text=hasNotText,
|
|
663
|
+
has=has,
|
|
664
|
+
has_not=hasNot,
|
|
665
|
+
)
|
|
666
|
+
|
|
667
|
+
def get_by_alt_text(
|
|
668
|
+
self, text: Union[str, Pattern[str]], exact: bool = None
|
|
669
|
+
) -> "Locator":
|
|
670
|
+
return self.locator(get_by_alt_text_selector(text, exact=exact))
|
|
671
|
+
|
|
672
|
+
def get_by_label(
|
|
673
|
+
self, text: Union[str, Pattern[str]], exact: bool = None
|
|
674
|
+
) -> "Locator":
|
|
675
|
+
return self.locator(get_by_label_selector(text, exact=exact))
|
|
676
|
+
|
|
677
|
+
def get_by_placeholder(
|
|
678
|
+
self, text: Union[str, Pattern[str]], exact: bool = None
|
|
679
|
+
) -> "Locator":
|
|
680
|
+
return self.locator(get_by_placeholder_selector(text, exact=exact))
|
|
681
|
+
|
|
682
|
+
def get_by_role(
|
|
683
|
+
self,
|
|
684
|
+
role: AriaRole,
|
|
685
|
+
checked: bool = None,
|
|
686
|
+
disabled: bool = None,
|
|
687
|
+
expanded: bool = None,
|
|
688
|
+
includeHidden: bool = None,
|
|
689
|
+
level: int = None,
|
|
690
|
+
name: Union[str, Pattern[str]] = None,
|
|
691
|
+
pressed: bool = None,
|
|
692
|
+
selected: bool = None,
|
|
693
|
+
exact: bool = None,
|
|
694
|
+
description: Union[str, Pattern[str]] = None,
|
|
695
|
+
) -> "Locator":
|
|
696
|
+
return self.locator(
|
|
697
|
+
get_by_role_selector(
|
|
698
|
+
role,
|
|
699
|
+
checked=checked,
|
|
700
|
+
disabled=disabled,
|
|
701
|
+
expanded=expanded,
|
|
702
|
+
includeHidden=includeHidden,
|
|
703
|
+
level=level,
|
|
704
|
+
name=name,
|
|
705
|
+
pressed=pressed,
|
|
706
|
+
selected=selected,
|
|
707
|
+
exact=exact,
|
|
708
|
+
description=description,
|
|
709
|
+
)
|
|
710
|
+
)
|
|
711
|
+
|
|
712
|
+
def get_by_test_id(self, testId: Union[str, Pattern[str]]) -> "Locator":
|
|
713
|
+
return self.locator(get_by_test_id_selector(test_id_attribute_name(), testId))
|
|
714
|
+
|
|
715
|
+
def get_by_text(
|
|
716
|
+
self, text: Union[str, Pattern[str]], exact: bool = None
|
|
717
|
+
) -> "Locator":
|
|
718
|
+
return self.locator(get_by_text_selector(text, exact=exact))
|
|
719
|
+
|
|
720
|
+
def get_by_title(
|
|
721
|
+
self, text: Union[str, Pattern[str]], exact: bool = None
|
|
722
|
+
) -> "Locator":
|
|
723
|
+
return self.locator(get_by_title_selector(text, exact=exact))
|
|
724
|
+
|
|
725
|
+
def frame_locator(self, selector: str) -> FrameLocator:
|
|
726
|
+
return FrameLocator(self, selector)
|
|
727
|
+
|
|
728
|
+
async def focus(
|
|
729
|
+
self, selector: str, strict: bool = None, timeout: float = None
|
|
730
|
+
) -> None:
|
|
731
|
+
await self._channel.send("focus", self._timeout, locals_to_params(locals()))
|
|
732
|
+
|
|
733
|
+
async def text_content(
|
|
734
|
+
self, selector: str, strict: bool = None, timeout: float = None
|
|
735
|
+
) -> Optional[str]:
|
|
736
|
+
return await self._channel.send(
|
|
737
|
+
"textContent", self._timeout, locals_to_params(locals())
|
|
738
|
+
)
|
|
739
|
+
|
|
740
|
+
async def inner_text(
|
|
741
|
+
self, selector: str, strict: bool = None, timeout: float = None
|
|
742
|
+
) -> str:
|
|
743
|
+
return await self._channel.send(
|
|
744
|
+
"innerText", self._timeout, locals_to_params(locals())
|
|
745
|
+
)
|
|
746
|
+
|
|
747
|
+
async def inner_html(
|
|
748
|
+
self, selector: str, strict: bool = None, timeout: float = None
|
|
749
|
+
) -> str:
|
|
750
|
+
return await self._channel.send(
|
|
751
|
+
"innerHTML", self._timeout, locals_to_params(locals())
|
|
752
|
+
)
|
|
753
|
+
|
|
754
|
+
async def get_attribute(
|
|
755
|
+
self, selector: str, name: str, strict: bool = None, timeout: float = None
|
|
756
|
+
) -> Optional[str]:
|
|
757
|
+
return await self._channel.send(
|
|
758
|
+
"getAttribute", self._timeout, locals_to_params(locals())
|
|
759
|
+
)
|
|
760
|
+
|
|
761
|
+
async def hover(
|
|
762
|
+
self,
|
|
763
|
+
selector: str,
|
|
764
|
+
modifiers: Sequence[KeyboardModifier] = None,
|
|
765
|
+
position: Position = None,
|
|
766
|
+
timeout: float = None,
|
|
767
|
+
noWaitAfter: bool = None,
|
|
768
|
+
force: bool = None,
|
|
769
|
+
strict: bool = None,
|
|
770
|
+
trial: bool = None,
|
|
771
|
+
scroll: Literal["auto", "none"] = None,
|
|
772
|
+
) -> None:
|
|
773
|
+
await self._channel.send("hover", self._timeout, locals_to_params(locals()))
|
|
774
|
+
|
|
775
|
+
async def drag_and_drop(
|
|
776
|
+
self,
|
|
777
|
+
source: str,
|
|
778
|
+
target: str,
|
|
779
|
+
sourcePosition: Position = None,
|
|
780
|
+
targetPosition: Position = None,
|
|
781
|
+
force: bool = None,
|
|
782
|
+
noWaitAfter: bool = None,
|
|
783
|
+
strict: bool = None,
|
|
784
|
+
timeout: float = None,
|
|
785
|
+
trial: bool = None,
|
|
786
|
+
steps: int = None,
|
|
787
|
+
scroll: Literal["auto", "none"] = None,
|
|
788
|
+
) -> None:
|
|
789
|
+
await self._channel.send(
|
|
790
|
+
"dragAndDrop", self._timeout, locals_to_params(locals())
|
|
791
|
+
)
|
|
792
|
+
|
|
793
|
+
async def select_option(
|
|
794
|
+
self,
|
|
795
|
+
selector: str,
|
|
796
|
+
value: Union[str, Sequence[str]] = None,
|
|
797
|
+
index: Union[int, Sequence[int]] = None,
|
|
798
|
+
label: Union[str, Sequence[str]] = None,
|
|
799
|
+
element: Union["ElementHandle", Sequence["ElementHandle"]] = None,
|
|
800
|
+
timeout: float = None,
|
|
801
|
+
noWaitAfter: bool = None,
|
|
802
|
+
strict: bool = None,
|
|
803
|
+
force: bool = None,
|
|
804
|
+
) -> List[str]:
|
|
805
|
+
params = locals_to_params(
|
|
806
|
+
dict(
|
|
807
|
+
selector=selector,
|
|
808
|
+
timeout=timeout,
|
|
809
|
+
strict=strict,
|
|
810
|
+
force=force,
|
|
811
|
+
**convert_select_option_values(value, index, label, element),
|
|
812
|
+
)
|
|
813
|
+
)
|
|
814
|
+
return await self._channel.send("selectOption", self._timeout, params)
|
|
815
|
+
|
|
816
|
+
async def input_value(
|
|
817
|
+
self,
|
|
818
|
+
selector: str,
|
|
819
|
+
strict: bool = None,
|
|
820
|
+
timeout: float = None,
|
|
821
|
+
) -> str:
|
|
822
|
+
return await self._channel.send(
|
|
823
|
+
"inputValue", self._timeout, locals_to_params(locals())
|
|
824
|
+
)
|
|
825
|
+
|
|
826
|
+
async def set_input_files(
|
|
827
|
+
self,
|
|
828
|
+
selector: str,
|
|
829
|
+
files: Union[
|
|
830
|
+
str, Path, FilePayload, Sequence[Union[str, Path]], Sequence[FilePayload]
|
|
831
|
+
],
|
|
832
|
+
strict: bool = None,
|
|
833
|
+
timeout: float = None,
|
|
834
|
+
noWaitAfter: bool = None,
|
|
835
|
+
) -> None:
|
|
836
|
+
converted = await convert_input_files(files, self.page.context)
|
|
837
|
+
await self._channel.send(
|
|
838
|
+
"setInputFiles",
|
|
839
|
+
self._timeout,
|
|
840
|
+
{
|
|
841
|
+
"selector": selector,
|
|
842
|
+
"strict": strict,
|
|
843
|
+
"timeout": self._timeout(timeout),
|
|
844
|
+
**converted,
|
|
845
|
+
},
|
|
846
|
+
)
|
|
847
|
+
|
|
848
|
+
async def _drop(
|
|
849
|
+
self,
|
|
850
|
+
selector: str,
|
|
851
|
+
payload: "DropPayload",
|
|
852
|
+
strict: bool = None,
|
|
853
|
+
position: Position = None,
|
|
854
|
+
timeout: float = None,
|
|
855
|
+
) -> None:
|
|
856
|
+
params: Dict[str, Any] = {
|
|
857
|
+
"selector": selector,
|
|
858
|
+
"strict": strict,
|
|
859
|
+
"position": position,
|
|
860
|
+
"timeout": self._timeout(timeout),
|
|
861
|
+
}
|
|
862
|
+
files = payload.get("files") if payload else None
|
|
863
|
+
if files is not None:
|
|
864
|
+
converted = await convert_input_files(files, self.page.context)
|
|
865
|
+
if "directoryStream" in converted or "directoryLocalPath" in converted:
|
|
866
|
+
raise Error(
|
|
867
|
+
"Dropping a directory is not supported, pass individual files instead."
|
|
868
|
+
)
|
|
869
|
+
params.update(converted)
|
|
870
|
+
data = payload.get("data") if payload else None
|
|
871
|
+
if data is not None:
|
|
872
|
+
params["data"] = [{"mimeType": k, "value": v} for k, v in data.items()]
|
|
873
|
+
await self._channel.send("drop", self._timeout, params)
|
|
874
|
+
|
|
875
|
+
async def type(
|
|
876
|
+
self,
|
|
877
|
+
selector: str,
|
|
878
|
+
text: str,
|
|
879
|
+
delay: float = None,
|
|
880
|
+
strict: bool = None,
|
|
881
|
+
timeout: float = None,
|
|
882
|
+
noWaitAfter: bool = None,
|
|
883
|
+
) -> None:
|
|
884
|
+
await self._channel.send("type", self._timeout, locals_to_params(locals()))
|
|
885
|
+
|
|
886
|
+
async def press(
|
|
887
|
+
self,
|
|
888
|
+
selector: str,
|
|
889
|
+
key: str,
|
|
890
|
+
delay: float = None,
|
|
891
|
+
strict: bool = None,
|
|
892
|
+
timeout: float = None,
|
|
893
|
+
noWaitAfter: bool = None,
|
|
894
|
+
) -> None:
|
|
895
|
+
await self._channel.send("press", self._timeout, locals_to_params(locals()))
|
|
896
|
+
|
|
897
|
+
async def check(
|
|
898
|
+
self,
|
|
899
|
+
selector: str,
|
|
900
|
+
position: Position = None,
|
|
901
|
+
timeout: float = None,
|
|
902
|
+
force: bool = None,
|
|
903
|
+
noWaitAfter: bool = None,
|
|
904
|
+
strict: bool = None,
|
|
905
|
+
trial: bool = None,
|
|
906
|
+
scroll: Literal["auto", "none"] = None,
|
|
907
|
+
) -> None:
|
|
908
|
+
await self._channel.send("check", self._timeout, locals_to_params(locals()))
|
|
909
|
+
|
|
910
|
+
async def uncheck(
|
|
911
|
+
self,
|
|
912
|
+
selector: str,
|
|
913
|
+
position: Position = None,
|
|
914
|
+
timeout: float = None,
|
|
915
|
+
force: bool = None,
|
|
916
|
+
noWaitAfter: bool = None,
|
|
917
|
+
strict: bool = None,
|
|
918
|
+
trial: bool = None,
|
|
919
|
+
scroll: Literal["auto", "none"] = None,
|
|
920
|
+
) -> None:
|
|
921
|
+
await self._channel.send("uncheck", self._timeout, locals_to_params(locals()))
|
|
922
|
+
|
|
923
|
+
async def wait_for_timeout(self, timeout: float) -> None:
|
|
924
|
+
await self._channel.send("waitForTimeout", None, {"waitTimeout": timeout})
|
|
925
|
+
|
|
926
|
+
async def wait_for_function(
|
|
927
|
+
self,
|
|
928
|
+
expression: str,
|
|
929
|
+
arg: Serializable = None,
|
|
930
|
+
timeout: float = None,
|
|
931
|
+
polling: Union[float, Literal["raf"]] = None,
|
|
932
|
+
) -> JSHandle:
|
|
933
|
+
if isinstance(polling, str) and polling != "raf":
|
|
934
|
+
raise Error(f"Unknown polling option: {polling}")
|
|
935
|
+
params = locals_to_params(locals())
|
|
936
|
+
params["arg"] = serialize_argument(arg)
|
|
937
|
+
if polling is not None and polling != "raf":
|
|
938
|
+
params["pollingInterval"] = polling
|
|
939
|
+
return from_channel(
|
|
940
|
+
await self._channel.send("waitForFunction", self._timeout, params)
|
|
941
|
+
)
|
|
942
|
+
|
|
943
|
+
async def title(self) -> str:
|
|
944
|
+
return await self._channel.send("title", None)
|
|
945
|
+
|
|
946
|
+
async def set_checked(
|
|
947
|
+
self,
|
|
948
|
+
selector: str,
|
|
949
|
+
checked: bool,
|
|
950
|
+
position: Position = None,
|
|
951
|
+
timeout: float = None,
|
|
952
|
+
force: bool = None,
|
|
953
|
+
noWaitAfter: bool = None,
|
|
954
|
+
strict: bool = None,
|
|
955
|
+
trial: bool = None,
|
|
956
|
+
scroll: Literal["auto", "none"] = None,
|
|
957
|
+
) -> None:
|
|
958
|
+
if checked:
|
|
959
|
+
await self.check(
|
|
960
|
+
selector=selector,
|
|
961
|
+
position=position,
|
|
962
|
+
timeout=timeout,
|
|
963
|
+
force=force,
|
|
964
|
+
strict=strict,
|
|
965
|
+
trial=trial,
|
|
966
|
+
scroll=scroll,
|
|
967
|
+
)
|
|
968
|
+
else:
|
|
969
|
+
await self.uncheck(
|
|
970
|
+
selector=selector,
|
|
971
|
+
position=position,
|
|
972
|
+
timeout=timeout,
|
|
973
|
+
force=force,
|
|
974
|
+
strict=strict,
|
|
975
|
+
trial=trial,
|
|
976
|
+
scroll=scroll,
|
|
977
|
+
)
|
|
978
|
+
|
|
979
|
+
async def _highlight(self, selector: str, style: str = None) -> None:
|
|
980
|
+
await self._channel.send(
|
|
981
|
+
"highlight", None, {"selector": selector, "style": style}
|
|
982
|
+
)
|
|
983
|
+
|
|
984
|
+
async def _hide_highlight(self, selector: str) -> None:
|
|
985
|
+
await self._channel.send("hideHighlight", None, {"selector": selector})
|