pure-patchright 1.62.3__py3-none-any.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 (142) hide show
  1. patchright/__init__.py +5 -0
  2. patchright/__main__.py +18 -0
  3. patchright/_impl/__init__.py +0 -0
  4. patchright/_impl/__pyinstaller/__init__.py +20 -0
  5. patchright/_impl/__pyinstaller/hook-playwright.async_api.py +3 -0
  6. patchright/_impl/__pyinstaller/hook-playwright.sync_api.py +3 -0
  7. patchright/_impl/_api_structures.py +343 -0
  8. patchright/_impl/_artifact.py +46 -0
  9. patchright/_impl/_assertions.py +1014 -0
  10. patchright/_impl/_async_base.py +88 -0
  11. patchright/_impl/_browser.py +267 -0
  12. patchright/_impl/_browser_context.py +759 -0
  13. patchright/_impl/_browser_type.py +336 -0
  14. patchright/_impl/_cdp_session.py +25 -0
  15. patchright/_impl/_clock.py +62 -0
  16. patchright/_impl/_connection.py +686 -0
  17. patchright/_impl/_console_message.py +83 -0
  18. patchright/_impl/_credentials.py +38 -0
  19. patchright/_impl/_debugger.py +37 -0
  20. patchright/_impl/_dialog.py +45 -0
  21. patchright/_impl/_disposable.py +71 -0
  22. patchright/_impl/_download.py +49 -0
  23. patchright/_impl/_driver.py +24 -0
  24. patchright/_impl/_element_handle.py +446 -0
  25. patchright/_impl/_errors.py +46 -0
  26. patchright/_impl/_event_context_manager.py +19 -0
  27. patchright/_impl/_fetch.py +592 -0
  28. patchright/_impl/_file_chooser.py +42 -0
  29. patchright/_impl/_form_data.py +19 -0
  30. patchright/_impl/_frame.py +959 -0
  31. patchright/_impl/_glob.py +47 -0
  32. patchright/_impl/_greenlets.py +35 -0
  33. patchright/_impl/_har_router.py +98 -0
  34. patchright/_impl/_helper.py +551 -0
  35. patchright/_impl/_impl_to_api_mapping.py +141 -0
  36. patchright/_impl/_input.py +85 -0
  37. patchright/_impl/_js_handle.py +297 -0
  38. patchright/_impl/_json_pipe.py +55 -0
  39. patchright/_impl/_local_utils.py +73 -0
  40. patchright/_impl/_locator.py +894 -0
  41. patchright/_impl/_map.py +18 -0
  42. patchright/_impl/_network.py +953 -0
  43. patchright/_impl/_object_factory.py +93 -0
  44. patchright/_impl/_page.py +1601 -0
  45. patchright/_impl/_path_utils.py +13 -0
  46. patchright/_impl/_playwright.py +43 -0
  47. patchright/_impl/_screencast.py +149 -0
  48. patchright/_impl/_selectors.py +48 -0
  49. patchright/_impl/_set_input_files_helpers.py +134 -0
  50. patchright/_impl/_str_utils.py +59 -0
  51. patchright/_impl/_stream.py +31 -0
  52. patchright/_impl/_sync_base.py +130 -0
  53. patchright/_impl/_tracing.py +243 -0
  54. patchright/_impl/_transport.py +151 -0
  55. patchright/_impl/_video.py +41 -0
  56. patchright/_impl/_waiter.py +168 -0
  57. patchright/_impl/_web_error.py +33 -0
  58. patchright/_impl/_web_storage.py +41 -0
  59. patchright/_impl/_writable_stream.py +26 -0
  60. patchright/_repo_version.py +1 -0
  61. patchright/async_api/__init__.py +234 -0
  62. patchright/async_api/_context_manager.py +38 -0
  63. patchright/async_api/_generated.py +23396 -0
  64. patchright/driver/README.md +1 -0
  65. patchright/driver/package/README.md +3 -0
  66. patchright/driver/package/ThirdPartyNotices.txt +13 -0
  67. patchright/driver/package/bin/install_media_pack.ps1 +5 -0
  68. patchright/driver/package/bin/install_webkit_wsl.ps1 +33 -0
  69. patchright/driver/package/bin/reinstall_chrome_beta_linux.sh +42 -0
  70. patchright/driver/package/bin/reinstall_chrome_beta_mac.sh +13 -0
  71. patchright/driver/package/bin/reinstall_chrome_beta_win.ps1 +24 -0
  72. patchright/driver/package/bin/reinstall_chrome_stable_linux.sh +42 -0
  73. patchright/driver/package/bin/reinstall_chrome_stable_mac.sh +12 -0
  74. patchright/driver/package/bin/reinstall_chrome_stable_win.ps1 +24 -0
  75. patchright/driver/package/bin/reinstall_msedge_beta_linux.sh +48 -0
  76. patchright/driver/package/bin/reinstall_msedge_beta_mac.sh +11 -0
  77. patchright/driver/package/bin/reinstall_msedge_beta_win.ps1 +23 -0
  78. patchright/driver/package/bin/reinstall_msedge_dev_linux.sh +48 -0
  79. patchright/driver/package/bin/reinstall_msedge_dev_mac.sh +11 -0
  80. patchright/driver/package/bin/reinstall_msedge_dev_win.ps1 +23 -0
  81. patchright/driver/package/bin/reinstall_msedge_stable_linux.sh +48 -0
  82. patchright/driver/package/bin/reinstall_msedge_stable_mac.sh +11 -0
  83. patchright/driver/package/bin/reinstall_msedge_stable_win.ps1 +24 -0
  84. patchright/driver/package/browsers.json +75 -0
  85. patchright/driver/package/cli.js +21 -0
  86. patchright/driver/package/index.js +17 -0
  87. patchright/driver/package/index.mjs +28 -0
  88. patchright/driver/package/lib/bootstrap.js +88 -0
  89. patchright/driver/package/lib/coreBundle.js +77498 -0
  90. patchright/driver/package/lib/entry/cliDaemon.js +5 -0
  91. patchright/driver/package/lib/entry/dashboardApp.js +3 -0
  92. patchright/driver/package/lib/entry/mcp.js +10 -0
  93. patchright/driver/package/lib/entry/oopBrowserDownload.js +3 -0
  94. patchright/driver/package/lib/package.js +50 -0
  95. patchright/driver/package/lib/server/chromium/appIcon.png +0 -0
  96. patchright/driver/package/lib/server/electron/loader.js +107 -0
  97. patchright/driver/package/lib/serverRegistry.js +7347 -0
  98. patchright/driver/package/lib/serverRegistry.js.LICENSE +354 -0
  99. patchright/driver/package/lib/tools/cli-client/channelSessions.js +141 -0
  100. patchright/driver/package/lib/tools/cli-client/cli.js +6 -0
  101. patchright/driver/package/lib/tools/cli-client/help.json +708 -0
  102. patchright/driver/package/lib/tools/cli-client/minimist.js +128 -0
  103. patchright/driver/package/lib/tools/cli-client/output.js +343 -0
  104. patchright/driver/package/lib/tools/cli-client/program.js +404 -0
  105. patchright/driver/package/lib/tools/cli-client/registry.js +176 -0
  106. patchright/driver/package/lib/tools/cli-client/session.js +258 -0
  107. patchright/driver/package/lib/tools/dashboard/appIcon.png +0 -0
  108. patchright/driver/package/lib/tools/skills/playwright-cli/SKILL.md +420 -0
  109. patchright/driver/package/lib/tools/skills/playwright-cli/references/element-attributes.md +23 -0
  110. patchright/driver/package/lib/tools/skills/playwright-cli/references/playwright-tests.md +39 -0
  111. patchright/driver/package/lib/tools/skills/playwright-cli/references/request-mocking.md +87 -0
  112. patchright/driver/package/lib/tools/skills/playwright-cli/references/running-code.md +241 -0
  113. patchright/driver/package/lib/tools/skills/playwright-cli/references/session-management.md +225 -0
  114. patchright/driver/package/lib/tools/skills/playwright-cli/references/storage-state.md +275 -0
  115. patchright/driver/package/lib/tools/skills/playwright-cli/references/test-generation.md +433 -0
  116. patchright/driver/package/lib/tools/skills/playwright-cli/references/tracing.md +139 -0
  117. patchright/driver/package/lib/tools/skills/playwright-cli/references/video-recording.md +143 -0
  118. patchright/driver/package/lib/tools/skills/playwright-component-testing/SKILL.md +143 -0
  119. patchright/driver/package/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +144 -0
  120. patchright/driver/package/lib/tools/skills/playwright-component-testing/references/migration.md +85 -0
  121. patchright/driver/package/lib/tools/skills/playwright-component-testing/references/react.md +67 -0
  122. patchright/driver/package/lib/tools/skills/playwright-component-testing/references/vue.md +75 -0
  123. patchright/driver/package/lib/tools/skills/playwright-trace/SKILL.md +171 -0
  124. patchright/driver/package/lib/tools/utils/extension.js +101 -0
  125. patchright/driver/package/lib/tools/utils/socketConnection.js +108 -0
  126. patchright/driver/package/lib/utilsBundle.js +90764 -0
  127. patchright/driver/package/lib/utilsBundle.js.LICENSE +2179 -0
  128. patchright/driver/package/lib/webp_codec.LICENSE +173 -0
  129. patchright/driver/package/lib/webp_codec.wasm +0 -0
  130. patchright/driver/package/lib/xdg-open +1267 -0
  131. patchright/driver/package/package.json +34 -0
  132. patchright/py.typed +0 -0
  133. patchright/sync_api/__init__.py +234 -0
  134. patchright/sync_api/_context_manager.py +73 -0
  135. patchright/sync_api/_generated.py +23590 -0
  136. pure_patchright-1.62.3.dist-info/LICENSE +201 -0
  137. pure_patchright-1.62.3.dist-info/METADATA +96 -0
  138. pure_patchright-1.62.3.dist-info/RECORD +142 -0
  139. pure_patchright-1.62.3.dist-info/WHEEL +4 -0
  140. pure_patchright-1.62.3.dist-info/entry_points.txt +5 -0
  141. pure_patchright-1.62.3.dist-info/licenses/LICENSE +202 -0
  142. pure_patchright-1.62.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,26 @@
