@stablyai/internal-playwright-core 0.1.0
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.
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +3 -0
- package/ThirdPartyNotices.txt +1134 -0
- package/bin/install_media_pack.ps1 +5 -0
- package/bin/install_webkit_wsl.ps1 +35 -0
- package/bin/reinstall_chrome_beta_linux.sh +42 -0
- package/bin/reinstall_chrome_beta_mac.sh +13 -0
- package/bin/reinstall_chrome_beta_win.ps1 +24 -0
- package/bin/reinstall_chrome_stable_linux.sh +42 -0
- package/bin/reinstall_chrome_stable_mac.sh +12 -0
- package/bin/reinstall_chrome_stable_win.ps1 +24 -0
- package/bin/reinstall_msedge_beta_linux.sh +48 -0
- package/bin/reinstall_msedge_beta_mac.sh +11 -0
- package/bin/reinstall_msedge_beta_win.ps1 +23 -0
- package/bin/reinstall_msedge_dev_linux.sh +48 -0
- package/bin/reinstall_msedge_dev_mac.sh +11 -0
- package/bin/reinstall_msedge_dev_win.ps1 +23 -0
- package/bin/reinstall_msedge_stable_linux.sh +48 -0
- package/bin/reinstall_msedge_stable_mac.sh +11 -0
- package/bin/reinstall_msedge_stable_win.ps1 +24 -0
- package/browsers.json +80 -0
- package/cli.js +18 -0
- package/index.d.ts +17 -0
- package/index.js +32 -0
- package/index.mjs +28 -0
- package/lib/androidServerImpl.js +65 -0
- package/lib/browserServerImpl.js +120 -0
- package/lib/cli/cli.js +58 -0
- package/lib/cli/driver.js +97 -0
- package/lib/cli/program.js +634 -0
- package/lib/cli/programWithTestStub.js +74 -0
- package/lib/client/accessibility.js +49 -0
- package/lib/client/android.js +361 -0
- package/lib/client/api.js +137 -0
- package/lib/client/artifact.js +79 -0
- package/lib/client/browser.js +163 -0
- package/lib/client/browserContext.js +529 -0
- package/lib/client/browserType.js +184 -0
- package/lib/client/cdpSession.js +51 -0
- package/lib/client/channelOwner.js +194 -0
- package/lib/client/clientHelper.js +64 -0
- package/lib/client/clientInstrumentation.js +55 -0
- package/lib/client/clientStackTrace.js +69 -0
- package/lib/client/clock.js +68 -0
- package/lib/client/connection.js +314 -0
- package/lib/client/consoleMessage.js +54 -0
- package/lib/client/coverage.js +44 -0
- package/lib/client/dialog.js +56 -0
- package/lib/client/download.js +62 -0
- package/lib/client/electron.js +138 -0
- package/lib/client/elementHandle.js +281 -0
- package/lib/client/errors.js +77 -0
- package/lib/client/eventEmitter.js +314 -0
- package/lib/client/events.js +99 -0
- package/lib/client/fetch.js +369 -0
- package/lib/client/fileChooser.js +46 -0
- package/lib/client/fileUtils.js +34 -0
- package/lib/client/frame.js +408 -0
- package/lib/client/harRouter.js +87 -0
- package/lib/client/input.js +84 -0
- package/lib/client/jsHandle.js +109 -0
- package/lib/client/jsonPipe.js +39 -0
- package/lib/client/localUtils.js +60 -0
- package/lib/client/locator.js +368 -0
- package/lib/client/network.js +747 -0
- package/lib/client/page.js +721 -0
- package/lib/client/platform.js +74 -0
- package/lib/client/playwright.js +71 -0
- package/lib/client/selectors.js +55 -0
- package/lib/client/stream.js +39 -0
- package/lib/client/timeoutSettings.js +79 -0
- package/lib/client/tracing.js +117 -0
- package/lib/client/types.js +28 -0
- package/lib/client/video.js +59 -0
- package/lib/client/waiter.js +142 -0
- package/lib/client/webError.js +39 -0
- package/lib/client/webSocket.js +93 -0
- package/lib/client/worker.js +63 -0
- package/lib/client/writableStream.js +39 -0
- package/lib/common/debugLogger.js +90 -0
- package/lib/common/socksProxy.js +569 -0
- package/lib/common/timeoutSettings.js +73 -0
- package/lib/common/types.js +5 -0
- package/lib/generated/bindingsControllerSource.js +28 -0
- package/lib/generated/clockSource.js +28 -0
- package/lib/generated/consoleApiSource.js +28 -0
- package/lib/generated/injectedScriptSource.js +28 -0
- package/lib/generated/pollingRecorderSource.js +28 -0
- package/lib/generated/recorderSource.js +28 -0
- package/lib/generated/storageScriptSource.js +28 -0
- package/lib/generated/utilityScriptSource.js +28 -0
- package/lib/generated/webSocketMockSource.js +336 -0
- package/lib/image_tools/colorUtils.js +98 -0
- package/lib/image_tools/compare.js +108 -0
- package/lib/image_tools/imageChannel.js +70 -0
- package/lib/image_tools/stats.js +102 -0
- package/lib/inProcessFactory.js +60 -0
- package/lib/index.js +19 -0
- package/lib/inprocess.js +3 -0
- package/lib/outofprocess.js +76 -0
- package/lib/protocol/debug.js +27 -0
- package/lib/protocol/serializers.js +192 -0
- package/lib/protocol/transport.js +82 -0
- package/lib/protocol/validator.js +2919 -0
- package/lib/protocol/validatorPrimitives.js +193 -0
- package/lib/remote/playwrightConnection.js +129 -0
- package/lib/remote/playwrightServer.js +335 -0
- package/lib/server/accessibility.js +69 -0
- package/lib/server/android/android.js +465 -0
- package/lib/server/android/backendAdb.js +177 -0
- package/lib/server/artifact.js +127 -0
- package/lib/server/bidi/bidiBrowser.js +490 -0
- package/lib/server/bidi/bidiChromium.js +153 -0
- package/lib/server/bidi/bidiConnection.js +212 -0
- package/lib/server/bidi/bidiExecutionContext.js +221 -0
- package/lib/server/bidi/bidiFirefox.js +130 -0
- package/lib/server/bidi/bidiInput.js +146 -0
- package/lib/server/bidi/bidiNetworkManager.js +383 -0
- package/lib/server/bidi/bidiOverCdp.js +102 -0
- package/lib/server/bidi/bidiPage.js +552 -0
- package/lib/server/bidi/bidiPdf.js +106 -0
- package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
- package/lib/server/bidi/third_party/bidiDeserializer.js +98 -0
- package/lib/server/bidi/third_party/bidiKeyboard.js +256 -0
- package/lib/server/bidi/third_party/bidiProtocol.js +24 -0
- package/lib/server/bidi/third_party/bidiProtocolCore.js +179 -0
- package/lib/server/bidi/third_party/bidiProtocolPermissions.js +42 -0
- package/lib/server/bidi/third_party/bidiSerializer.js +148 -0
- package/lib/server/bidi/third_party/firefoxPrefs.js +259 -0
- package/lib/server/browser.js +149 -0
- package/lib/server/browserContext.js +695 -0
- package/lib/server/browserType.js +328 -0
- package/lib/server/callLog.js +82 -0
- package/lib/server/chromium/appIcon.png +0 -0
- package/lib/server/chromium/chromium.js +402 -0
- package/lib/server/chromium/chromiumSwitches.js +95 -0
- package/lib/server/chromium/crAccessibility.js +263 -0
- package/lib/server/chromium/crBrowser.js +501 -0
- package/lib/server/chromium/crConnection.js +202 -0
- package/lib/server/chromium/crCoverage.js +235 -0
- package/lib/server/chromium/crDevTools.js +113 -0
- package/lib/server/chromium/crDragDrop.js +131 -0
- package/lib/server/chromium/crExecutionContext.js +146 -0
- package/lib/server/chromium/crInput.js +187 -0
- package/lib/server/chromium/crNetworkManager.js +666 -0
- package/lib/server/chromium/crPage.js +1069 -0
- package/lib/server/chromium/crPdf.js +121 -0
- package/lib/server/chromium/crProtocolHelper.js +145 -0
- package/lib/server/chromium/crServiceWorker.js +123 -0
- package/lib/server/chromium/defaultFontFamilies.js +162 -0
- package/lib/server/chromium/protocol.d.js +16 -0
- package/lib/server/chromium/videoRecorder.js +113 -0
- package/lib/server/clock.js +149 -0
- package/lib/server/codegen/csharp.js +327 -0
- package/lib/server/codegen/java.js +274 -0
- package/lib/server/codegen/javascript.js +270 -0
- package/lib/server/codegen/jsonl.js +52 -0
- package/lib/server/codegen/language.js +132 -0
- package/lib/server/codegen/languages.js +68 -0
- package/lib/server/codegen/python.js +279 -0
- package/lib/server/codegen/types.js +16 -0
- package/lib/server/console.js +53 -0
- package/lib/server/cookieStore.js +206 -0
- package/lib/server/debugController.js +191 -0
- package/lib/server/debugger.js +119 -0
- package/lib/server/deviceDescriptors.js +39 -0
- package/lib/server/deviceDescriptorsSource.json +1779 -0
- package/lib/server/dialog.js +116 -0
- package/lib/server/dispatchers/androidDispatcher.js +325 -0
- package/lib/server/dispatchers/artifactDispatcher.js +118 -0
- package/lib/server/dispatchers/browserContextDispatcher.js +364 -0
- package/lib/server/dispatchers/browserDispatcher.js +118 -0
- package/lib/server/dispatchers/browserTypeDispatcher.js +64 -0
- package/lib/server/dispatchers/cdpSessionDispatcher.js +44 -0
- package/lib/server/dispatchers/debugControllerDispatcher.js +78 -0
- package/lib/server/dispatchers/dialogDispatcher.js +47 -0
- package/lib/server/dispatchers/dispatcher.js +371 -0
- package/lib/server/dispatchers/electronDispatcher.js +89 -0
- package/lib/server/dispatchers/elementHandlerDispatcher.js +181 -0
- package/lib/server/dispatchers/frameDispatcher.js +227 -0
- package/lib/server/dispatchers/jsHandleDispatcher.js +85 -0
- package/lib/server/dispatchers/jsonPipeDispatcher.js +58 -0
- package/lib/server/dispatchers/localUtilsDispatcher.js +149 -0
- package/lib/server/dispatchers/networkDispatchers.js +213 -0
- package/lib/server/dispatchers/pageDispatcher.js +401 -0
- package/lib/server/dispatchers/playwrightDispatcher.js +108 -0
- package/lib/server/dispatchers/selectorsDispatcher.js +36 -0
- package/lib/server/dispatchers/streamDispatcher.js +67 -0
- package/lib/server/dispatchers/tracingDispatcher.js +68 -0
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +165 -0
- package/lib/server/dispatchers/writableStreamDispatcher.js +79 -0
- package/lib/server/dom.js +806 -0
- package/lib/server/download.js +70 -0
- package/lib/server/electron/electron.js +270 -0
- package/lib/server/electron/loader.js +29 -0
- package/lib/server/errors.js +69 -0
- package/lib/server/fetch.js +621 -0
- package/lib/server/fileChooser.js +43 -0
- package/lib/server/fileUploadUtils.js +84 -0
- package/lib/server/firefox/ffAccessibility.js +238 -0
- package/lib/server/firefox/ffBrowser.js +428 -0
- package/lib/server/firefox/ffConnection.js +147 -0
- package/lib/server/firefox/ffExecutionContext.js +150 -0
- package/lib/server/firefox/ffInput.js +159 -0
- package/lib/server/firefox/ffNetworkManager.js +256 -0
- package/lib/server/firefox/ffPage.js +503 -0
- package/lib/server/firefox/firefox.js +116 -0
- package/lib/server/firefox/protocol.d.js +16 -0
- package/lib/server/formData.js +147 -0
- package/lib/server/frameSelectors.js +156 -0
- package/lib/server/frames.js +1502 -0
- package/lib/server/har/harRecorder.js +147 -0
- package/lib/server/har/harTracer.js +607 -0
- package/lib/server/harBackend.js +157 -0
- package/lib/server/helper.js +96 -0
- package/lib/server/index.js +58 -0
- package/lib/server/input.js +273 -0
- package/lib/server/instrumentation.js +69 -0
- package/lib/server/isomorphic/utilityScriptSerializers.js +212 -0
- package/lib/server/javascript.js +291 -0
- package/lib/server/launchApp.js +128 -0
- package/lib/server/localUtils.js +218 -0
- package/lib/server/macEditingCommands.js +143 -0
- package/lib/server/network.js +629 -0
- package/lib/server/page.js +871 -0
- package/lib/server/pipeTransport.js +89 -0
- package/lib/server/playwright.js +69 -0
- package/lib/server/progress.js +112 -0
- package/lib/server/protocolError.js +52 -0
- package/lib/server/recorder/chat.js +161 -0
- package/lib/server/recorder/codeGenerator.js +153 -0
- package/lib/server/recorder/csharp.js +310 -0
- package/lib/server/recorder/java.js +248 -0
- package/lib/server/recorder/javascript.js +229 -0
- package/lib/server/recorder/jsonl.js +47 -0
- package/lib/server/recorder/language.js +44 -0
- package/lib/server/recorder/python.js +276 -0
- package/lib/server/recorder/recorderActions.js +5 -0
- package/lib/server/recorder/recorderApp.js +387 -0
- package/lib/server/recorder/recorderRunner.js +138 -0
- package/lib/server/recorder/recorderSignalProcessor.js +83 -0
- package/lib/server/recorder/recorderUtils.js +157 -0
- package/lib/server/recorder/throttledFile.js +57 -0
- package/lib/server/recorder/utils.js +45 -0
- package/lib/server/recorder.js +499 -0
- package/lib/server/registry/browserFetcher.js +175 -0
- package/lib/server/registry/dependencies.js +371 -0
- package/lib/server/registry/index.js +1331 -0
- package/lib/server/registry/nativeDeps.js +1280 -0
- package/lib/server/registry/oopDownloadBrowserMain.js +120 -0
- package/lib/server/screenshotter.js +333 -0
- package/lib/server/selectors.js +112 -0
- package/lib/server/socksClientCertificatesInterceptor.js +383 -0
- package/lib/server/socksInterceptor.js +95 -0
- package/lib/server/stably/ai-tools/http-request.js +70 -0
- package/lib/server/stably/ai-tools/stablyApiCaller.js +137 -0
- package/lib/server/stably/autohealing/elementHandleFromCoordinates.js +64 -0
- package/lib/server/stably/autohealing/healingService.js +228 -0
- package/lib/server/stably/autohealing/screenshotFrame.js +41 -0
- package/lib/server/stably/constants.js +31 -0
- package/lib/server/trace/recorder/snapshotter.js +147 -0
- package/lib/server/trace/recorder/snapshotterInjected.js +541 -0
- package/lib/server/trace/recorder/tracing.js +602 -0
- package/lib/server/trace/test/inMemorySnapshotter.js +87 -0
- package/lib/server/trace/viewer/traceViewer.js +240 -0
- package/lib/server/transport.js +181 -0
- package/lib/server/types.js +28 -0
- package/lib/server/usKeyboardLayout.js +145 -0
- package/lib/server/utils/ascii.js +44 -0
- package/lib/server/utils/comparators.js +161 -0
- package/lib/server/utils/crypto.js +216 -0
- package/lib/server/utils/debug.js +42 -0
- package/lib/server/utils/debugLogger.js +122 -0
- package/lib/server/utils/env.js +73 -0
- package/lib/server/utils/eventsHelper.js +39 -0
- package/lib/server/utils/expectUtils.js +38 -0
- package/lib/server/utils/fileUtils.js +191 -0
- package/lib/server/utils/happyEyeballs.js +207 -0
- package/lib/server/utils/hostPlatform.js +111 -0
- package/lib/server/utils/httpServer.js +218 -0
- package/lib/server/utils/image_tools/colorUtils.js +89 -0
- package/lib/server/utils/image_tools/compare.js +109 -0
- package/lib/server/utils/image_tools/imageChannel.js +78 -0
- package/lib/server/utils/image_tools/stats.js +102 -0
- package/lib/server/utils/linuxUtils.js +71 -0
- package/lib/server/utils/network.js +233 -0
- package/lib/server/utils/nodePlatform.js +148 -0
- package/lib/server/utils/pipeTransport.js +84 -0
- package/lib/server/utils/processLauncher.js +241 -0
- package/lib/server/utils/profiler.js +65 -0
- package/lib/server/utils/socksProxy.js +511 -0
- package/lib/server/utils/spawnAsync.js +41 -0
- package/lib/server/utils/task.js +51 -0
- package/lib/server/utils/userAgent.js +98 -0
- package/lib/server/utils/wsServer.js +121 -0
- package/lib/server/utils/zipFile.js +74 -0
- package/lib/server/utils/zones.js +57 -0
- package/lib/server/webkit/protocol.d.js +16 -0
- package/lib/server/webkit/webkit.js +119 -0
- package/lib/server/webkit/wkAccessibility.js +237 -0
- package/lib/server/webkit/wkBrowser.js +339 -0
- package/lib/server/webkit/wkConnection.js +149 -0
- package/lib/server/webkit/wkExecutionContext.js +154 -0
- package/lib/server/webkit/wkInput.js +181 -0
- package/lib/server/webkit/wkInterceptableRequest.js +169 -0
- package/lib/server/webkit/wkPage.js +1134 -0
- package/lib/server/webkit/wkProvisionalPage.js +83 -0
- package/lib/server/webkit/wkWorkers.js +104 -0
- package/lib/server/webkit/wsl/webkit-wsl-transport-client.js +74 -0
- package/lib/server/webkit/wsl/webkit-wsl-transport-server.js +113 -0
- package/lib/third_party/diff_match_patch.js +2222 -0
- package/lib/third_party/pixelmatch.js +255 -0
- package/lib/utils/ascii.js +31 -0
- package/lib/utils/comparators.js +171 -0
- package/lib/utils/crypto.js +33 -0
- package/lib/utils/debug.js +46 -0
- package/lib/utils/debugLogger.js +89 -0
- package/lib/utils/env.js +49 -0
- package/lib/utils/eventsHelper.js +38 -0
- package/lib/utils/fileUtils.js +205 -0
- package/lib/utils/glob.js +83 -0
- package/lib/utils/happy-eyeballs.js +160 -0
- package/lib/utils/headers.js +52 -0
- package/lib/utils/hostPlatform.js +128 -0
- package/lib/utils/httpServer.js +236 -0
- package/lib/utils/index.js +346 -0
- package/lib/utils/isomorphic/ariaSnapshot.js +392 -0
- package/lib/utils/isomorphic/assert.js +31 -0
- package/lib/utils/isomorphic/colors.js +72 -0
- package/lib/utils/isomorphic/cssParser.js +245 -0
- package/lib/utils/isomorphic/cssTokenizer.js +1051 -0
- package/lib/utils/isomorphic/headers.js +53 -0
- package/lib/utils/isomorphic/locatorGenerators.js +673 -0
- package/lib/utils/isomorphic/locatorParser.js +176 -0
- package/lib/utils/isomorphic/locatorUtils.js +81 -0
- package/lib/utils/isomorphic/manualPromise.js +114 -0
- package/lib/utils/isomorphic/mimeType.js +459 -0
- package/lib/utils/isomorphic/multimap.js +80 -0
- package/lib/utils/isomorphic/protocolFormatter.js +78 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +321 -0
- package/lib/utils/isomorphic/rtti.js +43 -0
- package/lib/utils/isomorphic/selectorParser.js +386 -0
- package/lib/utils/isomorphic/semaphore.js +54 -0
- package/lib/utils/isomorphic/stackTrace.js +158 -0
- package/lib/utils/isomorphic/stringUtils.js +155 -0
- package/lib/utils/isomorphic/time.js +49 -0
- package/lib/utils/isomorphic/timeoutRunner.js +66 -0
- package/lib/utils/isomorphic/traceUtils.js +58 -0
- package/lib/utils/isomorphic/types.js +16 -0
- package/lib/utils/isomorphic/urlMatch.js +176 -0
- package/lib/utils/isomorphic/utilityScriptSerializers.js +251 -0
- package/lib/utils/linuxUtils.js +78 -0
- package/lib/utils/manualPromise.js +109 -0
- package/lib/utils/mimeType.js +29 -0
- package/lib/utils/multimap.js +75 -0
- package/lib/utils/network.js +188 -0
- package/lib/utils/processLauncher.js +248 -0
- package/lib/utils/profiler.js +53 -0
- package/lib/utils/rtti.js +44 -0
- package/lib/utils/semaphore.js +51 -0
- package/lib/utils/spawnAsync.js +45 -0
- package/lib/utils/stackTrace.js +121 -0
- package/lib/utils/task.js +58 -0
- package/lib/utils/time.js +37 -0
- package/lib/utils/timeoutRunner.js +66 -0
- package/lib/utils/traceUtils.js +44 -0
- package/lib/utils/userAgent.js +105 -0
- package/lib/utils/wsServer.js +127 -0
- package/lib/utils/zipFile.js +75 -0
- package/lib/utils/zones.js +62 -0
- package/lib/utils.js +107 -0
- package/lib/utilsBundle.js +109 -0
- package/lib/utilsBundleImpl/index.js +218 -0
- package/lib/utilsBundleImpl/xdg-open +1066 -0
- package/lib/vite/htmlReport/index.html +84 -0
- package/lib/vite/recorder/assets/codeMirrorModule-C3UTv-Ge.css +1 -0
- package/lib/vite/recorder/assets/codeMirrorModule-RJCXzfmE.js +24 -0
- package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/lib/vite/recorder/assets/index-Ri0uHF7I.css +1 -0
- package/lib/vite/recorder/assets/index-Y-X2TGJv.js +193 -0
- package/lib/vite/recorder/index.html +29 -0
- package/lib/vite/recorder/playwright-logo.svg +9 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-Bhnc5o2x.js +24 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-ClwvkA2N.js +265 -0
- package/lib/vite/traceViewer/assets/xtermModule-CsJ4vdCR.js +9 -0
- package/lib/vite/traceViewer/codeMirrorModule.C3UTv-Ge.css +1 -0
- package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/lib/vite/traceViewer/defaultSettingsView.TQ8_7ybu.css +1 -0
- package/lib/vite/traceViewer/index.DFO9NNF5.js +2 -0
- package/lib/vite/traceViewer/index.I8N9v4jT.css +1 -0
- package/lib/vite/traceViewer/index.html +43 -0
- package/lib/vite/traceViewer/playwright-logo.svg +9 -0
- package/lib/vite/traceViewer/snapshot.html +21 -0
- package/lib/vite/traceViewer/sw.bundle.js +3 -0
- package/lib/vite/traceViewer/uiMode.Btcz36p_.css +1 -0
- package/lib/vite/traceViewer/uiMode.Shu3QS-1.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +17 -0
- package/lib/vite/traceViewer/xtermModule.DYP7pi_n.css +32 -0
- package/lib/zipBundle.js +34 -0
- package/lib/zipBundleImpl.js +5 -0
- package/package.json +43 -0
- package/types/protocol.d.ts +23130 -0
- package/types/structs.d.ts +45 -0
- package/types/types.d.ts +22857 -0
@@ -0,0 +1,634 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var program_exports = {};
|
30
|
+
__export(program_exports, {
|
31
|
+
program: () => import_utilsBundle2.program
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(program_exports);
|
34
|
+
var import_fs = __toESM(require("fs"));
|
35
|
+
var import_os = __toESM(require("os"));
|
36
|
+
var import_path = __toESM(require("path"));
|
37
|
+
var playwright = __toESM(require("../.."));
|
38
|
+
var import_driver = require("./driver");
|
39
|
+
var import_server = require("../server");
|
40
|
+
var import_utils = require("../utils");
|
41
|
+
var import_traceViewer = require("../server/trace/viewer/traceViewer");
|
42
|
+
var import_utils2 = require("../utils");
|
43
|
+
var import_ascii = require("../server/utils/ascii");
|
44
|
+
var import_utilsBundle = require("../utilsBundle");
|
45
|
+
var import_utilsBundle2 = require("../utilsBundle");
|
46
|
+
const packageJSON = require("../../package.json");
|
47
|
+
import_utilsBundle.program.version("Version " + (process.env.PW_CLI_DISPLAY_VERSION || packageJSON.version)).name(buildBasePlaywrightCLICommand(process.env.PW_LANG_NAME));
|
48
|
+
import_utilsBundle.program.command("mark-docker-image [dockerImageNameTemplate]", { hidden: true }).description("mark docker image").allowUnknownOption(true).action(function(dockerImageNameTemplate) {
|
49
|
+
(0, import_utils2.assert)(dockerImageNameTemplate, "dockerImageNameTemplate is required");
|
50
|
+
(0, import_server.writeDockerVersion)(dockerImageNameTemplate).catch(logErrorAndExit);
|
51
|
+
});
|
52
|
+
commandWithOpenOptions("open [url]", "open page in browser specified via -b, --browser", []).action(function(url, options) {
|
53
|
+
open(options, url).catch(logErrorAndExit);
|
54
|
+
}).addHelpText("afterAll", `
|
55
|
+
Examples:
|
56
|
+
|
57
|
+
$ open
|
58
|
+
$ open -b webkit https://example.com`);
|
59
|
+
commandWithOpenOptions(
|
60
|
+
"codegen [url]",
|
61
|
+
"open page and generate code for user actions",
|
62
|
+
[
|
63
|
+
["-o, --output <file name>", "saves the generated script to a file"],
|
64
|
+
["--target <language>", `language to generate, one of javascript, playwright-test, python, python-async, python-pytest, csharp, csharp-mstest, csharp-nunit, java, java-junit`, codegenId()],
|
65
|
+
["--test-id-attribute <attributeName>", "use the specified attribute to generate data test ID selectors"]
|
66
|
+
]
|
67
|
+
).action(async function(url, options) {
|
68
|
+
await codegen(options, url);
|
69
|
+
}).addHelpText("afterAll", `
|
70
|
+
Examples:
|
71
|
+
|
72
|
+
$ codegen
|
73
|
+
$ codegen --target=python
|
74
|
+
$ codegen -b webkit https://example.com`);
|
75
|
+
function suggestedBrowsersToInstall() {
|
76
|
+
return import_server.registry.executables().filter((e) => e.installType !== "none" && e.type !== "tool").map((e) => e.name).join(", ");
|
77
|
+
}
|
78
|
+
function defaultBrowsersToInstall(options) {
|
79
|
+
let executables = import_server.registry.defaultExecutables();
|
80
|
+
if (options.noShell)
|
81
|
+
executables = executables.filter((e) => e.name !== "chromium-headless-shell");
|
82
|
+
if (options.onlyShell)
|
83
|
+
executables = executables.filter((e) => e.name !== "chromium");
|
84
|
+
return executables;
|
85
|
+
}
|
86
|
+
function checkBrowsersToInstall(args, options) {
|
87
|
+
if (options.noShell && options.onlyShell)
|
88
|
+
throw new Error(`Only one of --no-shell and --only-shell can be specified`);
|
89
|
+
const faultyArguments = [];
|
90
|
+
const executables = [];
|
91
|
+
const handleArgument = (arg) => {
|
92
|
+
const executable = import_server.registry.findExecutable(arg);
|
93
|
+
if (!executable || executable.installType === "none")
|
94
|
+
faultyArguments.push(arg);
|
95
|
+
else
|
96
|
+
executables.push(executable);
|
97
|
+
if (executable?.browserName === "chromium")
|
98
|
+
executables.push(import_server.registry.findExecutable("ffmpeg"));
|
99
|
+
};
|
100
|
+
for (const arg of args) {
|
101
|
+
if (arg === "chromium") {
|
102
|
+
if (!options.onlyShell)
|
103
|
+
handleArgument("chromium");
|
104
|
+
if (!options.noShell)
|
105
|
+
handleArgument("chromium-headless-shell");
|
106
|
+
} else {
|
107
|
+
handleArgument(arg);
|
108
|
+
}
|
109
|
+
}
|
110
|
+
if (process.platform === "win32")
|
111
|
+
executables.push(import_server.registry.findExecutable("winldd"));
|
112
|
+
if (faultyArguments.length)
|
113
|
+
throw new Error(`Invalid installation targets: ${faultyArguments.map((name) => `'${name}'`).join(", ")}. Expecting one of: ${suggestedBrowsersToInstall()}`);
|
114
|
+
return executables;
|
115
|
+
}
|
116
|
+
function printInstalledBrowsers(browsers2) {
|
117
|
+
const browserPaths = /* @__PURE__ */ new Set();
|
118
|
+
for (const browser of browsers2)
|
119
|
+
browserPaths.add(browser.browserPath);
|
120
|
+
console.log(` Browsers:`);
|
121
|
+
for (const browserPath of [...browserPaths].sort())
|
122
|
+
console.log(` ${browserPath}`);
|
123
|
+
console.log(` References:`);
|
124
|
+
const references = /* @__PURE__ */ new Set();
|
125
|
+
for (const browser of browsers2)
|
126
|
+
references.add(browser.referenceDir);
|
127
|
+
for (const reference of [...references].sort())
|
128
|
+
console.log(` ${reference}`);
|
129
|
+
}
|
130
|
+
function printGroupedByPlaywrightVersion(browsers2) {
|
131
|
+
const dirToVersion = /* @__PURE__ */ new Map();
|
132
|
+
for (const browser of browsers2) {
|
133
|
+
if (dirToVersion.has(browser.referenceDir))
|
134
|
+
continue;
|
135
|
+
const packageJSON2 = require(import_path.default.join(browser.referenceDir, "package.json"));
|
136
|
+
const version = packageJSON2.version;
|
137
|
+
dirToVersion.set(browser.referenceDir, version);
|
138
|
+
}
|
139
|
+
const groupedByPlaywrightMinorVersion = /* @__PURE__ */ new Map();
|
140
|
+
for (const browser of browsers2) {
|
141
|
+
const version = dirToVersion.get(browser.referenceDir);
|
142
|
+
let entries = groupedByPlaywrightMinorVersion.get(version);
|
143
|
+
if (!entries) {
|
144
|
+
entries = [];
|
145
|
+
groupedByPlaywrightMinorVersion.set(version, entries);
|
146
|
+
}
|
147
|
+
entries.push(browser);
|
148
|
+
}
|
149
|
+
const sortedVersions = [...groupedByPlaywrightMinorVersion.keys()].sort((a, b) => {
|
150
|
+
const aComponents = a.split(".");
|
151
|
+
const bComponents = b.split(".");
|
152
|
+
const aMajor = parseInt(aComponents[0], 10);
|
153
|
+
const bMajor = parseInt(bComponents[0], 10);
|
154
|
+
if (aMajor !== bMajor)
|
155
|
+
return aMajor - bMajor;
|
156
|
+
const aMinor = parseInt(aComponents[1], 10);
|
157
|
+
const bMinor = parseInt(bComponents[1], 10);
|
158
|
+
if (aMinor !== bMinor)
|
159
|
+
return aMinor - bMinor;
|
160
|
+
return aComponents.slice(2).join(".").localeCompare(bComponents.slice(2).join("."));
|
161
|
+
});
|
162
|
+
for (const version of sortedVersions) {
|
163
|
+
console.log(`
|
164
|
+
Playwright version: ${version}`);
|
165
|
+
printInstalledBrowsers(groupedByPlaywrightMinorVersion.get(version));
|
166
|
+
}
|
167
|
+
}
|
168
|
+
import_utilsBundle.program.command("install [browser...]").description("ensure browsers necessary for this version of Playwright are installed").option("--with-deps", "install system dependencies for browsers").option("--dry-run", "do not execute installation, only print information").option("--list", "prints list of browsers from all playwright installations").option("--force", "force reinstall of stable browser channels").option("--only-shell", "only install headless shell when installing chromium").option("--no-shell", "do not install chromium headless shell").action(async function(args, options) {
|
169
|
+
if (options.shell === false)
|
170
|
+
options.noShell = true;
|
171
|
+
if ((0, import_utils.isLikelyNpxGlobal)()) {
|
172
|
+
console.error((0, import_ascii.wrapInASCIIBox)([
|
173
|
+
`WARNING: It looks like you are running 'npx playwright install' without first`,
|
174
|
+
`installing your project's dependencies.`,
|
175
|
+
``,
|
176
|
+
`To avoid unexpected behavior, please install your dependencies first, and`,
|
177
|
+
`then run Playwright's install command:`,
|
178
|
+
``,
|
179
|
+
` npm install`,
|
180
|
+
` npx playwright install`,
|
181
|
+
``,
|
182
|
+
`If your project does not yet depend on Playwright, first install the`,
|
183
|
+
`applicable npm package (most commonly @playwright/test), and`,
|
184
|
+
`then run Playwright's install command to download the browsers:`,
|
185
|
+
``,
|
186
|
+
` npm install @playwright/test`,
|
187
|
+
` npx playwright install`,
|
188
|
+
``
|
189
|
+
].join("\n"), 1));
|
190
|
+
}
|
191
|
+
try {
|
192
|
+
const hasNoArguments = !args.length;
|
193
|
+
const executables = hasNoArguments ? defaultBrowsersToInstall(options) : checkBrowsersToInstall(args, options);
|
194
|
+
if (options.withDeps)
|
195
|
+
await import_server.registry.installDeps(executables, !!options.dryRun);
|
196
|
+
if (options.dryRun && options.list)
|
197
|
+
throw new Error(`Only one of --dry-run and --list can be specified`);
|
198
|
+
if (options.dryRun) {
|
199
|
+
for (const executable of executables) {
|
200
|
+
const version = executable.browserVersion ? `version ` + executable.browserVersion : "";
|
201
|
+
console.log(`browser: ${executable.name}${version ? " " + version : ""}`);
|
202
|
+
console.log(` Install location: ${executable.directory ?? "<system>"}`);
|
203
|
+
if (executable.downloadURLs?.length) {
|
204
|
+
const [url, ...fallbacks] = executable.downloadURLs;
|
205
|
+
console.log(` Download url: ${url}`);
|
206
|
+
for (let i = 0; i < fallbacks.length; ++i)
|
207
|
+
console.log(` Download fallback ${i + 1}: ${fallbacks[i]}`);
|
208
|
+
}
|
209
|
+
console.log(``);
|
210
|
+
}
|
211
|
+
} else if (options.list) {
|
212
|
+
const browsers2 = await import_server.registry.listInstalledBrowsers();
|
213
|
+
printGroupedByPlaywrightVersion(browsers2);
|
214
|
+
} else {
|
215
|
+
const forceReinstall = hasNoArguments ? false : !!options.force;
|
216
|
+
await import_server.registry.install(executables, forceReinstall);
|
217
|
+
await import_server.registry.validateHostRequirementsForExecutablesIfNeeded(executables, process.env.PW_LANG_NAME || "javascript").catch((e) => {
|
218
|
+
e.name = "Playwright Host validation warning";
|
219
|
+
console.error(e);
|
220
|
+
});
|
221
|
+
}
|
222
|
+
} catch (e) {
|
223
|
+
console.log(`Failed to install browsers
|
224
|
+
${e}`);
|
225
|
+
(0, import_utils.gracefullyProcessExitDoNotHang)(1);
|
226
|
+
}
|
227
|
+
}).addHelpText("afterAll", `
|
228
|
+
|
229
|
+
Examples:
|
230
|
+
- $ install
|
231
|
+
Install default browsers.
|
232
|
+
|
233
|
+
- $ install chrome firefox
|
234
|
+
Install custom browsers, supports ${suggestedBrowsersToInstall()}.`);
|
235
|
+
import_utilsBundle.program.command("uninstall").description("Removes browsers used by this installation of Playwright from the system (chromium, firefox, webkit, ffmpeg). This does not include branded channels.").option("--all", "Removes all browsers used by any Playwright installation from the system.").action(async (options) => {
|
236
|
+
delete process.env.PLAYWRIGHT_SKIP_BROWSER_GC;
|
237
|
+
await import_server.registry.uninstall(!!options.all).then(({ numberOfBrowsersLeft }) => {
|
238
|
+
if (!options.all && numberOfBrowsersLeft > 0) {
|
239
|
+
console.log("Successfully uninstalled Playwright browsers for the current Playwright installation.");
|
240
|
+
console.log(`There are still ${numberOfBrowsersLeft} browsers left, used by other Playwright installations.
|
241
|
+
To uninstall Playwright browsers for all installations, re-run with --all flag.`);
|
242
|
+
}
|
243
|
+
}).catch(logErrorAndExit);
|
244
|
+
});
|
245
|
+
import_utilsBundle.program.command("install-deps [browser...]").description("install dependencies necessary to run browsers (will ask for sudo permissions)").option("--dry-run", "Do not execute installation commands, only print them").action(async function(args, options) {
|
246
|
+
try {
|
247
|
+
if (!args.length)
|
248
|
+
await import_server.registry.installDeps(defaultBrowsersToInstall({}), !!options.dryRun);
|
249
|
+
else
|
250
|
+
await import_server.registry.installDeps(checkBrowsersToInstall(args, {}), !!options.dryRun);
|
251
|
+
} catch (e) {
|
252
|
+
console.log(`Failed to install browser dependencies
|
253
|
+
${e}`);
|
254
|
+
(0, import_utils.gracefullyProcessExitDoNotHang)(1);
|
255
|
+
}
|
256
|
+
}).addHelpText("afterAll", `
|
257
|
+
Examples:
|
258
|
+
- $ install-deps
|
259
|
+
Install dependencies for default browsers.
|
260
|
+
|
261
|
+
- $ install-deps chrome firefox
|
262
|
+
Install dependencies for specific browsers, supports ${suggestedBrowsersToInstall()}.`);
|
263
|
+
const browsers = [
|
264
|
+
{ alias: "cr", name: "Chromium", type: "chromium" },
|
265
|
+
{ alias: "ff", name: "Firefox", type: "firefox" },
|
266
|
+
{ alias: "wk", name: "WebKit", type: "webkit" }
|
267
|
+
];
|
268
|
+
for (const { alias, name, type } of browsers) {
|
269
|
+
commandWithOpenOptions(`${alias} [url]`, `open page in ${name}`, []).action(function(url, options) {
|
270
|
+
open({ ...options, browser: type }, url).catch(logErrorAndExit);
|
271
|
+
}).addHelpText("afterAll", `
|
272
|
+
Examples:
|
273
|
+
|
274
|
+
$ ${alias} https://example.com`);
|
275
|
+
}
|
276
|
+
commandWithOpenOptions(
|
277
|
+
"screenshot <url> <filename>",
|
278
|
+
"capture a page screenshot",
|
279
|
+
[
|
280
|
+
["--wait-for-selector <selector>", "wait for selector before taking a screenshot"],
|
281
|
+
["--wait-for-timeout <timeout>", "wait for timeout in milliseconds before taking a screenshot"],
|
282
|
+
["--full-page", "whether to take a full page screenshot (entire scrollable area)"]
|
283
|
+
]
|
284
|
+
).action(function(url, filename, command) {
|
285
|
+
screenshot(command, command, url, filename).catch(logErrorAndExit);
|
286
|
+
}).addHelpText("afterAll", `
|
287
|
+
Examples:
|
288
|
+
|
289
|
+
$ screenshot -b webkit https://example.com example.png`);
|
290
|
+
commandWithOpenOptions(
|
291
|
+
"pdf <url> <filename>",
|
292
|
+
"save page as pdf",
|
293
|
+
[
|
294
|
+
["--paper-format <format>", "paper format: Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6"],
|
295
|
+
["--wait-for-selector <selector>", "wait for given selector before saving as pdf"],
|
296
|
+
["--wait-for-timeout <timeout>", "wait for given timeout in milliseconds before saving as pdf"]
|
297
|
+
]
|
298
|
+
).action(function(url, filename, options) {
|
299
|
+
pdf(options, options, url, filename).catch(logErrorAndExit);
|
300
|
+
}).addHelpText("afterAll", `
|
301
|
+
Examples:
|
302
|
+
|
303
|
+
$ pdf https://example.com example.pdf`);
|
304
|
+
import_utilsBundle.program.command("run-driver", { hidden: true }).action(function(options) {
|
305
|
+
(0, import_driver.runDriver)();
|
306
|
+
});
|
307
|
+
import_utilsBundle.program.command("run-server").option("--port <port>", "Server port").option("--host <host>", "Server host").option("--path <path>", "Endpoint Path", "/").option("--max-clients <maxClients>", "Maximum clients").option("--mode <mode>", 'Server mode, either "default" or "extension"').action(function(options) {
|
308
|
+
(0, import_driver.runServer)({
|
309
|
+
port: options.port ? +options.port : void 0,
|
310
|
+
host: options.host,
|
311
|
+
path: options.path,
|
312
|
+
maxConnections: options.maxClients ? +options.maxClients : Infinity,
|
313
|
+
extension: options.mode === "extension" || !!process.env.PW_EXTENSION_MODE
|
314
|
+
}).catch(logErrorAndExit);
|
315
|
+
});
|
316
|
+
import_utilsBundle.program.command("print-api-json", { hidden: true }).action(function(options) {
|
317
|
+
(0, import_driver.printApiJson)();
|
318
|
+
});
|
319
|
+
import_utilsBundle.program.command("launch-server", { hidden: true }).requiredOption("--browser <browserName>", 'Browser name, one of "chromium", "firefox" or "webkit"').option("--config <path-to-config-file>", "JSON file with launchServer options").action(function(options) {
|
320
|
+
(0, import_driver.launchBrowserServer)(options.browser, options.config);
|
321
|
+
});
|
322
|
+
import_utilsBundle.program.command("show-trace [trace]").option("-b, --browser <browserType>", "browser to use, one of cr, chromium, ff, firefox, wk, webkit", "chromium").option("-h, --host <host>", "Host to serve trace on; specifying this option opens trace in a browser tab").option("-p, --port <port>", "Port to serve trace on, 0 for any free port; specifying this option opens trace in a browser tab").option("--stdin", "Accept trace URLs over stdin to update the viewer").description("show trace viewer").action(function(trace, options) {
|
323
|
+
if (options.browser === "cr")
|
324
|
+
options.browser = "chromium";
|
325
|
+
if (options.browser === "ff")
|
326
|
+
options.browser = "firefox";
|
327
|
+
if (options.browser === "wk")
|
328
|
+
options.browser = "webkit";
|
329
|
+
const openOptions = {
|
330
|
+
host: options.host,
|
331
|
+
port: +options.port,
|
332
|
+
isServer: !!options.stdin
|
333
|
+
};
|
334
|
+
if (options.port !== void 0 || options.host !== void 0)
|
335
|
+
(0, import_traceViewer.runTraceInBrowser)(trace, openOptions).catch(logErrorAndExit);
|
336
|
+
else
|
337
|
+
(0, import_traceViewer.runTraceViewerApp)(trace, options.browser, openOptions, true).catch(logErrorAndExit);
|
338
|
+
}).addHelpText("afterAll", `
|
339
|
+
Examples:
|
340
|
+
|
341
|
+
$ show-trace
|
342
|
+
$ show-trace https://example.com/trace.zip`);
|
343
|
+
async function launchContext(options, extraOptions) {
|
344
|
+
validateOptions(options);
|
345
|
+
const browserType = lookupBrowserType(options);
|
346
|
+
const launchOptions = extraOptions;
|
347
|
+
if (options.channel)
|
348
|
+
launchOptions.channel = options.channel;
|
349
|
+
launchOptions.handleSIGINT = false;
|
350
|
+
const contextOptions = (
|
351
|
+
// Copy the device descriptor since we have to compare and modify the options.
|
352
|
+
options.device ? { ...playwright.devices[options.device] } : {}
|
353
|
+
);
|
354
|
+
if (!extraOptions.headless)
|
355
|
+
contextOptions.deviceScaleFactor = import_os.default.platform() === "darwin" ? 2 : 1;
|
356
|
+
if (browserType.name() === "webkit" && process.platform === "linux") {
|
357
|
+
delete contextOptions.hasTouch;
|
358
|
+
delete contextOptions.isMobile;
|
359
|
+
}
|
360
|
+
if (contextOptions.isMobile && browserType.name() === "firefox")
|
361
|
+
contextOptions.isMobile = void 0;
|
362
|
+
if (options.blockServiceWorkers)
|
363
|
+
contextOptions.serviceWorkers = "block";
|
364
|
+
if (options.proxyServer) {
|
365
|
+
launchOptions.proxy = {
|
366
|
+
server: options.proxyServer
|
367
|
+
};
|
368
|
+
if (options.proxyBypass)
|
369
|
+
launchOptions.proxy.bypass = options.proxyBypass;
|
370
|
+
}
|
371
|
+
if (options.viewportSize) {
|
372
|
+
try {
|
373
|
+
const [width, height] = options.viewportSize.split(",").map((n) => +n);
|
374
|
+
if (isNaN(width) || isNaN(height))
|
375
|
+
throw new Error("bad values");
|
376
|
+
contextOptions.viewport = { width, height };
|
377
|
+
} catch (e) {
|
378
|
+
throw new Error('Invalid viewport size format: use "width,height", for example --viewport-size="800,600"');
|
379
|
+
}
|
380
|
+
}
|
381
|
+
if (options.geolocation) {
|
382
|
+
try {
|
383
|
+
const [latitude, longitude] = options.geolocation.split(",").map((n) => parseFloat(n.trim()));
|
384
|
+
contextOptions.geolocation = {
|
385
|
+
latitude,
|
386
|
+
longitude
|
387
|
+
};
|
388
|
+
} catch (e) {
|
389
|
+
throw new Error('Invalid geolocation format, should be "lat,long". For example --geolocation="37.819722,-122.478611"');
|
390
|
+
}
|
391
|
+
contextOptions.permissions = ["geolocation"];
|
392
|
+
}
|
393
|
+
if (options.userAgent)
|
394
|
+
contextOptions.userAgent = options.userAgent;
|
395
|
+
if (options.lang)
|
396
|
+
contextOptions.locale = options.lang;
|
397
|
+
if (options.colorScheme)
|
398
|
+
contextOptions.colorScheme = options.colorScheme;
|
399
|
+
if (options.timezone)
|
400
|
+
contextOptions.timezoneId = options.timezone;
|
401
|
+
if (options.loadStorage)
|
402
|
+
contextOptions.storageState = options.loadStorage;
|
403
|
+
if (options.ignoreHttpsErrors)
|
404
|
+
contextOptions.ignoreHTTPSErrors = true;
|
405
|
+
if (options.saveHar) {
|
406
|
+
contextOptions.recordHar = { path: import_path.default.resolve(process.cwd(), options.saveHar), mode: "minimal" };
|
407
|
+
if (options.saveHarGlob)
|
408
|
+
contextOptions.recordHar.urlFilter = options.saveHarGlob;
|
409
|
+
contextOptions.serviceWorkers = "block";
|
410
|
+
}
|
411
|
+
let browser;
|
412
|
+
let context;
|
413
|
+
if (options.userDataDir) {
|
414
|
+
context = await browserType.launchPersistentContext(options.userDataDir, { ...launchOptions, ...contextOptions });
|
415
|
+
browser = context.browser();
|
416
|
+
} else {
|
417
|
+
browser = await browserType.launch(launchOptions);
|
418
|
+
context = await browser.newContext(contextOptions);
|
419
|
+
}
|
420
|
+
let closingBrowser = false;
|
421
|
+
async function closeBrowser() {
|
422
|
+
if (closingBrowser)
|
423
|
+
return;
|
424
|
+
closingBrowser = true;
|
425
|
+
if (options.saveStorage)
|
426
|
+
await context.storageState({ path: options.saveStorage }).catch((e) => null);
|
427
|
+
if (options.saveHar)
|
428
|
+
await context.close();
|
429
|
+
await browser.close();
|
430
|
+
}
|
431
|
+
context.on("page", (page) => {
|
432
|
+
page.on("dialog", () => {
|
433
|
+
});
|
434
|
+
page.on("close", () => {
|
435
|
+
const hasPage = browser.contexts().some((context2) => context2.pages().length > 0);
|
436
|
+
if (hasPage)
|
437
|
+
return;
|
438
|
+
closeBrowser().catch(() => {
|
439
|
+
});
|
440
|
+
});
|
441
|
+
});
|
442
|
+
process.on("SIGINT", async () => {
|
443
|
+
await closeBrowser();
|
444
|
+
(0, import_utils.gracefullyProcessExitDoNotHang)(130);
|
445
|
+
});
|
446
|
+
const timeout = options.timeout ? parseInt(options.timeout, 10) : 0;
|
447
|
+
context.setDefaultTimeout(timeout);
|
448
|
+
context.setDefaultNavigationTimeout(timeout);
|
449
|
+
delete launchOptions.headless;
|
450
|
+
delete launchOptions.executablePath;
|
451
|
+
delete launchOptions.handleSIGINT;
|
452
|
+
delete contextOptions.deviceScaleFactor;
|
453
|
+
return { browser, browserName: browserType.name(), context, contextOptions, launchOptions, closeBrowser };
|
454
|
+
}
|
455
|
+
async function openPage(context, url) {
|
456
|
+
let page = context.pages()[0];
|
457
|
+
if (!page)
|
458
|
+
page = await context.newPage();
|
459
|
+
if (url) {
|
460
|
+
if (import_fs.default.existsSync(url))
|
461
|
+
url = "file://" + import_path.default.resolve(url);
|
462
|
+
else if (!url.startsWith("http") && !url.startsWith("file://") && !url.startsWith("about:") && !url.startsWith("data:"))
|
463
|
+
url = "http://" + url;
|
464
|
+
await page.goto(url);
|
465
|
+
}
|
466
|
+
return page;
|
467
|
+
}
|
468
|
+
async function open(options, url) {
|
469
|
+
const { context } = await launchContext(options, { headless: !!process.env.PWTEST_CLI_HEADLESS, executablePath: process.env.PWTEST_CLI_EXECUTABLE_PATH });
|
470
|
+
await openPage(context, url);
|
471
|
+
}
|
472
|
+
async function codegen(options, url) {
|
473
|
+
const { target: language, output: outputFile, testIdAttribute: testIdAttributeName } = options;
|
474
|
+
const tracesDir = import_path.default.join(import_os.default.tmpdir(), `playwright-recorder-trace-${Date.now()}`);
|
475
|
+
const { context, browser, launchOptions, contextOptions, closeBrowser } = await launchContext(options, {
|
476
|
+
headless: !!process.env.PWTEST_CLI_HEADLESS,
|
477
|
+
executablePath: process.env.PWTEST_CLI_EXECUTABLE_PATH,
|
478
|
+
tracesDir
|
479
|
+
});
|
480
|
+
const donePromise = new import_utils.ManualPromise();
|
481
|
+
maybeSetupTestHooks(browser, closeBrowser, donePromise);
|
482
|
+
import_utilsBundle.dotenv.config({ path: "playwright.env" });
|
483
|
+
await context._enableRecorder({
|
484
|
+
language,
|
485
|
+
launchOptions,
|
486
|
+
contextOptions,
|
487
|
+
device: options.device,
|
488
|
+
saveStorage: options.saveStorage,
|
489
|
+
mode: "recording",
|
490
|
+
testIdAttributeName,
|
491
|
+
outputFile: outputFile ? import_path.default.resolve(outputFile) : void 0,
|
492
|
+
handleSIGINT: false
|
493
|
+
});
|
494
|
+
await openPage(context, url);
|
495
|
+
donePromise.resolve();
|
496
|
+
}
|
497
|
+
async function maybeSetupTestHooks(browser, closeBrowser, donePromise) {
|
498
|
+
if (!process.env.PWTEST_CLI_IS_UNDER_TEST)
|
499
|
+
return;
|
500
|
+
const logs = [];
|
501
|
+
require("playwright-core/lib/utilsBundle").debug.log = (...args) => {
|
502
|
+
const line = require("util").format(...args) + "\n";
|
503
|
+
logs.push(line);
|
504
|
+
process.stderr.write(line);
|
505
|
+
};
|
506
|
+
browser.on("disconnected", () => {
|
507
|
+
const hasCrashLine = logs.some((line) => line.includes("process did exit:") && !line.includes("process did exit: exitCode=0, signal=null"));
|
508
|
+
if (hasCrashLine) {
|
509
|
+
process.stderr.write("Detected browser crash.\n");
|
510
|
+
(0, import_utils.gracefullyProcessExitDoNotHang)(1);
|
511
|
+
}
|
512
|
+
});
|
513
|
+
const close = async () => {
|
514
|
+
await donePromise;
|
515
|
+
await closeBrowser();
|
516
|
+
};
|
517
|
+
if (process.env.PWTEST_CLI_EXIT_AFTER_TIMEOUT) {
|
518
|
+
setTimeout(close, +process.env.PWTEST_CLI_EXIT_AFTER_TIMEOUT);
|
519
|
+
return;
|
520
|
+
}
|
521
|
+
let stdin = "";
|
522
|
+
process.stdin.on("data", (data) => {
|
523
|
+
stdin += data.toString();
|
524
|
+
if (stdin.startsWith("exit")) {
|
525
|
+
process.stdin.destroy();
|
526
|
+
close();
|
527
|
+
}
|
528
|
+
});
|
529
|
+
}
|
530
|
+
async function waitForPage(page, captureOptions) {
|
531
|
+
if (captureOptions.waitForSelector) {
|
532
|
+
console.log(`Waiting for selector ${captureOptions.waitForSelector}...`);
|
533
|
+
await page.waitForSelector(captureOptions.waitForSelector);
|
534
|
+
}
|
535
|
+
if (captureOptions.waitForTimeout) {
|
536
|
+
console.log(`Waiting for timeout ${captureOptions.waitForTimeout}...`);
|
537
|
+
await page.waitForTimeout(parseInt(captureOptions.waitForTimeout, 10));
|
538
|
+
}
|
539
|
+
}
|
540
|
+
async function screenshot(options, captureOptions, url, path2) {
|
541
|
+
const { context } = await launchContext(options, { headless: true });
|
542
|
+
console.log("Navigating to " + url);
|
543
|
+
const page = await openPage(context, url);
|
544
|
+
await waitForPage(page, captureOptions);
|
545
|
+
console.log("Capturing screenshot into " + path2);
|
546
|
+
await page.screenshot({ path: path2, fullPage: !!captureOptions.fullPage });
|
547
|
+
await page.close();
|
548
|
+
}
|
549
|
+
async function pdf(options, captureOptions, url, path2) {
|
550
|
+
if (options.browser !== "chromium")
|
551
|
+
throw new Error("PDF creation is only working with Chromium");
|
552
|
+
const { context } = await launchContext({ ...options, browser: "chromium" }, { headless: true });
|
553
|
+
console.log("Navigating to " + url);
|
554
|
+
const page = await openPage(context, url);
|
555
|
+
await waitForPage(page, captureOptions);
|
556
|
+
console.log("Saving as pdf into " + path2);
|
557
|
+
await page.pdf({ path: path2, format: captureOptions.paperFormat });
|
558
|
+
await page.close();
|
559
|
+
}
|
560
|
+
function lookupBrowserType(options) {
|
561
|
+
let name = options.browser;
|
562
|
+
if (options.device) {
|
563
|
+
const device = playwright.devices[options.device];
|
564
|
+
name = device.defaultBrowserType;
|
565
|
+
}
|
566
|
+
let browserType;
|
567
|
+
switch (name) {
|
568
|
+
case "chromium":
|
569
|
+
browserType = playwright.chromium;
|
570
|
+
break;
|
571
|
+
case "webkit":
|
572
|
+
browserType = playwright.webkit;
|
573
|
+
break;
|
574
|
+
case "firefox":
|
575
|
+
browserType = playwright.firefox;
|
576
|
+
break;
|
577
|
+
case "cr":
|
578
|
+
browserType = playwright.chromium;
|
579
|
+
break;
|
580
|
+
case "wk":
|
581
|
+
browserType = playwright.webkit;
|
582
|
+
break;
|
583
|
+
case "ff":
|
584
|
+
browserType = playwright.firefox;
|
585
|
+
break;
|
586
|
+
}
|
587
|
+
if (browserType)
|
588
|
+
return browserType;
|
589
|
+
import_utilsBundle.program.help();
|
590
|
+
}
|
591
|
+
function validateOptions(options) {
|
592
|
+
if (options.device && !(options.device in playwright.devices)) {
|
593
|
+
const lines = [`Device descriptor not found: '${options.device}', available devices are:`];
|
594
|
+
for (const name in playwright.devices)
|
595
|
+
lines.push(` "${name}"`);
|
596
|
+
throw new Error(lines.join("\n"));
|
597
|
+
}
|
598
|
+
if (options.colorScheme && !["light", "dark"].includes(options.colorScheme))
|
599
|
+
throw new Error('Invalid color scheme, should be one of "light", "dark"');
|
600
|
+
}
|
601
|
+
function logErrorAndExit(e) {
|
602
|
+
if (process.env.PWDEBUGIMPL)
|
603
|
+
console.error(e);
|
604
|
+
else
|
605
|
+
console.error(e.name + ": " + e.message);
|
606
|
+
(0, import_utils.gracefullyProcessExitDoNotHang)(1);
|
607
|
+
}
|
608
|
+
function codegenId() {
|
609
|
+
return process.env.PW_LANG_NAME || "playwright-test";
|
610
|
+
}
|
611
|
+
function commandWithOpenOptions(command, description, options) {
|
612
|
+
let result = import_utilsBundle.program.command(command).description(description);
|
613
|
+
for (const option of options)
|
614
|
+
result = result.option(option[0], ...option.slice(1));
|
615
|
+
return result.option("-b, --browser <browserType>", "browser to use, one of cr, chromium, ff, firefox, wk, webkit", "chromium").option("--block-service-workers", "block service workers").option("--channel <channel>", 'Chromium distribution channel, "chrome", "chrome-beta", "msedge-dev", etc').option("--color-scheme <scheme>", 'emulate preferred color scheme, "light" or "dark"').option("--device <deviceName>", 'emulate device, for example "iPhone 11"').option("--geolocation <coordinates>", 'specify geolocation coordinates, for example "37.819722,-122.478611"').option("--ignore-https-errors", "ignore https errors").option("--load-storage <filename>", "load context storage state from the file, previously saved with --save-storage").option("--lang <language>", 'specify language / locale, for example "en-GB"').option("--proxy-server <proxy>", 'specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080"').option("--proxy-bypass <bypass>", 'comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com"').option("--save-har <filename>", "save HAR file with all network activity at the end").option("--save-har-glob <glob pattern>", "filter entries in the HAR by matching url against this glob pattern").option("--save-storage <filename>", "save context storage state at the end, for later use with --load-storage").option("--timezone <time zone>", 'time zone to emulate, for example "Europe/Rome"').option("--timeout <timeout>", "timeout for Playwright actions in milliseconds, no timeout by default").option("--user-agent <ua string>", "specify user agent string").option("--user-data-dir <directory>", "use the specified user data directory instead of a new context").option("--viewport-size <size>", 'specify browser viewport size in pixels, for example "1280, 720"');
|
616
|
+
}
|
617
|
+
function buildBasePlaywrightCLICommand(cliTargetLang) {
|
618
|
+
switch (cliTargetLang) {
|
619
|
+
case "python":
|
620
|
+
return `playwright`;
|
621
|
+
case "java":
|
622
|
+
return `mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="...options.."`;
|
623
|
+
case "csharp":
|
624
|
+
return `pwsh bin/Debug/netX/playwright.ps1`;
|
625
|
+
default: {
|
626
|
+
const packageManagerCommand = (0, import_utils2.getPackageManagerExecCommand)();
|
627
|
+
return `${packageManagerCommand} playwright`;
|
628
|
+
}
|
629
|
+
}
|
630
|
+
}
|
631
|
+
// Annotate the CommonJS export names for ESM import in node:
|
632
|
+
0 && (module.exports = {
|
633
|
+
program
|
634
|
+
});
|