playwright 1.56.0-alpha-2025-09-11 → 1.56.0-alpha-1757624765000
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/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 🎭 Playwright
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/playwright) <!-- GEN:chromium-version-badge -->[](https://www.npmjs.com/package/playwright) <!-- GEN:chromium-version-badge -->[](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> <!-- GEN:webkit-version-badge -->[](https://webkit.org/)<!-- GEN:stop --> [](https://aka.ms/playwright/discord)
|
|
4
4
|
|
|
5
5
|
## [Documentation](https://playwright.dev) | [API reference](https://playwright.dev/docs/api/class-playwright)
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ Playwright is a framework for Web Testing and Automation. It allows testing [Chr
|
|
|
8
8
|
|
|
9
9
|
| | Linux | macOS | Windows |
|
|
10
10
|
| :--- | :---: | :---: | :---: |
|
|
11
|
-
| Chromium <!-- GEN:chromium-version -->141.0.7390.
|
|
11
|
+
| Chromium <!-- GEN:chromium-version -->141.0.7390.16<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
|
12
12
|
| WebKit <!-- GEN:webkit-version -->26.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
|
13
13
|
| Firefox <!-- GEN:firefox-version -->142.0.1<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
|
14
14
|
|
|
@@ -38,6 +38,7 @@ var import_path = __toESM(require("path"));
|
|
|
38
38
|
var playwright = __toESM(require("playwright-core"));
|
|
39
39
|
var import_registry = require("playwright-core/lib/server/registry/index");
|
|
40
40
|
var import_server = require("playwright-core/lib/server");
|
|
41
|
+
var import_processUtils = require("./processUtils");
|
|
41
42
|
var import_log = require("../log");
|
|
42
43
|
var import_config = require("./config");
|
|
43
44
|
function contextFactory(config) {
|
|
@@ -160,32 +161,32 @@ class PersistentContextFactory {
|
|
|
160
161
|
(0, import_log.testDebug)("lock user data dir", userDataDir);
|
|
161
162
|
const browserType = playwright[this.config.browser.browserName];
|
|
162
163
|
for (let i = 0; i < 5; i++) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
164
|
+
if (!await alreadyRunning(this.config, browserType, userDataDir))
|
|
165
|
+
break;
|
|
166
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
167
|
+
}
|
|
168
|
+
const launchOptions = {
|
|
169
|
+
tracesDir,
|
|
170
|
+
...this.config.browser.launchOptions,
|
|
171
|
+
...this.config.browser.contextOptions,
|
|
172
|
+
handleSIGINT: false,
|
|
173
|
+
handleSIGTERM: false,
|
|
174
|
+
ignoreDefaultArgs: [
|
|
175
|
+
"--disable-extensions"
|
|
176
|
+
],
|
|
177
|
+
assistantMode: true
|
|
178
|
+
};
|
|
179
|
+
try {
|
|
180
|
+
const browserContext = await browserType.launchPersistentContext(userDataDir, launchOptions);
|
|
181
|
+
const close = () => this._closeBrowserContext(browserContext, userDataDir);
|
|
182
|
+
return { browserContext, close };
|
|
183
|
+
} catch (error) {
|
|
184
|
+
if (error.message.includes("Executable doesn't exist"))
|
|
185
|
+
throw new Error(`Browser specified in your config is not installed. Either install it (likely) or change the config.`);
|
|
186
|
+
if (error.message.includes("ProcessSingleton") || error.message.includes("Invalid URL"))
|
|
187
|
+
throw new Error(`Browser is already in use for ${userDataDir}, use --isolated to run multiple instances of the same browser`);
|
|
188
|
+
throw error;
|
|
187
189
|
}
|
|
188
|
-
throw new Error(`Browser is already in use for ${userDataDir}, use --isolated to run multiple instances of the same browser`);
|
|
189
190
|
}
|
|
190
191
|
async _closeBrowserContext(browserContext, userDataDir) {
|
|
191
192
|
(0, import_log.testDebug)("close browser context (persistent)");
|
|
@@ -204,6 +205,12 @@ class PersistentContextFactory {
|
|
|
204
205
|
return result;
|
|
205
206
|
}
|
|
206
207
|
}
|
|
208
|
+
async function alreadyRunning(config, browserType, userDataDir) {
|
|
209
|
+
const execPath = config.browser.launchOptions.executablePath ?? (0, import_processUtils.getBrowserExecPath)(config.browser.launchOptions.channel ?? browserType.name());
|
|
210
|
+
if (!execPath)
|
|
211
|
+
return false;
|
|
212
|
+
return !!(0, import_processUtils.findBrowserProcess)(execPath, userDataDir);
|
|
213
|
+
}
|
|
207
214
|
async function injectCdpPort(browserConfig) {
|
|
208
215
|
if (browserConfig.browserName === "chromium")
|
|
209
216
|
browserConfig.launchOptions.cdpPort = await findFreePort();
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var processUtils_exports = {};
|
|
30
|
+
__export(processUtils_exports, {
|
|
31
|
+
findBrowserProcess: () => findBrowserProcess,
|
|
32
|
+
getBrowserExecPath: () => getBrowserExecPath
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(processUtils_exports);
|
|
35
|
+
var import_child_process = __toESM(require("child_process"));
|
|
36
|
+
var import_fs = __toESM(require("fs"));
|
|
37
|
+
var import_registry = require("playwright-core/lib/server/registry/index");
|
|
38
|
+
function getBrowserExecPath(channelOrName) {
|
|
39
|
+
return import_registry.registry.findExecutable(channelOrName)?.executablePath("javascript");
|
|
40
|
+
}
|
|
41
|
+
function findBrowserProcess(execPath, arg) {
|
|
42
|
+
const predicate = (line) => line.includes(execPath) && line.includes(arg) && !line.includes("--type");
|
|
43
|
+
try {
|
|
44
|
+
switch (process.platform) {
|
|
45
|
+
case "darwin":
|
|
46
|
+
return findProcessMacos(predicate);
|
|
47
|
+
case "linux":
|
|
48
|
+
return findProcessLinux(predicate);
|
|
49
|
+
case "win32":
|
|
50
|
+
return findProcessWindows(execPath, arg, predicate);
|
|
51
|
+
default:
|
|
52
|
+
return void 0;
|
|
53
|
+
}
|
|
54
|
+
} catch {
|
|
55
|
+
return void 0;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function findProcessLinux(predicate) {
|
|
59
|
+
const procDirs = import_fs.default.readdirSync("/proc").filter((name) => /^\d+$/.test(name));
|
|
60
|
+
for (const pid of procDirs) {
|
|
61
|
+
try {
|
|
62
|
+
const cmdlineBuffer = import_fs.default.readFileSync(`/proc/${pid}/cmdline`);
|
|
63
|
+
const cmdline = cmdlineBuffer.toString().replace(/\0/g, " ").trim();
|
|
64
|
+
if (predicate(cmdline))
|
|
65
|
+
return `${pid} ${cmdline}`;
|
|
66
|
+
} catch {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return void 0;
|
|
71
|
+
}
|
|
72
|
+
function findProcessMacos(predicate) {
|
|
73
|
+
const result = import_child_process.default.spawnSync("/bin/ps", ["-axo", "pid=,command="]);
|
|
74
|
+
if (result.status !== 0 || !result.stdout)
|
|
75
|
+
return void 0;
|
|
76
|
+
return findMatchingLine(result.stdout.toString(), predicate);
|
|
77
|
+
}
|
|
78
|
+
function findProcessWindows(execPath, arg, predicate) {
|
|
79
|
+
const psEscape = (path) => `'${path.replaceAll("'", "''")}'`;
|
|
80
|
+
const filter = `$_.ExecutablePath -eq ${psEscape(execPath)} -and $_.CommandLine.Contains(${psEscape(arg)}) -and $_.CommandLine -notmatch '--type'`;
|
|
81
|
+
const ps = import_child_process.default.spawnSync(
|
|
82
|
+
"powershell.exe",
|
|
83
|
+
[
|
|
84
|
+
"-NoProfile",
|
|
85
|
+
"-Command",
|
|
86
|
+
`Get-CimInstance Win32_Process | Where-Object { ${filter} } | Select-Object -Property ProcessId,CommandLine | ForEach-Object { "$($_.ProcessId) $($_.CommandLine)" }`
|
|
87
|
+
],
|
|
88
|
+
{ encoding: "utf8" }
|
|
89
|
+
);
|
|
90
|
+
if (ps.status !== 0 || !ps.stdout)
|
|
91
|
+
return void 0;
|
|
92
|
+
return findMatchingLine(ps.stdout.toString(), predicate);
|
|
93
|
+
}
|
|
94
|
+
function findMatchingLine(psOutput, predicate) {
|
|
95
|
+
const lines = psOutput.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
96
|
+
return lines.find(predicate);
|
|
97
|
+
}
|
|
98
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
+
0 && (module.exports = {
|
|
100
|
+
findBrowserProcess,
|
|
101
|
+
getBrowserExecPath
|
|
102
|
+
});
|
package/lib/runner/testRunner.js
CHANGED
|
@@ -71,6 +71,7 @@ class TestRunner extends import_events.default {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
async initialize(params) {
|
|
74
|
+
(0, import_utils.setPlaywrightTestProcessEnv)();
|
|
74
75
|
this._watchTestDirs = !!params.watchTestDirs;
|
|
75
76
|
this._populateDependenciesOnList = !!params.populateDependenciesOnList;
|
|
76
77
|
}
|
|
@@ -352,6 +353,7 @@ async function resolveCtDirs(config) {
|
|
|
352
353
|
};
|
|
353
354
|
}
|
|
354
355
|
async function runAllTestsWithConfig(config) {
|
|
356
|
+
(0, import_utils.setPlaywrightTestProcessEnv)();
|
|
355
357
|
const listOnly = config.cliListOnly;
|
|
356
358
|
(0, import_gitCommitInfoPlugin.addGitCommitInfoPlugin)(config);
|
|
357
359
|
(0, import_webServerPlugin.webServerPluginsForConfig)(config).forEach((p) => config.plugins.push({ factory: p }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playwright",
|
|
3
|
-
"version": "1.56.0-alpha-
|
|
3
|
+
"version": "1.56.0-alpha-1757624765000",
|
|
4
4
|
"description": "A high-level API to automate web browsers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"license": "Apache-2.0",
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"playwright-core": "1.56.0-alpha-
|
|
67
|
+
"playwright-core": "1.56.0-alpha-1757624765000"
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
70
|
"fsevents": "2.3.2"
|