1
+ import base64
2
+ import os
3
+ from pathlib import Path
4
+ from typing import Dict, Union
5
+ from patchright._impl._connection import ChannelOwner
6
+
7
+ _WINDOWS = os.name == "nt"
8
+ COPY_BUFSIZE = 1024 * 1024 if _WINDOWS else 64 * 1024
9
+
10
+
11
+ class WritableStream(ChannelOwner):
12
+ def __init__(
13
+ self, parent: ChannelOwner, type: str, guid: str, initializer: Dict
14
+ ) -> None:
15
+ super().__init__(parent, type, guid, initializer)
16
+
17
+ async def copy(self, path: Union[str, Path]) -> None:
18
+ with open(path, "rb") as f:
19
+ while True:
20
+ data = f.read(COPY_BUFSIZE)
21
+ if not data:
22
+ break
23
+ await self._channel.send(
24
+ "write", None, {"binary": base64.b64encode(data).decode()}
25
+ )
26
+ await self._channel.send("close", None)
@@ -0,0 +1 @@
1
+ version = '1.62.3'
@@ -0,0 +1,234 @@
1
+ """
2
+ Python package `playwright` is a Python library to automate Chromium,
3
+ Firefox and WebKit with a single API. Playwright is built to enable cross-browser
4
+ web automation that is ever-green, capable, reliable and fast.
5
+ """
6
+
7
+ from typing import Any, Optional, Union, overload
8
+ import patchright._impl._api_structures
9
+ import patchright._impl._errors
10
+ import patchright._impl._form_data
11
+ import patchright.async_api._generated
12
+ from patchright._impl._assertions import (
13
+ APIResponseAssertions as APIResponseAssertionsImpl,
14
+ )
15
+ from patchright._impl._assertions import LocatorAssertions as LocatorAssertionsImpl
16
+ from patchright._impl._assertions import PageAssertions as PageAssertionsImpl
17
+ from patchright.async_api._context_manager import PlaywrightContextManager
18
+ from patchright.async_api._generated import (
19
+ APIRequest,
20
+ APIRequestContext,
21
+ APIResponse,
22
+ APIResponseAssertions,
23
+ Browser,
24
+ BrowserContext,
25
+ BrowserType,
26
+ CDPSession,
27
+ ConsoleMessage,
28
+ Dialog,
29
+ Download,
30
+ ElementHandle,
31
+ FileChooser,
32
+ Frame,
33
+ FrameLocator,
34
+ JSHandle,
35
+ Keyboard,
36
+ Locator,
37
+ LocatorAssertions,
38
+ Mouse,
39
+ Page,
40
+ PageAssertions,
41
+ Playwright,
42
+ Request,
43
+ Response,
44
+ Route,
45
+ Selectors,
46
+ Touchscreen,
47
+ Video,
48
+ WebError,
49
+ WebSocket,
50
+ WebSocketRoute,
51
+ Worker,
52
+ )
53
+
54
+ ChromiumBrowserContext = BrowserContext
55
+ Cookie = patchright._impl._api_structures.Cookie
56
+ FilePayload = patchright._impl._api_structures.FilePayload
57
+ FormData = patchright._impl._form_data.FormData
58
+ FloatRect = patchright._impl._api_structures.FloatRect
59
+ Geolocation = patchright._impl._api_structures.Geolocation
60
+ HttpCredentials = patchright._impl._api_structures.HttpCredentials
61
+ BrowserBindResult = patchright._impl._api_structures.BrowserBindResult
62
+ DebuggerLocation = patchright._impl._api_structures.DebuggerLocation
63
+ DebuggerPausedDetails = patchright._impl._api_structures.DebuggerPausedDetails
64
+ PdfMargins = patchright._impl._api_structures.PdfMargins
65
+ Position = patchright._impl._api_structures.Position
66
+ ProxySettings = patchright._impl._api_structures.ProxySettings
67
+ ResourceTiming = patchright._impl._api_structures.ResourceTiming
68
+ ScreencastFrame = patchright._impl._api_structures.ScreencastFrame
69
+ ScreencastSize = patchright._impl._api_structures.ScreencastSize
70
+ SourceLocation = patchright._impl._api_structures.SourceLocation
71
+ StorageState = patchright._impl._api_structures.StorageState
72
+ StorageStateCookie = patchright._impl._api_structures.StorageStateCookie
73
+ ViewportSize = patchright._impl._api_structures.ViewportSize
74
+ VirtualCredential = patchright._impl._api_structures.VirtualCredential
75
+ Error = patchright._impl._errors.Error
76
+ TimeoutError = patchright._impl._errors.TimeoutError
77
+
78
+
79
+ def async_playwright() -> PlaywrightContextManager:
80
+ return PlaywrightContextManager()
81
+
82
+
83
+ class Expect:
84
+ _unset: Any = object()
85
+
86
+ def __init__(self) -> None:
87
+ self._timeout: Optional[float] = None
88
+
89
+ def set_options(self, timeout: Optional[float] = _unset) -> None:
90
+ """
91
+ This method sets global `expect()` options.
92
+
93
+ Args:
94
+ timeout (float): Timeout value in milliseconds. Default to 5000 milliseconds.
95
+
96
+ Returns:
97
+ None
98
+ """
99
+ if timeout is not self._unset:
100
+ self._timeout = timeout
101
+
102
+ @overload
103
+ def __call__(
104
+ self, actual: Page, message: Optional[str] = None
105
+ ) -> PageAssertions: ...
106
+
107
+ @overload
108
+ def __call__(
109
+ self, actual: Locator, message: Optional[str] = None
110
+ ) -> LocatorAssertions: ...
111
+
112
+ @overload
113
+ def __call__(
114
+ self, actual: APIResponse, message: Optional[str] = None
115
+ ) -> APIResponseAssertions: ...
116
+
117
+ def __call__(
118
+ self, actual: Union[Page, Locator, APIResponse], message: Optional[str] = None
119
+ ) -> Union[PageAssertions, LocatorAssertions, APIResponseAssertions]:
120
+ return self._dispatch(actual, message, is_soft=False)
121
+
122
+ @overload
123
+ def soft(self, actual: Page, message: Optional[str] = None) -> PageAssertions: ...
124
+
125
+ @overload
126
+ def soft(
127
+ self, actual: Locator, message: Optional[str] = None
128
+ ) -> LocatorAssertions: ...
129
+
130
+ @overload
131
+ def soft(
132
+ self, actual: APIResponse, message: Optional[str] = None
133
+ ) -> APIResponseAssertions: ...
134
+
135
+ def soft(
136
+ self, actual: Union[Page, Locator, APIResponse], message: Optional[str] = None
137
+ ) -> Union[PageAssertions, LocatorAssertions, APIResponseAssertions]:
138
+ """
139
+ Creates a [soft assertion](https://playwright.dev/python/docs/test-assertions#soft-assertions).
140
+ Failing soft assertions do not abort test execution, but mark the test
141
+ as failed. Multiple failures from the same test are surfaced together
142
+ at the end of the test.
143
+
144
+ Requires the [pytest-playwright](https://pypi.org/project/pytest-playwright/)
145
+ plugin to establish the per-test scope that collects soft assertion
146
+ failures.
147
+ """
148
+ return self._dispatch(actual, message, is_soft=True)
149
+
150
+ def _dispatch(
151
+ self,
152
+ actual: Union[Page, Locator, APIResponse],
153
+ message: Optional[str],
154
+ is_soft: bool,
155
+ ) -> Union[PageAssertions, LocatorAssertions, APIResponseAssertions]:
156
+ if isinstance(actual, Page):
157
+ return PageAssertions(
158
+ PageAssertionsImpl(
159
+ actual._impl_obj, self._timeout, message=message, is_soft=is_soft
160
+ )
161
+ )
162
+ elif isinstance(actual, Locator):
163
+ return LocatorAssertions(
164
+ LocatorAssertionsImpl(
165
+ actual._impl_obj, self._timeout, message=message, is_soft=is_soft
166
+ )
167
+ )
168
+ elif isinstance(actual, APIResponse):
169
+ return APIResponseAssertions(
170
+ APIResponseAssertionsImpl(
171
+ actual._impl_obj, self._timeout, message=message, is_soft=is_soft
172
+ )
173
+ )
174
+ raise ValueError(f"Unsupported type: {type(actual)}")
175
+
176
+
177
+ expect = Expect()
178
+ __all__ = [
179
+ "expect",
180
+ "async_playwright",
181
+ "APIRequest",
182
+ "APIRequestContext",
183
+ "APIResponse",
184
+ "Browser",
185
+ "BrowserBindResult",
186
+ "BrowserContext",
187
+ "BrowserType",
188
+ "CDPSession",
189
+ "ChromiumBrowserContext",
190
+ "ConsoleMessage",
191
+ "Cookie",
192
+ "Dialog",
193
+ "Download",
194
+ "ElementHandle",
195
+ "Error",
196
+ "FileChooser",
197
+ "FilePayload",
198
+ "FloatRect",
199
+ "FormData",
200
+ "Frame",
201
+ "FrameLocator",
202
+ "Geolocation",
203
+ "HttpCredentials",
204
+ "JSHandle",
205
+ "Keyboard",
206
+ "Locator",
207
+ "Mouse",
208
+ "DebuggerLocation",
209
+ "DebuggerPausedDetails",
210
+ "Page",
211
+ "PdfMargins",
212
+ "Position",
213
+ "Playwright",
214
+ "ProxySettings",
215
+ "Request",
216
+ "ResourceTiming",
217
+ "Response",
218
+ "Route",
219
+ "ScreencastFrame",
220
+ "ScreencastSize",
221
+ "Selectors",
222
+ "SourceLocation",
223
+ "StorageState",
224
+ "StorageStateCookie",
225
+ "TimeoutError",
226
+ "Touchscreen",
227
+ "Video",
228
+ "ViewportSize",
229
+ "VirtualCredential",
230
+ "WebError",
231
+ "WebSocket",
232
+ "WebSocketRoute",
233
+ "Worker",
234
+ ]
@@ -0,0 +1,38 @@
1
+ import asyncio
2
+ from typing import Any
3
+ from patchright._impl._connection import Connection
4
+ from patchright._impl._object_factory import create_remote_object
5
+ from patchright._impl._transport import PipeTransport
6
+ from patchright.async_api._generated import Playwright as AsyncPlaywright
7
+
8
+
9
+ class PlaywrightContextManager:
10
+ def __init__(self) -> None:
11
+ self._connection: Connection
12
+ self._exit_was_called = False
13
+
14
+ async def __aenter__(self) -> AsyncPlaywright:
15
+ loop = asyncio.get_running_loop()
16
+ self._connection = Connection(
17
+ None, create_remote_object, PipeTransport(loop), loop
18
+ )
19
+ loop.create_task(self._connection.run())
20
+ playwright_future = self._connection.playwright_future
21
+ done, _ = await asyncio.wait(
22
+ {self._connection._transport.on_error_future, playwright_future},
23
+ return_when=asyncio.FIRST_COMPLETED,
24
+ )
25
+ if not playwright_future.done():
26
+ playwright_future.cancel()
27
+ playwright = AsyncPlaywright(next(iter(done)).result())
28
+ playwright.stop = self.__aexit__
29
+ return playwright
30
+
31
+ async def start(self) -> AsyncPlaywright:
32
+ return await self.__aenter__()
33
+
34
+ async def __aexit__(self, *args: Any) -> None:
35
+ if self._exit_was_called:
36
+ return
37
+ self._exit_was_called = True
38
+ await self._connection.stop_async()