@wdio/utils 9.2.2 → 9.2.5
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/build/index.js +145 -646
- package/build/startWebDriver.d.ts +1 -1
- package/build/startWebDriver.d.ts.map +1 -1
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -1,128 +1,129 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
-
var __esm = (fn, res) => function __init() {
|
|
4
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
|
-
};
|
|
6
2
|
var __export = (target, all) => {
|
|
7
3
|
for (var name in all)
|
|
8
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
5
|
};
|
|
10
6
|
|
|
11
|
-
// src/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"use strict";
|
|
16
|
-
UNICODE_CHARACTERS = {
|
|
17
|
-
"NULL": "\uE000",
|
|
18
|
-
"Unidentified": "\uE000",
|
|
19
|
-
"Cancel": "\uE001",
|
|
20
|
-
"Help": "\uE002",
|
|
21
|
-
"Backspace": "\uE003",
|
|
22
|
-
"Back space": "\uE003",
|
|
23
|
-
"Tab": "\uE004",
|
|
24
|
-
"Clear": "\uE005",
|
|
25
|
-
"Return": "\uE006",
|
|
26
|
-
"Enter": "\uE007",
|
|
27
|
-
"Shift": "\uE008",
|
|
28
|
-
"Control": "\uE009",
|
|
29
|
-
"Control Left": "\uE009",
|
|
30
|
-
"Control Right": "\uE051",
|
|
31
|
-
"Alt": "\uE00A",
|
|
32
|
-
"Pause": "\uE00B",
|
|
33
|
-
"Escape": "\uE00C",
|
|
34
|
-
"Space": "\uE00D",
|
|
35
|
-
" ": "\uE00D",
|
|
36
|
-
"PageUp": "\uE00E",
|
|
37
|
-
"Pageup": "\uE00E",
|
|
38
|
-
"Page_Up": "\uE00E",
|
|
39
|
-
"PageDown": "\uE00F",
|
|
40
|
-
"Pagedown": "\uE00F",
|
|
41
|
-
"Page_Down": "\uE00F",
|
|
42
|
-
"End": "\uE010",
|
|
43
|
-
"Home": "\uE011",
|
|
44
|
-
"ArrowLeft": "\uE012",
|
|
45
|
-
"Left arrow": "\uE012",
|
|
46
|
-
"Arrow_Left": "\uE012",
|
|
47
|
-
"ArrowUp": "\uE013",
|
|
48
|
-
"Up arrow": "\uE013",
|
|
49
|
-
"Arrow_Up": "\uE013",
|
|
50
|
-
"ArrowRight": "\uE014",
|
|
51
|
-
"Right arrow": "\uE014",
|
|
52
|
-
"Arrow_Right": "\uE014",
|
|
53
|
-
"ArrowDown": "\uE015",
|
|
54
|
-
"Down arrow": "\uE015",
|
|
55
|
-
"Arrow_Down": "\uE015",
|
|
56
|
-
"Insert": "\uE016",
|
|
57
|
-
"Delete": "\uE017",
|
|
58
|
-
"Semicolon": "\uE018",
|
|
59
|
-
"Equals": "\uE019",
|
|
60
|
-
"Numpad 0": "\uE01A",
|
|
61
|
-
"Numpad 1": "\uE01B",
|
|
62
|
-
"Numpad 2": "\uE01C",
|
|
63
|
-
"Numpad 3": "\uE01D",
|
|
64
|
-
"Numpad 4": "\uE01E",
|
|
65
|
-
"Numpad 5": "\uE01F",
|
|
66
|
-
"Numpad 6": "\uE020",
|
|
67
|
-
"Numpad 7": "\uE021",
|
|
68
|
-
"Numpad 8": "\uE022",
|
|
69
|
-
"Numpad 9": "\uE023",
|
|
70
|
-
"Multiply": "\uE024",
|
|
71
|
-
"Add": "\uE025",
|
|
72
|
-
"Separator": "\uE026",
|
|
73
|
-
"Subtract": "\uE027",
|
|
74
|
-
"Decimal": "\uE028",
|
|
75
|
-
"Divide": "\uE029",
|
|
76
|
-
"F1": "\uE031",
|
|
77
|
-
"F2": "\uE032",
|
|
78
|
-
"F3": "\uE033",
|
|
79
|
-
"F4": "\uE034",
|
|
80
|
-
"F5": "\uE035",
|
|
81
|
-
"F6": "\uE036",
|
|
82
|
-
"F7": "\uE037",
|
|
83
|
-
"F8": "\uE038",
|
|
84
|
-
"F9": "\uE039",
|
|
85
|
-
"F10": "\uE03A",
|
|
86
|
-
"F11": "\uE03B",
|
|
87
|
-
"F12": "\uE03C",
|
|
88
|
-
"Command": "\uE03D",
|
|
89
|
-
"Meta": "\uE03D",
|
|
90
|
-
"ZenkakuHankaku": "\uE040",
|
|
91
|
-
"Zenkaku_Hankaku": "\uE040"
|
|
92
|
-
};
|
|
93
|
-
SUPPORTED_BROWSERNAMES = {
|
|
94
|
-
chrome: ["chrome", "googlechrome", "chromium", "chromium-browser"],
|
|
95
|
-
firefox: ["firefox", "ff", "mozilla", "mozilla firefox"],
|
|
96
|
-
edge: ["edge", "microsoftedge", "msedge"],
|
|
97
|
-
safari: ["safari", "safari technology preview"]
|
|
98
|
-
};
|
|
99
|
-
DEFAULT_HOSTNAME = "localhost";
|
|
100
|
-
DEFAULT_PROTOCOL = "http";
|
|
101
|
-
DEFAULT_PATH = "/";
|
|
102
|
-
HOOK_DEFINITION = {
|
|
103
|
-
type: "object",
|
|
104
|
-
validate: (param) => {
|
|
105
|
-
if (!Array.isArray(param)) {
|
|
106
|
-
throw new Error("a hook option needs to be a list of functions");
|
|
107
|
-
}
|
|
108
|
-
for (const option of param) {
|
|
109
|
-
if (typeof option === "function") {
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
throw new Error("expected hook to be type of function");
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
});
|
|
7
|
+
// src/monad.ts
|
|
8
|
+
import { EventEmitter } from "node:events";
|
|
9
|
+
import logger from "@wdio/logger";
|
|
10
|
+
import { MESSAGE_TYPES } from "@wdio/types";
|
|
118
11
|
|
|
119
12
|
// src/utils.ts
|
|
120
13
|
import fs from "node:fs/promises";
|
|
121
14
|
import url from "node:url";
|
|
122
15
|
import path from "node:path";
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
16
|
+
|
|
17
|
+
// src/constants.ts
|
|
18
|
+
var UNICODE_CHARACTERS = {
|
|
19
|
+
"NULL": "\uE000",
|
|
20
|
+
"Unidentified": "\uE000",
|
|
21
|
+
"Cancel": "\uE001",
|
|
22
|
+
"Help": "\uE002",
|
|
23
|
+
"Backspace": "\uE003",
|
|
24
|
+
"Back space": "\uE003",
|
|
25
|
+
"Tab": "\uE004",
|
|
26
|
+
"Clear": "\uE005",
|
|
27
|
+
"Return": "\uE006",
|
|
28
|
+
"Enter": "\uE007",
|
|
29
|
+
"Shift": "\uE008",
|
|
30
|
+
"Control": "\uE009",
|
|
31
|
+
"Control Left": "\uE009",
|
|
32
|
+
"Control Right": "\uE051",
|
|
33
|
+
"Alt": "\uE00A",
|
|
34
|
+
"Pause": "\uE00B",
|
|
35
|
+
"Escape": "\uE00C",
|
|
36
|
+
"Space": "\uE00D",
|
|
37
|
+
" ": "\uE00D",
|
|
38
|
+
"PageUp": "\uE00E",
|
|
39
|
+
"Pageup": "\uE00E",
|
|
40
|
+
"Page_Up": "\uE00E",
|
|
41
|
+
"PageDown": "\uE00F",
|
|
42
|
+
"Pagedown": "\uE00F",
|
|
43
|
+
"Page_Down": "\uE00F",
|
|
44
|
+
"End": "\uE010",
|
|
45
|
+
"Home": "\uE011",
|
|
46
|
+
"ArrowLeft": "\uE012",
|
|
47
|
+
"Left arrow": "\uE012",
|
|
48
|
+
"Arrow_Left": "\uE012",
|
|
49
|
+
"ArrowUp": "\uE013",
|
|
50
|
+
"Up arrow": "\uE013",
|
|
51
|
+
"Arrow_Up": "\uE013",
|
|
52
|
+
"ArrowRight": "\uE014",
|
|
53
|
+
"Right arrow": "\uE014",
|
|
54
|
+
"Arrow_Right": "\uE014",
|
|
55
|
+
"ArrowDown": "\uE015",
|
|
56
|
+
"Down arrow": "\uE015",
|
|
57
|
+
"Arrow_Down": "\uE015",
|
|
58
|
+
"Insert": "\uE016",
|
|
59
|
+
"Delete": "\uE017",
|
|
60
|
+
"Semicolon": "\uE018",
|
|
61
|
+
"Equals": "\uE019",
|
|
62
|
+
"Numpad 0": "\uE01A",
|
|
63
|
+
"Numpad 1": "\uE01B",
|
|
64
|
+
"Numpad 2": "\uE01C",
|
|
65
|
+
"Numpad 3": "\uE01D",
|
|
66
|
+
"Numpad 4": "\uE01E",
|
|
67
|
+
"Numpad 5": "\uE01F",
|
|
68
|
+
"Numpad 6": "\uE020",
|
|
69
|
+
"Numpad 7": "\uE021",
|
|
70
|
+
"Numpad 8": "\uE022",
|
|
71
|
+
"Numpad 9": "\uE023",
|
|
72
|
+
"Multiply": "\uE024",
|
|
73
|
+
"Add": "\uE025",
|
|
74
|
+
"Separator": "\uE026",
|
|
75
|
+
"Subtract": "\uE027",
|
|
76
|
+
"Decimal": "\uE028",
|
|
77
|
+
"Divide": "\uE029",
|
|
78
|
+
"F1": "\uE031",
|
|
79
|
+
"F2": "\uE032",
|
|
80
|
+
"F3": "\uE033",
|
|
81
|
+
"F4": "\uE034",
|
|
82
|
+
"F5": "\uE035",
|
|
83
|
+
"F6": "\uE036",
|
|
84
|
+
"F7": "\uE037",
|
|
85
|
+
"F8": "\uE038",
|
|
86
|
+
"F9": "\uE039",
|
|
87
|
+
"F10": "\uE03A",
|
|
88
|
+
"F11": "\uE03B",
|
|
89
|
+
"F12": "\uE03C",
|
|
90
|
+
"Command": "\uE03D",
|
|
91
|
+
"Meta": "\uE03D",
|
|
92
|
+
"ZenkakuHankaku": "\uE040",
|
|
93
|
+
"Zenkaku_Hankaku": "\uE040"
|
|
94
|
+
};
|
|
95
|
+
var SUPPORTED_BROWSERNAMES = {
|
|
96
|
+
chrome: ["chrome", "googlechrome", "chromium", "chromium-browser"],
|
|
97
|
+
firefox: ["firefox", "ff", "mozilla", "mozilla firefox"],
|
|
98
|
+
edge: ["edge", "microsoftedge", "msedge"],
|
|
99
|
+
safari: ["safari", "safari technology preview"]
|
|
100
|
+
};
|
|
101
|
+
var DEFAULT_HOSTNAME = "localhost";
|
|
102
|
+
var DEFAULT_PROTOCOL = "http";
|
|
103
|
+
var DEFAULT_PATH = "/";
|
|
104
|
+
var HOOK_DEFINITION = {
|
|
105
|
+
type: "object",
|
|
106
|
+
validate: (param) => {
|
|
107
|
+
if (!Array.isArray(param)) {
|
|
108
|
+
throw new Error("a hook option needs to be a list of functions");
|
|
109
|
+
}
|
|
110
|
+
for (const option of param) {
|
|
111
|
+
if (typeof option === "function") {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
throw new Error("expected hook to be type of function");
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// src/utils.ts
|
|
120
|
+
var SCREENSHOT_REPLACEMENT = '"<Screenshot[base64]>"';
|
|
121
|
+
var SCRIPT_PLACEHOLDER = '"<Script[base64]>"';
|
|
122
|
+
var REGEX_SCRIPT_NAME = /return \((async )?function (\w+)/;
|
|
123
|
+
var SLASH = "/";
|
|
124
|
+
function assertPath(path2) {
|
|
125
|
+
if (typeof path2 !== "string") {
|
|
126
|
+
throw new TypeError("Path must be a string. Received " + JSON.stringify(path2));
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
function isAbsolute(p) {
|
|
@@ -289,6 +290,7 @@ function isBase64(str) {
|
|
|
289
290
|
const firstPaddingChar = str.indexOf("=");
|
|
290
291
|
return firstPaddingChar === -1 || firstPaddingChar === len - 1 || firstPaddingChar === len - 2 && str[len - 1] === "=";
|
|
291
292
|
}
|
|
293
|
+
var sleep = (ms = 0) => new Promise((r) => setTimeout(r, ms));
|
|
292
294
|
function isAppiumCapability(caps) {
|
|
293
295
|
return Boolean(
|
|
294
296
|
caps && // @ts-expect-error outdated jsonwp cap
|
|
@@ -302,18 +304,6 @@ function definesRemoteDriver(options) {
|
|
|
302
304
|
options.protocol && options.protocol !== DEFAULT_PROTOCOL || options.hostname && options.hostname !== DEFAULT_HOSTNAME || Boolean(options.port) || options.path && options.path !== DEFAULT_PATH || Boolean(options.user && options.key)
|
|
303
305
|
);
|
|
304
306
|
}
|
|
305
|
-
function isChrome(browserName) {
|
|
306
|
-
return Boolean(browserName && SUPPORTED_BROWSERNAMES.chrome.includes(browserName.toLowerCase()));
|
|
307
|
-
}
|
|
308
|
-
function isSafari(browserName) {
|
|
309
|
-
return Boolean(browserName && SUPPORTED_BROWSERNAMES.safari.includes(browserName.toLowerCase()));
|
|
310
|
-
}
|
|
311
|
-
function isFirefox(browserName) {
|
|
312
|
-
return Boolean(browserName && SUPPORTED_BROWSERNAMES.firefox.includes(browserName.toLowerCase()));
|
|
313
|
-
}
|
|
314
|
-
function isEdge(browserName) {
|
|
315
|
-
return Boolean(browserName && SUPPORTED_BROWSERNAMES.edge.includes(browserName.toLowerCase()));
|
|
316
|
-
}
|
|
317
307
|
function getBrowserObject(elem) {
|
|
318
308
|
const elemObject = elem;
|
|
319
309
|
return elemObject.parent ? getBrowserObject(elemObject.parent) : elem;
|
|
@@ -325,489 +315,8 @@ async function enableFileLogging(outputDir) {
|
|
|
325
315
|
await fs.mkdir(path.join(outputDir), { recursive: true });
|
|
326
316
|
process.env.WDIO_LOG_PATH = path.join(outputDir, "wdio.log");
|
|
327
317
|
}
|
|
328
|
-
var SCREENSHOT_REPLACEMENT, SCRIPT_PLACEHOLDER, REGEX_SCRIPT_NAME, SLASH, sleep;
|
|
329
|
-
var init_utils = __esm({
|
|
330
|
-
"src/utils.ts"() {
|
|
331
|
-
"use strict";
|
|
332
|
-
init_constants();
|
|
333
|
-
SCREENSHOT_REPLACEMENT = '"<Screenshot[base64]>"';
|
|
334
|
-
SCRIPT_PLACEHOLDER = '"<Script[base64]>"';
|
|
335
|
-
REGEX_SCRIPT_NAME = /return \((async )?function (\w+)/;
|
|
336
|
-
SLASH = "/";
|
|
337
|
-
sleep = (ms = 0) => new Promise((r) => setTimeout(r, ms));
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
// src/node/utils.ts
|
|
342
|
-
import os from "node:os";
|
|
343
|
-
import fs2 from "node:fs";
|
|
344
|
-
import fsp from "node:fs/promises";
|
|
345
|
-
import path2 from "node:path";
|
|
346
|
-
import cp from "node:child_process";
|
|
347
|
-
import decamelize from "decamelize";
|
|
348
|
-
import logger2 from "@wdio/logger";
|
|
349
|
-
import {
|
|
350
|
-
install,
|
|
351
|
-
canDownload,
|
|
352
|
-
resolveBuildId,
|
|
353
|
-
detectBrowserPlatform,
|
|
354
|
-
Browser as Browser2,
|
|
355
|
-
ChromeReleaseChannel,
|
|
356
|
-
computeExecutablePath
|
|
357
|
-
} from "@puppeteer/browsers";
|
|
358
|
-
import { download as downloadGeckodriver } from "geckodriver";
|
|
359
|
-
import { download as downloadEdgedriver } from "edgedriver";
|
|
360
|
-
import { locateChrome, locateFirefox, locateApp } from "locate-app";
|
|
361
|
-
function parseParams(params) {
|
|
362
|
-
return Object.entries(params).filter(([key]) => !EXCLUDED_PARAMS.includes(key)).map(([key, val]) => {
|
|
363
|
-
if (typeof val === "boolean" && !val) {
|
|
364
|
-
return "";
|
|
365
|
-
}
|
|
366
|
-
const vals = Array.isArray(val) ? val : [val];
|
|
367
|
-
return vals.map((v) => `--${decamelize(key, { separator: "-" })}${typeof v === "boolean" ? "" : `=${v}`}`);
|
|
368
|
-
}).flat().filter(Boolean);
|
|
369
|
-
}
|
|
370
|
-
function getBuildIdByChromePath(chromePath) {
|
|
371
|
-
if (!chromePath) {
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
if (os.platform() === "win32") {
|
|
375
|
-
const versionPath = path2.dirname(chromePath);
|
|
376
|
-
const contents = fs2.readdirSync(versionPath);
|
|
377
|
-
const versions = contents.filter((a) => /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/g.test(a));
|
|
378
|
-
const oldest = versions.sort((a, b) => a > b ? -1 : 1)[0];
|
|
379
|
-
return oldest;
|
|
380
|
-
}
|
|
381
|
-
const versionString = cp.execSync(`"${chromePath}" --version --no-sandbox`).toString();
|
|
382
|
-
const versionSanitized = versionString.trim().split(" ").find((s) => s.split(".").length === 4);
|
|
383
|
-
if (!versionSanitized) {
|
|
384
|
-
throw new Error(`Couldn't find valid Chrome version from "${versionString}", please raise an issue in the WebdriverIO project (https://github.com/webdriverio/webdriverio/issues/new/choose)`);
|
|
385
|
-
}
|
|
386
|
-
return versionSanitized;
|
|
387
|
-
}
|
|
388
|
-
async function getBuildIdByFirefoxPath(firefoxPath) {
|
|
389
|
-
if (!firefoxPath) {
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
if (os.platform() === "win32") {
|
|
393
|
-
const appPath = path2.dirname(firefoxPath);
|
|
394
|
-
const contents = (await fsp.readFile(path2.join(appPath, "application.ini"))).toString("utf-8");
|
|
395
|
-
return contents.split("\n").filter((line) => line.startsWith("Version=")).map((line) => line.replace("Version=", "").replace(/\r/, "")).pop();
|
|
396
|
-
}
|
|
397
|
-
const versionString = cp.execSync(`"${firefoxPath}" --version`).toString();
|
|
398
|
-
return versionString.trim().split(" ").pop()?.trim();
|
|
399
|
-
}
|
|
400
|
-
function locateChromeSafely() {
|
|
401
|
-
return locateChrome().catch(() => void 0);
|
|
402
|
-
}
|
|
403
|
-
async function setupPuppeteerBrowser(cacheDir, caps) {
|
|
404
|
-
caps.browserName = caps.browserName?.toLowerCase();
|
|
405
|
-
const browserName = caps.browserName === Browser2.FIREFOX ? Browser2.FIREFOX : caps.browserName === Browser2.CHROMIUM ? Browser2.CHROMIUM : Browser2.CHROME;
|
|
406
|
-
const exist = await fsp.access(cacheDir).then(() => true, () => false);
|
|
407
|
-
const isChromeOrChromium = browserName === Browser2.CHROME || caps.browserName === Browser2.CHROMIUM;
|
|
408
|
-
if (!exist) {
|
|
409
|
-
await fsp.mkdir(cacheDir, { recursive: true });
|
|
410
|
-
}
|
|
411
|
-
if (browserName === Browser2.CHROMIUM) {
|
|
412
|
-
caps.browserName = Browser2.CHROME;
|
|
413
|
-
}
|
|
414
|
-
const browserOptions = (isChromeOrChromium ? caps["goog:chromeOptions"] : caps["moz:firefoxOptions"]) || {};
|
|
415
|
-
if (typeof browserOptions.binary === "string") {
|
|
416
|
-
return {
|
|
417
|
-
executablePath: browserOptions.binary,
|
|
418
|
-
browserVersion: caps.browserVersion || (isChromeOrChromium ? getBuildIdByChromePath(browserOptions.binary) : await getBuildIdByFirefoxPath(browserOptions.binary))
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
const platform = detectBrowserPlatform();
|
|
422
|
-
if (!platform) {
|
|
423
|
-
throw new Error("The current platform is not supported.");
|
|
424
|
-
}
|
|
425
|
-
if (!caps.browserVersion) {
|
|
426
|
-
const executablePath2 = browserName === Browser2.CHROME ? await locateChromeSafely() : browserName === Browser2.CHROMIUM ? await locateApp({
|
|
427
|
-
appName: Browser2.CHROMIUM,
|
|
428
|
-
macOsName: Browser2.CHROMIUM,
|
|
429
|
-
linuxWhich: "chromium-browser"
|
|
430
|
-
}).catch(() => void 0) : await locateFirefox().catch(() => void 0);
|
|
431
|
-
const browserVersion2 = isChromeOrChromium ? getBuildIdByChromePath(executablePath2) : await getBuildIdByFirefoxPath(executablePath2);
|
|
432
|
-
if (browserVersion2) {
|
|
433
|
-
return {
|
|
434
|
-
executablePath: executablePath2,
|
|
435
|
-
browserVersion: browserVersion2
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
const tag = browserName === Browser2.CHROME ? caps.browserVersion || ChromeReleaseChannel.STABLE : caps.browserVersion || "latest";
|
|
440
|
-
const buildId = await resolveBuildId(browserName, platform, tag);
|
|
441
|
-
const installOptions = {
|
|
442
|
-
unpack: true,
|
|
443
|
-
cacheDir,
|
|
444
|
-
platform,
|
|
445
|
-
buildId,
|
|
446
|
-
browser: browserName,
|
|
447
|
-
downloadProgressCallback: (downloadedBytes, totalBytes) => downloadProgressCallback(`${browserName} (${buildId})`, downloadedBytes, totalBytes)
|
|
448
|
-
};
|
|
449
|
-
const isCombinationAvailable = await canDownload(installOptions);
|
|
450
|
-
if (!isCombinationAvailable) {
|
|
451
|
-
throw new Error(`Couldn't find a matching ${browserName} browser for tag "${buildId}" on platform "${platform}"`);
|
|
452
|
-
}
|
|
453
|
-
log.info(`Setting up ${browserName} v${buildId}`);
|
|
454
|
-
await _install(installOptions);
|
|
455
|
-
const executablePath = computeExecutablePath(installOptions);
|
|
456
|
-
let browserVersion = buildId;
|
|
457
|
-
if (browserName === Browser2.CHROMIUM) {
|
|
458
|
-
browserVersion = await resolveBuildId(Browser2.CHROME, platform, tag);
|
|
459
|
-
}
|
|
460
|
-
return { executablePath, browserVersion };
|
|
461
|
-
}
|
|
462
|
-
function getDriverOptions(caps) {
|
|
463
|
-
return caps["wdio:chromedriverOptions"] || caps["wdio:geckodriverOptions"] || caps["wdio:edgedriverOptions"] || // Safaridriver does not have any options as it already
|
|
464
|
-
// is installed on macOS
|
|
465
|
-
{};
|
|
466
|
-
}
|
|
467
|
-
function getCacheDir(options, caps) {
|
|
468
|
-
const driverOptions = getDriverOptions(caps);
|
|
469
|
-
return driverOptions.cacheDir || options.cacheDir || os.tmpdir();
|
|
470
|
-
}
|
|
471
|
-
function getMajorVersionFromString(fullVersion) {
|
|
472
|
-
let prefix;
|
|
473
|
-
if (fullVersion) {
|
|
474
|
-
prefix = fullVersion.match(/^[+-]?([0-9]+)/);
|
|
475
|
-
}
|
|
476
|
-
return prefix && prefix.length > 0 ? prefix[0] : "";
|
|
477
|
-
}
|
|
478
|
-
async function setupChromedriver(cacheDir, driverVersion) {
|
|
479
|
-
const platform = detectBrowserPlatform();
|
|
480
|
-
if (!platform) {
|
|
481
|
-
throw new Error("The current platform is not supported.");
|
|
482
|
-
}
|
|
483
|
-
const version = driverVersion || getBuildIdByChromePath(await locateChromeSafely()) || ChromeReleaseChannel.STABLE;
|
|
484
|
-
const buildId = await resolveBuildId(Browser2.CHROMEDRIVER, platform, version);
|
|
485
|
-
let executablePath = computeExecutablePath({
|
|
486
|
-
browser: Browser2.CHROMEDRIVER,
|
|
487
|
-
buildId,
|
|
488
|
-
platform,
|
|
489
|
-
cacheDir
|
|
490
|
-
});
|
|
491
|
-
const hasChromedriverInstalled = await fsp.access(executablePath).then(() => true, () => false);
|
|
492
|
-
if (!hasChromedriverInstalled) {
|
|
493
|
-
log.info(`Downloading Chromedriver v${buildId}`);
|
|
494
|
-
const chromedriverInstallOpts = {
|
|
495
|
-
cacheDir,
|
|
496
|
-
buildId,
|
|
497
|
-
platform,
|
|
498
|
-
browser: Browser2.CHROMEDRIVER,
|
|
499
|
-
unpack: true,
|
|
500
|
-
downloadProgressCallback: (downloadedBytes, totalBytes) => downloadProgressCallback("Chromedriver", downloadedBytes, totalBytes)
|
|
501
|
-
};
|
|
502
|
-
let knownBuild = buildId;
|
|
503
|
-
if (await canDownload(chromedriverInstallOpts)) {
|
|
504
|
-
await _install({ ...chromedriverInstallOpts, buildId });
|
|
505
|
-
log.info(`Download of Chromedriver v${buildId} was successful`);
|
|
506
|
-
} else {
|
|
507
|
-
log.warn(`Chromedriver v${buildId} don't exist, trying to find known good version...`);
|
|
508
|
-
knownBuild = await resolveBuildId(Browser2.CHROMEDRIVER, platform, getMajorVersionFromString(version));
|
|
509
|
-
if (knownBuild) {
|
|
510
|
-
await _install({ ...chromedriverInstallOpts, buildId: knownBuild });
|
|
511
|
-
log.info(`Download of Chromedriver v${knownBuild} was successful`);
|
|
512
|
-
} else {
|
|
513
|
-
throw new Error(`Couldn't download any known good version from Chromedriver major v${getMajorVersionFromString(version)}, requested full version - v${version}`);
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
executablePath = computeExecutablePath({
|
|
517
|
-
browser: Browser2.CHROMEDRIVER,
|
|
518
|
-
buildId: knownBuild,
|
|
519
|
-
platform,
|
|
520
|
-
cacheDir
|
|
521
|
-
});
|
|
522
|
-
} else {
|
|
523
|
-
log.info(`Using Chromedriver v${buildId} from cache directory ${cacheDir}`);
|
|
524
|
-
}
|
|
525
|
-
return { executablePath };
|
|
526
|
-
}
|
|
527
|
-
function setupGeckodriver(cacheDir, driverVersion) {
|
|
528
|
-
return downloadGeckodriver(driverVersion, cacheDir);
|
|
529
|
-
}
|
|
530
|
-
function setupEdgedriver(cacheDir, driverVersion) {
|
|
531
|
-
return downloadEdgedriver(driverVersion, cacheDir);
|
|
532
|
-
}
|
|
533
|
-
var log, EXCLUDED_PARAMS, canAccess, lastTimeCalled, downloadProgressCallback, _install;
|
|
534
|
-
var init_utils2 = __esm({
|
|
535
|
-
"src/node/utils.ts"() {
|
|
536
|
-
"use strict";
|
|
537
|
-
log = logger2("webdriver");
|
|
538
|
-
EXCLUDED_PARAMS = ["version", "help"];
|
|
539
|
-
canAccess = (file) => {
|
|
540
|
-
if (!file) {
|
|
541
|
-
return false;
|
|
542
|
-
}
|
|
543
|
-
try {
|
|
544
|
-
fs2.accessSync(file);
|
|
545
|
-
return true;
|
|
546
|
-
} catch (err) {
|
|
547
|
-
return false;
|
|
548
|
-
}
|
|
549
|
-
};
|
|
550
|
-
lastTimeCalled = Date.now();
|
|
551
|
-
downloadProgressCallback = (artifact, downloadedBytes, totalBytes) => {
|
|
552
|
-
if (Date.now() - lastTimeCalled < 1e3) {
|
|
553
|
-
return;
|
|
554
|
-
}
|
|
555
|
-
const percentage = (downloadedBytes / totalBytes * 100).toFixed(2);
|
|
556
|
-
log.progress(`Downloading ${artifact} ${percentage}%`);
|
|
557
|
-
lastTimeCalled = Date.now();
|
|
558
|
-
};
|
|
559
|
-
_install = async (args, retry = false) => {
|
|
560
|
-
await install(args).catch((err) => {
|
|
561
|
-
const error = `Failed downloading ${args.browser} v${args.buildId} using ${JSON.stringify(args)}: ${err.message}, retrying ...`;
|
|
562
|
-
if (retry) {
|
|
563
|
-
err.message += "\n" + error.replace(", retrying ...", "");
|
|
564
|
-
throw new Error(err);
|
|
565
|
-
}
|
|
566
|
-
log.error(error);
|
|
567
|
-
return _install(args, true);
|
|
568
|
-
});
|
|
569
|
-
log.progress("");
|
|
570
|
-
};
|
|
571
|
-
}
|
|
572
|
-
});
|
|
573
|
-
|
|
574
|
-
// src/node/startWebDriver.ts
|
|
575
|
-
import fs3 from "node:fs";
|
|
576
|
-
import path3 from "node:path";
|
|
577
|
-
import cp2 from "node:child_process";
|
|
578
|
-
import getPort from "get-port";
|
|
579
|
-
import waitPort from "wait-port";
|
|
580
|
-
import logger3 from "@wdio/logger";
|
|
581
|
-
import split2 from "split2";
|
|
582
|
-
import { deepmerge } from "deepmerge-ts";
|
|
583
|
-
import { start as startSafaridriver } from "safaridriver";
|
|
584
|
-
import { start as startGeckodriver } from "geckodriver";
|
|
585
|
-
import { start as startEdgedriver, findEdgePath } from "edgedriver";
|
|
586
|
-
async function startWebDriver(options) {
|
|
587
|
-
if (process.env.WDIO_SKIP_DRIVER_SETUP) {
|
|
588
|
-
options.hostname = "localhost";
|
|
589
|
-
options.port = 4321;
|
|
590
|
-
return;
|
|
591
|
-
}
|
|
592
|
-
let driverProcess;
|
|
593
|
-
let driver = "";
|
|
594
|
-
const start = Date.now();
|
|
595
|
-
const caps = options.capabilities.alwaysMatch || options.capabilities;
|
|
596
|
-
if (isAppiumCapability(caps)) {
|
|
597
|
-
return;
|
|
598
|
-
}
|
|
599
|
-
if (!caps.browserName) {
|
|
600
|
-
throw new Error(
|
|
601
|
-
`No "browserName" defined in capabilities nor hostname or port found!
|
|
602
|
-
If you like to run a local browser session make sure to pick from one of the following browser names: ${Object.values(SUPPORTED_BROWSERNAMES).flat(Infinity)}`
|
|
603
|
-
);
|
|
604
|
-
}
|
|
605
|
-
const port = await getPort();
|
|
606
|
-
const cacheDir = getCacheDir(options, caps);
|
|
607
|
-
if (isChrome(caps.browserName)) {
|
|
608
|
-
const chromedriverOptions = caps["wdio:chromedriverOptions"] || {};
|
|
609
|
-
const chromedriverBinary = chromedriverOptions.binary || process.env.CHROMEDRIVER_PATH;
|
|
610
|
-
const { executablePath: chromeExecuteablePath, browserVersion } = await setupPuppeteerBrowser(cacheDir, caps);
|
|
611
|
-
const { executablePath: chromedriverExcecuteablePath } = chromedriverBinary ? { executablePath: chromedriverBinary } : await setupChromedriver(cacheDir, browserVersion);
|
|
612
|
-
caps["goog:chromeOptions"] = deepmerge(
|
|
613
|
-
{ binary: chromeExecuteablePath },
|
|
614
|
-
caps["goog:chromeOptions"] || {}
|
|
615
|
-
);
|
|
616
|
-
chromedriverOptions.allowedOrigins = chromedriverOptions.allowedOrigins || ["*"];
|
|
617
|
-
chromedriverOptions.allowedIps = chromedriverOptions.allowedIps || ["0.0.0.0"];
|
|
618
|
-
const driverParams = parseParams({ port, ...chromedriverOptions });
|
|
619
|
-
driverProcess = cp2.spawn(chromedriverExcecuteablePath, driverParams);
|
|
620
|
-
driver = `Chromedriver v${browserVersion} with params ${driverParams.join(" ")}`;
|
|
621
|
-
} else if (isSafari(caps.browserName)) {
|
|
622
|
-
const safaridriverOptions = caps["wdio:safaridriverOptions"] || {};
|
|
623
|
-
driver = "SafariDriver";
|
|
624
|
-
driverProcess = startSafaridriver({
|
|
625
|
-
useTechnologyPreview: Boolean(caps.browserName.match(/preview/i)),
|
|
626
|
-
...safaridriverOptions,
|
|
627
|
-
port
|
|
628
|
-
});
|
|
629
|
-
} else if (isFirefox(caps.browserName)) {
|
|
630
|
-
const { executablePath } = await setupPuppeteerBrowser(cacheDir, caps);
|
|
631
|
-
caps["moz:firefoxOptions"] = deepmerge(
|
|
632
|
-
{ binary: executablePath },
|
|
633
|
-
caps["moz:firefoxOptions"] || {}
|
|
634
|
-
);
|
|
635
|
-
delete caps.browserVersion;
|
|
636
|
-
const { binary, ...geckodriverOptions } = caps["wdio:geckodriverOptions"] || {};
|
|
637
|
-
if (binary) {
|
|
638
|
-
geckodriverOptions.customGeckoDriverPath = binary;
|
|
639
|
-
}
|
|
640
|
-
driver = "GeckoDriver";
|
|
641
|
-
driverProcess = await startGeckodriver({ ...geckodriverOptions, cacheDir, port, allowHosts: ["localhost"] });
|
|
642
|
-
} else if (isEdge(caps.browserName)) {
|
|
643
|
-
const { binary, ...edgedriverOptions } = caps["wdio:edgedriverOptions"] || {};
|
|
644
|
-
if (binary) {
|
|
645
|
-
edgedriverOptions.customEdgeDriverPath = binary;
|
|
646
|
-
}
|
|
647
|
-
driver = "EdgeDriver";
|
|
648
|
-
driverProcess = await startEdgedriver({ ...edgedriverOptions, cacheDir, port, allowedIps: ["0.0.0.0"] }).catch((err) => {
|
|
649
|
-
log2.warn(`Couldn't start EdgeDriver: ${err.message}, retry ...`);
|
|
650
|
-
return startEdgedriver({ ...edgedriverOptions, cacheDir, port });
|
|
651
|
-
});
|
|
652
|
-
caps.browserName = "MicrosoftEdge";
|
|
653
|
-
if (!caps["ms:edgeOptions"]?.binary) {
|
|
654
|
-
caps["ms:edgeOptions"] = caps["ms:edgeOptions"] || {};
|
|
655
|
-
caps["ms:edgeOptions"].binary = findEdgePath();
|
|
656
|
-
log2.info(`Found Edge binary at ${caps["ms:edgeOptions"].binary}`);
|
|
657
|
-
}
|
|
658
|
-
} else {
|
|
659
|
-
throw new Error(
|
|
660
|
-
`Unknown browser name "${caps.browserName}". Make sure to pick from one of the following ` + Object.values(SUPPORTED_BROWSERNAMES).flat(Infinity)
|
|
661
|
-
);
|
|
662
|
-
}
|
|
663
|
-
const logIdentifier = driver.split(" ").shift()?.toLowerCase() || "driver";
|
|
664
|
-
if (options.outputDir) {
|
|
665
|
-
const logFileName = process.env.WDIO_WORKER_ID ? `wdio-${process.env.WDIO_WORKER_ID}-${logIdentifier}.log` : `wdio-${logIdentifier}-${port}.log`;
|
|
666
|
-
const logFile = path3.resolve(options.outputDir, logFileName);
|
|
667
|
-
const logStream = fs3.createWriteStream(logFile, { flags: "w" });
|
|
668
|
-
driverProcess.stdout?.pipe(logStream);
|
|
669
|
-
driverProcess.stderr?.pipe(logStream);
|
|
670
|
-
} else {
|
|
671
|
-
const driverLog = logger3(logIdentifier);
|
|
672
|
-
driverProcess.stdout?.pipe(split2()).on("data", driverLog.info.bind(driverLog));
|
|
673
|
-
driverProcess.stderr?.pipe(split2()).on("data", driverLog.warn.bind(driverLog));
|
|
674
|
-
}
|
|
675
|
-
await waitPort({ port, output: "silent", timeout: DRIVER_WAIT_TIMEOUT }).catch((e) => {
|
|
676
|
-
throw new Error(`Timed out to connect to ${driver}: ${e.message}`);
|
|
677
|
-
});
|
|
678
|
-
options.hostname = "localhost";
|
|
679
|
-
options.port = port;
|
|
680
|
-
log2.info(`Started ${driver} in ${Date.now() - start}ms on port ${port}`);
|
|
681
|
-
return driverProcess;
|
|
682
|
-
}
|
|
683
|
-
var log2, DRIVER_WAIT_TIMEOUT;
|
|
684
|
-
var init_startWebDriver = __esm({
|
|
685
|
-
"src/node/startWebDriver.ts"() {
|
|
686
|
-
"use strict";
|
|
687
|
-
init_utils2();
|
|
688
|
-
init_utils();
|
|
689
|
-
init_constants();
|
|
690
|
-
log2 = logger3("@wdio/utils");
|
|
691
|
-
DRIVER_WAIT_TIMEOUT = 10 * 1e3;
|
|
692
|
-
}
|
|
693
|
-
});
|
|
694
|
-
|
|
695
|
-
// src/node/manager.ts
|
|
696
|
-
import logger4 from "@wdio/logger";
|
|
697
|
-
function mapCapabilities(options, caps, task, taskItemLabel) {
|
|
698
|
-
const capabilitiesToRequireSetup = (Array.isArray(caps) ? caps.map((cap) => {
|
|
699
|
-
const w3cCaps = cap;
|
|
700
|
-
const multiremoteCaps = cap;
|
|
701
|
-
const multiremoteInstanceNames = Object.keys(multiremoteCaps);
|
|
702
|
-
if (typeof multiremoteCaps[multiremoteInstanceNames[0]] === "object" && "capabilities" in multiremoteCaps[multiremoteInstanceNames[0]]) {
|
|
703
|
-
return Object.values(multiremoteCaps).map((c) => "alwaysMatch" in c.capabilities ? c.capabilities.alwaysMatch : c.capabilities);
|
|
704
|
-
}
|
|
705
|
-
if (w3cCaps.alwaysMatch) {
|
|
706
|
-
return w3cCaps.alwaysMatch;
|
|
707
|
-
}
|
|
708
|
-
return cap;
|
|
709
|
-
}).flat() : Object.values(caps).map((mrOpts) => {
|
|
710
|
-
const w3cCaps = mrOpts.capabilities;
|
|
711
|
-
if (w3cCaps.alwaysMatch) {
|
|
712
|
-
return w3cCaps.alwaysMatch;
|
|
713
|
-
}
|
|
714
|
-
return mrOpts.capabilities;
|
|
715
|
-
})).flat().filter((cap) => (
|
|
716
|
-
/**
|
|
717
|
-
* only set up driver if
|
|
718
|
-
*/
|
|
719
|
-
// - capabilities are defined and not empty
|
|
720
|
-
cap && // - browserName is defined so we know it is a browser session
|
|
721
|
-
cap.browserName && // - we are not about to run a cloud session
|
|
722
|
-
!definesRemoteDriver(options) && // - we are not running Safari (driver already installed on macOS)
|
|
723
|
-
!isSafari(cap.browserName) && // - driver options don't define a binary path
|
|
724
|
-
!getDriverOptions(cap).binary && // - environment does not define a binary path
|
|
725
|
-
!(process.env.CHROMEDRIVER_PATH && isChrome(cap.browserName))
|
|
726
|
-
));
|
|
727
|
-
if (capabilitiesToRequireSetup.length === 0) {
|
|
728
|
-
return;
|
|
729
|
-
}
|
|
730
|
-
const queueByBrowserName = capabilitiesToRequireSetup.reduce((queue, cap) => {
|
|
731
|
-
if (!cap.browserName) {
|
|
732
|
-
return queue;
|
|
733
|
-
}
|
|
734
|
-
if (!queue.has(cap.browserName)) {
|
|
735
|
-
queue.set(cap.browserName, /* @__PURE__ */ new Map());
|
|
736
|
-
}
|
|
737
|
-
const browserVersion = cap.browserVersion || UNDEFINED_BROWSER_VERSION;
|
|
738
|
-
queue.get(cap.browserName).set(browserVersion, cap);
|
|
739
|
-
return queue;
|
|
740
|
-
}, /* @__PURE__ */ new Map());
|
|
741
|
-
const driverToSetupString = Array.from(queueByBrowserName.entries()).map(([browserName, versions]) => `${browserName}@${Array.from(versions.keys()).map((bv) => bv || "stable").join(", ")}`).join(" - ");
|
|
742
|
-
log3.info(`Setting up ${taskItemLabel} for: ${driverToSetupString}`);
|
|
743
|
-
return Promise.all(
|
|
744
|
-
Array.from(queueByBrowserName.entries()).map(([browserName, queueByBrowserVersion]) => {
|
|
745
|
-
return Array.from(queueByBrowserVersion).map(([browserVersion, cap]) => task({
|
|
746
|
-
...cap,
|
|
747
|
-
browserName,
|
|
748
|
-
...browserVersion !== UNDEFINED_BROWSER_VERSION ? { browserVersion } : {}
|
|
749
|
-
}));
|
|
750
|
-
}).flat()
|
|
751
|
-
);
|
|
752
|
-
}
|
|
753
|
-
async function setupDriver(options, caps) {
|
|
754
|
-
return mapCapabilities(options, caps, async (cap) => {
|
|
755
|
-
const cacheDir = getCacheDir(options, cap);
|
|
756
|
-
if (isEdge(cap.browserName)) {
|
|
757
|
-
return setupEdgedriver(cacheDir, cap.browserVersion);
|
|
758
|
-
} else if (isFirefox(cap.browserName)) {
|
|
759
|
-
const version = cap.browserVersion === "latest" ? void 0 : cap.browserVersion;
|
|
760
|
-
return setupGeckodriver(cacheDir, version);
|
|
761
|
-
} else if (isChrome(cap.browserName)) {
|
|
762
|
-
return setupChromedriver(cacheDir, cap.browserVersion);
|
|
763
|
-
}
|
|
764
|
-
return Promise.resolve();
|
|
765
|
-
}, "browser driver" /* DRIVER */);
|
|
766
|
-
}
|
|
767
|
-
function setupBrowser(options, caps) {
|
|
768
|
-
return mapCapabilities(options, caps, async (cap) => {
|
|
769
|
-
const cacheDir = getCacheDir(options, cap);
|
|
770
|
-
if (isEdge(cap.browserName)) {
|
|
771
|
-
return Promise.resolve();
|
|
772
|
-
} else if (isChrome(cap.browserName) || isFirefox(cap.browserName)) {
|
|
773
|
-
return setupPuppeteerBrowser(cacheDir, cap);
|
|
774
|
-
}
|
|
775
|
-
return Promise.resolve();
|
|
776
|
-
}, "browser binaries" /* BROWSER */);
|
|
777
|
-
}
|
|
778
|
-
var log3, UNDEFINED_BROWSER_VERSION;
|
|
779
|
-
var init_manager = __esm({
|
|
780
|
-
"src/node/manager.ts"() {
|
|
781
|
-
"use strict";
|
|
782
|
-
init_utils2();
|
|
783
|
-
init_utils();
|
|
784
|
-
log3 = logger4("@wdio/utils");
|
|
785
|
-
UNDEFINED_BROWSER_VERSION = null;
|
|
786
|
-
}
|
|
787
|
-
});
|
|
788
|
-
|
|
789
|
-
// src/node/index.ts
|
|
790
|
-
var node_exports = {};
|
|
791
|
-
__export(node_exports, {
|
|
792
|
-
canAccess: () => canAccess,
|
|
793
|
-
setupBrowser: () => setupBrowser,
|
|
794
|
-
setupDriver: () => setupDriver,
|
|
795
|
-
startWebDriver: () => startWebDriver
|
|
796
|
-
});
|
|
797
|
-
var init_node = __esm({
|
|
798
|
-
"src/node/index.ts"() {
|
|
799
|
-
"use strict";
|
|
800
|
-
init_startWebDriver();
|
|
801
|
-
init_manager();
|
|
802
|
-
init_utils2();
|
|
803
|
-
}
|
|
804
|
-
});
|
|
805
318
|
|
|
806
319
|
// src/monad.ts
|
|
807
|
-
init_utils();
|
|
808
|
-
import { EventEmitter } from "node:events";
|
|
809
|
-
import logger from "@wdio/logger";
|
|
810
|
-
import { MESSAGE_TYPES } from "@wdio/types";
|
|
811
320
|
var SCOPE_TYPES = {
|
|
812
321
|
browser: (
|
|
813
322
|
/* istanbul ignore next */
|
|
@@ -824,7 +333,7 @@ function WebDriver(options, modifier, propertiesObject = {}) {
|
|
|
824
333
|
const scopeType = SCOPE_TYPES[propertiesObject.scope?.value || "browser"];
|
|
825
334
|
delete propertiesObject.scope;
|
|
826
335
|
const prototype = Object.create(scopeType.prototype);
|
|
827
|
-
const
|
|
336
|
+
const log4 = logger("webdriver");
|
|
828
337
|
const eventHandler = new EventEmitter();
|
|
829
338
|
const EVENTHANDLER_FUNCTIONS = Object.getPrototypeOf(eventHandler);
|
|
830
339
|
function unit(sessionId, commandWrapper) {
|
|
@@ -902,7 +411,7 @@ function WebDriver(options, modifier, propertiesObject = {}) {
|
|
|
902
411
|
}
|
|
903
412
|
unit.lift = function(name, func, proto, origCommand) {
|
|
904
413
|
(proto || prototype)[name] = function next(...args) {
|
|
905
|
-
|
|
414
|
+
log4.info("COMMAND", commandCallStructure(name, args));
|
|
906
415
|
Object.defineProperty(func, "name", {
|
|
907
416
|
value: name,
|
|
908
417
|
writable: false
|
|
@@ -916,7 +425,7 @@ function WebDriver(options, modifier, propertiesObject = {}) {
|
|
|
916
425
|
} else if (res instanceof SCOPE_TYPES.browser) {
|
|
917
426
|
resultLog = "WebdriverIO.Browser";
|
|
918
427
|
}
|
|
919
|
-
|
|
428
|
+
log4.info("RESULT", resultLog);
|
|
920
429
|
this.emit("result", { name, result: res });
|
|
921
430
|
}).catch(() => {
|
|
922
431
|
});
|
|
@@ -940,7 +449,6 @@ function WebDriver(options, modifier, propertiesObject = {}) {
|
|
|
940
449
|
}
|
|
941
450
|
|
|
942
451
|
// src/initializePlugin.ts
|
|
943
|
-
init_utils();
|
|
944
452
|
async function initializePlugin(name, type) {
|
|
945
453
|
if (name[0] === "@" || isAbsolute(name)) {
|
|
946
454
|
const service = await safeImport(name);
|
|
@@ -965,38 +473,38 @@ async function initializePlugin(name, type) {
|
|
|
965
473
|
}
|
|
966
474
|
|
|
967
475
|
// src/startWebDriver.ts
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
async function startWebDriver2(options) {
|
|
476
|
+
import logger2 from "@wdio/logger";
|
|
477
|
+
var log = logger2("@wdio/utils");
|
|
478
|
+
async function startWebDriver(options) {
|
|
972
479
|
if (definesRemoteDriver(options)) {
|
|
973
|
-
|
|
480
|
+
log.info(`Connecting to existing driver at ${options.protocol}://${options.hostname}:${options.port}${options.path}`);
|
|
974
481
|
return;
|
|
975
482
|
}
|
|
976
483
|
if (globalThis.process) {
|
|
977
|
-
const
|
|
978
|
-
|
|
484
|
+
const nodeModule = "./node.js";
|
|
485
|
+
const { startWebDriver: startWebDriver2 } = await import(nodeModule);
|
|
486
|
+
return startWebDriver2(options);
|
|
979
487
|
}
|
|
980
488
|
throw new Error("Please provide a valid `hostname` and `port` to start WebDriver sessions in the browser!");
|
|
981
489
|
}
|
|
982
490
|
|
|
983
491
|
// src/initializeServices.ts
|
|
984
|
-
import
|
|
985
|
-
var
|
|
492
|
+
import logger3 from "@wdio/logger";
|
|
493
|
+
var log2 = logger3("@wdio/utils:initializeServices");
|
|
986
494
|
async function initializeServices(services) {
|
|
987
495
|
const initializedServices = [];
|
|
988
496
|
for (const [serviceName, serviceConfig = {}] of services) {
|
|
989
497
|
if (typeof serviceName === "object") {
|
|
990
|
-
|
|
498
|
+
log2.debug("initialize custom initiated service");
|
|
991
499
|
initializedServices.push([serviceName, {}]);
|
|
992
500
|
continue;
|
|
993
501
|
}
|
|
994
502
|
if (typeof serviceName === "function") {
|
|
995
|
-
|
|
503
|
+
log2.debug(`initialize custom service "${serviceName.name}"`);
|
|
996
504
|
initializedServices.push([serviceName, serviceConfig]);
|
|
997
505
|
continue;
|
|
998
506
|
}
|
|
999
|
-
|
|
507
|
+
log2.debug(`initialize service "${serviceName}" as NPM package`);
|
|
1000
508
|
const service = await initializePlugin(serviceName, "service");
|
|
1001
509
|
initializedServices.push([service, serviceConfig, serviceName]);
|
|
1002
510
|
}
|
|
@@ -1060,11 +568,8 @@ async function initializeWorkerService(config, caps, ignoredWorkerServices = [])
|
|
|
1060
568
|
}
|
|
1061
569
|
}
|
|
1062
570
|
|
|
1063
|
-
// src/index.ts
|
|
1064
|
-
init_utils();
|
|
1065
|
-
|
|
1066
571
|
// src/shim.ts
|
|
1067
|
-
import
|
|
572
|
+
import logger4 from "@wdio/logger";
|
|
1068
573
|
|
|
1069
574
|
// src/pIteration.ts
|
|
1070
575
|
var pIteration_exports = {};
|
|
@@ -1291,8 +796,7 @@ var reduce = async (array, callback, initialValue) => {
|
|
|
1291
796
|
};
|
|
1292
797
|
|
|
1293
798
|
// src/shim.ts
|
|
1294
|
-
|
|
1295
|
-
var log6 = logger7("@wdio/utils:shim");
|
|
799
|
+
var log3 = logger4("@wdio/utils:shim");
|
|
1296
800
|
var inCommandHook = false;
|
|
1297
801
|
var ELEMENT_QUERY_COMMANDS = [
|
|
1298
802
|
"$",
|
|
@@ -1345,7 +849,7 @@ async function executeHooksWithArgs(hookName, hooks = [], args = []) {
|
|
|
1345
849
|
if (rejectIfSkipped(e, reject)) {
|
|
1346
850
|
return;
|
|
1347
851
|
}
|
|
1348
|
-
|
|
852
|
+
log3.error(e.stack);
|
|
1349
853
|
return resolve(e);
|
|
1350
854
|
}
|
|
1351
855
|
if (result2 && typeof result2.then === "function") {
|
|
@@ -1353,7 +857,7 @@ async function executeHooksWithArgs(hookName, hooks = [], args = []) {
|
|
|
1353
857
|
if (rejectIfSkipped(e, reject)) {
|
|
1354
858
|
return;
|
|
1355
859
|
}
|
|
1356
|
-
|
|
860
|
+
log3.error(e.stack || e.message);
|
|
1357
861
|
resolve(e);
|
|
1358
862
|
});
|
|
1359
863
|
}
|
|
@@ -1362,7 +866,7 @@ async function executeHooksWithArgs(hookName, hooks = [], args = []) {
|
|
|
1362
866
|
const start = Date.now();
|
|
1363
867
|
const result = await Promise.all(hooksPromises);
|
|
1364
868
|
if (hooksPromises.length) {
|
|
1365
|
-
|
|
869
|
+
log3.debug(`Finished to run "${hookName}" hook in ${Date.now() - start}ms`);
|
|
1366
870
|
}
|
|
1367
871
|
return result;
|
|
1368
872
|
}
|
|
@@ -1607,7 +1111,6 @@ var filterStackTrace = (stack) => {
|
|
|
1607
1111
|
};
|
|
1608
1112
|
|
|
1609
1113
|
// src/test-framework/testInterfaceWrapper.ts
|
|
1610
|
-
init_utils();
|
|
1611
1114
|
var MOCHA_COMMANDS = ["skip", "only"];
|
|
1612
1115
|
var runHook = function(hookFn, origFn, beforeFn, beforeFnArgs, afterFn, afterFnArgs, cid, repeatTest, timeout) {
|
|
1613
1116
|
const wrappedHook = function(...hookFnArgs) {
|
|
@@ -1724,7 +1227,6 @@ function addMochaCommands(origFn, newFn) {
|
|
|
1724
1227
|
}
|
|
1725
1228
|
|
|
1726
1229
|
// src/envDetector.ts
|
|
1727
|
-
init_constants();
|
|
1728
1230
|
var APPIUM_CAPABILITY_PREFIX = "appium:";
|
|
1729
1231
|
var MOBILE_BROWSER_NAMES = ["ipad", "iphone", "android"];
|
|
1730
1232
|
var MOBILE_CAPABILITIES = [
|
|
@@ -1760,7 +1262,7 @@ function isW3C(capabilities) {
|
|
|
1760
1262
|
const hasWebdriverFlag = Boolean(capabilities["ms:experimental-webdriver"]);
|
|
1761
1263
|
return Boolean(hasW3CCaps || isAppium || hasWebdriverFlag);
|
|
1762
1264
|
}
|
|
1763
|
-
function
|
|
1265
|
+
function isChrome(capabilities) {
|
|
1764
1266
|
if (!capabilities) {
|
|
1765
1267
|
return false;
|
|
1766
1268
|
}
|
|
@@ -1768,13 +1270,13 @@ function isChrome2(capabilities) {
|
|
|
1768
1270
|
capabilities["goog:chromeOptions"] && (capabilities.browserName === "chrome" || capabilities.browserName === "chrome-headless-shell")
|
|
1769
1271
|
);
|
|
1770
1272
|
}
|
|
1771
|
-
function
|
|
1273
|
+
function isEdge(capabilities) {
|
|
1772
1274
|
if (!capabilities) {
|
|
1773
1275
|
return false;
|
|
1774
1276
|
}
|
|
1775
1277
|
return Boolean(capabilities.browserName && SUPPORTED_BROWSERNAMES.edge.includes(capabilities.browserName.toLowerCase()) || capabilities["ms:edgeOptions"]);
|
|
1776
1278
|
}
|
|
1777
|
-
function
|
|
1279
|
+
function isFirefox(capabilities) {
|
|
1778
1280
|
if (!capabilities) {
|
|
1779
1281
|
return false;
|
|
1780
1282
|
}
|
|
@@ -1858,12 +1360,12 @@ function isChromium(capabilities) {
|
|
|
1858
1360
|
if (!capabilities) {
|
|
1859
1361
|
return false;
|
|
1860
1362
|
}
|
|
1861
|
-
return
|
|
1363
|
+
return isChrome(capabilities) || isEdge(capabilities);
|
|
1862
1364
|
}
|
|
1863
1365
|
function capabilitiesEnvironmentDetector(capabilities) {
|
|
1864
1366
|
return {
|
|
1865
|
-
isChrome:
|
|
1866
|
-
isFirefox:
|
|
1367
|
+
isChrome: isChrome(capabilities),
|
|
1368
|
+
isFirefox: isFirefox(capabilities),
|
|
1867
1369
|
isMobile: isMobile(capabilities),
|
|
1868
1370
|
isIOS: isIOS(capabilities),
|
|
1869
1371
|
isAndroid: isAndroid(capabilities),
|
|
@@ -1878,8 +1380,8 @@ function sessionEnvironmentDetector({
|
|
|
1878
1380
|
}) {
|
|
1879
1381
|
return {
|
|
1880
1382
|
isW3C: isW3C(capabilities),
|
|
1881
|
-
isChrome:
|
|
1882
|
-
isFirefox:
|
|
1383
|
+
isChrome: isChrome(capabilities),
|
|
1384
|
+
isFirefox: isFirefox(capabilities),
|
|
1883
1385
|
isMobile: isMobile(capabilities),
|
|
1884
1386
|
isIOS: isIOS(capabilities),
|
|
1885
1387
|
isAndroid: isAndroid(capabilities),
|
|
@@ -1889,9 +1391,6 @@ function sessionEnvironmentDetector({
|
|
|
1889
1391
|
isChromium: isChromium(capabilities)
|
|
1890
1392
|
};
|
|
1891
1393
|
}
|
|
1892
|
-
|
|
1893
|
-
// src/index.ts
|
|
1894
|
-
init_constants();
|
|
1895
1394
|
export {
|
|
1896
1395
|
HOOK_DEFINITION,
|
|
1897
1396
|
UNICODE_CHARACTERS,
|
|
@@ -1914,7 +1413,7 @@ export {
|
|
|
1914
1413
|
safeImport,
|
|
1915
1414
|
sessionEnvironmentDetector,
|
|
1916
1415
|
sleep,
|
|
1917
|
-
|
|
1416
|
+
startWebDriver,
|
|
1918
1417
|
testFnWrapper,
|
|
1919
1418
|
transformCommandLogResult,
|
|
1920
1419
|
userImport,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Capabilities } from '@wdio/types';
|
|
2
|
-
export declare function startWebDriver(options: Capabilities.RemoteConfig): Promise<
|
|
2
|
+
export declare function startWebDriver(options: Capabilities.RemoteConfig): Promise<any>;
|
|
3
3
|
//# sourceMappingURL=startWebDriver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startWebDriver.d.ts","sourceRoot":"","sources":["../src/startWebDriver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAM/C,wBAAsB,cAAc,CAAE,OAAO,EAAE,YAAY,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"startWebDriver.d.ts","sourceRoot":"","sources":["../src/startWebDriver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAM/C,wBAAsB,cAAc,CAAE,OAAO,EAAE,YAAY,CAAC,YAAY,gBAsBvE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/utils",
|
|
3
|
-
"version": "9.2.
|
|
3
|
+
"version": "9.2.5",
|
|
4
4
|
"description": "A WDIO helper utility to provide several utility functions used across the project.",
|
|
5
5
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-utils",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "4c2bcd9c674afd799436639d215aac7b6861fcc1"
|
|
57
57
|
}
|