@checkly/playwright-core 1.51.17-beta.1 → 1.54.2-beta.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/ThirdPartyNotices.txt +65 -123
- package/browsers.json +16 -14
- package/index.js +1 -1
- package/lib/androidServerImpl.js +47 -50
- package/lib/browserServerImpl.js +89 -69
- package/lib/checkly/escapeRegExp.js +23 -27
- package/lib/checkly/fetch.js +64 -46
- package/lib/checkly/secretsFilter.js +49 -36
- package/lib/cli/driver.js +71 -69
- package/lib/cli/program.js +400 -359
- package/lib/cli/programWithTestStub.js +51 -45
- package/lib/client/accessibility.js +31 -32
- package/lib/client/android.js +151 -242
- package/lib/client/api.js +135 -283
- package/lib/client/artifact.js +39 -36
- package/lib/client/browser.js +96 -71
- package/lib/client/browserContext.js +314 -345
- package/lib/client/browserType.js +103 -127
- package/lib/client/cdpSession.js +29 -31
- package/lib/client/channelOwner.js +90 -113
- package/lib/client/clientHelper.js +48 -39
- package/lib/client/clientInstrumentation.js +40 -37
- package/lib/client/clientStackTrace.js +41 -37
- package/lib/client/clock.js +36 -36
- package/lib/client/connection.js +188 -214
- package/lib/client/consoleMessage.js +31 -28
- package/lib/client/coverage.js +25 -22
- package/lib/client/dialog.js +30 -31
- package/lib/client/download.js +25 -25
- package/lib/client/electron.js +80 -77
- package/lib/client/elementHandle.js +120 -159
- package/lib/client/errors.js +53 -53
- package/lib/client/eventEmitter.js +124 -121
- package/lib/client/events.js +72 -68
- package/lib/client/fetch.js +166 -190
- package/lib/client/fileChooser.js +25 -24
- package/lib/client/fileUtils.js +31 -28
- package/lib/client/frame.js +207 -306
- package/lib/client/harRouter.js +42 -52
- package/lib/client/input.js +42 -69
- package/lib/client/jsHandle.js +54 -69
- package/lib/client/jsonPipe.js +27 -23
- package/lib/client/localUtils.js +29 -29
- package/lib/client/locator.js +145 -237
- package/lib/client/network.js +282 -307
- package/lib/client/page.js +269 -318
- package/lib/client/platform.js +46 -43
- package/lib/client/playwright.js +51 -76
- package/lib/client/selectors.js +45 -63
- package/lib/client/stream.js +29 -25
- package/lib/client/timeoutSettings.js +55 -41
- package/lib/client/tracing.js +49 -96
- package/lib/client/types.js +26 -22
- package/lib/client/video.js +35 -27
- package/lib/client/waiter.js +69 -88
- package/lib/client/webError.js +25 -23
- package/lib/client/webSocket.js +43 -56
- package/lib/client/worker.js +48 -56
- package/lib/client/writableStream.js +27 -23
- package/lib/generated/bindingsControllerSource.js +28 -0
- package/lib/generated/clockSource.js +26 -6
- package/lib/generated/consoleApiSource.js +26 -6
- package/lib/generated/injectedScriptSource.js +26 -6
- package/lib/generated/pollingRecorderSource.js +26 -6
- package/lib/generated/storageScriptSource.js +28 -0
- package/lib/generated/utilityScriptSource.js +26 -6
- package/lib/generated/webSocketMockSource.js +333 -5
- package/lib/inProcessFactory.js +51 -53
- package/lib/inprocess.js +2 -19
- package/lib/outofprocess.js +51 -46
- package/lib/protocol/serializers.js +153 -134
- package/lib/protocol/validator.js +2807 -2739
- package/lib/protocol/validatorPrimitives.js +114 -73
- package/lib/remote/playwrightConnection.js +88 -242
- package/lib/remote/playwrightServer.js +305 -92
- package/lib/server/accessibility.js +44 -37
- package/lib/server/android/android.js +251 -241
- package/lib/server/android/backendAdb.js +87 -82
- package/lib/server/artifact.js +78 -55
- package/lib/server/bidi/bidiBrowser.js +297 -158
- package/lib/server/bidi/bidiChromium.js +119 -89
- package/lib/server/bidi/bidiConnection.js +66 -83
- package/lib/server/bidi/bidiExecutionContext.js +129 -113
- package/lib/server/bidi/bidiFirefox.js +86 -76
- package/lib/server/bidi/bidiInput.js +106 -117
- package/lib/server/bidi/bidiNetworkManager.js +142 -159
- package/lib/server/bidi/bidiOverCdp.js +57 -58
- package/lib/server/bidi/bidiPage.js +260 -260
- package/lib/server/bidi/bidiPdf.js +52 -86
- package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
- package/lib/server/bidi/third_party/bidiDeserializer.js +55 -50
- package/lib/server/bidi/third_party/bidiKeyboard.js +236 -220
- package/lib/server/bidi/third_party/bidiProtocol.js +22 -137
- package/lib/server/bidi/third_party/bidiProtocolCore.js +152 -0
- package/lib/server/bidi/third_party/bidiProtocolPermissions.js +42 -0
- package/lib/server/bidi/third_party/bidiSerializer.js +67 -63
- package/lib/server/bidi/third_party/firefoxPrefs.js +141 -119
- package/lib/server/browser.js +93 -95
- package/lib/server/browserContext.js +419 -429
- package/lib/server/browserType.js +186 -216
- package/lib/server/callLog.js +47 -44
- package/lib/server/chromium/chromium.js +235 -203
- package/lib/server/chromium/chromiumSwitches.js +100 -67
- package/lib/server/chromium/crAccessibility.js +157 -131
- package/lib/server/chromium/crBrowser.js +310 -292
- package/lib/server/chromium/crConnection.js +95 -121
- package/lib/server/chromium/crCoverage.js +121 -131
- package/lib/server/chromium/crDevTools.js +60 -51
- package/lib/server/chromium/crDragDrop.js +68 -84
- package/lib/server/chromium/crExecutionContext.js +89 -83
- package/lib/server/chromium/crInput.js +118 -113
- package/lib/server/chromium/crNetworkManager.js +274 -375
- package/lib/server/chromium/crPage.js +536 -593
- package/lib/server/chromium/crPdf.js +54 -86
- package/lib/server/chromium/crProtocolHelper.js +92 -80
- package/lib/server/chromium/crServiceWorker.js +84 -73
- package/lib/server/chromium/defaultFontFamilies.js +152 -135
- package/lib/server/chromium/protocol.d.js +16 -0
- package/lib/server/chromium/videoRecorder.js +66 -99
- package/lib/server/clock.js +107 -83
- package/lib/server/codegen/csharp.js +192 -162
- package/lib/server/codegen/java.js +156 -129
- package/lib/server/codegen/javascript.js +163 -148
- package/lib/server/codegen/jsonl.js +32 -28
- package/lib/server/codegen/language.js +75 -52
- package/lib/server/codegen/languages.js +65 -27
- package/lib/server/codegen/python.js +141 -126
- package/lib/server/codegen/types.js +15 -4
- package/lib/server/console.js +28 -32
- package/lib/server/cookieStore.js +108 -86
- package/lib/server/debugController.js +147 -151
- package/lib/server/debugger.js +86 -78
- package/lib/server/deviceDescriptors.js +37 -24
- package/lib/server/deviceDescriptorsSource.json +238 -128
- package/lib/server/dialog.js +84 -39
- package/lib/server/dispatchers/androidDispatcher.js +257 -148
- package/lib/server/dispatchers/artifactDispatcher.js +79 -79
- package/lib/server/dispatchers/browserContextDispatcher.js +289 -259
- package/lib/server/dispatchers/browserDispatcher.js +96 -148
- package/lib/server/dispatchers/browserTypeDispatcher.js +50 -41
- package/lib/server/dispatchers/cdpSessionDispatcher.js +35 -39
- package/lib/server/dispatchers/debugControllerDispatcher.js +65 -83
- package/lib/server/dispatchers/dialogDispatcher.js +34 -31
- package/lib/server/dispatchers/dispatcher.js +208 -248
- package/lib/server/dispatchers/electronDispatcher.js +66 -70
- package/lib/server/dispatchers/elementHandlerDispatcher.js +164 -216
- package/lib/server/dispatchers/frameDispatcher.js +211 -272
- package/lib/server/dispatchers/jsHandleDispatcher.js +63 -75
- package/lib/server/dispatchers/jsonPipeDispatcher.js +37 -38
- package/lib/server/dispatchers/localUtilsDispatcher.js +121 -119
- package/lib/server/dispatchers/networkDispatchers.js +117 -128
- package/lib/server/dispatchers/pageDispatcher.js +256 -248
- package/lib/server/dispatchers/playwrightDispatcher.js +92 -87
- package/lib/server/dispatchers/streamDispatcher.js +52 -48
- package/lib/server/dispatchers/tracingDispatcher.js +47 -52
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +126 -150
- package/lib/server/dispatchers/writableStreamDispatcher.js +65 -43
- package/lib/server/dom.js +485 -582
- package/lib/server/download.js +47 -37
- package/lib/server/electron/electron.js +216 -243
- package/lib/server/electron/loader.js +9 -37
- package/lib/server/errors.js +47 -46
- package/lib/server/fetch.js +317 -360
- package/lib/server/fileChooser.js +25 -24
- package/lib/server/fileUploadUtils.js +66 -60
- package/lib/server/firefox/ffAccessibility.js +153 -131
- package/lib/server/firefox/ffBrowser.js +268 -305
- package/lib/server/firefox/ffConnection.js +63 -84
- package/lib/server/firefox/ffExecutionContext.js +92 -73
- package/lib/server/firefox/ffInput.js +82 -84
- package/lib/server/firefox/ffNetworkManager.js +137 -114
- package/lib/server/firefox/ffPage.js +261 -293
- package/lib/server/firefox/firefox.js +80 -72
- package/lib/server/firefox/protocol.d.js +16 -0
- package/lib/server/formData.js +107 -35
- package/lib/server/frameSelectors.js +98 -114
- package/lib/server/frames.js +845 -1055
- package/lib/server/har/harRecorder.js +85 -77
- package/lib/server/har/harTracer.js +290 -223
- package/lib/server/harBackend.js +80 -80
- package/lib/server/helper.js +55 -59
- package/lib/server/index.js +59 -99
- package/lib/server/input.js +151 -189
- package/lib/server/instrumentation.js +57 -44
- package/lib/server/javascript.js +133 -134
- package/lib/server/launchApp.js +113 -75
- package/lib/server/localUtils.js +150 -142
- package/lib/server/macEditingCommands.js +141 -137
- package/lib/server/network.js +299 -303
- package/lib/server/page.js +513 -544
- package/lib/server/pipeTransport.js +49 -45
- package/lib/server/playwright.js +58 -67
- package/lib/server/progress.js +137 -68
- package/lib/server/protocolError.js +34 -31
- package/lib/server/recorder/chat.js +70 -86
- package/lib/server/recorder/recorderApp.js +341 -176
- package/lib/server/recorder/recorderInTraceViewer.js +65 -94
- package/lib/server/recorder/recorderRunner.js +93 -116
- package/lib/server/recorder/recorderSignalProcessor.js +83 -0
- package/lib/server/recorder/recorderUtils.js +104 -47
- package/lib/server/recorder/throttledFile.js +42 -30
- package/lib/server/recorder.js +395 -275
- package/lib/server/registry/browserFetcher.js +106 -101
- package/lib/server/registry/dependencies.js +245 -196
- package/lib/server/registry/index.js +930 -803
- package/lib/server/registry/nativeDeps.js +1073 -464
- package/lib/server/registry/oopDownloadBrowserMain.js +57 -75
- package/lib/server/screenshotter.js +160 -191
- package/lib/server/selectors.js +90 -51
- package/lib/server/socksClientCertificatesInterceptor.js +171 -186
- package/lib/server/socksInterceptor.js +62 -70
- package/lib/server/trace/recorder/snapshotter.js +76 -102
- package/lib/server/trace/recorder/snapshotterInjected.js +238 -217
- package/lib/server/trace/recorder/tracing.js +354 -362
- package/lib/server/trace/test/inMemorySnapshotter.js +46 -52
- package/lib/server/trace/viewer/traceViewer.js +160 -147
- package/lib/server/transport.js +119 -134
- package/lib/server/types.js +26 -22
- package/lib/server/usKeyboardLayout.js +135 -545
- package/lib/server/utils/ascii.js +39 -26
- package/lib/server/utils/comparators.js +105 -103
- package/lib/server/utils/crypto.js +157 -112
- package/lib/server/utils/debug.js +36 -32
- package/lib/server/utils/debugLogger.js +77 -48
- package/lib/server/utils/env.js +52 -37
- package/lib/server/utils/eventsHelper.js +29 -28
- package/lib/server/utils/expectUtils.js +31 -26
- package/lib/server/utils/fileUtils.js +123 -136
- package/lib/server/utils/happyEyeballs.js +141 -126
- package/lib/server/utils/hostPlatform.js +84 -120
- package/lib/server/utils/httpServer.js +106 -121
- package/lib/server/utils/image_tools/colorUtils.js +42 -51
- package/lib/server/utils/image_tools/compare.js +44 -43
- package/lib/server/utils/image_tools/imageChannel.js +38 -30
- package/lib/server/utils/image_tools/stats.js +40 -40
- package/lib/server/utils/linuxUtils.js +50 -37
- package/lib/server/utils/network.js +152 -96
- package/lib/server/utils/nodePlatform.js +87 -79
- package/lib/server/utils/pipeTransport.js +44 -42
- package/lib/server/utils/processLauncher.js +111 -121
- package/lib/server/utils/profiler.js +52 -39
- package/lib/server/utils/socksProxy.js +280 -339
- package/lib/server/utils/spawnAsync.js +37 -41
- package/lib/server/utils/task.js +31 -38
- package/lib/server/utils/userAgent.js +73 -66
- package/lib/server/utils/wsServer.js +68 -75
- package/lib/server/utils/zipFile.js +36 -37
- package/lib/server/utils/zones.js +37 -34
- package/lib/server/webkit/protocol.d.js +16 -0
- package/lib/server/webkit/webkit.js +77 -61
- package/lib/server/webkit/wkAccessibility.js +161 -118
- package/lib/server/webkit/wkBrowser.js +193 -184
- package/lib/server/webkit/wkConnection.js +59 -83
- package/lib/server/webkit/wkExecutionContext.js +85 -70
- package/lib/server/webkit/wkInput.js +97 -95
- package/lib/server/webkit/wkInterceptableRequest.js +102 -95
- package/lib/server/webkit/wkPage.js +568 -667
- package/lib/server/webkit/wkProvisionalPage.js +45 -56
- package/lib/server/webkit/wkWorkers.js +79 -79
- package/lib/utils/expectUtils.js +31 -26
- package/lib/utils/isomorphic/ariaSnapshot.js +149 -152
- package/lib/utils/isomorphic/assert.js +28 -22
- package/lib/utils/isomorphic/colors.js +66 -59
- package/lib/utils/isomorphic/cssParser.js +120 -125
- package/lib/utils/isomorphic/cssTokenizer.js +436 -364
- package/lib/utils/isomorphic/headers.js +38 -37
- package/lib/utils/isomorphic/locatorGenerators.js +358 -357
- package/lib/utils/isomorphic/locatorParser.js +96 -105
- package/lib/utils/isomorphic/locatorUtils.js +63 -44
- package/lib/utils/isomorphic/manualPromise.js +46 -39
- package/lib/utils/isomorphic/mimeType.js +447 -25
- package/lib/utils/isomorphic/multimap.js +34 -27
- package/lib/utils/isomorphic/protocolFormatter.js +68 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +321 -0
- package/lib/utils/isomorphic/recorderUtils.js +140 -181
- package/lib/utils/isomorphic/rtti.js +35 -33
- package/lib/utils/isomorphic/selectorParser.js +182 -193
- package/lib/utils/isomorphic/semaphore.js +27 -24
- package/lib/utils/isomorphic/stackTrace.js +87 -98
- package/lib/utils/isomorphic/stringUtils.js +98 -112
- package/lib/utils/isomorphic/time.js +46 -22
- package/lib/utils/isomorphic/timeoutRunner.js +53 -53
- package/lib/utils/isomorphic/traceUtils.js +37 -41
- package/lib/utils/isomorphic/types.js +15 -4
- package/lib/utils/isomorphic/urlMatch.js +113 -67
- package/lib/utils/isomorphic/utilityScriptSerializers.js +251 -0
- package/lib/utils.js +101 -443
- package/lib/utilsBundle.js +101 -52
- package/lib/utilsBundleImpl/index.js +160 -150
- package/lib/zipBundle.js +32 -23
- package/lib/zipBundleImpl.js +4 -4
- package/package.json +1 -1
- package/types/protocol.d.ts +1267 -1057
- package/types/types.d.ts +131 -29
- package/lib/common/socksProxy.js +0 -569
- package/lib/common/timeoutSettings.js +0 -73
- package/lib/common/types.js +0 -5
- package/lib/image_tools/colorUtils.js +0 -98
- package/lib/image_tools/compare.js +0 -108
- package/lib/image_tools/imageChannel.js +0 -70
- package/lib/image_tools/stats.js +0 -102
- package/lib/protocol/debug.js +0 -27
- package/lib/protocol/transport.js +0 -82
- package/lib/server/dispatchers/selectorsDispatcher.js +0 -36
- package/lib/server/isomorphic/utilityScriptSerializers.js +0 -229
- package/lib/server/recorder/contextRecorder.js +0 -290
- package/lib/server/recorder/recorderCollection.js +0 -104
- package/lib/server/recorder/recorderFrontend.js +0 -5
- package/lib/server/storageScript.js +0 -160
- package/lib/server/timeoutSettings.js +0 -74
- package/lib/third_party/diff_match_patch.js +0 -2222
- package/lib/utils/ascii.js +0 -31
- package/lib/utils/comparators.js +0 -171
- package/lib/utils/crypto.js +0 -174
- package/lib/utils/debug.js +0 -46
- package/lib/utils/debugLogger.js +0 -91
- package/lib/utils/env.js +0 -49
- package/lib/utils/eventsHelper.js +0 -38
- package/lib/utils/fileUtils.js +0 -205
- package/lib/utils/happy-eyeballs.js +0 -210
- package/lib/utils/headers.js +0 -52
- package/lib/utils/hostPlatform.js +0 -133
- package/lib/utils/httpServer.js +0 -237
- package/lib/utils/index.js +0 -368
- package/lib/utils/linuxUtils.js +0 -78
- package/lib/utils/manualPromise.js +0 -109
- package/lib/utils/multimap.js +0 -75
- package/lib/utils/network.js +0 -160
- package/lib/utils/processLauncher.js +0 -248
- package/lib/utils/profiler.js +0 -53
- package/lib/utils/rtti.js +0 -44
- package/lib/utils/semaphore.js +0 -51
- package/lib/utils/spawnAsync.js +0 -45
- package/lib/utils/stackTrace.js +0 -121
- package/lib/utils/task.js +0 -58
- package/lib/utils/time.js +0 -37
- package/lib/utils/timeoutRunner.js +0 -66
- package/lib/utils/traceUtils.js +0 -44
- package/lib/utils/userAgent.js +0 -105
- package/lib/utils/wsServer.js +0 -127
- package/lib/utils/zipFile.js +0 -75
- package/lib/utils/zones.js +0 -62
- package/lib/vite/htmlReport/index.html +0 -69
- package/lib/vite/recorder/assets/codeMirrorModule-DrMbgOIo.js +0 -16684
- package/lib/vite/recorder/assets/codeMirrorModule-DuST8d_k.css +0 -344
- package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/lib/vite/recorder/assets/index-5NM3V7eb.css +0 -2524
- package/lib/vite/recorder/assets/index-CT-scFHn.js +0 -16848
- package/lib/vite/recorder/index.html +0 -29
- package/lib/vite/recorder/playwright-logo.svg +0 -9
- package/lib/vite/traceViewer/assets/codeMirrorModule-CB-2okZ8.js +0 -16684
- package/lib/vite/traceViewer/assets/defaultSettingsView-CBiB4avC.js +0 -217
- package/lib/vite/traceViewer/assets/inspectorTab-CwgfffWb.js +0 -25143
- package/lib/vite/traceViewer/assets/workbench-CWZselvp.js +0 -2470
- package/lib/vite/traceViewer/assets/xtermModule-Es_gt_u7.js +0 -5994
- package/lib/vite/traceViewer/codeMirrorModule.DuST8d_k.css +0 -344
- package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/lib/vite/traceViewer/defaultSettingsView.Dp3b_92q.css +0 -41
- package/lib/vite/traceViewer/embedded.BeldSa2G.css +0 -68
- package/lib/vite/traceViewer/embedded.gzudoghF.js +0 -106
- package/lib/vite/traceViewer/embedded.html +0 -18
- package/lib/vite/traceViewer/index.DilotR1h.js +0 -314
- package/lib/vite/traceViewer/index.QewjJ85u.css +0 -131
- package/lib/vite/traceViewer/index.html +0 -47
- package/lib/vite/traceViewer/inspectorTab.DnGm18kV.css +0 -3178
- package/lib/vite/traceViewer/playwright-logo.svg +0 -9
- package/lib/vite/traceViewer/recorder.DLgqV9db.css +0 -15
- package/lib/vite/traceViewer/recorder.DVrkq3Um.js +0 -551
- package/lib/vite/traceViewer/recorder.html +0 -17
- package/lib/vite/traceViewer/snapshot.html +0 -21
- package/lib/vite/traceViewer/sw.bundle.js +0 -3
- package/lib/vite/traceViewer/uiMode.C9_OcpPU.js +0 -1756
- package/lib/vite/traceViewer/uiMode.c5ORgcrX.css +0 -1424
- package/lib/vite/traceViewer/uiMode.html +0 -21
- package/lib/vite/traceViewer/workbench.xUZSA8PY.css +0 -787
- package/lib/vite/traceViewer/xtermModule.EsaqrrTX.css +0 -209
package/lib/cli/program.js
CHANGED
|
@@ -1,134 +1,235 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Object.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 });
|
|
10
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
|
|
11
32
|
});
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* You may obtain a copy of the License at
|
|
31
|
-
*
|
|
32
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
33
|
-
*
|
|
34
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
35
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
36
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
37
|
-
* See the License for the specific language governing permissions and
|
|
38
|
-
* limitations under the License.
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
/* eslint-disable no-console */
|
|
42
|
-
|
|
43
|
-
const packageJSON = require('../../package.json');
|
|
44
|
-
_utilsBundle.program.version('Version ' + (process.env.PW_CLI_DISPLAY_VERSION || packageJSON.version)).name(buildBasePlaywrightCLICommand(process.env.PW_LANG_NAME));
|
|
45
|
-
_utilsBundle.program.command('mark-docker-image [dockerImageNameTemplate]', {
|
|
46
|
-
hidden: true
|
|
47
|
-
}).description('mark docker image').allowUnknownOption(true).action(function (dockerImageNameTemplate) {
|
|
48
|
-
(0, _utils.assert)(dockerImageNameTemplate, 'dockerImageNameTemplate is required');
|
|
49
|
-
(0, _server.writeDockerVersion)(dockerImageNameTemplate).catch(logErrorAndExit);
|
|
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);
|
|
50
51
|
});
|
|
51
|
-
commandWithOpenOptions(
|
|
52
|
-
open(options, url
|
|
53
|
-
}).addHelpText(
|
|
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", `
|
|
54
55
|
Examples:
|
|
55
56
|
|
|
56
57
|
$ open
|
|
57
58
|
$ open -b webkit https://example.com`);
|
|
58
|
-
commandWithOpenOptions(
|
|
59
|
-
codegen
|
|
60
|
-
|
|
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(function(url, options) {
|
|
68
|
+
codegen(options, url).catch((error) => {
|
|
69
|
+
if (process.env.PWTEST_CLI_AUTO_EXIT_WHEN) {
|
|
70
|
+
} else {
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}).addHelpText("afterAll", `
|
|
61
75
|
Examples:
|
|
62
76
|
|
|
63
77
|
$ codegen
|
|
64
78
|
$ codegen --target=python
|
|
65
79
|
$ codegen -b webkit https://example.com`);
|
|
66
80
|
function suggestedBrowsersToInstall() {
|
|
67
|
-
return
|
|
81
|
+
return import_server.registry.executables().filter((e) => e.installType !== "none" && e.type !== "tool").map((e) => e.name).join(", ");
|
|
68
82
|
}
|
|
69
83
|
function defaultBrowsersToInstall(options) {
|
|
70
|
-
let executables =
|
|
71
|
-
if (options.noShell)
|
|
72
|
-
|
|
84
|
+
let executables = import_server.registry.defaultExecutables();
|
|
85
|
+
if (options.noShell)
|
|
86
|
+
executables = executables.filter((e) => e.name !== "chromium-headless-shell");
|
|
87
|
+
if (options.onlyShell)
|
|
88
|
+
executables = executables.filter((e) => e.name !== "chromium");
|
|
73
89
|
return executables;
|
|
74
90
|
}
|
|
75
91
|
function checkBrowsersToInstall(args, options) {
|
|
76
|
-
if (options.noShell && options.onlyShell)
|
|
92
|
+
if (options.noShell && options.onlyShell)
|
|
93
|
+
throw new Error(`Only one of --no-shell and --only-shell can be specified`);
|
|
77
94
|
const faultyArguments = [];
|
|
78
95
|
const executables = [];
|
|
79
|
-
const handleArgument = arg => {
|
|
80
|
-
const executable =
|
|
81
|
-
if (!executable || executable.installType ===
|
|
82
|
-
|
|
96
|
+
const handleArgument = (arg) => {
|
|
97
|
+
const executable = import_server.registry.findExecutable(arg);
|
|
98
|
+
if (!executable || executable.installType === "none")
|
|
99
|
+
faultyArguments.push(arg);
|
|
100
|
+
else
|
|
101
|
+
executables.push(executable);
|
|
102
|
+
if (executable?.browserName === "chromium")
|
|
103
|
+
executables.push(import_server.registry.findExecutable("ffmpeg"));
|
|
83
104
|
};
|
|
84
105
|
for (const arg of args) {
|
|
85
|
-
if (arg ===
|
|
86
|
-
if (!options.onlyShell)
|
|
87
|
-
|
|
106
|
+
if (arg === "chromium") {
|
|
107
|
+
if (!options.onlyShell)
|
|
108
|
+
handleArgument("chromium");
|
|
109
|
+
if (!options.noShell)
|
|
110
|
+
handleArgument("chromium-headless-shell");
|
|
88
111
|
} else {
|
|
89
112
|
handleArgument(arg);
|
|
90
113
|
}
|
|
91
114
|
}
|
|
92
|
-
if (process.platform ===
|
|
93
|
-
|
|
115
|
+
if (process.platform === "win32")
|
|
116
|
+
executables.push(import_server.registry.findExecutable("winldd"));
|
|
117
|
+
if (faultyArguments.length)
|
|
118
|
+
throw new Error(`Invalid installation targets: ${faultyArguments.map((name) => `'${name}'`).join(", ")}. Expecting one of: ${suggestedBrowsersToInstall()}`);
|
|
94
119
|
return executables;
|
|
95
120
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
121
|
+
function printInstalledBrowsers(browsers2) {
|
|
122
|
+
const browserPaths = /* @__PURE__ */ new Set();
|
|
123
|
+
for (const browser of browsers2)
|
|
124
|
+
browserPaths.add(browser.browserPath);
|
|
125
|
+
console.log(` Browsers:`);
|
|
126
|
+
for (const browserPath of [...browserPaths].sort())
|
|
127
|
+
console.log(` ${browserPath}`);
|
|
128
|
+
console.log(` References:`);
|
|
129
|
+
const references = /* @__PURE__ */ new Set();
|
|
130
|
+
for (const browser of browsers2)
|
|
131
|
+
references.add(browser.referenceDir);
|
|
132
|
+
for (const reference of [...references].sort())
|
|
133
|
+
console.log(` ${reference}`);
|
|
134
|
+
}
|
|
135
|
+
function printGroupedByPlaywrightVersion(browsers2) {
|
|
136
|
+
const dirToVersion = /* @__PURE__ */ new Map();
|
|
137
|
+
for (const browser of browsers2) {
|
|
138
|
+
if (dirToVersion.has(browser.referenceDir))
|
|
139
|
+
continue;
|
|
140
|
+
const packageJSON2 = require(import_path.default.join(browser.referenceDir, "package.json"));
|
|
141
|
+
const version = packageJSON2.version;
|
|
142
|
+
dirToVersion.set(browser.referenceDir, version);
|
|
143
|
+
}
|
|
144
|
+
const groupedByPlaywrightMinorVersion = /* @__PURE__ */ new Map();
|
|
145
|
+
for (const browser of browsers2) {
|
|
146
|
+
const version = dirToVersion.get(browser.referenceDir);
|
|
147
|
+
let entries = groupedByPlaywrightMinorVersion.get(version);
|
|
148
|
+
if (!entries) {
|
|
149
|
+
entries = [];
|
|
150
|
+
groupedByPlaywrightMinorVersion.set(version, entries);
|
|
151
|
+
}
|
|
152
|
+
entries.push(browser);
|
|
153
|
+
}
|
|
154
|
+
const sortedVersions = [...groupedByPlaywrightMinorVersion.keys()].sort((a, b) => {
|
|
155
|
+
const aComponents = a.split(".");
|
|
156
|
+
const bComponents = b.split(".");
|
|
157
|
+
const aMajor = parseInt(aComponents[0], 10);
|
|
158
|
+
const bMajor = parseInt(bComponents[0], 10);
|
|
159
|
+
if (aMajor !== bMajor)
|
|
160
|
+
return aMajor - bMajor;
|
|
161
|
+
const aMinor = parseInt(aComponents[1], 10);
|
|
162
|
+
const bMinor = parseInt(bComponents[1], 10);
|
|
163
|
+
if (aMinor !== bMinor)
|
|
164
|
+
return aMinor - bMinor;
|
|
165
|
+
return aComponents.slice(2).join(".").localeCompare(bComponents.slice(2).join("."));
|
|
166
|
+
});
|
|
167
|
+
for (const version of sortedVersions) {
|
|
168
|
+
console.log(`
|
|
169
|
+
Playwright version: ${version}`);
|
|
170
|
+
printInstalledBrowsers(groupedByPlaywrightMinorVersion.get(version));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
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) {
|
|
174
|
+
if (options.shell === false)
|
|
175
|
+
options.noShell = true;
|
|
176
|
+
if ((0, import_utils.isLikelyNpxGlobal)()) {
|
|
177
|
+
console.error((0, import_ascii.wrapInASCIIBox)([
|
|
178
|
+
`WARNING: It looks like you are running 'npx playwright install' without first`,
|
|
179
|
+
`installing your project's dependencies.`,
|
|
180
|
+
``,
|
|
181
|
+
`To avoid unexpected behavior, please install your dependencies first, and`,
|
|
182
|
+
`then run Playwright's install command:`,
|
|
183
|
+
``,
|
|
184
|
+
` npm install`,
|
|
185
|
+
` npx playwright install`,
|
|
186
|
+
``,
|
|
187
|
+
`If your project does not yet depend on Playwright, first install the`,
|
|
188
|
+
`applicable npm package (most commonly @playwright/test), and`,
|
|
189
|
+
`then run Playwright's install command to download the browsers:`,
|
|
190
|
+
``,
|
|
191
|
+
` npm install @playwright/test`,
|
|
192
|
+
` npx playwright install`,
|
|
193
|
+
``
|
|
194
|
+
].join("\n"), 1));
|
|
101
195
|
}
|
|
102
196
|
try {
|
|
103
197
|
const hasNoArguments = !args.length;
|
|
104
198
|
const executables = hasNoArguments ? defaultBrowsersToInstall(options) : checkBrowsersToInstall(args, options);
|
|
105
|
-
if (options.withDeps)
|
|
199
|
+
if (options.withDeps)
|
|
200
|
+
await import_server.registry.installDeps(executables, !!options.dryRun);
|
|
201
|
+
if (options.dryRun && options.list)
|
|
202
|
+
throw new Error(`Only one of --dry-run and --list can be specified`);
|
|
106
203
|
if (options.dryRun) {
|
|
107
204
|
for (const executable of executables) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
console.log(`
|
|
111
|
-
|
|
112
|
-
if ((_executable$downloadU = executable.downloadURLs) !== null && _executable$downloadU !== void 0 && _executable$downloadU.length) {
|
|
205
|
+
const version = executable.browserVersion ? `version ` + executable.browserVersion : "";
|
|
206
|
+
console.log(`browser: ${executable.name}${version ? " " + version : ""}`);
|
|
207
|
+
console.log(` Install location: ${executable.directory ?? "<system>"}`);
|
|
208
|
+
if (executable.downloadURLs?.length) {
|
|
113
209
|
const [url, ...fallbacks] = executable.downloadURLs;
|
|
114
210
|
console.log(` Download url: ${url}`);
|
|
115
|
-
for (let i = 0; i < fallbacks.length; ++i)
|
|
211
|
+
for (let i = 0; i < fallbacks.length; ++i)
|
|
212
|
+
console.log(` Download fallback ${i + 1}: ${fallbacks[i]}`);
|
|
116
213
|
}
|
|
117
214
|
console.log(``);
|
|
118
215
|
}
|
|
216
|
+
} else if (options.list) {
|
|
217
|
+
const browsers2 = await import_server.registry.listInstalledBrowsers();
|
|
218
|
+
printGroupedByPlaywrightVersion(browsers2);
|
|
119
219
|
} else {
|
|
120
220
|
const forceReinstall = hasNoArguments ? false : !!options.force;
|
|
121
|
-
await
|
|
122
|
-
await
|
|
123
|
-
e.name =
|
|
221
|
+
await import_server.registry.install(executables, forceReinstall);
|
|
222
|
+
await import_server.registry.validateHostRequirementsForExecutablesIfNeeded(executables, process.env.PW_LANG_NAME || "javascript").catch((e) => {
|
|
223
|
+
e.name = "Playwright Host validation warning";
|
|
124
224
|
console.error(e);
|
|
125
225
|
});
|
|
126
226
|
}
|
|
127
227
|
} catch (e) {
|
|
128
|
-
console.log(`Failed to install browsers
|
|
129
|
-
|
|
228
|
+
console.log(`Failed to install browsers
|
|
229
|
+
${e}`);
|
|
230
|
+
(0, import_utils.gracefullyProcessExitDoNotHang)(1);
|
|
130
231
|
}
|
|
131
|
-
}).addHelpText(
|
|
232
|
+
}).addHelpText("afterAll", `
|
|
132
233
|
|
|
133
234
|
Examples:
|
|
134
235
|
- $ install
|
|
@@ -136,106 +237,110 @@ Examples:
|
|
|
136
237
|
|
|
137
238
|
- $ install chrome firefox
|
|
138
239
|
Install custom browsers, supports ${suggestedBrowsersToInstall()}.`);
|
|
139
|
-
|
|
240
|
+
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) => {
|
|
140
241
|
delete process.env.PLAYWRIGHT_SKIP_BROWSER_GC;
|
|
141
|
-
await
|
|
142
|
-
numberOfBrowsersLeft
|
|
143
|
-
}) => {
|
|
242
|
+
await import_server.registry.uninstall(!!options.all).then(({ numberOfBrowsersLeft }) => {
|
|
144
243
|
if (!options.all && numberOfBrowsersLeft > 0) {
|
|
145
|
-
console.log(
|
|
146
|
-
console.log(`There are still ${numberOfBrowsersLeft} browsers left, used by other Playwright installations
|
|
244
|
+
console.log("Successfully uninstalled Playwright browsers for the current Playwright installation.");
|
|
245
|
+
console.log(`There are still ${numberOfBrowsersLeft} browsers left, used by other Playwright installations.
|
|
246
|
+
To uninstall Playwright browsers for all installations, re-run with --all flag.`);
|
|
147
247
|
}
|
|
148
248
|
}).catch(logErrorAndExit);
|
|
149
249
|
});
|
|
150
|
-
|
|
250
|
+
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) {
|
|
151
251
|
try {
|
|
152
|
-
if (!args.length)
|
|
252
|
+
if (!args.length)
|
|
253
|
+
await import_server.registry.installDeps(defaultBrowsersToInstall({}), !!options.dryRun);
|
|
254
|
+
else
|
|
255
|
+
await import_server.registry.installDeps(checkBrowsersToInstall(args, {}), !!options.dryRun);
|
|
153
256
|
} catch (e) {
|
|
154
|
-
console.log(`Failed to install browser dependencies
|
|
155
|
-
|
|
257
|
+
console.log(`Failed to install browser dependencies
|
|
258
|
+
${e}`);
|
|
259
|
+
(0, import_utils.gracefullyProcessExitDoNotHang)(1);
|
|
156
260
|
}
|
|
157
|
-
}).addHelpText(
|
|
261
|
+
}).addHelpText("afterAll", `
|
|
158
262
|
Examples:
|
|
159
263
|
- $ install-deps
|
|
160
264
|
Install dependencies for default browsers.
|
|
161
265
|
|
|
162
266
|
- $ install-deps chrome firefox
|
|
163
267
|
Install dependencies for specific browsers, supports ${suggestedBrowsersToInstall()}.`);
|
|
164
|
-
const browsers = [
|
|
165
|
-
alias:
|
|
166
|
-
name:
|
|
167
|
-
type:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
name
|
|
171
|
-
|
|
172
|
-
},
|
|
173
|
-
alias: 'wk',
|
|
174
|
-
name: 'WebKit',
|
|
175
|
-
type: 'webkit'
|
|
176
|
-
}];
|
|
177
|
-
for (const {
|
|
178
|
-
alias,
|
|
179
|
-
name,
|
|
180
|
-
type
|
|
181
|
-
} of browsers) {
|
|
182
|
-
commandWithOpenOptions(`${alias} [url]`, `open page in ${name}`, []).action(function (url, options) {
|
|
183
|
-
open({
|
|
184
|
-
...options,
|
|
185
|
-
browser: type
|
|
186
|
-
}, url, options.target).catch(logErrorAndExit);
|
|
187
|
-
}).addHelpText('afterAll', `
|
|
268
|
+
const browsers = [
|
|
269
|
+
{ alias: "cr", name: "Chromium", type: "chromium" },
|
|
270
|
+
{ alias: "ff", name: "Firefox", type: "firefox" },
|
|
271
|
+
{ alias: "wk", name: "WebKit", type: "webkit" }
|
|
272
|
+
];
|
|
273
|
+
for (const { alias, name, type } of browsers) {
|
|
274
|
+
commandWithOpenOptions(`${alias} [url]`, `open page in ${name}`, []).action(function(url, options) {
|
|
275
|
+
open({ ...options, browser: type }, url).catch(logErrorAndExit);
|
|
276
|
+
}).addHelpText("afterAll", `
|
|
188
277
|
Examples:
|
|
189
278
|
|
|
190
279
|
$ ${alias} https://example.com`);
|
|
191
280
|
}
|
|
192
|
-
commandWithOpenOptions(
|
|
281
|
+
commandWithOpenOptions(
|
|
282
|
+
"screenshot <url> <filename>",
|
|
283
|
+
"capture a page screenshot",
|
|
284
|
+
[
|
|
285
|
+
["--wait-for-selector <selector>", "wait for selector before taking a screenshot"],
|
|
286
|
+
["--wait-for-timeout <timeout>", "wait for timeout in milliseconds before taking a screenshot"],
|
|
287
|
+
["--full-page", "whether to take a full page screenshot (entire scrollable area)"]
|
|
288
|
+
]
|
|
289
|
+
).action(function(url, filename, command) {
|
|
193
290
|
screenshot(command, command, url, filename).catch(logErrorAndExit);
|
|
194
|
-
}).addHelpText(
|
|
291
|
+
}).addHelpText("afterAll", `
|
|
195
292
|
Examples:
|
|
196
293
|
|
|
197
294
|
$ screenshot -b webkit https://example.com example.png`);
|
|
198
|
-
commandWithOpenOptions(
|
|
295
|
+
commandWithOpenOptions(
|
|
296
|
+
"pdf <url> <filename>",
|
|
297
|
+
"save page as pdf",
|
|
298
|
+
[
|
|
299
|
+
["--paper-format <format>", "paper format: Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6"],
|
|
300
|
+
["--wait-for-selector <selector>", "wait for given selector before saving as pdf"],
|
|
301
|
+
["--wait-for-timeout <timeout>", "wait for given timeout in milliseconds before saving as pdf"]
|
|
302
|
+
]
|
|
303
|
+
).action(function(url, filename, options) {
|
|
199
304
|
pdf(options, options, url, filename).catch(logErrorAndExit);
|
|
200
|
-
}).addHelpText(
|
|
305
|
+
}).addHelpText("afterAll", `
|
|
201
306
|
Examples:
|
|
202
307
|
|
|
203
308
|
$ pdf https://example.com example.pdf`);
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}).action(function (options) {
|
|
207
|
-
(0, _driver.runDriver)();
|
|
309
|
+
import_utilsBundle.program.command("run-driver", { hidden: true }).action(function(options) {
|
|
310
|
+
(0, import_driver.runDriver)();
|
|
208
311
|
});
|
|
209
|
-
|
|
210
|
-
(0,
|
|
211
|
-
port: options.port ? +options.port :
|
|
312
|
+
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) {
|
|
313
|
+
(0, import_driver.runServer)({
|
|
314
|
+
port: options.port ? +options.port : void 0,
|
|
212
315
|
host: options.host,
|
|
213
316
|
path: options.path,
|
|
214
317
|
maxConnections: options.maxClients ? +options.maxClients : Infinity,
|
|
215
|
-
extension: options.mode ===
|
|
318
|
+
extension: options.mode === "extension" || !!process.env.PW_EXTENSION_MODE
|
|
216
319
|
}).catch(logErrorAndExit);
|
|
217
320
|
});
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}).action(function (options) {
|
|
221
|
-
(0, _driver.printApiJson)();
|
|
321
|
+
import_utilsBundle.program.command("print-api-json", { hidden: true }).action(function(options) {
|
|
322
|
+
(0, import_driver.printApiJson)();
|
|
222
323
|
});
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}).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) {
|
|
226
|
-
(0, _driver.launchBrowserServer)(options.browser, options.config);
|
|
324
|
+
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) {
|
|
325
|
+
(0, import_driver.launchBrowserServer)(options.browser, options.config);
|
|
227
326
|
});
|
|
228
|
-
|
|
229
|
-
if (options.browser ===
|
|
230
|
-
|
|
231
|
-
if (options.browser ===
|
|
327
|
+
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(traces, options) {
|
|
328
|
+
if (options.browser === "cr")
|
|
329
|
+
options.browser = "chromium";
|
|
330
|
+
if (options.browser === "ff")
|
|
331
|
+
options.browser = "firefox";
|
|
332
|
+
if (options.browser === "wk")
|
|
333
|
+
options.browser = "webkit";
|
|
232
334
|
const openOptions = {
|
|
233
335
|
host: options.host,
|
|
234
336
|
port: +options.port,
|
|
235
337
|
isServer: !!options.stdin
|
|
236
338
|
};
|
|
237
|
-
if (options.port !==
|
|
238
|
-
|
|
339
|
+
if (options.port !== void 0 || options.host !== void 0)
|
|
340
|
+
(0, import_traceViewer.runTraceInBrowser)(traces, openOptions).catch(logErrorAndExit);
|
|
341
|
+
else
|
|
342
|
+
(0, import_traceViewer.runTraceViewerApp)(traces, options.browser, openOptions, true).catch(logErrorAndExit);
|
|
343
|
+
}).addHelpText("afterAll", `
|
|
239
344
|
Examples:
|
|
240
345
|
|
|
241
346
|
$ show-trace https://example.com/trace.zip`);
|
|
@@ -243,79 +348,43 @@ async function launchContext(options, extraOptions) {
|
|
|
243
348
|
validateOptions(options);
|
|
244
349
|
const browserType = lookupBrowserType(options);
|
|
245
350
|
const launchOptions = extraOptions;
|
|
246
|
-
if (options.channel)
|
|
351
|
+
if (options.channel)
|
|
352
|
+
launchOptions.channel = options.channel;
|
|
247
353
|
launchOptions.handleSIGINT = false;
|
|
248
|
-
const contextOptions =
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
// In headless, keep things the way it works in Playwright by default.
|
|
256
|
-
// Assume high-dpi on MacOS. TODO: this is not perfect.
|
|
257
|
-
if (!extraOptions.headless) contextOptions.deviceScaleFactor = _os.default.platform() === 'darwin' ? 2 : 1;
|
|
258
|
-
|
|
259
|
-
// Work around the WebKit GTK scrolling issue.
|
|
260
|
-
if (browserType.name() === 'webkit' && process.platform === 'linux') {
|
|
354
|
+
const contextOptions = (
|
|
355
|
+
// Copy the device descriptor since we have to compare and modify the options.
|
|
356
|
+
options.device ? { ...playwright.devices[options.device] } : {}
|
|
357
|
+
);
|
|
358
|
+
if (!extraOptions.headless)
|
|
359
|
+
contextOptions.deviceScaleFactor = import_os.default.platform() === "darwin" ? 2 : 1;
|
|
360
|
+
if (browserType.name() === "webkit" && process.platform === "linux") {
|
|
261
361
|
delete contextOptions.hasTouch;
|
|
262
362
|
delete contextOptions.isMobile;
|
|
263
363
|
}
|
|
264
|
-
if (contextOptions.isMobile && browserType.name() ===
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
364
|
+
if (contextOptions.isMobile && browserType.name() === "firefox")
|
|
365
|
+
contextOptions.isMobile = void 0;
|
|
366
|
+
if (options.blockServiceWorkers)
|
|
367
|
+
contextOptions.serviceWorkers = "block";
|
|
269
368
|
if (options.proxyServer) {
|
|
270
369
|
launchOptions.proxy = {
|
|
271
370
|
server: options.proxyServer
|
|
272
371
|
};
|
|
273
|
-
if (options.proxyBypass)
|
|
274
|
-
|
|
275
|
-
const browser = await browserType.launch(launchOptions);
|
|
276
|
-
if (process.env.PWTEST_CLI_IS_UNDER_TEST) {
|
|
277
|
-
process._didSetSourcesForTest = text => {
|
|
278
|
-
process.stdout.write('\n-------------8<-------------\n');
|
|
279
|
-
process.stdout.write(text);
|
|
280
|
-
process.stdout.write('\n-------------8<-------------\n');
|
|
281
|
-
const autoExitCondition = process.env.PWTEST_CLI_AUTO_EXIT_WHEN;
|
|
282
|
-
if (autoExitCondition && text.includes(autoExitCondition)) closeBrowser();
|
|
283
|
-
};
|
|
284
|
-
// Make sure we exit abnormally when browser crashes.
|
|
285
|
-
const logs = [];
|
|
286
|
-
require('playwright-core/lib/utilsBundle').debug.log = (...args) => {
|
|
287
|
-
const line = require('util').format(...args) + '\n';
|
|
288
|
-
logs.push(line);
|
|
289
|
-
process.stderr.write(line);
|
|
290
|
-
};
|
|
291
|
-
browser.on('disconnected', () => {
|
|
292
|
-
const hasCrashLine = logs.some(line => line.includes('process did exit:') && !line.includes('process did exit: exitCode=0, signal=null'));
|
|
293
|
-
if (hasCrashLine) {
|
|
294
|
-
process.stderr.write('Detected browser crash.\n');
|
|
295
|
-
(0, _utils.gracefullyProcessExitDoNotHang)(1);
|
|
296
|
-
}
|
|
297
|
-
});
|
|
372
|
+
if (options.proxyBypass)
|
|
373
|
+
launchOptions.proxy.bypass = options.proxyBypass;
|
|
298
374
|
}
|
|
299
|
-
|
|
300
|
-
// Viewport size
|
|
301
375
|
if (options.viewportSize) {
|
|
302
376
|
try {
|
|
303
|
-
const [width, height] = options.viewportSize.split(
|
|
304
|
-
if (isNaN(width) || isNaN(height))
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
height
|
|
308
|
-
};
|
|
377
|
+
const [width, height] = options.viewportSize.split(",").map((n) => +n);
|
|
378
|
+
if (isNaN(width) || isNaN(height))
|
|
379
|
+
throw new Error("bad values");
|
|
380
|
+
contextOptions.viewport = { width, height };
|
|
309
381
|
} catch (e) {
|
|
310
382
|
throw new Error('Invalid viewport size format: use "width,height", for example --viewport-size="800,600"');
|
|
311
383
|
}
|
|
312
384
|
}
|
|
313
|
-
|
|
314
|
-
// Geolocation
|
|
315
|
-
|
|
316
385
|
if (options.geolocation) {
|
|
317
386
|
try {
|
|
318
|
-
const [latitude, longitude] = options.geolocation.split(
|
|
387
|
+
const [latitude, longitude] = options.geolocation.split(",").map((n) => parseFloat(n.trim()));
|
|
319
388
|
contextOptions.geolocation = {
|
|
320
389
|
latitude,
|
|
321
390
|
longitude
|
|
@@ -323,149 +392,128 @@ async function launchContext(options, extraOptions) {
|
|
|
323
392
|
} catch (e) {
|
|
324
393
|
throw new Error('Invalid geolocation format, should be "lat,long". For example --geolocation="37.819722,-122.478611"');
|
|
325
394
|
}
|
|
326
|
-
contextOptions.permissions = [
|
|
395
|
+
contextOptions.permissions = ["geolocation"];
|
|
327
396
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
// Timezone
|
|
342
|
-
|
|
343
|
-
if (options.timezone) contextOptions.timezoneId = options.timezone;
|
|
344
|
-
|
|
345
|
-
// Storage
|
|
346
|
-
|
|
347
|
-
if (options.loadStorage) contextOptions.storageState = options.loadStorage;
|
|
348
|
-
if (options.ignoreHttpsErrors) contextOptions.ignoreHTTPSErrors = true;
|
|
349
|
-
|
|
350
|
-
// HAR
|
|
351
|
-
|
|
397
|
+
if (options.userAgent)
|
|
398
|
+
contextOptions.userAgent = options.userAgent;
|
|
399
|
+
if (options.lang)
|
|
400
|
+
contextOptions.locale = options.lang;
|
|
401
|
+
if (options.colorScheme)
|
|
402
|
+
contextOptions.colorScheme = options.colorScheme;
|
|
403
|
+
if (options.timezone)
|
|
404
|
+
contextOptions.timezoneId = options.timezone;
|
|
405
|
+
if (options.loadStorage)
|
|
406
|
+
contextOptions.storageState = options.loadStorage;
|
|
407
|
+
if (options.ignoreHttpsErrors)
|
|
408
|
+
contextOptions.ignoreHTTPSErrors = true;
|
|
352
409
|
if (options.saveHar) {
|
|
353
|
-
contextOptions.recordHar = {
|
|
354
|
-
|
|
355
|
-
|
|
410
|
+
contextOptions.recordHar = { path: import_path.default.resolve(process.cwd(), options.saveHar), mode: "minimal" };
|
|
411
|
+
if (options.saveHarGlob)
|
|
412
|
+
contextOptions.recordHar.urlFilter = options.saveHarGlob;
|
|
413
|
+
contextOptions.serviceWorkers = "block";
|
|
414
|
+
}
|
|
415
|
+
let browser;
|
|
416
|
+
let context;
|
|
417
|
+
if (options.userDataDir) {
|
|
418
|
+
context = await browserType.launchPersistentContext(options.userDataDir, { ...launchOptions, ...contextOptions });
|
|
419
|
+
browser = context.browser();
|
|
420
|
+
} else {
|
|
421
|
+
browser = await browserType.launch(launchOptions);
|
|
422
|
+
context = await browser.newContext(contextOptions);
|
|
423
|
+
}
|
|
424
|
+
if (process.env.PWTEST_CLI_IS_UNDER_TEST) {
|
|
425
|
+
process._didSetSourcesForTest = (text) => {
|
|
426
|
+
process.stdout.write("\n-------------8<-------------\n");
|
|
427
|
+
process.stdout.write(text);
|
|
428
|
+
process.stdout.write("\n-------------8<-------------\n");
|
|
429
|
+
const autoExitCondition = process.env.PWTEST_CLI_AUTO_EXIT_WHEN;
|
|
430
|
+
if (autoExitCondition && text.includes(autoExitCondition))
|
|
431
|
+
closeBrowser();
|
|
432
|
+
};
|
|
433
|
+
const logs = [];
|
|
434
|
+
require("playwright-core/lib/utilsBundle").debug.log = (...args) => {
|
|
435
|
+
const line = require("util").format(...args) + "\n";
|
|
436
|
+
logs.push(line);
|
|
437
|
+
process.stderr.write(line);
|
|
356
438
|
};
|
|
357
|
-
|
|
358
|
-
|
|
439
|
+
browser.on("disconnected", () => {
|
|
440
|
+
const hasCrashLine = logs.some((line) => line.includes("process did exit:") && !line.includes("process did exit: exitCode=0, signal=null"));
|
|
441
|
+
if (hasCrashLine) {
|
|
442
|
+
process.stderr.write("Detected browser crash.\n");
|
|
443
|
+
(0, import_utils.gracefullyProcessExitDoNotHang)(1);
|
|
444
|
+
}
|
|
445
|
+
});
|
|
359
446
|
}
|
|
360
|
-
|
|
361
|
-
// Close app when the last window closes.
|
|
362
|
-
|
|
363
|
-
const context = await browser.newContext(contextOptions);
|
|
364
447
|
let closingBrowser = false;
|
|
365
448
|
async function closeBrowser() {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
if (closingBrowser) return;
|
|
449
|
+
if (closingBrowser)
|
|
450
|
+
return;
|
|
369
451
|
closingBrowser = true;
|
|
370
|
-
if (options.saveStorage)
|
|
371
|
-
path: options.saveStorage
|
|
372
|
-
|
|
373
|
-
|
|
452
|
+
if (options.saveStorage)
|
|
453
|
+
await context.storageState({ path: options.saveStorage }).catch((e) => null);
|
|
454
|
+
if (options.saveHar)
|
|
455
|
+
await context.close();
|
|
374
456
|
await browser.close();
|
|
375
457
|
}
|
|
376
|
-
context.on(
|
|
377
|
-
page.on(
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
458
|
+
context.on("page", (page) => {
|
|
459
|
+
page.on("dialog", () => {
|
|
460
|
+
});
|
|
461
|
+
page.on("close", () => {
|
|
462
|
+
const hasPage = browser.contexts().some((context2) => context2.pages().length > 0);
|
|
463
|
+
if (hasPage)
|
|
464
|
+
return;
|
|
465
|
+
closeBrowser().catch(() => {
|
|
466
|
+
});
|
|
383
467
|
});
|
|
384
468
|
});
|
|
385
|
-
process.on(
|
|
469
|
+
process.on("SIGINT", async () => {
|
|
386
470
|
await closeBrowser();
|
|
387
|
-
(0,
|
|
471
|
+
(0, import_utils.gracefullyProcessExitDoNotHang)(130);
|
|
388
472
|
});
|
|
389
473
|
const timeout = options.timeout ? parseInt(options.timeout, 10) : 0;
|
|
390
474
|
context.setDefaultTimeout(timeout);
|
|
391
475
|
context.setDefaultNavigationTimeout(timeout);
|
|
392
|
-
|
|
393
|
-
// Omit options that we add automatically for presentation purpose.
|
|
394
476
|
delete launchOptions.headless;
|
|
395
477
|
delete launchOptions.executablePath;
|
|
396
478
|
delete launchOptions.handleSIGINT;
|
|
397
479
|
delete contextOptions.deviceScaleFactor;
|
|
398
|
-
return {
|
|
399
|
-
browser,
|
|
400
|
-
browserName: browserType.name(),
|
|
401
|
-
context,
|
|
402
|
-
contextOptions,
|
|
403
|
-
launchOptions
|
|
404
|
-
};
|
|
480
|
+
return { browser, browserName: browserType.name(), context, contextOptions, launchOptions };
|
|
405
481
|
}
|
|
406
482
|
async function openPage(context, url) {
|
|
407
|
-
|
|
483
|
+
let page = context.pages()[0];
|
|
484
|
+
if (!page)
|
|
485
|
+
page = await context.newPage();
|
|
408
486
|
if (url) {
|
|
409
|
-
if (
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
} else {
|
|
415
|
-
throw error;
|
|
416
|
-
}
|
|
417
|
-
});
|
|
487
|
+
if (import_fs.default.existsSync(url))
|
|
488
|
+
url = "file://" + import_path.default.resolve(url);
|
|
489
|
+
else if (!url.startsWith("http") && !url.startsWith("file://") && !url.startsWith("about:") && !url.startsWith("data:"))
|
|
490
|
+
url = "http://" + url;
|
|
491
|
+
await page.goto(url);
|
|
418
492
|
}
|
|
419
493
|
return page;
|
|
420
494
|
}
|
|
421
|
-
async function open(options, url
|
|
422
|
-
const {
|
|
423
|
-
context,
|
|
424
|
-
launchOptions,
|
|
425
|
-
contextOptions
|
|
426
|
-
} = await launchContext(options, {
|
|
427
|
-
headless: !!process.env.PWTEST_CLI_HEADLESS,
|
|
428
|
-
executablePath: process.env.PWTEST_CLI_EXECUTABLE_PATH
|
|
429
|
-
});
|
|
430
|
-
await context._enableRecorder({
|
|
431
|
-
language,
|
|
432
|
-
launchOptions,
|
|
433
|
-
contextOptions,
|
|
434
|
-
device: options.device,
|
|
435
|
-
saveStorage: options.saveStorage,
|
|
436
|
-
handleSIGINT: false
|
|
437
|
-
});
|
|
495
|
+
async function open(options, url) {
|
|
496
|
+
const { context } = await launchContext(options, { headless: !!process.env.PWTEST_CLI_HEADLESS, executablePath: process.env.PWTEST_CLI_EXECUTABLE_PATH });
|
|
438
497
|
await openPage(context, url);
|
|
439
498
|
}
|
|
440
499
|
async function codegen(options, url) {
|
|
441
|
-
const {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
testIdAttribute: testIdAttributeName
|
|
445
|
-
} = options;
|
|
446
|
-
const tracesDir = _path.default.join(_os.default.tmpdir(), `playwright-recorder-trace-${Date.now()}`);
|
|
447
|
-
const {
|
|
448
|
-
context,
|
|
449
|
-
launchOptions,
|
|
450
|
-
contextOptions
|
|
451
|
-
} = await launchContext(options, {
|
|
500
|
+
const { target: language, output: outputFile, testIdAttribute: testIdAttributeName } = options;
|
|
501
|
+
const tracesDir = import_path.default.join(import_os.default.tmpdir(), `playwright-recorder-trace-${Date.now()}`);
|
|
502
|
+
const { context, launchOptions, contextOptions } = await launchContext(options, {
|
|
452
503
|
headless: !!process.env.PWTEST_CLI_HEADLESS,
|
|
453
504
|
executablePath: process.env.PWTEST_CLI_EXECUTABLE_PATH,
|
|
454
505
|
tracesDir
|
|
455
506
|
});
|
|
456
|
-
|
|
457
|
-
path: 'playwright.env'
|
|
458
|
-
});
|
|
507
|
+
import_utilsBundle.dotenv.config({ path: "playwright.env" });
|
|
459
508
|
await context._enableRecorder({
|
|
460
509
|
language,
|
|
461
510
|
launchOptions,
|
|
462
511
|
contextOptions,
|
|
463
512
|
device: options.device,
|
|
464
513
|
saveStorage: options.saveStorage,
|
|
465
|
-
mode:
|
|
466
|
-
codegenMode: process.env.PW_RECORDER_IS_TRACE_VIEWER ? 'trace-events' : 'actions',
|
|
514
|
+
mode: "recording",
|
|
467
515
|
testIdAttributeName,
|
|
468
|
-
outputFile: outputFile ?
|
|
516
|
+
outputFile: outputFile ? import_path.default.resolve(outputFile) : void 0,
|
|
469
517
|
handleSIGINT: false
|
|
470
518
|
});
|
|
471
519
|
await openPage(context, url);
|
|
@@ -480,41 +528,24 @@ async function waitForPage(page, captureOptions) {
|
|
|
480
528
|
await page.waitForTimeout(parseInt(captureOptions.waitForTimeout, 10));
|
|
481
529
|
}
|
|
482
530
|
}
|
|
483
|
-
async function screenshot(options, captureOptions, url,
|
|
484
|
-
const {
|
|
485
|
-
|
|
486
|
-
} = await launchContext(options, {
|
|
487
|
-
headless: true
|
|
488
|
-
});
|
|
489
|
-
console.log('Navigating to ' + url);
|
|
531
|
+
async function screenshot(options, captureOptions, url, path2) {
|
|
532
|
+
const { context } = await launchContext(options, { headless: true });
|
|
533
|
+
console.log("Navigating to " + url);
|
|
490
534
|
const page = await openPage(context, url);
|
|
491
535
|
await waitForPage(page, captureOptions);
|
|
492
|
-
console.log(
|
|
493
|
-
await page.screenshot({
|
|
494
|
-
path,
|
|
495
|
-
fullPage: !!captureOptions.fullPage
|
|
496
|
-
});
|
|
497
|
-
// launchContext takes care of closing the browser.
|
|
536
|
+
console.log("Capturing screenshot into " + path2);
|
|
537
|
+
await page.screenshot({ path: path2, fullPage: !!captureOptions.fullPage });
|
|
498
538
|
await page.close();
|
|
499
539
|
}
|
|
500
|
-
async function pdf(options, captureOptions, url,
|
|
501
|
-
if (options.browser !==
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
...options,
|
|
506
|
-
browser: 'chromium'
|
|
507
|
-
}, {
|
|
508
|
-
headless: true
|
|
509
|
-
});
|
|
510
|
-
console.log('Navigating to ' + url);
|
|
540
|
+
async function pdf(options, captureOptions, url, path2) {
|
|
541
|
+
if (options.browser !== "chromium")
|
|
542
|
+
throw new Error("PDF creation is only working with Chromium");
|
|
543
|
+
const { context } = await launchContext({ ...options, browser: "chromium" }, { headless: true });
|
|
544
|
+
console.log("Navigating to " + url);
|
|
511
545
|
const page = await openPage(context, url);
|
|
512
546
|
await waitForPage(page, captureOptions);
|
|
513
|
-
console.log(
|
|
514
|
-
await page.pdf({
|
|
515
|
-
path
|
|
516
|
-
});
|
|
517
|
-
// launchContext takes care of closing the browser.
|
|
547
|
+
console.log("Saving as pdf into " + path2);
|
|
548
|
+
await page.pdf({ path: path2, format: captureOptions.paperFormat });
|
|
518
549
|
await page.close();
|
|
519
550
|
}
|
|
520
551
|
function lookupBrowserType(options) {
|
|
@@ -525,60 +556,70 @@ function lookupBrowserType(options) {
|
|
|
525
556
|
}
|
|
526
557
|
let browserType;
|
|
527
558
|
switch (name) {
|
|
528
|
-
case
|
|
559
|
+
case "chromium":
|
|
529
560
|
browserType = playwright.chromium;
|
|
530
561
|
break;
|
|
531
|
-
case
|
|
562
|
+
case "webkit":
|
|
532
563
|
browserType = playwright.webkit;
|
|
533
564
|
break;
|
|
534
|
-
case
|
|
565
|
+
case "firefox":
|
|
535
566
|
browserType = playwright.firefox;
|
|
536
567
|
break;
|
|
537
|
-
case
|
|
568
|
+
case "cr":
|
|
538
569
|
browserType = playwright.chromium;
|
|
539
570
|
break;
|
|
540
|
-
case
|
|
571
|
+
case "wk":
|
|
541
572
|
browserType = playwright.webkit;
|
|
542
573
|
break;
|
|
543
|
-
case
|
|
574
|
+
case "ff":
|
|
544
575
|
browserType = playwright.firefox;
|
|
545
576
|
break;
|
|
546
577
|
}
|
|
547
|
-
if (browserType)
|
|
548
|
-
|
|
578
|
+
if (browserType)
|
|
579
|
+
return browserType;
|
|
580
|
+
import_utilsBundle.program.help();
|
|
549
581
|
}
|
|
550
582
|
function validateOptions(options) {
|
|
551
583
|
if (options.device && !(options.device in playwright.devices)) {
|
|
552
584
|
const lines = [`Device descriptor not found: '${options.device}', available devices are:`];
|
|
553
|
-
for (const name in playwright.devices)
|
|
554
|
-
|
|
585
|
+
for (const name in playwright.devices)
|
|
586
|
+
lines.push(` "${name}"`);
|
|
587
|
+
throw new Error(lines.join("\n"));
|
|
555
588
|
}
|
|
556
|
-
if (options.colorScheme && ![
|
|
589
|
+
if (options.colorScheme && !["light", "dark"].includes(options.colorScheme))
|
|
590
|
+
throw new Error('Invalid color scheme, should be one of "light", "dark"');
|
|
557
591
|
}
|
|
558
592
|
function logErrorAndExit(e) {
|
|
559
|
-
if (process.env.PWDEBUGIMPL)
|
|
560
|
-
|
|
593
|
+
if (process.env.PWDEBUGIMPL)
|
|
594
|
+
console.error(e);
|
|
595
|
+
else
|
|
596
|
+
console.error(e.name + ": " + e.message);
|
|
597
|
+
(0, import_utils.gracefullyProcessExitDoNotHang)(1);
|
|
561
598
|
}
|
|
562
599
|
function codegenId() {
|
|
563
|
-
return process.env.PW_LANG_NAME ||
|
|
600
|
+
return process.env.PW_LANG_NAME || "playwright-test";
|
|
564
601
|
}
|
|
565
602
|
function commandWithOpenOptions(command, description, options) {
|
|
566
|
-
let result =
|
|
567
|
-
for (const option of options)
|
|
568
|
-
|
|
603
|
+
let result = import_utilsBundle.program.command(command).description(description);
|
|
604
|
+
for (const option of options)
|
|
605
|
+
result = result.option(option[0], ...option.slice(1));
|
|
606
|
+
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"');
|
|
569
607
|
}
|
|
570
608
|
function buildBasePlaywrightCLICommand(cliTargetLang) {
|
|
571
609
|
switch (cliTargetLang) {
|
|
572
|
-
case
|
|
610
|
+
case "python":
|
|
573
611
|
return `playwright`;
|
|
574
|
-
case
|
|
612
|
+
case "java":
|
|
575
613
|
return `mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="...options.."`;
|
|
576
|
-
case
|
|
614
|
+
case "csharp":
|
|
577
615
|
return `pwsh bin/Debug/netX/playwright.ps1`;
|
|
578
|
-
default:
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
}
|
|
616
|
+
default: {
|
|
617
|
+
const packageManagerCommand = (0, import_utils2.getPackageManagerExecCommand)();
|
|
618
|
+
return `${packageManagerCommand} playwright`;
|
|
619
|
+
}
|
|
583
620
|
}
|
|
584
|
-
}
|
|
621
|
+
}
|
|
622
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
623
|
+
0 && (module.exports = {
|
|
624
|
+
program
|
|
625
|
+
});
|