patchright 1.48.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.
- patchright/__init__.py +5 -0
- patchright/__main__.py +18 -0
- patchright/_impl/__init__.py +0 -0
- patchright/_impl/__pyinstaller/__init__.py +20 -0
- patchright/_impl/__pyinstaller/hook-playwright.async_api.py +17 -0
- patchright/_impl/__pyinstaller/hook-playwright.sync_api.py +17 -0
- patchright/_impl/_accessibility.py +50 -0
- patchright/_impl/_api_structures.py +271 -0
- patchright/_impl/_artifact.py +45 -0
- patchright/_impl/_assertions.py +779 -0
- patchright/_impl/_async_base.py +92 -0
- patchright/_impl/_browser.py +243 -0
- patchright/_impl/_browser_context.py +724 -0
- patchright/_impl/_browser_type.py +264 -0
- patchright/_impl/_cdp_session.py +21 -0
- patchright/_impl/_clock.py +57 -0
- patchright/_impl/_connection.py +554 -0
- patchright/_impl/_console_message.py +45 -0
- patchright/_impl/_dialog.py +40 -0
- patchright/_impl/_download.py +50 -0
- patchright/_impl/_driver.py +26 -0
- patchright/_impl/_element_handle.py +376 -0
- patchright/_impl/_errors.py +44 -0
- patchright/_impl/_event_context_manager.py +20 -0
- patchright/_impl/_fetch.py +511 -0
- patchright/_impl/_file_chooser.py +43 -0
- patchright/_impl/_frame.py +755 -0
- patchright/_impl/_glob.py +51 -0
- patchright/_impl/_greenlets.py +39 -0
- patchright/_impl/_har_router.py +99 -0
- patchright/_impl/_helper.py +421 -0
- patchright/_impl/_impl_to_api_mapping.py +123 -0
- patchright/_impl/_input.py +71 -0
- patchright/_impl/_js_handle.py +234 -0
- patchright/_impl/_json_pipe.py +56 -0
- patchright/_impl/_local_utils.py +73 -0
- patchright/_impl/_locator.py +784 -0
- patchright/_impl/_map.py +19 -0
- patchright/_impl/_network.py +934 -0
- patchright/_impl/_object_factory.py +91 -0
- patchright/_impl/_page.py +1446 -0
- patchright/_impl/_path_utils.py +11 -0
- patchright/_impl/_playwright.py +51 -0
- patchright/_impl/_selectors.py +62 -0
- patchright/_impl/_set_input_files_helpers.py +135 -0
- patchright/_impl/_str_utils.py +57 -0
- patchright/_impl/_stream.py +32 -0
- patchright/_impl/_sync_base.py +134 -0
- patchright/_impl/_tracing.py +103 -0
- patchright/_impl/_transport.py +150 -0
- patchright/_impl/_video.py +57 -0
- patchright/_impl/_waiter.py +142 -0
- patchright/_impl/_web_error.py +22 -0
- patchright/_impl/_writable_stream.py +27 -0
- patchright/_repo_version.py +12 -0
- patchright/async_api/__init__.py +177 -0
- patchright/async_api/_context_manager.py +39 -0
- patchright/async_api/_generated.py +19960 -0
- patchright/driver/LICENSE +2174 -0
- patchright/driver/README.md +1 -0
- patchright/driver/node.exe +0 -0
- patchright/driver/package/README.md +3 -0
- patchright/driver/package/ThirdPartyNotices.txt +1548 -0
- patchright/driver/package/api.json +1 -0
- patchright/driver/package/bin/PrintDeps.exe +0 -0
- patchright/driver/package/bin/README.md +2 -0
- patchright/driver/package/bin/install_media_pack.ps1 +5 -0
- patchright/driver/package/bin/reinstall_chrome_beta_linux.sh +40 -0
- patchright/driver/package/bin/reinstall_chrome_beta_mac.sh +13 -0
- patchright/driver/package/bin/reinstall_chrome_beta_win.ps1 +24 -0
- patchright/driver/package/bin/reinstall_chrome_stable_linux.sh +40 -0
- patchright/driver/package/bin/reinstall_chrome_stable_mac.sh +12 -0
- patchright/driver/package/bin/reinstall_chrome_stable_win.ps1 +24 -0
- patchright/driver/package/bin/reinstall_msedge_beta_linux.sh +40 -0
- patchright/driver/package/bin/reinstall_msedge_beta_mac.sh +11 -0
- patchright/driver/package/bin/reinstall_msedge_beta_win.ps1 +23 -0
- patchright/driver/package/bin/reinstall_msedge_dev_linux.sh +40 -0
- patchright/driver/package/bin/reinstall_msedge_dev_mac.sh +11 -0
- patchright/driver/package/bin/reinstall_msedge_dev_win.ps1 +23 -0
- patchright/driver/package/bin/reinstall_msedge_stable_linux.sh +40 -0
- patchright/driver/package/bin/reinstall_msedge_stable_mac.sh +11 -0
- patchright/driver/package/bin/reinstall_msedge_stable_win.ps1 +24 -0
- patchright/driver/package/browsers.json +57 -0
- patchright/driver/package/cli.js +18 -0
- patchright/driver/package/index.d.ts +17 -0
- patchright/driver/package/index.js +33 -0
- patchright/driver/package/index.mjs +28 -0
- patchright/driver/package/lib/androidServerImpl.js +69 -0
- patchright/driver/package/lib/browserServerImpl.js +92 -0
- patchright/driver/package/lib/cli/driver.js +95 -0
- patchright/driver/package/lib/cli/program.js +587 -0
- patchright/driver/package/lib/cli/programWithTestStub.js +67 -0
- patchright/driver/package/lib/client/accessibility.js +50 -0
- patchright/driver/package/lib/client/android.js +473 -0
- patchright/driver/package/lib/client/api.js +285 -0
- patchright/driver/package/lib/client/artifact.js +79 -0
- patchright/driver/package/lib/client/browser.js +145 -0
- patchright/driver/package/lib/client/browserContext.js +559 -0
- patchright/driver/package/lib/client/browserType.js +241 -0
- patchright/driver/package/lib/client/cdpSession.js +53 -0
- patchright/driver/package/lib/client/channelOwner.js +235 -0
- patchright/driver/package/lib/client/clientHelper.js +57 -0
- patchright/driver/package/lib/client/clientInstrumentation.js +50 -0
- patchright/driver/package/lib/client/clock.js +68 -0
- patchright/driver/package/lib/client/connection.js +333 -0
- patchright/driver/package/lib/client/consoleMessage.js +55 -0
- patchright/driver/package/lib/client/coverage.js +41 -0
- patchright/driver/package/lib/client/dialog.js +57 -0
- patchright/driver/package/lib/client/download.js +62 -0
- patchright/driver/package/lib/client/electron.js +135 -0
- patchright/driver/package/lib/client/elementHandle.js +321 -0
- patchright/driver/package/lib/client/errors.js +77 -0
- patchright/driver/package/lib/client/eventEmitter.js +314 -0
- patchright/driver/package/lib/client/events.js +94 -0
- patchright/driver/package/lib/client/fetch.js +391 -0
- patchright/driver/package/lib/client/fileChooser.js +45 -0
- patchright/driver/package/lib/client/frame.js +504 -0
- patchright/driver/package/lib/client/harRouter.js +99 -0
- patchright/driver/package/lib/client/input.js +111 -0
- patchright/driver/package/lib/client/jsHandle.js +121 -0
- patchright/driver/package/lib/client/jsonPipe.js +35 -0
- patchright/driver/package/lib/client/localUtils.js +36 -0
- patchright/driver/package/lib/client/locator.js +441 -0
- patchright/driver/package/lib/client/network.js +762 -0
- patchright/driver/package/lib/client/page.js +746 -0
- patchright/driver/package/lib/client/playwright.js +80 -0
- patchright/driver/package/lib/client/selectors.js +67 -0
- patchright/driver/package/lib/client/stream.js +54 -0
- patchright/driver/package/lib/client/tracing.js +134 -0
- patchright/driver/package/lib/client/types.js +24 -0
- patchright/driver/package/lib/client/video.js +51 -0
- patchright/driver/package/lib/client/waiter.js +158 -0
- patchright/driver/package/lib/client/webError.js +37 -0
- patchright/driver/package/lib/client/worker.js +71 -0
- patchright/driver/package/lib/client/writableStream.js +54 -0
- patchright/driver/package/lib/common/socksProxy.js +569 -0
- patchright/driver/package/lib/common/timeoutSettings.js +73 -0
- patchright/driver/package/lib/common/types.js +5 -0
- patchright/driver/package/lib/generated/clockSource.js +7 -0
- patchright/driver/package/lib/generated/consoleApiSource.js +7 -0
- patchright/driver/package/lib/generated/injectedScriptSource.js +7 -0
- patchright/driver/package/lib/generated/pollingRecorderSource.js +7 -0
- patchright/driver/package/lib/generated/utilityScriptSource.js +7 -0
- patchright/driver/package/lib/generated/webSocketMockSource.js +7 -0
- patchright/driver/package/lib/image_tools/colorUtils.js +98 -0
- patchright/driver/package/lib/image_tools/compare.js +108 -0
- patchright/driver/package/lib/image_tools/imageChannel.js +70 -0
- patchright/driver/package/lib/image_tools/stats.js +102 -0
- patchright/driver/package/lib/inProcessFactory.js +54 -0
- patchright/driver/package/lib/inprocess.js +20 -0
- patchright/driver/package/lib/outofprocess.js +67 -0
- patchright/driver/package/lib/protocol/debug.js +27 -0
- patchright/driver/package/lib/protocol/serializers.js +173 -0
- patchright/driver/package/lib/protocol/transport.js +82 -0
- patchright/driver/package/lib/protocol/validator.js +2759 -0
- patchright/driver/package/lib/protocol/validatorPrimitives.js +139 -0
- patchright/driver/package/lib/remote/playwrightConnection.js +274 -0
- patchright/driver/package/lib/remote/playwrightServer.js +110 -0
- patchright/driver/package/lib/server/accessibility.js +62 -0
- patchright/driver/package/lib/server/android/android.js +441 -0
- patchright/driver/package/lib/server/android/backendAdb.js +172 -0
- patchright/driver/package/lib/server/artifact.js +104 -0
- patchright/driver/package/lib/server/bidi/bidiBrowser.js +311 -0
- patchright/driver/package/lib/server/bidi/bidiChromium.js +124 -0
- patchright/driver/package/lib/server/bidi/bidiConnection.js +206 -0
- patchright/driver/package/lib/server/bidi/bidiExecutionContext.js +159 -0
- patchright/driver/package/lib/server/bidi/bidiFirefox.js +104 -0
- patchright/driver/package/lib/server/bidi/bidiInput.js +158 -0
- patchright/driver/package/lib/server/bidi/bidiNetworkManager.js +338 -0
- patchright/driver/package/lib/server/bidi/bidiOverCdp.js +103 -0
- patchright/driver/package/lib/server/bidi/bidiPage.js +529 -0
- patchright/driver/package/lib/server/bidi/bidiPdf.js +140 -0
- patchright/driver/package/lib/server/bidi/third_party/bidiDeserializer.js +93 -0
- patchright/driver/package/lib/server/bidi/third_party/bidiKeyboard.js +238 -0
- patchright/driver/package/lib/server/bidi/third_party/bidiProtocol.js +139 -0
- patchright/driver/package/lib/server/bidi/third_party/bidiSerializer.js +144 -0
- patchright/driver/package/lib/server/bidi/third_party/firefoxPrefs.js +221 -0
- patchright/driver/package/lib/server/browser.js +148 -0
- patchright/driver/package/lib/server/browserContext.js +666 -0
- patchright/driver/package/lib/server/browserType.js +335 -0
- patchright/driver/package/lib/server/chromium/appIcon.png +0 -0
- patchright/driver/package/lib/server/chromium/chromium.js +350 -0
- patchright/driver/package/lib/server/chromium/chromiumSwitches.js +36 -0
- patchright/driver/package/lib/server/chromium/crAccessibility.js +237 -0
- patchright/driver/package/lib/server/chromium/crBrowser.js +522 -0
- patchright/driver/package/lib/server/chromium/crConnection.js +228 -0
- patchright/driver/package/lib/server/chromium/crCoverage.js +246 -0
- patchright/driver/package/lib/server/chromium/crDevTools.js +104 -0
- patchright/driver/package/lib/server/chromium/crDragDrop.js +143 -0
- patchright/driver/package/lib/server/chromium/crExecutionContext.js +149 -0
- patchright/driver/package/lib/server/chromium/crInput.js +171 -0
- patchright/driver/package/lib/server/chromium/crNetworkManager.js +809 -0
- patchright/driver/package/lib/server/chromium/crPage.js +1235 -0
- patchright/driver/package/lib/server/chromium/crPdf.js +153 -0
- patchright/driver/package/lib/server/chromium/crProtocolHelper.js +133 -0
- patchright/driver/package/lib/server/chromium/crServiceWorker.js +111 -0
- patchright/driver/package/lib/server/chromium/defaultFontFamilies.js +145 -0
- patchright/driver/package/lib/server/chromium/videoRecorder.js +155 -0
- patchright/driver/package/lib/server/clock.js +133 -0
- patchright/driver/package/lib/server/codegen/csharp.js +299 -0
- patchright/driver/package/lib/server/codegen/java.js +235 -0
- patchright/driver/package/lib/server/codegen/javascript.js +223 -0
- patchright/driver/package/lib/server/codegen/jsonl.js +47 -0
- patchright/driver/package/lib/server/codegen/language.js +88 -0
- patchright/driver/package/lib/server/codegen/languages.js +30 -0
- patchright/driver/package/lib/server/codegen/python.js +265 -0
- patchright/driver/package/lib/server/codegen/types.js +5 -0
- patchright/driver/package/lib/server/console.js +57 -0
- patchright/driver/package/lib/server/cookieStore.js +185 -0
- patchright/driver/package/lib/server/debugController.js +234 -0
- patchright/driver/package/lib/server/debugger.js +132 -0
- patchright/driver/package/lib/server/deviceDescriptors.js +26 -0
- patchright/driver/package/lib/server/deviceDescriptorsSource.json +1669 -0
- patchright/driver/package/lib/server/dialog.js +71 -0
- patchright/driver/package/lib/server/dispatchers/androidDispatcher.js +193 -0
- patchright/driver/package/lib/server/dispatchers/artifactDispatcher.js +118 -0
- patchright/driver/package/lib/server/dispatchers/browserContextDispatcher.js +368 -0
- patchright/driver/package/lib/server/dispatchers/browserDispatcher.js +170 -0
- patchright/driver/package/lib/server/dispatchers/browserTypeDispatcher.js +55 -0
- patchright/driver/package/lib/server/dispatchers/cdpSessionDispatcher.js +48 -0
- patchright/driver/package/lib/server/dispatchers/debugControllerDispatcher.js +103 -0
- patchright/driver/package/lib/server/dispatchers/dialogDispatcher.js +44 -0
- patchright/driver/package/lib/server/dispatchers/dispatcher.js +395 -0
- patchright/driver/package/lib/server/dispatchers/electronDispatcher.js +93 -0
- patchright/driver/package/lib/server/dispatchers/elementHandlerDispatcher.js +228 -0
- patchright/driver/package/lib/server/dispatchers/frameDispatcher.js +286 -0
- patchright/driver/package/lib/server/dispatchers/jsHandleDispatcher.js +97 -0
- patchright/driver/package/lib/server/dispatchers/jsonPipeDispatcher.js +59 -0
- patchright/driver/package/lib/server/dispatchers/localUtilsDispatcher.js +413 -0
- patchright/driver/package/lib/server/dispatchers/networkDispatchers.js +221 -0
- patchright/driver/package/lib/server/dispatchers/pageDispatcher.js +367 -0
- patchright/driver/package/lib/server/dispatchers/playwrightDispatcher.js +107 -0
- patchright/driver/package/lib/server/dispatchers/selectorsDispatcher.js +36 -0
- patchright/driver/package/lib/server/dispatchers/streamDispatcher.js +62 -0
- patchright/driver/package/lib/server/dispatchers/tracingDispatcher.js +54 -0
- patchright/driver/package/lib/server/dispatchers/webSocketRouteDispatcher.js +189 -0
- patchright/driver/package/lib/server/dispatchers/writableStreamDispatcher.js +58 -0
- patchright/driver/package/lib/server/dom.js +845 -0
- patchright/driver/package/lib/server/download.js +60 -0
- patchright/driver/package/lib/server/electron/electron.js +296 -0
- patchright/driver/package/lib/server/electron/loader.js +57 -0
- patchright/driver/package/lib/server/errors.js +68 -0
- patchright/driver/package/lib/server/fetch.js +656 -0
- patchright/driver/package/lib/server/fileChooser.js +42 -0
- patchright/driver/package/lib/server/fileUploadUtils.js +75 -0
- patchright/driver/package/lib/server/firefox/ffAccessibility.js +216 -0
- patchright/driver/package/lib/server/firefox/ffBrowser.js +460 -0
- patchright/driver/package/lib/server/firefox/ffConnection.js +168 -0
- patchright/driver/package/lib/server/firefox/ffExecutionContext.js +135 -0
- patchright/driver/package/lib/server/firefox/ffInput.js +150 -0
- patchright/driver/package/lib/server/firefox/ffNetworkManager.js +233 -0
- patchright/driver/package/lib/server/firefox/ffPage.js +559 -0
- patchright/driver/package/lib/server/firefox/firefox.js +99 -0
- patchright/driver/package/lib/server/formData.js +75 -0
- patchright/driver/package/lib/server/frameSelectors.js +171 -0
- patchright/driver/package/lib/server/frames.js +1808 -0
- patchright/driver/package/lib/server/har/harRecorder.js +139 -0
- patchright/driver/package/lib/server/har/harTracer.js +542 -0
- patchright/driver/package/lib/server/helper.js +103 -0
- patchright/driver/package/lib/server/index.js +114 -0
- patchright/driver/package/lib/server/input.js +310 -0
- patchright/driver/package/lib/server/instrumentation.js +70 -0
- patchright/driver/package/lib/server/isomorphic/utilityScriptSerializers.js +226 -0
- patchright/driver/package/lib/server/javascript.js +299 -0
- patchright/driver/package/lib/server/launchApp.js +91 -0
- patchright/driver/package/lib/server/macEditingCommands.js +139 -0
- patchright/driver/package/lib/server/network.js +617 -0
- patchright/driver/package/lib/server/page.js +819 -0
- patchright/driver/package/lib/server/pipeTransport.js +85 -0
- patchright/driver/package/lib/server/playwright.js +88 -0
- patchright/driver/package/lib/server/progress.js +102 -0
- patchright/driver/package/lib/server/protocolError.js +49 -0
- patchright/driver/package/lib/server/recorder/contextRecorder.js +299 -0
- patchright/driver/package/lib/server/recorder/recorderApp.js +196 -0
- patchright/driver/package/lib/server/recorder/recorderCollection.js +116 -0
- patchright/driver/package/lib/server/recorder/recorderFrontend.js +5 -0
- patchright/driver/package/lib/server/recorder/recorderInTraceViewer.js +144 -0
- patchright/driver/package/lib/server/recorder/recorderRunner.js +155 -0
- patchright/driver/package/lib/server/recorder/recorderUtils.js +112 -0
- patchright/driver/package/lib/server/recorder/throttledFile.js +46 -0
- patchright/driver/package/lib/server/recorder.js +327 -0
- patchright/driver/package/lib/server/registry/browserFetcher.js +168 -0
- patchright/driver/package/lib/server/registry/dependencies.js +322 -0
- patchright/driver/package/lib/server/registry/index.js +1005 -0
- patchright/driver/package/lib/server/registry/nativeDeps.js +490 -0
- patchright/driver/package/lib/server/registry/oopDownloadBrowserMain.js +138 -0
- patchright/driver/package/lib/server/screenshotter.js +348 -0
- patchright/driver/package/lib/server/selectors.js +73 -0
- patchright/driver/package/lib/server/socksClientCertificatesInterceptor.js +340 -0
- patchright/driver/package/lib/server/socksInterceptor.js +100 -0
- patchright/driver/package/lib/server/trace/recorder/snapshotter.js +172 -0
- patchright/driver/package/lib/server/trace/recorder/snapshotterInjected.js +493 -0
- patchright/driver/package/lib/server/trace/recorder/tracing.js +542 -0
- patchright/driver/package/lib/server/trace/test/inMemorySnapshotter.js +93 -0
- patchright/driver/package/lib/server/trace/viewer/traceViewer.js +213 -0
- patchright/driver/package/lib/server/transport.js +191 -0
- patchright/driver/package/lib/server/types.js +24 -0
- patchright/driver/package/lib/server/usKeyboardLayout.js +555 -0
- patchright/driver/package/lib/server/webkit/webkit.js +87 -0
- patchright/driver/package/lib/server/webkit/wkAccessibility.js +194 -0
- patchright/driver/package/lib/server/webkit/wkBrowser.js +329 -0
- patchright/driver/package/lib/server/webkit/wkConnection.js +173 -0
- patchright/driver/package/lib/server/webkit/wkExecutionContext.js +143 -0
- patchright/driver/package/lib/server/webkit/wkInput.js +169 -0
- patchright/driver/package/lib/server/webkit/wkInterceptableRequest.js +162 -0
- patchright/driver/package/lib/server/webkit/wkPage.js +1219 -0
- patchright/driver/package/lib/server/webkit/wkProvisionalPage.js +94 -0
- patchright/driver/package/lib/server/webkit/wkWorkers.js +104 -0
- patchright/driver/package/lib/third_party/diff_match_patch.js +2222 -0
- patchright/driver/package/lib/third_party/pixelmatch.js +255 -0
- patchright/driver/package/lib/utils/ascii.js +31 -0
- patchright/driver/package/lib/utils/comparators.js +171 -0
- patchright/driver/package/lib/utils/crypto.js +174 -0
- patchright/driver/package/lib/utils/debug.js +46 -0
- patchright/driver/package/lib/utils/debugLogger.js +91 -0
- patchright/driver/package/lib/utils/env.js +49 -0
- patchright/driver/package/lib/utils/eventsHelper.js +38 -0
- patchright/driver/package/lib/utils/expectUtils.js +33 -0
- patchright/driver/package/lib/utils/fileUtils.js +205 -0
- patchright/driver/package/lib/utils/happy-eyeballs.js +194 -0
- patchright/driver/package/lib/utils/headers.js +52 -0
- patchright/driver/package/lib/utils/hostPlatform.js +133 -0
- patchright/driver/package/lib/utils/httpServer.js +237 -0
- patchright/driver/package/lib/utils/index.js +368 -0
- patchright/driver/package/lib/utils/isomorphic/cssParser.js +250 -0
- patchright/driver/package/lib/utils/isomorphic/cssTokenizer.js +979 -0
- patchright/driver/package/lib/utils/isomorphic/locatorGenerators.js +642 -0
- patchright/driver/package/lib/utils/isomorphic/locatorParser.js +179 -0
- patchright/driver/package/lib/utils/isomorphic/locatorUtils.js +62 -0
- patchright/driver/package/lib/utils/isomorphic/mimeType.js +29 -0
- patchright/driver/package/lib/utils/isomorphic/recorderUtils.js +195 -0
- patchright/driver/package/lib/utils/isomorphic/selectorParser.js +397 -0
- patchright/driver/package/lib/utils/isomorphic/stringUtils.js +139 -0
- patchright/driver/package/lib/utils/isomorphic/traceUtils.js +39 -0
- patchright/driver/package/lib/utils/isomorphic/urlMatch.js +120 -0
- patchright/driver/package/lib/utils/linuxUtils.js +78 -0
- patchright/driver/package/lib/utils/manualPromise.js +109 -0
- patchright/driver/package/lib/utils/multimap.js +75 -0
- patchright/driver/package/lib/utils/network.js +160 -0
- patchright/driver/package/lib/utils/processLauncher.js +248 -0
- patchright/driver/package/lib/utils/profiler.js +53 -0
- patchright/driver/package/lib/utils/rtti.js +44 -0
- patchright/driver/package/lib/utils/semaphore.js +51 -0
- patchright/driver/package/lib/utils/spawnAsync.js +45 -0
- patchright/driver/package/lib/utils/stackTrace.js +121 -0
- patchright/driver/package/lib/utils/task.js +58 -0
- patchright/driver/package/lib/utils/time.js +37 -0
- patchright/driver/package/lib/utils/timeoutRunner.js +66 -0
- patchright/driver/package/lib/utils/traceUtils.js +44 -0
- patchright/driver/package/lib/utils/userAgent.js +105 -0
- patchright/driver/package/lib/utils/wsServer.js +127 -0
- patchright/driver/package/lib/utils/zipFile.js +75 -0
- patchright/driver/package/lib/utils/zones.js +62 -0
- patchright/driver/package/lib/utilsBundle.js +82 -0
- patchright/driver/package/lib/utilsBundleImpl/index.js +53 -0
- patchright/driver/package/lib/utilsBundleImpl/xdg-open +1066 -0
- patchright/driver/package/lib/vite/htmlReport/index.html +66 -0
- patchright/driver/package/lib/vite/recorder/assets/codeMirrorModule-d0KhC1qL.js +24 -0
- patchright/driver/package/lib/vite/recorder/assets/codeMirrorModule-ez37Vkbh.css +1 -0
- patchright/driver/package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- patchright/driver/package/lib/vite/recorder/assets/index-BW-aOBcL.css +1 -0
- patchright/driver/package/lib/vite/recorder/assets/index-Bxxcmxlu.js +42 -0
- patchright/driver/package/lib/vite/recorder/index.html +29 -0
- patchright/driver/package/lib/vite/recorder/playwright-logo.svg +9 -0
- patchright/driver/package/lib/vite/traceViewer/assets/codeMirrorModule-CZTtn9l8.js +24 -0
- patchright/driver/package/lib/vite/traceViewer/assets/inspectorTab-DTusvprx.js +64 -0
- patchright/driver/package/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +1 -0
- patchright/driver/package/lib/vite/traceViewer/assets/workbench-DIEjrm3Z.js +9 -0
- patchright/driver/package/lib/vite/traceViewer/assets/xtermModule-BeNbaIVa.js +9 -0
- patchright/driver/package/lib/vite/traceViewer/codeMirrorModule.ez37Vkbh.css +1 -0
- patchright/driver/package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- patchright/driver/package/lib/vite/traceViewer/embedded.Do_J5Hgs.js +2 -0
- patchright/driver/package/lib/vite/traceViewer/embedded.html +18 -0
- patchright/driver/package/lib/vite/traceViewer/embedded.w7WN2u1R.css +1 -0
- patchright/driver/package/lib/vite/traceViewer/index.B21BXreT.js +2 -0
- patchright/driver/package/lib/vite/traceViewer/index.CrbWWHbf.css +1 -0
- patchright/driver/package/lib/vite/traceViewer/index.html +29 -0
- patchright/driver/package/lib/vite/traceViewer/inspectorTab.DLjBDrQR.css +1 -0
- patchright/driver/package/lib/vite/traceViewer/playwright-logo.svg +9 -0
- patchright/driver/package/lib/vite/traceViewer/recorder.B_SY1GJM.css +0 -0
- patchright/driver/package/lib/vite/traceViewer/recorder.Bfh_9UGt.js +2 -0
- patchright/driver/package/lib/vite/traceViewer/recorder.html +17 -0
- patchright/driver/package/lib/vite/traceViewer/snapshot.html +21 -0
- patchright/driver/package/lib/vite/traceViewer/sw.bundle.js +3 -0
- patchright/driver/package/lib/vite/traceViewer/uiMode.CAYqod-m.css +1 -0
- patchright/driver/package/lib/vite/traceViewer/uiMode.DloKQa-h.js +5 -0
- patchright/driver/package/lib/vite/traceViewer/uiMode.html +20 -0
- patchright/driver/package/lib/vite/traceViewer/workbench.D3JVcA9K.css +1 -0
- patchright/driver/package/lib/vite/traceViewer/xtermModule.DSXBckUd.css +32 -0
- patchright/driver/package/lib/zipBundle.js +25 -0
- patchright/driver/package/lib/zipBundleImpl.js +5 -0
- patchright/driver/package/package.json +44 -0
- patchright/driver/package/protocol.yml +3720 -0
- patchright/driver/package/types/protocol.d.ts +21571 -0
- patchright/driver/package/types/structs.d.ts +45 -0
- patchright/driver/package/types/types.d.ts +22519 -0
- patchright/py.typed +0 -0
- patchright/sync_api/__init__.py +177 -0
- patchright/sync_api/_context_manager.py +74 -0
- patchright/sync_api/_generated.py +20155 -0
- patchright-1.48.0.dist-info/LICENSE +202 -0
- patchright-1.48.0.dist-info/METADATA +83 -0
- patchright-1.48.0.dist-info/RECORD +406 -0
- patchright-1.48.0.dist-info/WHEEL +5 -0
- patchright-1.48.0.dist-info/entry_points.txt +5 -0
- patchright-1.48.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import io
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import subprocess
|
|
6
|
+
import sys
|
|
7
|
+
from abc import ABC, abstractmethod
|
|
8
|
+
from typing import Callable, Dict, Optional, Union
|
|
9
|
+
from patchright._impl._driver import compute_driver_executable, get_driver_env
|
|
10
|
+
from patchright._impl._helper import ParsedMessagePayload
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _get_stderr_fileno() -> Optional[int]:
|
|
14
|
+
try:
|
|
15
|
+
if sys.stderr is None or not hasattr(sys.stderr, "closed"):
|
|
16
|
+
return None
|
|
17
|
+
if sys.stderr.closed:
|
|
18
|
+
return None
|
|
19
|
+
return sys.stderr.fileno()
|
|
20
|
+
except (NotImplementedError, AttributeError, io.UnsupportedOperation):
|
|
21
|
+
if not hasattr(sys, "__stderr__") or not sys.__stderr__:
|
|
22
|
+
return None
|
|
23
|
+
return sys.__stderr__.fileno()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class Transport(ABC):
|
|
27
|
+
|
|
28
|
+
def __init__(self, loop: asyncio.AbstractEventLoop) -> None:
|
|
29
|
+
self._loop = loop
|
|
30
|
+
self.on_message: Callable[[ParsedMessagePayload], None] = lambda _: None
|
|
31
|
+
self.on_error_future: asyncio.Future = loop.create_future()
|
|
32
|
+
|
|
33
|
+
@abstractmethod
|
|
34
|
+
def request_stop(self) -> None:
|
|
35
|
+
pass
|
|
36
|
+
|
|
37
|
+
def dispose(self) -> None:
|
|
38
|
+
pass
|
|
39
|
+
|
|
40
|
+
@abstractmethod
|
|
41
|
+
async def wait_until_stopped(self) -> None:
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
@abstractmethod
|
|
45
|
+
async def connect(self) -> None:
|
|
46
|
+
pass
|
|
47
|
+
|
|
48
|
+
@abstractmethod
|
|
49
|
+
async def run(self) -> None:
|
|
50
|
+
pass
|
|
51
|
+
|
|
52
|
+
@abstractmethod
|
|
53
|
+
def send(self, message: Dict) -> None:
|
|
54
|
+
pass
|
|
55
|
+
|
|
56
|
+
def serialize_message(self, message: Dict) -> bytes:
|
|
57
|
+
msg = json.dumps(message)
|
|
58
|
+
if "DEBUGP" in os.environ:
|
|
59
|
+
print("\x1b[32mSEND>\x1b[0m", json.dumps(message, indent=2))
|
|
60
|
+
return msg.encode()
|
|
61
|
+
|
|
62
|
+
def deserialize_message(self, data: Union[str, bytes]) -> ParsedMessagePayload:
|
|
63
|
+
obj = json.loads(data)
|
|
64
|
+
if "DEBUGP" in os.environ:
|
|
65
|
+
print("\x1b[33mRECV>\x1b[0m", json.dumps(obj, indent=2))
|
|
66
|
+
return obj
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class PipeTransport(Transport):
|
|
70
|
+
|
|
71
|
+
def __init__(self, loop: asyncio.AbstractEventLoop) -> None:
|
|
72
|
+
super().__init__(loop)
|
|
73
|
+
self._stopped = False
|
|
74
|
+
|
|
75
|
+
def request_stop(self) -> None:
|
|
76
|
+
assert self._output
|
|
77
|
+
self._stopped = True
|
|
78
|
+
self._output.close()
|
|
79
|
+
|
|
80
|
+
async def wait_until_stopped(self) -> None:
|
|
81
|
+
await self._stopped_future
|
|
82
|
+
|
|
83
|
+
async def connect(self) -> None:
|
|
84
|
+
self._stopped_future: asyncio.Future = asyncio.Future()
|
|
85
|
+
try:
|
|
86
|
+
env = get_driver_env()
|
|
87
|
+
if getattr(sys, "frozen", False) or globals().get("__compiled__"):
|
|
88
|
+
env.setdefault("PLAYWRIGHT_BROWSERS_PATH", "0")
|
|
89
|
+
startupinfo = None
|
|
90
|
+
if sys.platform == "win32":
|
|
91
|
+
startupinfo = subprocess.STARTUPINFO()
|
|
92
|
+
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
|
93
|
+
startupinfo.wShowWindow = subprocess.SW_HIDE
|
|
94
|
+
executable_path, entrypoint_path = compute_driver_executable()
|
|
95
|
+
self._proc = await asyncio.create_subprocess_exec(
|
|
96
|
+
executable_path,
|
|
97
|
+
entrypoint_path,
|
|
98
|
+
"run-driver",
|
|
99
|
+
stdin=asyncio.subprocess.PIPE,
|
|
100
|
+
stdout=asyncio.subprocess.PIPE,
|
|
101
|
+
stderr=_get_stderr_fileno(),
|
|
102
|
+
limit=32768,
|
|
103
|
+
env=env,
|
|
104
|
+
startupinfo=startupinfo,
|
|
105
|
+
)
|
|
106
|
+
except Exception as exc:
|
|
107
|
+
self.on_error_future.set_exception(exc)
|
|
108
|
+
raise exc
|
|
109
|
+
self._output = self._proc.stdin
|
|
110
|
+
|
|
111
|
+
async def run(self) -> None:
|
|
112
|
+
assert self._proc.stdout
|
|
113
|
+
assert self._proc.stdin
|
|
114
|
+
while not self._stopped:
|
|
115
|
+
try:
|
|
116
|
+
buffer = await self._proc.stdout.readexactly(4)
|
|
117
|
+
if self._stopped:
|
|
118
|
+
break
|
|
119
|
+
length = int.from_bytes(buffer, byteorder="little", signed=False)
|
|
120
|
+
buffer = bytes(0)
|
|
121
|
+
while length:
|
|
122
|
+
to_read = min(length, 32768)
|
|
123
|
+
data = await self._proc.stdout.readexactly(to_read)
|
|
124
|
+
if self._stopped:
|
|
125
|
+
break
|
|
126
|
+
length -= to_read
|
|
127
|
+
if len(buffer):
|
|
128
|
+
buffer = buffer + data
|
|
129
|
+
else:
|
|
130
|
+
buffer = data
|
|
131
|
+
if self._stopped:
|
|
132
|
+
break
|
|
133
|
+
obj = self.deserialize_message(buffer)
|
|
134
|
+
self.on_message(obj)
|
|
135
|
+
except asyncio.IncompleteReadError:
|
|
136
|
+
if not self._stopped:
|
|
137
|
+
self.on_error_future.set_exception(
|
|
138
|
+
Exception("Connection closed while reading from the driver")
|
|
139
|
+
)
|
|
140
|
+
break
|
|
141
|
+
await asyncio.sleep(0)
|
|
142
|
+
await self._proc.wait()
|
|
143
|
+
self._stopped_future.set_result(None)
|
|
144
|
+
|
|
145
|
+
def send(self, message: Dict) -> None:
|
|
146
|
+
assert self._output
|
|
147
|
+
data = self.serialize_message(message)
|
|
148
|
+
self._output.write(
|
|
149
|
+
len(data).to_bytes(4, byteorder="little", signed=False) + data
|
|
150
|
+
)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import pathlib
|
|
2
|
+
from typing import TYPE_CHECKING, Union
|
|
3
|
+
from patchright._impl._artifact import Artifact
|
|
4
|
+
from patchright._impl._helper import Error
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from patchright._impl._page import Page
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Video:
|
|
11
|
+
|
|
12
|
+
def __init__(self, page: "Page") -> None:
|
|
13
|
+
self._loop = page._loop
|
|
14
|
+
self._dispatcher_fiber = page._dispatcher_fiber
|
|
15
|
+
self._page = page
|
|
16
|
+
self._artifact_future = page._loop.create_future()
|
|
17
|
+
if page.is_closed():
|
|
18
|
+
self._page_closed()
|
|
19
|
+
else:
|
|
20
|
+
page.on("close", lambda page: self._page_closed())
|
|
21
|
+
|
|
22
|
+
def __repr__(self) -> str:
|
|
23
|
+
return f"<Video page={self._page}>"
|
|
24
|
+
|
|
25
|
+
def _page_closed(self) -> None:
|
|
26
|
+
if not self._artifact_future.done():
|
|
27
|
+
self._artifact_future.set_exception(Error("Page closed"))
|
|
28
|
+
|
|
29
|
+
def _artifact_ready(self, artifact: Artifact) -> None:
|
|
30
|
+
if not self._artifact_future.done():
|
|
31
|
+
self._artifact_future.set_result(artifact)
|
|
32
|
+
|
|
33
|
+
async def path(self) -> pathlib.Path:
|
|
34
|
+
if self._page._connection.is_remote:
|
|
35
|
+
raise Error(
|
|
36
|
+
"Path is not available when using browserType.connect(). Use save_as() to save a local copy."
|
|
37
|
+
)
|
|
38
|
+
artifact = await self._artifact_future
|
|
39
|
+
if not artifact:
|
|
40
|
+
raise Error("Page did not produce any video frames")
|
|
41
|
+
return artifact.absolute_path
|
|
42
|
+
|
|
43
|
+
async def save_as(self, path: Union[str, pathlib.Path]) -> None:
|
|
44
|
+
if self._page._connection._is_sync and (not self._page._is_closed):
|
|
45
|
+
raise Error(
|
|
46
|
+
"Page is not yet closed. Close the page prior to calling save_as"
|
|
47
|
+
)
|
|
48
|
+
artifact = await self._artifact_future
|
|
49
|
+
if not artifact:
|
|
50
|
+
raise Error("Page did not produce any video frames")
|
|
51
|
+
await artifact.save_as(path)
|
|
52
|
+
|
|
53
|
+
async def delete(self) -> None:
|
|
54
|
+
artifact = await self._artifact_future
|
|
55
|
+
if not artifact:
|
|
56
|
+
raise Error("Page did not produce any video frames")
|
|
57
|
+
await artifact.delete()
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import math
|
|
3
|
+
import uuid
|
|
4
|
+
from asyncio.tasks import Task
|
|
5
|
+
from typing import Any, Callable, List, Tuple, Union
|
|
6
|
+
from pyee import EventEmitter
|
|
7
|
+
from patchright._impl._connection import ChannelOwner
|
|
8
|
+
from patchright._impl._errors import Error, TimeoutError
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Waiter:
|
|
12
|
+
|
|
13
|
+
def __init__(self, channel_owner: ChannelOwner, event: str) -> None:
|
|
14
|
+
self._result: asyncio.Future = asyncio.Future()
|
|
15
|
+
self._wait_id = uuid.uuid4().hex
|
|
16
|
+
self._loop = channel_owner._loop
|
|
17
|
+
self._pending_tasks: List[Task] = []
|
|
18
|
+
self._channel = channel_owner._channel
|
|
19
|
+
self._registered_listeners: List[Tuple[EventEmitter, str, Callable]] = []
|
|
20
|
+
self._logs: List[str] = []
|
|
21
|
+
self._wait_for_event_info_before(self._wait_id, event)
|
|
22
|
+
|
|
23
|
+
def _wait_for_event_info_before(self, wait_id: str, event: str) -> None:
|
|
24
|
+
self._channel.send_no_reply(
|
|
25
|
+
"waitForEventInfo",
|
|
26
|
+
{"info": {"waitId": wait_id, "phase": "before", "event": event}},
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
def _wait_for_event_info_after(self, wait_id: str, error: Exception = None) -> None:
|
|
30
|
+
self._channel._connection.wrap_api_call_sync(
|
|
31
|
+
lambda: self._channel.send_no_reply(
|
|
32
|
+
"waitForEventInfo",
|
|
33
|
+
{
|
|
34
|
+
"info": {
|
|
35
|
+
"waitId": wait_id,
|
|
36
|
+
"phase": "after",
|
|
37
|
+
**({"error": str(error)} if error else {}),
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
),
|
|
41
|
+
True,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
def reject_on_event(
|
|
45
|
+
self,
|
|
46
|
+
emitter: EventEmitter,
|
|
47
|
+
event: str,
|
|
48
|
+
error: Union[Error, Callable[..., Error]],
|
|
49
|
+
predicate: Callable = None,
|
|
50
|
+
) -> None:
|
|
51
|
+
|
|
52
|
+
def listener(event_data: Any = None) -> None:
|
|
53
|
+
if not predicate or predicate(event_data):
|
|
54
|
+
self._reject(error() if callable(error) else error)
|
|
55
|
+
|
|
56
|
+
emitter.on(event, listener)
|
|
57
|
+
self._registered_listeners.append((emitter, event, listener))
|
|
58
|
+
|
|
59
|
+
def reject_on_timeout(self, timeout: float, message: str) -> None:
|
|
60
|
+
if timeout == 0:
|
|
61
|
+
return
|
|
62
|
+
|
|
63
|
+
async def reject() -> None:
|
|
64
|
+
await asyncio.sleep(timeout / 1000)
|
|
65
|
+
self._reject(TimeoutError(message))
|
|
66
|
+
|
|
67
|
+
self._pending_tasks.append(self._loop.create_task(reject()))
|
|
68
|
+
|
|
69
|
+
def _cleanup(self) -> None:
|
|
70
|
+
for task in self._pending_tasks:
|
|
71
|
+
if not task.done():
|
|
72
|
+
task.cancel()
|
|
73
|
+
for listener in self._registered_listeners:
|
|
74
|
+
listener[0].remove_listener(listener[1], listener[2])
|
|
75
|
+
|
|
76
|
+
def _fulfill(self, result: Any) -> None:
|
|
77
|
+
self._cleanup()
|
|
78
|
+
if not self._result.done():
|
|
79
|
+
self._result.set_result(result)
|
|
80
|
+
self._wait_for_event_info_after(self._wait_id)
|
|
81
|
+
|
|
82
|
+
def _reject(self, exception: Exception) -> None:
|
|
83
|
+
self._cleanup()
|
|
84
|
+
if exception:
|
|
85
|
+
base_class = TimeoutError if isinstance(exception, TimeoutError) else Error
|
|
86
|
+
exception = base_class(str(exception) + format_log_recording(self._logs))
|
|
87
|
+
if not self._result.done():
|
|
88
|
+
self._result.set_exception(exception)
|
|
89
|
+
self._wait_for_event_info_after(self._wait_id, exception)
|
|
90
|
+
|
|
91
|
+
def wait_for_event(
|
|
92
|
+
self, emitter: EventEmitter, event: str, predicate: Callable = None
|
|
93
|
+
) -> None:
|
|
94
|
+
|
|
95
|
+
def listener(event_data: Any = None) -> None:
|
|
96
|
+
if not predicate or predicate(event_data):
|
|
97
|
+
self._fulfill(event_data)
|
|
98
|
+
|
|
99
|
+
emitter.on(event, listener)
|
|
100
|
+
self._registered_listeners.append((emitter, event, listener))
|
|
101
|
+
|
|
102
|
+
def result(self) -> asyncio.Future:
|
|
103
|
+
return self._result
|
|
104
|
+
|
|
105
|
+
def log(self, message: str) -> None:
|
|
106
|
+
self._logs.append(message)
|
|
107
|
+
try:
|
|
108
|
+
self._channel._connection.wrap_api_call_sync(
|
|
109
|
+
lambda: self._channel.send_no_reply(
|
|
110
|
+
"waitForEventInfo",
|
|
111
|
+
{
|
|
112
|
+
"info": {
|
|
113
|
+
"waitId": self._wait_id,
|
|
114
|
+
"phase": "log",
|
|
115
|
+
"message": message,
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
),
|
|
119
|
+
True,
|
|
120
|
+
)
|
|
121
|
+
except Exception:
|
|
122
|
+
pass
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def throw_on_timeout(timeout: float, exception: Exception) -> asyncio.Task:
|
|
126
|
+
|
|
127
|
+
async def throw() -> None:
|
|
128
|
+
await asyncio.sleep(timeout / 1000)
|
|
129
|
+
raise exception
|
|
130
|
+
|
|
131
|
+
return asyncio.create_task(throw())
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def format_log_recording(log: List[str]) -> str:
|
|
135
|
+
if not log:
|
|
136
|
+
return ""
|
|
137
|
+
header = " logs "
|
|
138
|
+
header_length = 60
|
|
139
|
+
left_length = math.floor((header_length - len(header)) / 2)
|
|
140
|
+
right_length = header_length - len(header) - left_length
|
|
141
|
+
new_line = "\n"
|
|
142
|
+
return f"{new_line}{'=' * left_length}{header}{'=' * right_length}{new_line}{new_line.join(log)}{new_line}{'=' * header_length}"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from asyncio import AbstractEventLoop
|
|
2
|
+
from typing import Optional
|
|
3
|
+
from patchright._impl._helper import Error
|
|
4
|
+
from patchright._impl._page import Page
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class WebError:
|
|
8
|
+
|
|
9
|
+
def __init__(
|
|
10
|
+
self, loop: AbstractEventLoop, page: Optional[Page], error: Error
|
|
11
|
+
) -> None:
|
|
12
|
+
self._loop = loop
|
|
13
|
+
self._page = page
|
|
14
|
+
self._error = error
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
def page(self) -> Optional[Page]:
|
|
18
|
+
return self._page
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def error(self) -> Error:
|
|
22
|
+
return self._error
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
|
|
13
|
+
def __init__(
|
|
14
|
+
self, parent: ChannelOwner, type: str, guid: str, initializer: Dict
|
|
15
|
+
) -> None:
|
|
16
|
+
super().__init__(parent, type, guid, initializer)
|
|
17
|
+
|
|
18
|
+
async def copy(self, path: Union[str, Path]) -> None:
|
|
19
|
+
with open(path, "rb") as f:
|
|
20
|
+
while True:
|
|
21
|
+
data = f.read(COPY_BUFSIZE)
|
|
22
|
+
if not data:
|
|
23
|
+
break
|
|
24
|
+
await self._channel.send(
|
|
25
|
+
"write", {"binary": base64.b64encode(data).decode()}
|
|
26
|
+
)
|
|
27
|
+
await self._channel.send("close")
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
TYPE_CHECKING = False
|
|
2
|
+
if TYPE_CHECKING:
|
|
3
|
+
from typing import Tuple, Union
|
|
4
|
+
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
5
|
+
else:
|
|
6
|
+
VERSION_TUPLE = object
|
|
7
|
+
version: str
|
|
8
|
+
__version__: str
|
|
9
|
+
__version_tuple__: VERSION_TUPLE
|
|
10
|
+
version_tuple: VERSION_TUPLE
|
|
11
|
+
__version__ = version = '1.48.0'
|
|
12
|
+
__version_tuple__ = version_tuple = (1, 48, 0)
|
|
@@ -0,0 +1,177 @@
|
|
|
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.async_api._generated
|
|
11
|
+
from patchright._impl._assertions import (
|
|
12
|
+
APIResponseAssertions as APIResponseAssertionsImpl,
|
|
13
|
+
)
|
|
14
|
+
from patchright._impl._assertions import LocatorAssertions as LocatorAssertionsImpl
|
|
15
|
+
from patchright._impl._assertions import PageAssertions as PageAssertionsImpl
|
|
16
|
+
from patchright.async_api._context_manager import PlaywrightContextManager
|
|
17
|
+
from patchright.async_api._generated import (
|
|
18
|
+
Accessibility,
|
|
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
|
+
WebSocket,
|
|
49
|
+
WebSocketRoute,
|
|
50
|
+
Worker,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
ChromiumBrowserContext = BrowserContext
|
|
54
|
+
Cookie = patchright._impl._api_structures.Cookie
|
|
55
|
+
FilePayload = patchright._impl._api_structures.FilePayload
|
|
56
|
+
FloatRect = patchright._impl._api_structures.FloatRect
|
|
57
|
+
Geolocation = patchright._impl._api_structures.Geolocation
|
|
58
|
+
HttpCredentials = patchright._impl._api_structures.HttpCredentials
|
|
59
|
+
PdfMargins = patchright._impl._api_structures.PdfMargins
|
|
60
|
+
Position = patchright._impl._api_structures.Position
|
|
61
|
+
ProxySettings = patchright._impl._api_structures.ProxySettings
|
|
62
|
+
ResourceTiming = patchright._impl._api_structures.ResourceTiming
|
|
63
|
+
SourceLocation = patchright._impl._api_structures.SourceLocation
|
|
64
|
+
StorageState = patchright._impl._api_structures.StorageState
|
|
65
|
+
ViewportSize = patchright._impl._api_structures.ViewportSize
|
|
66
|
+
Error = patchright._impl._errors.Error
|
|
67
|
+
TimeoutError = patchright._impl._errors.TimeoutError
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def async_playwright() -> PlaywrightContextManager:
|
|
71
|
+
return PlaywrightContextManager()
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class Expect:
|
|
75
|
+
_unset: Any = object()
|
|
76
|
+
|
|
77
|
+
def __init__(self) -> None:
|
|
78
|
+
self._timeout: Optional[float] = None
|
|
79
|
+
|
|
80
|
+
def set_options(self, timeout: Optional[float] = _unset) -> None:
|
|
81
|
+
"""
|
|
82
|
+
This method sets global `expect()` options.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
timeout (float): Timeout value in milliseconds. Default to 5000 milliseconds.
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
None
|
|
89
|
+
"""
|
|
90
|
+
if timeout is not self._unset:
|
|
91
|
+
self._timeout = timeout
|
|
92
|
+
|
|
93
|
+
@overload
|
|
94
|
+
def __call__(
|
|
95
|
+
self, actual: Page, message: Optional[str] = None
|
|
96
|
+
) -> PageAssertions: ...
|
|
97
|
+
|
|
98
|
+
@overload
|
|
99
|
+
def __call__(
|
|
100
|
+
self, actual: Locator, message: Optional[str] = None
|
|
101
|
+
) -> LocatorAssertions: ...
|
|
102
|
+
|
|
103
|
+
@overload
|
|
104
|
+
def __call__(
|
|
105
|
+
self, actual: APIResponse, message: Optional[str] = None
|
|
106
|
+
) -> APIResponseAssertions: ...
|
|
107
|
+
|
|
108
|
+
def __call__(
|
|
109
|
+
self, actual: Union[Page, Locator, APIResponse], message: Optional[str] = None
|
|
110
|
+
) -> Union[PageAssertions, LocatorAssertions, APIResponseAssertions]:
|
|
111
|
+
if isinstance(actual, Page):
|
|
112
|
+
return PageAssertions(
|
|
113
|
+
PageAssertionsImpl(actual._impl_obj, self._timeout, message=message)
|
|
114
|
+
)
|
|
115
|
+
elif isinstance(actual, Locator):
|
|
116
|
+
return LocatorAssertions(
|
|
117
|
+
LocatorAssertionsImpl(actual._impl_obj, self._timeout, message=message)
|
|
118
|
+
)
|
|
119
|
+
elif isinstance(actual, APIResponse):
|
|
120
|
+
return APIResponseAssertions(
|
|
121
|
+
APIResponseAssertionsImpl(
|
|
122
|
+
actual._impl_obj, self._timeout, message=message
|
|
123
|
+
)
|
|
124
|
+
)
|
|
125
|
+
raise ValueError(f"Unsupported type: {type(actual)}")
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
expect = Expect()
|
|
129
|
+
__all__ = [
|
|
130
|
+
"expect",
|
|
131
|
+
"async_playwright",
|
|
132
|
+
"Accessibility",
|
|
133
|
+
"APIRequest",
|
|
134
|
+
"APIRequestContext",
|
|
135
|
+
"APIResponse",
|
|
136
|
+
"Browser",
|
|
137
|
+
"BrowserContext",
|
|
138
|
+
"BrowserType",
|
|
139
|
+
"CDPSession",
|
|
140
|
+
"ChromiumBrowserContext",
|
|
141
|
+
"ConsoleMessage",
|
|
142
|
+
"Cookie",
|
|
143
|
+
"Dialog",
|
|
144
|
+
"Download",
|
|
145
|
+
"ElementHandle",
|
|
146
|
+
"Error",
|
|
147
|
+
"FileChooser",
|
|
148
|
+
"FilePayload",
|
|
149
|
+
"FloatRect",
|
|
150
|
+
"Frame",
|
|
151
|
+
"FrameLocator",
|
|
152
|
+
"Geolocation",
|
|
153
|
+
"HttpCredentials",
|
|
154
|
+
"JSHandle",
|
|
155
|
+
"Keyboard",
|
|
156
|
+
"Locator",
|
|
157
|
+
"Mouse",
|
|
158
|
+
"Page",
|
|
159
|
+
"PdfMargins",
|
|
160
|
+
"Position",
|
|
161
|
+
"Playwright",
|
|
162
|
+
"ProxySettings",
|
|
163
|
+
"Request",
|
|
164
|
+
"ResourceTiming",
|
|
165
|
+
"Response",
|
|
166
|
+
"Route",
|
|
167
|
+
"Selectors",
|
|
168
|
+
"SourceLocation",
|
|
169
|
+
"StorageState",
|
|
170
|
+
"TimeoutError",
|
|
171
|
+
"Touchscreen",
|
|
172
|
+
"Video",
|
|
173
|
+
"ViewportSize",
|
|
174
|
+
"WebSocket",
|
|
175
|
+
"WebSocketRoute",
|
|
176
|
+
"Worker",
|
|
177
|
+
]
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
|
|
11
|
+
def __init__(self) -> None:
|
|
12
|
+
self._connection: Connection
|
|
13
|
+
self._exit_was_called = False
|
|
14
|
+
|
|
15
|
+
async def __aenter__(self) -> AsyncPlaywright:
|
|
16
|
+
loop = asyncio.get_running_loop()
|
|
17
|
+
self._connection = Connection(
|
|
18
|
+
None, create_remote_object, PipeTransport(loop), loop
|
|
19
|
+
)
|
|
20
|
+
loop.create_task(self._connection.run())
|
|
21
|
+
playwright_future = self._connection.playwright_future
|
|
22
|
+
done, _ = await asyncio.wait(
|
|
23
|
+
{self._connection._transport.on_error_future, playwright_future},
|
|
24
|
+
return_when=asyncio.FIRST_COMPLETED,
|
|
25
|
+
)
|
|
26
|
+
if not playwright_future.done():
|
|
27
|
+
playwright_future.cancel()
|
|
28
|
+
playwright = AsyncPlaywright(next(iter(done)).result())
|
|
29
|
+
playwright.stop = self.__aexit__
|
|
30
|
+
return playwright
|
|
31
|
+
|
|
32
|
+
async def start(self) -> AsyncPlaywright:
|
|
33
|
+
return await self.__aenter__()
|
|
34
|
+
|
|
35
|
+
async def __aexit__(self, *args: Any) -> None:
|
|
36
|
+
if self._exit_was_called:
|
|
37
|
+
return
|
|
38
|
+
self._exit_was_called = True
|
|
39
|
+
await self._connection.stop_async()
|