patchright-core 1.57.0 → 1.59.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 +2688 -297
- package/browsers.json +23 -22
- package/lib/bootstrap.js +77 -0
- package/lib/cli/browserActions.js +308 -0
- package/lib/cli/driver.js +3 -2
- package/lib/cli/installActions.js +171 -0
- package/lib/cli/program.js +48 -413
- package/lib/client/android.js +4 -4
- package/lib/client/api.js +3 -0
- package/lib/client/browser.js +11 -5
- package/lib/client/browserContext.js +20 -23
- package/lib/client/browserType.js +23 -54
- package/lib/client/cdpSession.js +6 -2
- package/lib/client/channelOwner.js +1 -1
- package/lib/client/clientHelper.js +2 -1
- package/lib/client/clock.js +0 -1
- package/lib/client/{webSocket.js → connect.js} +57 -7
- package/lib/client/connection.js +8 -0
- package/lib/client/consoleMessage.js +3 -0
- package/lib/client/debugger.js +57 -0
- package/lib/client/dialog.js +8 -1
- package/lib/client/disposable.js +76 -0
- package/lib/client/electron.js +1 -0
- package/lib/client/elementHandle.js +1 -1
- package/lib/client/events.js +3 -0
- package/lib/client/fetch.js +2 -4
- package/lib/client/frame.js +9 -13
- package/lib/client/harRouter.js +13 -1
- package/lib/client/jsHandle.js +4 -8
- package/lib/client/locator.js +13 -36
- package/lib/client/network.js +14 -11
- package/lib/client/page.js +44 -50
- package/lib/client/screencast.js +88 -0
- package/lib/client/selectors.js +3 -1
- package/lib/client/tracing.js +11 -5
- package/lib/client/video.js +13 -20
- package/lib/client/worker.js +6 -6
- package/lib/generated/bindingsControllerSource.js +1 -1
- package/lib/generated/clockSource.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/pollingRecorderSource.js +1 -1
- package/lib/generated/storageScriptSource.js +1 -1
- package/lib/generated/utilityScriptSource.js +1 -1
- package/lib/mcpBundle.js +78 -0
- package/lib/mcpBundleImpl.js +91 -0
- package/lib/protocol/serializers.js +5 -0
- package/lib/protocol/validator.js +228 -58
- package/lib/protocol/validatorPrimitives.js +1 -1
- package/lib/remote/playwrightConnection.js +10 -8
- package/lib/remote/playwrightPipeServer.js +100 -0
- package/lib/remote/playwrightServer.js +14 -10
- package/lib/remote/playwrightWebSocketServer.js +73 -0
- package/lib/remote/serverTransport.js +96 -0
- package/lib/server/android/android.js +2 -2
- package/lib/server/artifact.js +1 -1
- package/lib/server/bidi/bidiBrowser.js +80 -14
- package/lib/server/bidi/bidiChromium.js +23 -14
- package/lib/server/bidi/bidiConnection.js +1 -0
- package/lib/server/bidi/bidiDeserializer.js +116 -0
- package/lib/server/bidi/bidiExecutionContext.js +75 -29
- package/lib/server/bidi/bidiFirefox.js +6 -8
- package/lib/server/bidi/bidiNetworkManager.js +40 -12
- package/lib/server/bidi/bidiPage.js +67 -40
- package/lib/server/bidi/third_party/bidiProtocolCore.js +1 -0
- package/lib/server/bidi/third_party/firefoxPrefs.js +3 -1
- package/lib/server/browser.js +84 -21
- package/lib/server/browserContext.js +137 -77
- package/lib/server/browserType.js +26 -16
- package/lib/server/chromium/chromium.js +28 -31
- package/lib/server/chromium/chromiumSwitches.js +16 -4
- package/lib/server/chromium/crBrowser.js +40 -27
- package/lib/server/chromium/crConnection.js +0 -5
- package/lib/server/chromium/crDevTools.js +1 -2
- package/lib/server/chromium/crNetworkManager.js +54 -229
- package/lib/server/chromium/crPage.js +74 -260
- package/lib/server/chromium/crServiceWorker.js +7 -14
- package/lib/server/clock.js +33 -41
- package/lib/server/codegen/javascript.js +6 -29
- package/lib/server/console.js +5 -1
- package/lib/server/debugController.js +12 -6
- package/lib/server/debugger.js +40 -47
- package/lib/server/deviceDescriptorsSource.json +137 -137
- package/lib/server/dispatchers/browserContextDispatcher.js +30 -30
- package/lib/server/dispatchers/browserDispatcher.js +11 -5
- package/lib/server/dispatchers/browserTypeDispatcher.js +7 -0
- package/lib/server/dispatchers/cdpSessionDispatcher.js +4 -1
- package/lib/server/dispatchers/debuggerDispatcher.js +84 -0
- package/lib/server/dispatchers/dispatcher.js +7 -14
- package/lib/server/dispatchers/disposableDispatcher.js +39 -0
- package/lib/server/dispatchers/electronDispatcher.js +2 -1
- package/lib/server/dispatchers/frameDispatcher.js +7 -7
- package/lib/server/dispatchers/localUtilsDispatcher.js +37 -1
- package/lib/server/dispatchers/networkDispatchers.js +6 -5
- package/lib/server/dispatchers/pageDispatcher.js +101 -34
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +4 -5
- package/lib/server/disposable.js +41 -0
- package/lib/server/dom.js +56 -29
- package/lib/server/download.js +3 -2
- package/lib/server/electron/electron.js +17 -9
- package/lib/server/firefox/ffBrowser.js +9 -29
- package/lib/server/firefox/ffConnection.js +0 -5
- package/lib/server/firefox/ffInput.js +21 -5
- package/lib/server/firefox/ffNetworkManager.js +4 -4
- package/lib/server/firefox/ffPage.js +27 -33
- package/lib/server/firefox/firefox.js +6 -8
- package/lib/server/frameSelectors.js +14 -169
- package/lib/server/frames.js +263 -551
- package/lib/server/har/harRecorder.js +2 -2
- package/lib/server/har/harTracer.js +5 -4
- package/lib/server/input.js +49 -4
- package/lib/server/instrumentation.js +8 -0
- package/lib/server/javascript.js +6 -22
- package/lib/server/launchApp.js +0 -1
- package/lib/server/localUtils.js +6 -6
- package/lib/server/network.js +59 -20
- package/lib/server/overlay.js +138 -0
- package/lib/server/page.js +179 -157
- package/lib/server/progress.js +32 -6
- package/lib/server/recorder/recorderApp.js +84 -104
- package/lib/server/recorder.js +76 -40
- package/lib/server/registry/browserFetcher.js +6 -4
- package/lib/server/registry/index.js +222 -226
- package/lib/server/registry/nativeDeps.js +1 -0
- package/lib/server/registry/oopDownloadBrowserMain.js +3 -0
- package/lib/server/screencast.js +137 -0
- package/lib/server/trace/recorder/snapshotter.js +2 -2
- package/lib/server/trace/recorder/snapshotterInjected.js +21 -1
- package/lib/server/trace/recorder/tracing.js +98 -47
- package/lib/server/trace/viewer/traceViewer.js +24 -21
- package/lib/server/usKeyboardLayout.js +7 -0
- package/lib/server/utils/comparators.js +1 -1
- package/lib/server/utils/disposable.js +32 -0
- package/lib/server/utils/eventsHelper.js +3 -1
- package/lib/server/utils/expectUtils.js +87 -2
- package/lib/server/utils/fileUtils.js +16 -2
- package/lib/server/utils/happyEyeballs.js +15 -12
- package/lib/server/utils/httpServer.js +10 -23
- package/lib/server/utils/network.js +39 -29
- package/lib/server/utils/processLauncher.js +8 -6
- package/lib/server/utils/zipFile.js +2 -2
- package/lib/server/videoRecorder.js +194 -0
- package/lib/server/webkit/webkit.js +4 -6
- package/lib/server/webkit/wkBrowser.js +1 -10
- package/lib/server/webkit/wkConnection.js +1 -6
- package/lib/server/webkit/wkInterceptableRequest.js +29 -1
- package/lib/server/webkit/wkPage.js +88 -57
- package/lib/server/webkit/wkWorkers.js +2 -1
- package/lib/serverRegistry.js +156 -0
- package/lib/tools/backend/browserBackend.js +79 -0
- package/lib/tools/backend/common.js +63 -0
- package/lib/tools/backend/config.js +41 -0
- package/lib/tools/backend/console.js +66 -0
- package/lib/tools/backend/context.js +296 -0
- package/lib/tools/backend/cookies.js +152 -0
- package/lib/tools/backend/devtools.js +69 -0
- package/lib/tools/backend/dialogs.js +59 -0
- package/lib/tools/backend/evaluate.js +64 -0
- package/lib/tools/backend/files.js +60 -0
- package/lib/tools/backend/form.js +64 -0
- package/lib/tools/backend/keyboard.js +155 -0
- package/lib/tools/backend/logFile.js +95 -0
- package/lib/tools/backend/mouse.js +168 -0
- package/lib/tools/backend/navigate.js +106 -0
- package/lib/tools/backend/network.js +135 -0
- package/lib/tools/backend/pdf.js +48 -0
- package/lib/tools/backend/response.js +305 -0
- package/lib/tools/backend/route.js +140 -0
- package/lib/tools/backend/runCode.js +77 -0
- package/lib/tools/backend/screenshot.js +88 -0
- package/lib/tools/backend/sessionLog.js +74 -0
- package/lib/tools/backend/snapshot.js +208 -0
- package/lib/tools/backend/storage.js +68 -0
- package/lib/tools/backend/tab.js +445 -0
- package/lib/tools/backend/tabs.js +67 -0
- package/lib/tools/backend/tool.js +47 -0
- package/lib/tools/backend/tools.js +102 -0
- package/lib/tools/backend/tracing.js +78 -0
- package/lib/tools/backend/utils.js +83 -0
- package/lib/tools/backend/verify.js +151 -0
- package/lib/tools/backend/video.js +98 -0
- package/lib/tools/backend/wait.js +63 -0
- package/lib/tools/backend/webstorage.js +223 -0
- package/lib/tools/cli-client/cli.js +6 -0
- package/lib/tools/cli-client/help.json +399 -0
- package/lib/tools/cli-client/minimist.js +128 -0
- package/lib/tools/cli-client/program.js +350 -0
- package/lib/tools/cli-client/registry.js +176 -0
- package/lib/tools/cli-client/session.js +289 -0
- package/lib/tools/cli-client/skill/SKILL.md +328 -0
- package/lib/tools/cli-client/skill/references/element-attributes.md +23 -0
- package/lib/tools/cli-client/skill/references/playwright-tests.md +39 -0
- package/lib/tools/cli-client/skill/references/request-mocking.md +87 -0
- package/lib/tools/cli-client/skill/references/running-code.md +231 -0
- package/lib/tools/cli-client/skill/references/session-management.md +169 -0
- package/lib/tools/cli-client/skill/references/storage-state.md +275 -0
- package/lib/tools/cli-client/skill/references/test-generation.md +88 -0
- package/lib/tools/cli-client/skill/references/tracing.md +139 -0
- package/lib/tools/cli-client/skill/references/video-recording.md +143 -0
- package/lib/tools/cli-daemon/command.js +73 -0
- package/lib/tools/cli-daemon/commands.js +956 -0
- package/lib/tools/cli-daemon/daemon.js +157 -0
- package/lib/tools/cli-daemon/helpGenerator.js +177 -0
- package/lib/tools/cli-daemon/program.js +129 -0
- package/lib/tools/dashboard/appIcon.png +0 -0
- package/lib/tools/dashboard/dashboardApp.js +284 -0
- package/lib/tools/dashboard/dashboardController.js +296 -0
- package/lib/tools/exports.js +60 -0
- package/lib/tools/mcp/browserFactory.js +233 -0
- package/lib/tools/mcp/cdpRelay.js +352 -0
- package/lib/tools/mcp/cli-stub.js +7 -0
- package/lib/tools/mcp/config.d.js +16 -0
- package/lib/tools/mcp/config.js +446 -0
- package/lib/tools/mcp/configIni.js +189 -0
- package/lib/tools/mcp/extensionContextFactory.js +55 -0
- package/lib/tools/mcp/index.js +62 -0
- package/lib/tools/mcp/log.js +35 -0
- package/lib/tools/mcp/program.js +107 -0
- package/lib/tools/mcp/protocol.js +28 -0
- package/lib/tools/mcp/watchdog.js +44 -0
- package/lib/tools/trace/SKILL.md +171 -0
- package/lib/tools/trace/installSkill.js +48 -0
- package/lib/tools/trace/traceActions.js +142 -0
- package/lib/tools/trace/traceAttachments.js +69 -0
- package/lib/tools/trace/traceCli.js +87 -0
- package/lib/tools/trace/traceConsole.js +97 -0
- package/lib/tools/trace/traceErrors.js +55 -0
- package/lib/tools/trace/traceOpen.js +69 -0
- package/lib/tools/trace/traceParser.js +96 -0
- package/lib/tools/trace/traceRequests.js +182 -0
- package/lib/tools/trace/traceScreenshot.js +68 -0
- package/lib/tools/trace/traceSnapshot.js +149 -0
- package/lib/tools/trace/traceUtils.js +153 -0
- package/lib/tools/utils/connect.js +32 -0
- package/lib/tools/utils/mcp/http.js +152 -0
- package/lib/tools/utils/mcp/server.js +230 -0
- package/lib/tools/utils/mcp/tool.js +47 -0
- package/lib/tools/utils/socketConnection.js +108 -0
- package/lib/utils/isomorphic/ariaSnapshot.js +60 -2
- package/lib/utils/isomorphic/formatUtils.js +64 -0
- package/lib/utils/isomorphic/jsonSchema.js +89 -0
- package/lib/utils/isomorphic/lruCache.js +51 -0
- package/lib/utils/isomorphic/mimeType.js +7 -2
- package/lib/utils/isomorphic/protocolFormatter.js +2 -2
- package/lib/utils/isomorphic/protocolMetainfo.js +127 -98
- package/lib/utils/isomorphic/stringUtils.js +49 -0
- package/lib/utils/isomorphic/timeoutRunner.js +3 -3
- package/lib/utils/isomorphic/trace/entries.js +16 -0
- package/lib/utils/isomorphic/trace/snapshotRenderer.js +492 -0
- package/lib/utils/isomorphic/trace/snapshotServer.js +120 -0
- package/lib/utils/isomorphic/trace/snapshotStorage.js +89 -0
- package/lib/utils/isomorphic/trace/traceLoader.js +132 -0
- package/lib/utils/isomorphic/trace/traceModel.js +366 -0
- package/lib/utils/isomorphic/trace/traceModernizer.js +401 -0
- package/lib/utils/isomorphic/trace/versions/traceV3.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV4.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV5.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV6.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV7.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV8.js +16 -0
- package/lib/utils/isomorphic/urlMatch.js +54 -1
- package/lib/utils/isomorphic/utilityScriptSerializers.js +11 -0
- package/lib/utils/isomorphic/yaml.js +84 -0
- package/lib/utils.js +8 -2
- package/lib/utilsBundle.js +5 -26
- package/lib/utilsBundleImpl/index.js +172 -173
- package/lib/vite/dashboard/assets/index-BAOybkp8.js +50 -0
- package/lib/vite/dashboard/assets/index-CZAYOG76.css +1 -0
- package/lib/vite/dashboard/index.html +28 -0
- package/lib/vite/htmlReport/index.html +2 -70
- package/lib/vite/htmlReport/report.css +1 -0
- package/lib/vite/htmlReport/report.js +72 -0
- package/lib/vite/recorder/assets/codeMirrorModule-C8KMvO9L.js +32 -0
- package/lib/vite/recorder/assets/{codeMirrorModule-C3UTv-Ge.css → codeMirrorModule-DYBRYzYX.css} +1 -1
- package/lib/vite/recorder/assets/{index-Ri0uHF7I.css → index-BSjZa4pk.css} +1 -1
- package/lib/vite/recorder/assets/index-CqAYX1I3.js +193 -0
- package/lib/vite/recorder/index.html +2 -2
- package/lib/vite/traceViewer/assets/codeMirrorModule-DS0FLvoc.js +32 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-GTWI-W_B.js +262 -0
- package/lib/vite/traceViewer/{codeMirrorModule.C3UTv-Ge.css → codeMirrorModule.DYBRYzYX.css} +1 -1
- package/lib/vite/traceViewer/defaultSettingsView.B4dS75f0.css +1 -0
- package/lib/vite/traceViewer/index.CzXZzn5A.css +1 -0
- package/lib/vite/traceViewer/index.Dtstcb7U.js +2 -0
- package/lib/vite/traceViewer/index.html +4 -4
- package/lib/vite/traceViewer/sw.bundle.js +5 -3
- package/lib/vite/traceViewer/uiMode.Vipi55dB.js +6 -0
- package/lib/vite/traceViewer/uiMode.html +3 -3
- package/lib/zipBundleImpl.js +2 -2
- package/lib/zodBundle.js +39 -0
- package/lib/zodBundleImpl.js +40 -0
- package/package.json +7 -1
- package/types/protocol.d.ts +1696 -221
- package/types/types.d.ts +879 -112
- package/lib/server/bidi/third_party/bidiDeserializer.js +0 -98
- package/lib/server/chromium/videoRecorder.js +0 -115
- package/lib/server/pageBinding.js +0 -87
- package/lib/server/trace/test/inMemorySnapshotter.js +0 -87
- package/lib/utils/isomorphic/oldUtilityScriptSerializers.js +0 -248
- package/lib/vite/recorder/assets/codeMirrorModule-CBbSe-ZI.js +0 -25
- package/lib/vite/recorder/assets/index-CpZVd2nA.js +0 -193
- package/lib/vite/traceViewer/assets/codeMirrorModule-DHz0wP2C.js +0 -25
- package/lib/vite/traceViewer/assets/defaultSettingsView-WsZP88O6.js +0 -266
- package/lib/vite/traceViewer/defaultSettingsView.ConWv5KN.css +0 -1
- package/lib/vite/traceViewer/index.C4Y3Aw8n.css +0 -1
- package/lib/vite/traceViewer/index.C8xAeo93.js +0 -2
- package/lib/vite/traceViewer/uiMode.BltraIJB.js +0 -5
- /package/lib/{server/utils → utils/isomorphic}/imageUtils.js +0 -0
- /package/lib/utils/isomorphic/{traceUtils.js → trace/traceUtils.js} +0 -0
package/lib/cli/program.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,39 +15,25 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var program_exports = {};
|
|
30
20
|
__export(program_exports, {
|
|
31
21
|
program: () => import_utilsBundle2.program
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(program_exports);
|
|
34
|
-
var
|
|
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");
|
|
24
|
+
var import_bootstrap = require("../bootstrap");
|
|
40
25
|
var import_utils = require("../utils");
|
|
41
|
-
var
|
|
42
|
-
var import_utils2 = require("../utils");
|
|
43
|
-
var import_ascii = require("../server/utils/ascii");
|
|
26
|
+
var import_traceCli = require("../tools/trace/traceCli");
|
|
44
27
|
var import_utilsBundle = require("../utilsBundle");
|
|
45
28
|
var import_utilsBundle2 = require("../utilsBundle");
|
|
46
29
|
const packageJSON = require("../../package.json");
|
|
47
30
|
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
|
-
|
|
50
|
-
(
|
|
31
|
+
import_utilsBundle.program.command("mark-docker-image [dockerImageNameTemplate]", { hidden: true }).description("mark docker image").allowUnknownOption(true).action(async function(dockerImageNameTemplate) {
|
|
32
|
+
const { markDockerImage } = require("./installActions");
|
|
33
|
+
markDockerImage(dockerImageNameTemplate).catch(logErrorAndExit);
|
|
51
34
|
});
|
|
52
|
-
commandWithOpenOptions("open [url]", "open page in browser specified via -b, --browser", []).action(function(url, options) {
|
|
35
|
+
commandWithOpenOptions("open [url]", "open page in browser specified via -b, --browser", []).action(async function(url, options) {
|
|
36
|
+
const { open } = require("./browserActions");
|
|
53
37
|
open(options, url).catch(logErrorAndExit);
|
|
54
38
|
}).addHelpText("afterAll", `
|
|
55
39
|
Examples:
|
|
@@ -65,6 +49,7 @@ commandWithOpenOptions(
|
|
|
65
49
|
["--test-id-attribute <attributeName>", "use the specified attribute to generate data test ID selectors"]
|
|
66
50
|
]
|
|
67
51
|
).action(async function(url, options) {
|
|
52
|
+
const { codegen } = require("./browserActions");
|
|
68
53
|
await codegen(options, url);
|
|
69
54
|
}).addHelpText("afterAll", `
|
|
70
55
|
Examples:
|
|
@@ -72,112 +57,10 @@ Examples:
|
|
|
72
57
|
$ codegen
|
|
73
58
|
$ codegen --target=python
|
|
74
59
|
$ codegen -b webkit https://example.com`);
|
|
75
|
-
|
|
76
|
-
const browserPaths = /* @__PURE__ */ new Set();
|
|
77
|
-
for (const browser of browsers2)
|
|
78
|
-
browserPaths.add(browser.browserPath);
|
|
79
|
-
console.log(` Browsers:`);
|
|
80
|
-
for (const browserPath of [...browserPaths].sort())
|
|
81
|
-
console.log(` ${browserPath}`);
|
|
82
|
-
console.log(` References:`);
|
|
83
|
-
const references = /* @__PURE__ */ new Set();
|
|
84
|
-
for (const browser of browsers2)
|
|
85
|
-
references.add(browser.referenceDir);
|
|
86
|
-
for (const reference of [...references].sort())
|
|
87
|
-
console.log(` ${reference}`);
|
|
88
|
-
}
|
|
89
|
-
function printGroupedByPlaywrightVersion(browsers2) {
|
|
90
|
-
const dirToVersion = /* @__PURE__ */ new Map();
|
|
91
|
-
for (const browser of browsers2) {
|
|
92
|
-
if (dirToVersion.has(browser.referenceDir))
|
|
93
|
-
continue;
|
|
94
|
-
const packageJSON2 = require(import_path.default.join(browser.referenceDir, "package.json"));
|
|
95
|
-
const version = packageJSON2.version;
|
|
96
|
-
dirToVersion.set(browser.referenceDir, version);
|
|
97
|
-
}
|
|
98
|
-
const groupedByPlaywrightMinorVersion = /* @__PURE__ */ new Map();
|
|
99
|
-
for (const browser of browsers2) {
|
|
100
|
-
const version = dirToVersion.get(browser.referenceDir);
|
|
101
|
-
let entries = groupedByPlaywrightMinorVersion.get(version);
|
|
102
|
-
if (!entries) {
|
|
103
|
-
entries = [];
|
|
104
|
-
groupedByPlaywrightMinorVersion.set(version, entries);
|
|
105
|
-
}
|
|
106
|
-
entries.push(browser);
|
|
107
|
-
}
|
|
108
|
-
const sortedVersions = [...groupedByPlaywrightMinorVersion.keys()].sort((a, b) => {
|
|
109
|
-
const aComponents = a.split(".");
|
|
110
|
-
const bComponents = b.split(".");
|
|
111
|
-
const aMajor = parseInt(aComponents[0], 10);
|
|
112
|
-
const bMajor = parseInt(bComponents[0], 10);
|
|
113
|
-
if (aMajor !== bMajor)
|
|
114
|
-
return aMajor - bMajor;
|
|
115
|
-
const aMinor = parseInt(aComponents[1], 10);
|
|
116
|
-
const bMinor = parseInt(bComponents[1], 10);
|
|
117
|
-
if (aMinor !== bMinor)
|
|
118
|
-
return aMinor - bMinor;
|
|
119
|
-
return aComponents.slice(2).join(".").localeCompare(bComponents.slice(2).join("."));
|
|
120
|
-
});
|
|
121
|
-
for (const version of sortedVersions) {
|
|
122
|
-
console.log(`
|
|
123
|
-
Playwright version: ${version}`);
|
|
124
|
-
printInstalledBrowsers(groupedByPlaywrightMinorVersion.get(version));
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
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) {
|
|
128
|
-
if ((0, import_utils.isLikelyNpxGlobal)()) {
|
|
129
|
-
console.error((0, import_ascii.wrapInASCIIBox)([
|
|
130
|
-
`WARNING: It looks like you are running 'npx playwright install' without first`,
|
|
131
|
-
`installing your project's dependencies.`,
|
|
132
|
-
``,
|
|
133
|
-
`To avoid unexpected behavior, please install your dependencies first, and`,
|
|
134
|
-
`then run Playwright's install command:`,
|
|
135
|
-
``,
|
|
136
|
-
` npm install`,
|
|
137
|
-
` npx playwright install`,
|
|
138
|
-
``,
|
|
139
|
-
`If your project does not yet depend on Playwright, first install the`,
|
|
140
|
-
`applicable npm package (most commonly @playwright/test), and`,
|
|
141
|
-
`then run Playwright's install command to download the browsers:`,
|
|
142
|
-
``,
|
|
143
|
-
` npm install @playwright/test`,
|
|
144
|
-
` npx playwright install`,
|
|
145
|
-
``
|
|
146
|
-
].join("\n"), 1));
|
|
147
|
-
}
|
|
60
|
+
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 already installed browsers").option("--only-shell", "only install headless shell when installing chromium").option("--no-shell", "do not install chromium headless shell").action(async function(args, options) {
|
|
148
61
|
try {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const shell = options.shell === false ? "no" : options.onlyShell ? "only" : void 0;
|
|
152
|
-
const executables = import_server.registry.resolveBrowsers(args, { shell });
|
|
153
|
-
if (options.withDeps)
|
|
154
|
-
await import_server.registry.installDeps(executables, !!options.dryRun);
|
|
155
|
-
if (options.dryRun && options.list)
|
|
156
|
-
throw new Error(`Only one of --dry-run and --list can be specified`);
|
|
157
|
-
if (options.dryRun) {
|
|
158
|
-
for (const executable of executables) {
|
|
159
|
-
const version = executable.browserVersion ? `version ` + executable.browserVersion : "";
|
|
160
|
-
console.log(`browser: ${executable.name}${version ? " " + version : ""}`);
|
|
161
|
-
console.log(` Install location: ${executable.directory ?? "<system>"}`);
|
|
162
|
-
if (executable.downloadURLs?.length) {
|
|
163
|
-
const [url, ...fallbacks] = executable.downloadURLs;
|
|
164
|
-
console.log(` Download url: ${url}`);
|
|
165
|
-
for (let i = 0; i < fallbacks.length; ++i)
|
|
166
|
-
console.log(` Download fallback ${i + 1}: ${fallbacks[i]}`);
|
|
167
|
-
}
|
|
168
|
-
console.log(``);
|
|
169
|
-
}
|
|
170
|
-
} else if (options.list) {
|
|
171
|
-
const browsers2 = await import_server.registry.listInstalledBrowsers();
|
|
172
|
-
printGroupedByPlaywrightVersion(browsers2);
|
|
173
|
-
} else {
|
|
174
|
-
const force = args.length === 0 ? false : !!options.force;
|
|
175
|
-
await import_server.registry.install(executables, { force });
|
|
176
|
-
await import_server.registry.validateHostRequirementsForExecutablesIfNeeded(executables, process.env.PW_LANG_NAME || "javascript").catch((e) => {
|
|
177
|
-
e.name = "Playwright Host validation warning";
|
|
178
|
-
console.error(e);
|
|
179
|
-
});
|
|
180
|
-
}
|
|
62
|
+
const { installBrowsers } = require("./installActions");
|
|
63
|
+
await installBrowsers(args, options);
|
|
181
64
|
} catch (e) {
|
|
182
65
|
console.log(`Failed to install browsers
|
|
183
66
|
${e}`);
|
|
@@ -190,20 +73,15 @@ Examples:
|
|
|
190
73
|
Install default browsers.
|
|
191
74
|
|
|
192
75
|
- $ install chrome firefox
|
|
193
|
-
Install custom browsers, supports
|
|
76
|
+
Install custom browsers, supports chromium, firefox, webkit, chromium-headless-shell.`);
|
|
194
77
|
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) => {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (!options.all && numberOfBrowsersLeft > 0) {
|
|
198
|
-
console.log("Successfully uninstalled Playwright browsers for the current Playwright installation.");
|
|
199
|
-
console.log(`There are still ${numberOfBrowsersLeft} browsers left, used by other Playwright installations.
|
|
200
|
-
To uninstall Playwright browsers for all installations, re-run with --all flag.`);
|
|
201
|
-
}
|
|
202
|
-
}).catch(logErrorAndExit);
|
|
78
|
+
const { uninstallBrowsers } = require("./installActions");
|
|
79
|
+
uninstallBrowsers(options).catch(logErrorAndExit);
|
|
203
80
|
});
|
|
204
81
|
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) {
|
|
205
82
|
try {
|
|
206
|
-
|
|
83
|
+
const { installDeps } = require("./installActions");
|
|
84
|
+
await installDeps(args, options);
|
|
207
85
|
} catch (e) {
|
|
208
86
|
console.log(`Failed to install browser dependencies
|
|
209
87
|
${e}`);
|
|
@@ -215,14 +93,15 @@ Examples:
|
|
|
215
93
|
Install dependencies for default browsers.
|
|
216
94
|
|
|
217
95
|
- $ install-deps chrome firefox
|
|
218
|
-
Install dependencies for specific browsers, supports
|
|
96
|
+
Install dependencies for specific browsers, supports chromium, firefox, webkit, chromium-headless-shell.`);
|
|
219
97
|
const browsers = [
|
|
220
98
|
{ alias: "cr", name: "Chromium", type: "chromium" },
|
|
221
99
|
{ alias: "ff", name: "Firefox", type: "firefox" },
|
|
222
100
|
{ alias: "wk", name: "WebKit", type: "webkit" }
|
|
223
101
|
];
|
|
224
102
|
for (const { alias, name, type } of browsers) {
|
|
225
|
-
commandWithOpenOptions(`${alias} [url]`, `open page in ${name}`, []).action(function(url, options) {
|
|
103
|
+
commandWithOpenOptions(`${alias} [url]`, `open page in ${name}`, []).action(async function(url, options) {
|
|
104
|
+
const { open } = require("./browserActions");
|
|
226
105
|
open({ ...options, browser: type }, url).catch(logErrorAndExit);
|
|
227
106
|
}).addHelpText("afterAll", `
|
|
228
107
|
Examples:
|
|
@@ -237,7 +116,8 @@ commandWithOpenOptions(
|
|
|
237
116
|
["--wait-for-timeout <timeout>", "wait for timeout in milliseconds before taking a screenshot"],
|
|
238
117
|
["--full-page", "whether to take a full page screenshot (entire scrollable area)"]
|
|
239
118
|
]
|
|
240
|
-
).action(function(url, filename, command) {
|
|
119
|
+
).action(async function(url, filename, command) {
|
|
120
|
+
const { screenshot } = require("./browserActions");
|
|
241
121
|
screenshot(command, command, url, filename).catch(logErrorAndExit);
|
|
242
122
|
}).addHelpText("afterAll", `
|
|
243
123
|
Examples:
|
|
@@ -251,31 +131,37 @@ commandWithOpenOptions(
|
|
|
251
131
|
["--wait-for-selector <selector>", "wait for given selector before saving as pdf"],
|
|
252
132
|
["--wait-for-timeout <timeout>", "wait for given timeout in milliseconds before saving as pdf"]
|
|
253
133
|
]
|
|
254
|
-
).action(function(url, filename, options) {
|
|
134
|
+
).action(async function(url, filename, options) {
|
|
135
|
+
const { pdf } = require("./browserActions");
|
|
255
136
|
pdf(options, options, url, filename).catch(logErrorAndExit);
|
|
256
137
|
}).addHelpText("afterAll", `
|
|
257
138
|
Examples:
|
|
258
139
|
|
|
259
140
|
$ pdf https://example.com example.pdf`);
|
|
260
|
-
import_utilsBundle.program.command("run-driver", { hidden: true }).action(function(options) {
|
|
261
|
-
|
|
141
|
+
import_utilsBundle.program.command("run-driver", { hidden: true }).action(async function(options) {
|
|
142
|
+
const { runDriver } = require("./driver");
|
|
143
|
+
runDriver();
|
|
262
144
|
});
|
|
263
|
-
import_utilsBundle.program.command("run-server", { hidden: true }).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) {
|
|
264
|
-
|
|
145
|
+
import_utilsBundle.program.command("run-server", { hidden: true }).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"').option("--artifacts-dir <artifactsDir>", "Artifacts directory").action(async function(options) {
|
|
146
|
+
const { runServer } = require("./driver");
|
|
147
|
+
runServer({
|
|
265
148
|
port: options.port ? +options.port : void 0,
|
|
266
149
|
host: options.host,
|
|
267
150
|
path: options.path,
|
|
268
151
|
maxConnections: options.maxClients ? +options.maxClients : Infinity,
|
|
269
|
-
extension: options.mode === "extension" || !!process.env.PW_EXTENSION_MODE
|
|
152
|
+
extension: options.mode === "extension" || !!process.env.PW_EXTENSION_MODE,
|
|
153
|
+
artifactsDir: options.artifactsDir
|
|
270
154
|
}).catch(logErrorAndExit);
|
|
271
155
|
});
|
|
272
|
-
import_utilsBundle.program.command("print-api-json", { hidden: true }).action(function(options) {
|
|
273
|
-
|
|
156
|
+
import_utilsBundle.program.command("print-api-json", { hidden: true }).action(async function(options) {
|
|
157
|
+
const { printApiJson } = require("./driver");
|
|
158
|
+
printApiJson();
|
|
274
159
|
});
|
|
275
|
-
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) {
|
|
276
|
-
|
|
160
|
+
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(async function(options) {
|
|
161
|
+
const { launchBrowserServer } = require("./driver");
|
|
162
|
+
launchBrowserServer(options.browser, options.config);
|
|
277
163
|
});
|
|
278
|
-
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) {
|
|
164
|
+
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(async function(trace, options) {
|
|
279
165
|
if (options.browser === "cr")
|
|
280
166
|
options.browser = "chromium";
|
|
281
167
|
if (options.browser === "ff")
|
|
@@ -287,273 +173,22 @@ import_utilsBundle.program.command("show-trace [trace]").option("-b, --browser <
|
|
|
287
173
|
port: +options.port,
|
|
288
174
|
isServer: !!options.stdin
|
|
289
175
|
};
|
|
176
|
+
const { runTraceInBrowser, runTraceViewerApp } = require("../server/trace/viewer/traceViewer");
|
|
290
177
|
if (options.port !== void 0 || options.host !== void 0)
|
|
291
|
-
|
|
178
|
+
runTraceInBrowser(trace, openOptions).catch(logErrorAndExit);
|
|
292
179
|
else
|
|
293
|
-
|
|
180
|
+
runTraceViewerApp(trace, options.browser, openOptions).catch(logErrorAndExit);
|
|
294
181
|
}).addHelpText("afterAll", `
|
|
295
182
|
Examples:
|
|
296
183
|
|
|
297
184
|
$ show-trace
|
|
298
185
|
$ show-trace https://example.com/trace.zip`);
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
launchOptions.handleSIGINT = false;
|
|
306
|
-
const contextOptions = (
|
|
307
|
-
// Copy the device descriptor since we have to compare and modify the options.
|
|
308
|
-
options.device ? { ...playwright.devices[options.device] } : {}
|
|
309
|
-
);
|
|
310
|
-
if (!extraOptions.headless)
|
|
311
|
-
contextOptions.deviceScaleFactor = import_os.default.platform() === "darwin" ? 2 : 1;
|
|
312
|
-
if (browserType.name() === "webkit" && process.platform === "linux") {
|
|
313
|
-
delete contextOptions.hasTouch;
|
|
314
|
-
delete contextOptions.isMobile;
|
|
315
|
-
}
|
|
316
|
-
if (contextOptions.isMobile && browserType.name() === "firefox")
|
|
317
|
-
contextOptions.isMobile = void 0;
|
|
318
|
-
if (options.blockServiceWorkers)
|
|
319
|
-
contextOptions.serviceWorkers = "block";
|
|
320
|
-
if (options.proxyServer) {
|
|
321
|
-
launchOptions.proxy = {
|
|
322
|
-
server: options.proxyServer
|
|
323
|
-
};
|
|
324
|
-
if (options.proxyBypass)
|
|
325
|
-
launchOptions.proxy.bypass = options.proxyBypass;
|
|
326
|
-
}
|
|
327
|
-
if (options.viewportSize) {
|
|
328
|
-
try {
|
|
329
|
-
const [width, height] = options.viewportSize.split(",").map((n) => +n);
|
|
330
|
-
if (isNaN(width) || isNaN(height))
|
|
331
|
-
throw new Error("bad values");
|
|
332
|
-
contextOptions.viewport = { width, height };
|
|
333
|
-
} catch (e) {
|
|
334
|
-
throw new Error('Invalid viewport size format: use "width,height", for example --viewport-size="800,600"');
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
if (options.geolocation) {
|
|
338
|
-
try {
|
|
339
|
-
const [latitude, longitude] = options.geolocation.split(",").map((n) => parseFloat(n.trim()));
|
|
340
|
-
contextOptions.geolocation = {
|
|
341
|
-
latitude,
|
|
342
|
-
longitude
|
|
343
|
-
};
|
|
344
|
-
} catch (e) {
|
|
345
|
-
throw new Error('Invalid geolocation format, should be "lat,long". For example --geolocation="37.819722,-122.478611"');
|
|
346
|
-
}
|
|
347
|
-
contextOptions.permissions = ["geolocation"];
|
|
348
|
-
}
|
|
349
|
-
if (options.userAgent)
|
|
350
|
-
contextOptions.userAgent = options.userAgent;
|
|
351
|
-
if (options.lang)
|
|
352
|
-
contextOptions.locale = options.lang;
|
|
353
|
-
if (options.colorScheme)
|
|
354
|
-
contextOptions.colorScheme = options.colorScheme;
|
|
355
|
-
if (options.timezone)
|
|
356
|
-
contextOptions.timezoneId = options.timezone;
|
|
357
|
-
if (options.loadStorage)
|
|
358
|
-
contextOptions.storageState = options.loadStorage;
|
|
359
|
-
if (options.ignoreHttpsErrors)
|
|
360
|
-
contextOptions.ignoreHTTPSErrors = true;
|
|
361
|
-
if (options.saveHar) {
|
|
362
|
-
contextOptions.recordHar = { path: import_path.default.resolve(process.cwd(), options.saveHar), mode: "minimal" };
|
|
363
|
-
if (options.saveHarGlob)
|
|
364
|
-
contextOptions.recordHar.urlFilter = options.saveHarGlob;
|
|
365
|
-
contextOptions.serviceWorkers = "block";
|
|
366
|
-
}
|
|
367
|
-
let browser;
|
|
368
|
-
let context;
|
|
369
|
-
if (options.userDataDir) {
|
|
370
|
-
context = await browserType.launchPersistentContext(options.userDataDir, { ...launchOptions, ...contextOptions });
|
|
371
|
-
browser = context.browser();
|
|
372
|
-
} else {
|
|
373
|
-
browser = await browserType.launch(launchOptions);
|
|
374
|
-
context = await browser.newContext(contextOptions);
|
|
375
|
-
}
|
|
376
|
-
let closingBrowser = false;
|
|
377
|
-
async function closeBrowser() {
|
|
378
|
-
if (closingBrowser)
|
|
379
|
-
return;
|
|
380
|
-
closingBrowser = true;
|
|
381
|
-
if (options.saveStorage)
|
|
382
|
-
await context.storageState({ path: options.saveStorage }).catch((e) => null);
|
|
383
|
-
if (options.saveHar)
|
|
384
|
-
await context.close();
|
|
385
|
-
await browser.close();
|
|
386
|
-
}
|
|
387
|
-
context.on("page", (page) => {
|
|
388
|
-
page.on("dialog", () => {
|
|
389
|
-
});
|
|
390
|
-
page.on("close", () => {
|
|
391
|
-
const hasPage = browser.contexts().some((context2) => context2.pages().length > 0);
|
|
392
|
-
if (hasPage)
|
|
393
|
-
return;
|
|
394
|
-
closeBrowser().catch(() => {
|
|
395
|
-
});
|
|
396
|
-
});
|
|
397
|
-
});
|
|
398
|
-
process.on("SIGINT", async () => {
|
|
399
|
-
await closeBrowser();
|
|
400
|
-
(0, import_utils.gracefullyProcessExitDoNotHang)(130);
|
|
401
|
-
});
|
|
402
|
-
const timeout = options.timeout ? parseInt(options.timeout, 10) : 0;
|
|
403
|
-
context.setDefaultTimeout(timeout);
|
|
404
|
-
context.setDefaultNavigationTimeout(timeout);
|
|
405
|
-
delete launchOptions.headless;
|
|
406
|
-
delete launchOptions.executablePath;
|
|
407
|
-
delete launchOptions.handleSIGINT;
|
|
408
|
-
delete contextOptions.deviceScaleFactor;
|
|
409
|
-
return { browser, browserName: browserType.name(), context, contextOptions, launchOptions, closeBrowser };
|
|
410
|
-
}
|
|
411
|
-
async function openPage(context, url) {
|
|
412
|
-
let page = context.pages()[0];
|
|
413
|
-
if (!page)
|
|
414
|
-
page = await context.newPage();
|
|
415
|
-
if (url) {
|
|
416
|
-
if (import_fs.default.existsSync(url))
|
|
417
|
-
url = "file://" + import_path.default.resolve(url);
|
|
418
|
-
else if (!url.startsWith("http") && !url.startsWith("file://") && !url.startsWith("about:") && !url.startsWith("data:"))
|
|
419
|
-
url = "http://" + url;
|
|
420
|
-
await page.goto(url);
|
|
421
|
-
}
|
|
422
|
-
return page;
|
|
423
|
-
}
|
|
424
|
-
async function open(options, url) {
|
|
425
|
-
const { context } = await launchContext(options, { headless: !!process.env.PWTEST_CLI_HEADLESS, executablePath: process.env.PWTEST_CLI_EXECUTABLE_PATH });
|
|
426
|
-
await openPage(context, url);
|
|
427
|
-
}
|
|
428
|
-
async function codegen(options, url) {
|
|
429
|
-
const { target: language, output: outputFile, testIdAttribute: testIdAttributeName } = options;
|
|
430
|
-
const tracesDir = import_path.default.join(import_os.default.tmpdir(), `playwright-recorder-trace-${Date.now()}`);
|
|
431
|
-
const { context, browser, launchOptions, contextOptions, closeBrowser } = await launchContext(options, {
|
|
432
|
-
headless: !!process.env.PWTEST_CLI_HEADLESS,
|
|
433
|
-
executablePath: process.env.PWTEST_CLI_EXECUTABLE_PATH,
|
|
434
|
-
tracesDir
|
|
435
|
-
});
|
|
436
|
-
const donePromise = new import_utils.ManualPromise();
|
|
437
|
-
maybeSetupTestHooks(browser, closeBrowser, donePromise);
|
|
438
|
-
import_utilsBundle.dotenv.config({ path: "playwright.env" });
|
|
439
|
-
await context._enableRecorder({
|
|
440
|
-
language,
|
|
441
|
-
launchOptions,
|
|
442
|
-
contextOptions,
|
|
443
|
-
device: options.device,
|
|
444
|
-
saveStorage: options.saveStorage,
|
|
445
|
-
mode: "recording",
|
|
446
|
-
testIdAttributeName,
|
|
447
|
-
outputFile: outputFile ? import_path.default.resolve(outputFile) : void 0,
|
|
448
|
-
handleSIGINT: false
|
|
449
|
-
});
|
|
450
|
-
await openPage(context, url);
|
|
451
|
-
donePromise.resolve();
|
|
452
|
-
}
|
|
453
|
-
async function maybeSetupTestHooks(browser, closeBrowser, donePromise) {
|
|
454
|
-
if (!process.env.PWTEST_CLI_IS_UNDER_TEST)
|
|
455
|
-
return;
|
|
456
|
-
const logs = [];
|
|
457
|
-
require("playwright-core/lib/utilsBundle").debug.log = (...args) => {
|
|
458
|
-
const line = require("util").format(...args) + "\n";
|
|
459
|
-
logs.push(line);
|
|
460
|
-
process.stderr.write(line);
|
|
461
|
-
};
|
|
462
|
-
browser.on("disconnected", () => {
|
|
463
|
-
const hasCrashLine = logs.some((line) => line.includes("process did exit:") && !line.includes("process did exit: exitCode=0, signal=null"));
|
|
464
|
-
if (hasCrashLine) {
|
|
465
|
-
process.stderr.write("Detected browser crash.\n");
|
|
466
|
-
(0, import_utils.gracefullyProcessExitDoNotHang)(1);
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
const close = async () => {
|
|
470
|
-
await donePromise;
|
|
471
|
-
await closeBrowser();
|
|
472
|
-
};
|
|
473
|
-
if (process.env.PWTEST_CLI_EXIT_AFTER_TIMEOUT) {
|
|
474
|
-
setTimeout(close, +process.env.PWTEST_CLI_EXIT_AFTER_TIMEOUT);
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
let stdin = "";
|
|
478
|
-
process.stdin.on("data", (data) => {
|
|
479
|
-
stdin += data.toString();
|
|
480
|
-
if (stdin.startsWith("exit")) {
|
|
481
|
-
process.stdin.destroy();
|
|
482
|
-
close();
|
|
483
|
-
}
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
|
-
async function waitForPage(page, captureOptions) {
|
|
487
|
-
if (captureOptions.waitForSelector) {
|
|
488
|
-
console.log(`Waiting for selector ${captureOptions.waitForSelector}...`);
|
|
489
|
-
await page.waitForSelector(captureOptions.waitForSelector);
|
|
490
|
-
}
|
|
491
|
-
if (captureOptions.waitForTimeout) {
|
|
492
|
-
console.log(`Waiting for timeout ${captureOptions.waitForTimeout}...`);
|
|
493
|
-
await page.waitForTimeout(parseInt(captureOptions.waitForTimeout, 10));
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
async function screenshot(options, captureOptions, url, path2) {
|
|
497
|
-
const { context } = await launchContext(options, { headless: true });
|
|
498
|
-
console.log("Navigating to " + url);
|
|
499
|
-
const page = await openPage(context, url);
|
|
500
|
-
await waitForPage(page, captureOptions);
|
|
501
|
-
console.log("Capturing screenshot into " + path2);
|
|
502
|
-
await page.screenshot({ path: path2, fullPage: !!captureOptions.fullPage });
|
|
503
|
-
await page.close();
|
|
504
|
-
}
|
|
505
|
-
async function pdf(options, captureOptions, url, path2) {
|
|
506
|
-
if (options.browser !== "chromium")
|
|
507
|
-
throw new Error("PDF creation is only working with Chromium");
|
|
508
|
-
const { context } = await launchContext({ ...options, browser: "chromium" }, { headless: true });
|
|
509
|
-
console.log("Navigating to " + url);
|
|
510
|
-
const page = await openPage(context, url);
|
|
511
|
-
await waitForPage(page, captureOptions);
|
|
512
|
-
console.log("Saving as pdf into " + path2);
|
|
513
|
-
await page.pdf({ path: path2, format: captureOptions.paperFormat });
|
|
514
|
-
await page.close();
|
|
515
|
-
}
|
|
516
|
-
function lookupBrowserType(options) {
|
|
517
|
-
let name = options.browser;
|
|
518
|
-
if (options.device) {
|
|
519
|
-
const device = playwright.devices[options.device];
|
|
520
|
-
name = device.defaultBrowserType;
|
|
521
|
-
}
|
|
522
|
-
let browserType;
|
|
523
|
-
switch (name) {
|
|
524
|
-
case "chromium":
|
|
525
|
-
browserType = playwright.chromium;
|
|
526
|
-
break;
|
|
527
|
-
case "webkit":
|
|
528
|
-
browserType = playwright.webkit;
|
|
529
|
-
break;
|
|
530
|
-
case "firefox":
|
|
531
|
-
browserType = playwright.firefox;
|
|
532
|
-
break;
|
|
533
|
-
case "cr":
|
|
534
|
-
browserType = playwright.chromium;
|
|
535
|
-
break;
|
|
536
|
-
case "wk":
|
|
537
|
-
browserType = playwright.webkit;
|
|
538
|
-
break;
|
|
539
|
-
case "ff":
|
|
540
|
-
browserType = playwright.firefox;
|
|
541
|
-
break;
|
|
542
|
-
}
|
|
543
|
-
if (browserType)
|
|
544
|
-
return browserType;
|
|
545
|
-
import_utilsBundle.program.help();
|
|
546
|
-
}
|
|
547
|
-
function validateOptions(options) {
|
|
548
|
-
if (options.device && !(options.device in playwright.devices)) {
|
|
549
|
-
const lines = [`Device descriptor not found: '${options.device}', available devices are:`];
|
|
550
|
-
for (const name in playwright.devices)
|
|
551
|
-
lines.push(` "${name}"`);
|
|
552
|
-
throw new Error(lines.join("\n"));
|
|
553
|
-
}
|
|
554
|
-
if (options.colorScheme && !["light", "dark"].includes(options.colorScheme))
|
|
555
|
-
throw new Error('Invalid color scheme, should be one of "light", "dark"');
|
|
556
|
-
}
|
|
186
|
+
(0, import_traceCli.addTraceCommands)(import_utilsBundle.program, logErrorAndExit);
|
|
187
|
+
import_utilsBundle.program.command("cli", { hidden: true }).allowExcessArguments(true).allowUnknownOption(true).action(async (options) => {
|
|
188
|
+
const { program: cliProgram } = require("../tools/cli-client/program");
|
|
189
|
+
process.argv.splice(process.argv.indexOf("cli"), 1);
|
|
190
|
+
cliProgram().catch(logErrorAndExit);
|
|
191
|
+
});
|
|
557
192
|
function logErrorAndExit(e) {
|
|
558
193
|
if (process.env.PWDEBUGIMPL)
|
|
559
194
|
console.error(e);
|
|
@@ -579,7 +214,7 @@ function buildBasePlaywrightCLICommand(cliTargetLang) {
|
|
|
579
214
|
case "csharp":
|
|
580
215
|
return `pwsh bin/Debug/netX/playwright.ps1`;
|
|
581
216
|
default: {
|
|
582
|
-
const packageManagerCommand = (0,
|
|
217
|
+
const packageManagerCommand = (0, import_utils.getPackageManagerExecCommand)();
|
|
583
218
|
return `${packageManagerCommand} playwright`;
|
|
584
219
|
}
|
|
585
220
|
}
|
package/lib/client/android.js
CHANGED
|
@@ -35,7 +35,7 @@ var import_timeoutSettings = require("./timeoutSettings");
|
|
|
35
35
|
var import_rtti = require("../utils/isomorphic/rtti");
|
|
36
36
|
var import_time = require("../utils/isomorphic/time");
|
|
37
37
|
var import_timeoutRunner = require("../utils/isomorphic/timeoutRunner");
|
|
38
|
-
var
|
|
38
|
+
var import_connect = require("./connect");
|
|
39
39
|
class Android extends import_channelOwner.ChannelOwner {
|
|
40
40
|
static from(android) {
|
|
41
41
|
return android._object;
|
|
@@ -56,12 +56,12 @@ class Android extends import_channelOwner.ChannelOwner {
|
|
|
56
56
|
throw new Error("Launching server is not supported");
|
|
57
57
|
return await this._serverLauncher.launchServer(options);
|
|
58
58
|
}
|
|
59
|
-
async connect(
|
|
59
|
+
async connect(endpoint, options = {}) {
|
|
60
60
|
return await this._wrapApiCall(async () => {
|
|
61
61
|
const deadline = options.timeout ? (0, import_time.monotonicTime)() + options.timeout : 0;
|
|
62
62
|
const headers = { "x-playwright-browser": "android", ...options.headers };
|
|
63
|
-
const connectParams = {
|
|
64
|
-
const connection = await (0,
|
|
63
|
+
const connectParams = { endpoint, headers, slowMo: options.slowMo, timeout: options.timeout || 0 };
|
|
64
|
+
const connection = await (0, import_connect.connectToEndpoint)(this._connection, connectParams);
|
|
65
65
|
let device;
|
|
66
66
|
connection.on("close", () => {
|
|
67
67
|
device?._didClose();
|
package/lib/client/api.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(api_exports, {
|
|
|
33
33
|
Clock: () => import_clock.Clock,
|
|
34
34
|
ConsoleMessage: () => import_consoleMessage.ConsoleMessage,
|
|
35
35
|
Coverage: () => import_coverage.Coverage,
|
|
36
|
+
Debugger: () => import_debugger.Debugger,
|
|
36
37
|
Dialog: () => import_dialog.Dialog,
|
|
37
38
|
Download: () => import_download.Download,
|
|
38
39
|
Electron: () => import_electron.Electron,
|
|
@@ -68,6 +69,7 @@ var import_browserType = require("./browserType");
|
|
|
68
69
|
var import_clock = require("./clock");
|
|
69
70
|
var import_consoleMessage = require("./consoleMessage");
|
|
70
71
|
var import_coverage = require("./coverage");
|
|
72
|
+
var import_debugger = require("./debugger");
|
|
71
73
|
var import_dialog = require("./dialog");
|
|
72
74
|
var import_download = require("./download");
|
|
73
75
|
var import_electron = require("./electron");
|
|
@@ -105,6 +107,7 @@ var import_webError = require("./webError");
|
|
|
105
107
|
Clock,
|
|
106
108
|
ConsoleMessage,
|
|
107
109
|
Coverage,
|
|
110
|
+
Debugger,
|
|
108
111
|
Dialog,
|
|
109
112
|
Download,
|
|
110
113
|
Electron,
|
package/lib/client/browser.js
CHANGED
|
@@ -36,6 +36,7 @@ class Browser extends import_channelOwner.ChannelOwner {
|
|
|
36
36
|
this._shouldCloseConnectionOnClose = false;
|
|
37
37
|
this._options = {};
|
|
38
38
|
this._name = initializer.name;
|
|
39
|
+
this._browserName = initializer.browserName;
|
|
39
40
|
this._channel.on("context", ({ context }) => this._didCreateContext(import_browserContext.BrowserContext.from(context)));
|
|
40
41
|
this._channel.on("close", () => this._didClose());
|
|
41
42
|
this._closedPromise = new Promise((f) => this.once(import_events.Events.Browser.Disconnected, f));
|
|
@@ -62,11 +63,9 @@ class Browser extends import_channelOwner.ChannelOwner {
|
|
|
62
63
|
context._onClose();
|
|
63
64
|
await this._channel.disconnectFromReusedContext({ reason });
|
|
64
65
|
}
|
|
65
|
-
async _innerNewContext(
|
|
66
|
-
options = this._browserType._playwright.selectors._withSelectorOptions(
|
|
67
|
-
|
|
68
|
-
...options
|
|
69
|
-
});
|
|
66
|
+
async _innerNewContext(userOptions = {}, forReuse) {
|
|
67
|
+
const options = this._browserType._playwright.selectors._withSelectorOptions(userOptions);
|
|
68
|
+
await this._instrumentation.runBeforeCreateBrowserContext(options);
|
|
70
69
|
const contextOptions = await (0, import_browserContext.prepareBrowserContextParams)(this._platform, options);
|
|
71
70
|
const response = forReuse ? await this._channel.newContextForReuse(contextOptions) : await this._channel.newContext(contextOptions);
|
|
72
71
|
const context = import_browserContext.BrowserContext.from(response.context);
|
|
@@ -105,6 +104,13 @@ class Browser extends import_channelOwner.ChannelOwner {
|
|
|
105
104
|
version() {
|
|
106
105
|
return this._initializer.version;
|
|
107
106
|
}
|
|
107
|
+
async bind(title, options = {}) {
|
|
108
|
+
const { endpoint } = await this._channel.startServer({ title, ...options });
|
|
109
|
+
return { endpoint };
|
|
110
|
+
}
|
|
111
|
+
async unbind() {
|
|
112
|
+
await this._channel.stopServer();
|
|
113
|
+
}
|
|
108
114
|
async newPage(options = {}) {
|
|
109
115
|
return await this._wrapApiCall(async () => {
|
|
110
116
|
const context = await this.newContext(options);
|