playwright-browserstack 1.62.0__py3-none-win_amd64.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,480 @@
|
|
|
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 base64
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
from typing import (
|
|
18
|
+
TYPE_CHECKING,
|
|
19
|
+
Any,
|
|
20
|
+
Callable,
|
|
21
|
+
Dict,
|
|
22
|
+
List,
|
|
23
|
+
Literal,
|
|
24
|
+
Optional,
|
|
25
|
+
Sequence,
|
|
26
|
+
Union,
|
|
27
|
+
cast,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
from playwright._impl._api_structures import FilePayload, FloatRect, Position
|
|
31
|
+
from playwright._impl._connection import ChannelOwner, from_nullable_channel
|
|
32
|
+
from playwright._impl._helper import (
|
|
33
|
+
Error,
|
|
34
|
+
KeyboardModifier,
|
|
35
|
+
MouseButton,
|
|
36
|
+
async_writefile,
|
|
37
|
+
locals_to_params,
|
|
38
|
+
make_dirs_for_file,
|
|
39
|
+
)
|
|
40
|
+
from playwright._impl._js_handle import (
|
|
41
|
+
JSHandle,
|
|
42
|
+
Serializable,
|
|
43
|
+
parse_result,
|
|
44
|
+
serialize_argument,
|
|
45
|
+
)
|
|
46
|
+
from playwright._impl._set_input_files_helpers import convert_input_files
|
|
47
|
+
|
|
48
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
49
|
+
from playwright._impl._frame import Frame
|
|
50
|
+
from playwright._impl._locator import Locator
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class ElementHandle(JSHandle):
|
|
54
|
+
def __init__(
|
|
55
|
+
self, parent: ChannelOwner, type: str, guid: str, initializer: Dict
|
|
56
|
+
) -> None:
|
|
57
|
+
super().__init__(parent, type, guid, initializer)
|
|
58
|
+
self._frame = cast("Frame", parent)
|
|
59
|
+
|
|
60
|
+
async def _createSelectorForTest(self, name: str) -> Optional[str]:
|
|
61
|
+
return await self._channel.send(
|
|
62
|
+
"createSelectorForTest", self._frame._timeout, dict(name=name)
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
def as_element(self) -> Optional["ElementHandle"]:
|
|
66
|
+
return self
|
|
67
|
+
|
|
68
|
+
async def owner_frame(self) -> Optional["Frame"]:
|
|
69
|
+
return from_nullable_channel(await self._channel.send("ownerFrame", None))
|
|
70
|
+
|
|
71
|
+
async def content_frame(self) -> Optional["Frame"]:
|
|
72
|
+
return from_nullable_channel(await self._channel.send("contentFrame", None))
|
|
73
|
+
|
|
74
|
+
async def get_attribute(self, name: str) -> Optional[str]:
|
|
75
|
+
return await self._channel.send("getAttribute", None, dict(name=name))
|
|
76
|
+
|
|
77
|
+
async def text_content(self) -> Optional[str]:
|
|
78
|
+
return await self._channel.send("textContent", None)
|
|
79
|
+
|
|
80
|
+
async def inner_text(self) -> str:
|
|
81
|
+
return await self._channel.send("innerText", None)
|
|
82
|
+
|
|
83
|
+
async def inner_html(self) -> str:
|
|
84
|
+
return await self._channel.send("innerHTML", None)
|
|
85
|
+
|
|
86
|
+
async def is_checked(self) -> bool:
|
|
87
|
+
return await self._channel.send("isChecked", None)
|
|
88
|
+
|
|
89
|
+
async def is_disabled(self) -> bool:
|
|
90
|
+
return await self._channel.send("isDisabled", None)
|
|
91
|
+
|
|
92
|
+
async def is_editable(self) -> bool:
|
|
93
|
+
return await self._channel.send("isEditable", None)
|
|
94
|
+
|
|
95
|
+
async def is_enabled(self) -> bool:
|
|
96
|
+
return await self._channel.send("isEnabled", None)
|
|
97
|
+
|
|
98
|
+
async def is_hidden(self) -> bool:
|
|
99
|
+
return await self._channel.send("isHidden", None)
|
|
100
|
+
|
|
101
|
+
async def is_visible(self) -> bool:
|
|
102
|
+
return await self._channel.send("isVisible", None)
|
|
103
|
+
|
|
104
|
+
async def dispatch_event(self, type: str, eventInit: Dict = None) -> None:
|
|
105
|
+
await self._channel.send(
|
|
106
|
+
"dispatchEvent",
|
|
107
|
+
None,
|
|
108
|
+
dict(type=type, eventInit=serialize_argument(eventInit)),
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
async def scroll_into_view_if_needed(self, timeout: float = None) -> None:
|
|
112
|
+
await self._channel.send(
|
|
113
|
+
"scrollIntoViewIfNeeded", self._frame._timeout, locals_to_params(locals())
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
async def hover(
|
|
117
|
+
self,
|
|
118
|
+
modifiers: Sequence[KeyboardModifier] = None,
|
|
119
|
+
position: Position = None,
|
|
120
|
+
timeout: float = None,
|
|
121
|
+
noWaitAfter: bool = None,
|
|
122
|
+
force: bool = None,
|
|
123
|
+
trial: bool = None,
|
|
124
|
+
scroll: Literal["auto", "none"] = None,
|
|
125
|
+
) -> None:
|
|
126
|
+
await self._channel.send(
|
|
127
|
+
"hover", self._frame._timeout, locals_to_params(locals())
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
async def click(
|
|
131
|
+
self,
|
|
132
|
+
modifiers: Sequence[KeyboardModifier] = None,
|
|
133
|
+
position: Position = None,
|
|
134
|
+
delay: float = None,
|
|
135
|
+
button: MouseButton = None,
|
|
136
|
+
clickCount: int = None,
|
|
137
|
+
timeout: float = None,
|
|
138
|
+
force: bool = None,
|
|
139
|
+
noWaitAfter: bool = None,
|
|
140
|
+
trial: bool = None,
|
|
141
|
+
steps: int = None,
|
|
142
|
+
scroll: Literal["auto", "none"] = None,
|
|
143
|
+
) -> None:
|
|
144
|
+
await self._channel.send(
|
|
145
|
+
"click", self._frame._timeout, locals_to_params(locals())
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
async def dblclick(
|
|
149
|
+
self,
|
|
150
|
+
modifiers: Sequence[KeyboardModifier] = None,
|
|
151
|
+
position: Position = None,
|
|
152
|
+
delay: float = None,
|
|
153
|
+
button: MouseButton = None,
|
|
154
|
+
timeout: float = None,
|
|
155
|
+
force: bool = None,
|
|
156
|
+
noWaitAfter: bool = None,
|
|
157
|
+
trial: bool = None,
|
|
158
|
+
steps: int = None,
|
|
159
|
+
scroll: Literal["auto", "none"] = None,
|
|
160
|
+
) -> None:
|
|
161
|
+
await self._channel.send(
|
|
162
|
+
"dblclick", self._frame._timeout, locals_to_params(locals())
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
async def select_option(
|
|
166
|
+
self,
|
|
167
|
+
value: Union[str, Sequence[str]] = None,
|
|
168
|
+
index: Union[int, Sequence[int]] = None,
|
|
169
|
+
label: Union[str, Sequence[str]] = None,
|
|
170
|
+
element: Union["ElementHandle", Sequence["ElementHandle"]] = None,
|
|
171
|
+
timeout: float = None,
|
|
172
|
+
force: bool = None,
|
|
173
|
+
noWaitAfter: bool = None,
|
|
174
|
+
) -> List[str]:
|
|
175
|
+
params = locals_to_params(
|
|
176
|
+
dict(
|
|
177
|
+
timeout=timeout,
|
|
178
|
+
force=force,
|
|
179
|
+
**convert_select_option_values(value, index, label, element),
|
|
180
|
+
)
|
|
181
|
+
)
|
|
182
|
+
return await self._channel.send("selectOption", self._frame._timeout, params)
|
|
183
|
+
|
|
184
|
+
async def tap(
|
|
185
|
+
self,
|
|
186
|
+
modifiers: Sequence[KeyboardModifier] = None,
|
|
187
|
+
position: Position = None,
|
|
188
|
+
timeout: float = None,
|
|
189
|
+
force: bool = None,
|
|
190
|
+
noWaitAfter: bool = None,
|
|
191
|
+
trial: bool = None,
|
|
192
|
+
scroll: Literal["auto", "none"] = None,
|
|
193
|
+
) -> None:
|
|
194
|
+
await self._channel.send(
|
|
195
|
+
"tap", self._frame._timeout, locals_to_params(locals())
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
async def fill(
|
|
199
|
+
self,
|
|
200
|
+
value: str,
|
|
201
|
+
timeout: float = None,
|
|
202
|
+
noWaitAfter: bool = None,
|
|
203
|
+
force: bool = None,
|
|
204
|
+
) -> None:
|
|
205
|
+
await self._channel.send(
|
|
206
|
+
"fill", self._frame._timeout, locals_to_params(locals())
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
async def select_text(self, force: bool = None, timeout: float = None) -> None:
|
|
210
|
+
await self._channel.send(
|
|
211
|
+
"selectText", self._frame._timeout, locals_to_params(locals())
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
async def input_value(self, timeout: float = None) -> str:
|
|
215
|
+
return await self._channel.send(
|
|
216
|
+
"inputValue", self._frame._timeout, locals_to_params(locals())
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
async def set_input_files(
|
|
220
|
+
self,
|
|
221
|
+
files: Union[
|
|
222
|
+
str, Path, FilePayload, Sequence[Union[str, Path]], Sequence[FilePayload]
|
|
223
|
+
],
|
|
224
|
+
timeout: float = None,
|
|
225
|
+
noWaitAfter: bool = None,
|
|
226
|
+
) -> None:
|
|
227
|
+
frame = await self.owner_frame()
|
|
228
|
+
if not frame:
|
|
229
|
+
raise Error("Cannot set input files to detached element")
|
|
230
|
+
converted = await convert_input_files(files, frame.page.context)
|
|
231
|
+
await self._channel.send(
|
|
232
|
+
"setInputFiles",
|
|
233
|
+
self._frame._timeout,
|
|
234
|
+
{
|
|
235
|
+
"timeout": timeout,
|
|
236
|
+
**converted,
|
|
237
|
+
},
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
async def focus(self) -> None:
|
|
241
|
+
await self._channel.send("focus", None)
|
|
242
|
+
|
|
243
|
+
async def type(
|
|
244
|
+
self,
|
|
245
|
+
text: str,
|
|
246
|
+
delay: float = None,
|
|
247
|
+
timeout: float = None,
|
|
248
|
+
noWaitAfter: bool = None,
|
|
249
|
+
) -> None:
|
|
250
|
+
await self._channel.send(
|
|
251
|
+
"type", self._frame._timeout, locals_to_params(locals())
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
async def press(
|
|
255
|
+
self,
|
|
256
|
+
key: str,
|
|
257
|
+
delay: float = None,
|
|
258
|
+
timeout: float = None,
|
|
259
|
+
noWaitAfter: bool = None,
|
|
260
|
+
) -> None:
|
|
261
|
+
await self._channel.send(
|
|
262
|
+
"press", self._frame._timeout, locals_to_params(locals())
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
async def set_checked(
|
|
266
|
+
self,
|
|
267
|
+
checked: bool,
|
|
268
|
+
position: Position = None,
|
|
269
|
+
timeout: float = None,
|
|
270
|
+
force: bool = None,
|
|
271
|
+
noWaitAfter: bool = None,
|
|
272
|
+
trial: bool = None,
|
|
273
|
+
scroll: Literal["auto", "none"] = None,
|
|
274
|
+
) -> None:
|
|
275
|
+
if checked:
|
|
276
|
+
await self.check(
|
|
277
|
+
position=position,
|
|
278
|
+
timeout=timeout,
|
|
279
|
+
force=force,
|
|
280
|
+
trial=trial,
|
|
281
|
+
scroll=scroll,
|
|
282
|
+
)
|
|
283
|
+
else:
|
|
284
|
+
await self.uncheck(
|
|
285
|
+
position=position,
|
|
286
|
+
timeout=timeout,
|
|
287
|
+
force=force,
|
|
288
|
+
trial=trial,
|
|
289
|
+
scroll=scroll,
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
async def check(
|
|
293
|
+
self,
|
|
294
|
+
position: Position = None,
|
|
295
|
+
timeout: float = None,
|
|
296
|
+
force: bool = None,
|
|
297
|
+
noWaitAfter: bool = None,
|
|
298
|
+
trial: bool = None,
|
|
299
|
+
scroll: Literal["auto", "none"] = None,
|
|
300
|
+
) -> None:
|
|
301
|
+
await self._channel.send(
|
|
302
|
+
"check", self._frame._timeout, locals_to_params(locals())
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
async def uncheck(
|
|
306
|
+
self,
|
|
307
|
+
position: Position = None,
|
|
308
|
+
timeout: float = None,
|
|
309
|
+
force: bool = None,
|
|
310
|
+
noWaitAfter: bool = None,
|
|
311
|
+
trial: bool = None,
|
|
312
|
+
scroll: Literal["auto", "none"] = None,
|
|
313
|
+
) -> None:
|
|
314
|
+
await self._channel.send(
|
|
315
|
+
"uncheck", self._frame._timeout, locals_to_params(locals())
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
async def bounding_box(self) -> Optional[FloatRect]:
|
|
319
|
+
return await self._channel.send("boundingBox", None)
|
|
320
|
+
|
|
321
|
+
async def screenshot(
|
|
322
|
+
self,
|
|
323
|
+
timeout: float = None,
|
|
324
|
+
type: Literal["jpeg", "png", "webp"] = None,
|
|
325
|
+
path: Union[str, Path] = None,
|
|
326
|
+
quality: int = None,
|
|
327
|
+
omitBackground: bool = None,
|
|
328
|
+
animations: Literal["allow", "disabled"] = None,
|
|
329
|
+
caret: Literal["hide", "initial"] = None,
|
|
330
|
+
scale: Literal["css", "device"] = None,
|
|
331
|
+
mask: Sequence["Locator"] = None,
|
|
332
|
+
maskColor: str = None,
|
|
333
|
+
style: str = None,
|
|
334
|
+
) -> bytes:
|
|
335
|
+
params = locals_to_params(locals())
|
|
336
|
+
if "path" in params:
|
|
337
|
+
if "type" not in params:
|
|
338
|
+
params["type"] = determine_screenshot_type(params["path"])
|
|
339
|
+
del params["path"]
|
|
340
|
+
if "mask" in params:
|
|
341
|
+
params["mask"] = list(
|
|
342
|
+
map(
|
|
343
|
+
lambda locator: (
|
|
344
|
+
{
|
|
345
|
+
"frame": locator._frame._channel,
|
|
346
|
+
"selector": locator._selector,
|
|
347
|
+
}
|
|
348
|
+
),
|
|
349
|
+
params["mask"],
|
|
350
|
+
)
|
|
351
|
+
)
|
|
352
|
+
encoded_binary = await self._channel.send(
|
|
353
|
+
"screenshot", self._frame._timeout, params
|
|
354
|
+
)
|
|
355
|
+
decoded_binary = base64.b64decode(encoded_binary)
|
|
356
|
+
if path:
|
|
357
|
+
make_dirs_for_file(path)
|
|
358
|
+
await async_writefile(path, decoded_binary)
|
|
359
|
+
return decoded_binary
|
|
360
|
+
|
|
361
|
+
async def query_selector(self, selector: str) -> Optional["ElementHandle"]:
|
|
362
|
+
return from_nullable_channel(
|
|
363
|
+
await self._channel.send("querySelector", None, dict(selector=selector))
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
async def query_selector_all(self, selector: str) -> List["ElementHandle"]:
|
|
367
|
+
return list(
|
|
368
|
+
map(
|
|
369
|
+
cast(Callable[[Any], Any], from_nullable_channel),
|
|
370
|
+
await self._channel.send(
|
|
371
|
+
"querySelectorAll", None, dict(selector=selector)
|
|
372
|
+
),
|
|
373
|
+
)
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
async def eval_on_selector(
|
|
377
|
+
self,
|
|
378
|
+
selector: str,
|
|
379
|
+
expression: str,
|
|
380
|
+
arg: Serializable = None,
|
|
381
|
+
) -> Any:
|
|
382
|
+
return parse_result(
|
|
383
|
+
await self._channel.send(
|
|
384
|
+
"evalOnSelector",
|
|
385
|
+
None,
|
|
386
|
+
dict(
|
|
387
|
+
selector=selector,
|
|
388
|
+
expression=expression,
|
|
389
|
+
arg=serialize_argument(arg),
|
|
390
|
+
),
|
|
391
|
+
)
|
|
392
|
+
)
|
|
393
|
+
|
|
394
|
+
async def eval_on_selector_all(
|
|
395
|
+
self,
|
|
396
|
+
selector: str,
|
|
397
|
+
expression: str,
|
|
398
|
+
arg: Serializable = None,
|
|
399
|
+
) -> Any:
|
|
400
|
+
return parse_result(
|
|
401
|
+
await self._channel.send(
|
|
402
|
+
"evalOnSelectorAll",
|
|
403
|
+
None,
|
|
404
|
+
dict(
|
|
405
|
+
selector=selector,
|
|
406
|
+
expression=expression,
|
|
407
|
+
arg=serialize_argument(arg),
|
|
408
|
+
),
|
|
409
|
+
)
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
async def wait_for_element_state(
|
|
413
|
+
self,
|
|
414
|
+
state: Literal[
|
|
415
|
+
"disabled", "editable", "enabled", "hidden", "stable", "visible"
|
|
416
|
+
],
|
|
417
|
+
timeout: float = None,
|
|
418
|
+
) -> None:
|
|
419
|
+
await self._channel.send(
|
|
420
|
+
"waitForElementState", self._frame._timeout, locals_to_params(locals())
|
|
421
|
+
)
|
|
422
|
+
|
|
423
|
+
async def wait_for_selector(
|
|
424
|
+
self,
|
|
425
|
+
selector: str,
|
|
426
|
+
state: Literal["attached", "detached", "hidden", "visible"] = None,
|
|
427
|
+
timeout: float = None,
|
|
428
|
+
strict: bool = None,
|
|
429
|
+
) -> Optional["ElementHandle"]:
|
|
430
|
+
return from_nullable_channel(
|
|
431
|
+
await self._channel.send(
|
|
432
|
+
"waitForSelector", self._frame._timeout, locals_to_params(locals())
|
|
433
|
+
)
|
|
434
|
+
)
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
def convert_select_option_values(
|
|
438
|
+
value: Union[str, Sequence[str]] = None,
|
|
439
|
+
index: Union[int, Sequence[int]] = None,
|
|
440
|
+
label: Union[str, Sequence[str]] = None,
|
|
441
|
+
element: Union["ElementHandle", Sequence["ElementHandle"]] = None,
|
|
442
|
+
) -> Any:
|
|
443
|
+
if value is None and index is None and label is None and element is None:
|
|
444
|
+
return {}
|
|
445
|
+
|
|
446
|
+
options: Any = None
|
|
447
|
+
elements: Any = None
|
|
448
|
+
if value is not None:
|
|
449
|
+
if isinstance(value, str):
|
|
450
|
+
value = [value]
|
|
451
|
+
options = (options or []) + list(map(lambda e: dict(valueOrLabel=e), value))
|
|
452
|
+
if index is not None:
|
|
453
|
+
if isinstance(index, int):
|
|
454
|
+
index = [index]
|
|
455
|
+
options = (options or []) + list(map(lambda e: dict(index=e), index))
|
|
456
|
+
if label is not None:
|
|
457
|
+
if isinstance(label, str):
|
|
458
|
+
label = [label]
|
|
459
|
+
options = (options or []) + list(map(lambda e: dict(label=e), label))
|
|
460
|
+
if element:
|
|
461
|
+
if isinstance(element, ElementHandle):
|
|
462
|
+
element = [element]
|
|
463
|
+
elements = list(map(lambda e: e._channel, element))
|
|
464
|
+
|
|
465
|
+
return dict(options=options, elements=elements)
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
def determine_screenshot_type(path: Union[str, Path]) -> Literal["jpeg", "png", "webp"]:
|
|
469
|
+
# Detect by file extension rather than mimetypes.guess_type, whose result is
|
|
470
|
+
# OS-dependent (e.g. Windows does not register image/webp), mirroring
|
|
471
|
+
# upstream's getMimeTypeForPath extension map:
|
|
472
|
+
# https://github.com/microsoft/playwright/blob/e0e814deed7b0a4c4d2bdf98481e6be7419cda16/packages/isomorphic/mimeType.ts#L28
|
|
473
|
+
suffix = Path(path).suffix.lower()
|
|
474
|
+
if suffix == ".png":
|
|
475
|
+
return "png"
|
|
476
|
+
if suffix in (".jpeg", ".jpg"):
|
|
477
|
+
return "jpeg"
|
|
478
|
+
if suffix == ".webp":
|
|
479
|
+
return "webp"
|
|
480
|
+
raise Error(f'path: unsupported mime type "{suffix}"')
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
# These are types that we use in the API. They are public and are a part of the
|
|
16
|
+
# stable API.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
from typing import Any, List, Optional
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def is_target_closed_error(error: Exception) -> bool:
|
|
23
|
+
return isinstance(error, TargetClosedError)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class Error(Exception):
|
|
27
|
+
def __init__(self, message: str) -> None:
|
|
28
|
+
self._message = message
|
|
29
|
+
self._name: Optional[str] = None
|
|
30
|
+
self._stack: Optional[str] = None
|
|
31
|
+
self._details: Optional[Any] = None
|
|
32
|
+
self._log: Optional[List[str]] = None
|
|
33
|
+
super().__init__(message)
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def message(self) -> str:
|
|
37
|
+
return self._message
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def name(self) -> Optional[str]:
|
|
41
|
+
return self._name
|
|
42
|
+
|
|
43
|
+
@property
|
|
44
|
+
def stack(self) -> Optional[str]:
|
|
45
|
+
return self._stack
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class TimeoutError(Error):
|
|
49
|
+
pass
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class TargetClosedError(Error):
|
|
53
|
+
def __init__(self, message: str = None) -> None:
|
|
54
|
+
super().__init__(message or "Target page, context or browser has been closed")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def rewrite_error(error: Exception, message: str) -> Exception:
|
|
58
|
+
rewritten_exc = type(error)(message)
|
|
59
|
+
if isinstance(rewritten_exc, Error) and isinstance(error, Error):
|
|
60
|
+
rewritten_exc._name = error.name
|
|
61
|
+
rewritten_exc._stack = error.stack
|
|
62
|
+
rewritten_exc._details = error._details
|
|
63
|
+
rewritten_exc._log = error._log
|
|
64
|
+
return rewritten_exc
|
|
@@ -0,0 +1,33 @@
|
|
|
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 typing import Any, Generic, TypeVar
|
|
17
|
+
|
|
18
|
+
T = TypeVar("T")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class EventContextManagerImpl(Generic[T]):
|
|
22
|
+
def __init__(self, future: asyncio.Future) -> None:
|
|
23
|
+
self._future: asyncio.Future = future
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def future(self) -> asyncio.Future:
|
|
27
|
+
return self._future
|
|
28
|
+
|
|
29
|
+
async def __aenter__(self) -> asyncio.Future:
|
|
30
|
+
return self._future
|
|
31
|
+
|
|
32
|
+
async def __aexit__(self, *args: Any) -> None:
|
|
33
|
+
await self._future
|