@wdio/selenium-devtools 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/package.json +15 -15
- package/dist/assertPatcher.d.ts +0 -11
- package/dist/assertPatcher.js +0 -123
- package/dist/assertPatcher.js.map +0 -1
- package/dist/bidi.d.ts +0 -6
- package/dist/bidi.js +0 -222
- package/dist/bidi.js.map +0 -1
- package/dist/constants.d.ts +0 -75
- package/dist/constants.js +0 -146
- package/dist/constants.js.map +0 -1
- package/dist/driverPatcher.d.ts +0 -4
- package/dist/driverPatcher.js +0 -256
- package/dist/driverPatcher.js.map +0 -1
- package/dist/helpers/detachedBackend.d.ts +0 -7
- package/dist/helpers/detachedBackend.js +0 -34
- package/dist/helpers/detachedBackend.js.map +0 -1
- package/dist/helpers/runtime.d.ts +0 -3
- package/dist/helpers/runtime.js +0 -47
- package/dist/helpers/runtime.js.map +0 -1
- package/dist/helpers/suiteManager.d.ts +0 -19
- package/dist/helpers/suiteManager.js +0 -131
- package/dist/helpers/suiteManager.js.map +0 -1
- package/dist/helpers/testManager.d.ts +0 -47
- package/dist/helpers/testManager.js +0 -158
- package/dist/helpers/testManager.js.map +0 -1
- package/dist/helpers/utils.d.ts +0 -26
- package/dist/helpers/utils.js +0 -187
- package/dist/helpers/utils.js.map +0 -1
- package/dist/helpers/videoEncoder.d.ts +0 -2
- package/dist/helpers/videoEncoder.js +0 -89
- package/dist/helpers/videoEncoder.js.map +0 -1
- package/dist/index.d.ts +0 -15
- package/dist/index.js +0 -801
- package/dist/index.js.map +0 -1
- package/dist/reporter.d.ts +0 -18
- package/dist/reporter.js +0 -72
- package/dist/reporter.js.map +0 -1
- package/dist/rerunManager.d.ts +0 -8
- package/dist/rerunManager.js +0 -78
- package/dist/rerunManager.js.map +0 -1
- package/dist/runnerHooks.d.ts +0 -6
- package/dist/runnerHooks.js +0 -594
- package/dist/runnerHooks.js.map +0 -1
- package/dist/screencast.d.ts +0 -11
- package/dist/screencast.js +0 -179
- package/dist/screencast.js.map +0 -1
- package/dist/session.d.ts +0 -48
- package/dist/session.js +0 -480
- package/dist/session.js.map +0 -1
- package/dist/setupConsole.d.ts +0 -1
- package/dist/setupConsole.js +0 -13
- package/dist/setupConsole.js.map +0 -1
- package/dist/types.d.ts +0 -235
- package/dist/types.js +0 -5
- package/dist/types.js.map +0 -1
package/dist/constants.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Selenium WebDriver methods we don't want to surface as user commands.
|
|
3
|
-
* These are either internal lifecycle (quit, close, getSession), capability
|
|
4
|
-
* inspection (getCapabilities), or low-level helpers (sleep, schedule).
|
|
5
|
-
*/
|
|
6
|
-
export const INTERNAL_DRIVER_METHODS = [
|
|
7
|
-
'constructor',
|
|
8
|
-
'getSession',
|
|
9
|
-
'getCapabilities',
|
|
10
|
-
'getExecutor',
|
|
11
|
-
'execute',
|
|
12
|
-
'schedule',
|
|
13
|
-
'manage',
|
|
14
|
-
'navigate',
|
|
15
|
-
'switchTo',
|
|
16
|
-
'actions',
|
|
17
|
-
'wait',
|
|
18
|
-
'sleep',
|
|
19
|
-
'setFileDetector',
|
|
20
|
-
'getNetworkConnection',
|
|
21
|
-
'setNetworkConnection',
|
|
22
|
-
'on',
|
|
23
|
-
'once',
|
|
24
|
-
'addListener',
|
|
25
|
-
'removeListener',
|
|
26
|
-
'emit',
|
|
27
|
-
'eventNames',
|
|
28
|
-
/* Plumbing — selenium-webdriver itself calls these during BiDi/CDP setup. */
|
|
29
|
-
'getBidi',
|
|
30
|
-
'getCdpTargets',
|
|
31
|
-
'createCDPConnection',
|
|
32
|
-
'getWsUrl',
|
|
33
|
-
/* These are wrapped separately — see patchSelenium quit/close interceptors. */
|
|
34
|
-
'quit',
|
|
35
|
-
'close'
|
|
36
|
-
];
|
|
37
|
-
/**
|
|
38
|
-
* WebElement methods we DO surface (everything else is skipped).
|
|
39
|
-
* Whitelist approach because WebElement's prototype carries fewer interesting
|
|
40
|
-
* action methods than WebDriver's, and skipping is cheaper.
|
|
41
|
-
*/
|
|
42
|
-
export const TRACKED_ELEMENT_METHODS = [
|
|
43
|
-
'click',
|
|
44
|
-
'sendKeys',
|
|
45
|
-
'clear',
|
|
46
|
-
'submit',
|
|
47
|
-
'getText',
|
|
48
|
-
'getAttribute',
|
|
49
|
-
'getCssValue',
|
|
50
|
-
'getRect',
|
|
51
|
-
'getTagName',
|
|
52
|
-
'isDisplayed',
|
|
53
|
-
'isEnabled',
|
|
54
|
-
'isSelected'
|
|
55
|
-
];
|
|
56
|
-
export const NAVIGATION_COMMANDS = [
|
|
57
|
-
'get',
|
|
58
|
-
'navigate',
|
|
59
|
-
'to',
|
|
60
|
-
'back',
|
|
61
|
-
'forward',
|
|
62
|
-
'refresh'
|
|
63
|
-
];
|
|
64
|
-
export const CONSOLE_METHODS = ['log', 'info', 'warn', 'error'];
|
|
65
|
-
export const LOG_SOURCES = {
|
|
66
|
-
BROWSER: 'browser',
|
|
67
|
-
TEST: 'test',
|
|
68
|
-
TERMINAL: 'terminal'
|
|
69
|
-
};
|
|
70
|
-
export const ANSI_REGEX = /\x1b\[[?]?[0-9;]*[A-Za-z]/g;
|
|
71
|
-
export const SPINNER_RE = /^[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]/u;
|
|
72
|
-
export const DEFAULTS = {
|
|
73
|
-
CID: '0-0',
|
|
74
|
-
SESSION_TITLE: 'Selenium Session',
|
|
75
|
-
FILE_NAME: 'selenium',
|
|
76
|
-
RETRIES: 0,
|
|
77
|
-
DURATION: 0
|
|
78
|
-
};
|
|
79
|
-
export const TIMING = {
|
|
80
|
-
UI_RENDER_DELAY: 150,
|
|
81
|
-
TEST_START_DELAY: 100,
|
|
82
|
-
SUITE_COMPLETE_DELAY: 200,
|
|
83
|
-
UI_CONNECTION_WAIT: 2000,
|
|
84
|
-
BROWSER_CLOSE_WAIT: 2000,
|
|
85
|
-
INITIAL_CONNECTION_WAIT: 500,
|
|
86
|
-
BROWSER_POLL_INTERVAL: 1000
|
|
87
|
-
};
|
|
88
|
-
export const TEST_STATE = {
|
|
89
|
-
PENDING: 'pending',
|
|
90
|
-
RUNNING: 'running',
|
|
91
|
-
PASSED: 'passed',
|
|
92
|
-
FAILED: 'failed',
|
|
93
|
-
SKIPPED: 'skipped'
|
|
94
|
-
};
|
|
95
|
-
export const LOG_LEVEL_PATTERNS = [
|
|
96
|
-
{ level: 'trace', pattern: /\btrace\b/i },
|
|
97
|
-
{ level: 'debug', pattern: /\bdebug\b/i },
|
|
98
|
-
{ level: 'info', pattern: /\binfo\b/i },
|
|
99
|
-
{ level: 'warn', pattern: /\bwarn(ing)?\b/i },
|
|
100
|
-
{ level: 'error', pattern: /\berror\b/i }
|
|
101
|
-
];
|
|
102
|
-
export const SCREENCAST_DEFAULTS = {
|
|
103
|
-
enabled: false,
|
|
104
|
-
captureFormat: 'jpeg',
|
|
105
|
-
quality: 70,
|
|
106
|
-
maxWidth: 1280,
|
|
107
|
-
maxHeight: 720,
|
|
108
|
-
pollIntervalMs: 200
|
|
109
|
-
};
|
|
110
|
-
/** Test-state environment markers used by the rerun handshake. */
|
|
111
|
-
export const REUSE_ENV = {
|
|
112
|
-
REUSE: 'DEVTOOLS_APP_REUSE',
|
|
113
|
-
HOST: 'DEVTOOLS_APP_HOST',
|
|
114
|
-
PORT: 'DEVTOOLS_APP_PORT',
|
|
115
|
-
RERUN_LABEL: 'DEVTOOLS_RERUN_LABEL',
|
|
116
|
-
RERUN_ENTRY_TYPE: 'DEVTOOLS_RERUN_ENTRY_TYPE'
|
|
117
|
-
};
|
|
118
|
-
/**
|
|
119
|
-
* Decoded JPEG bytes below which a frame is treated as blank/uniform
|
|
120
|
-
* (Chrome's about:blank — solid colour compresses to <2KB; real renders >5KB).
|
|
121
|
-
*/
|
|
122
|
-
export const BLANK_FRAME_THRESHOLD_BYTES = 4_000;
|
|
123
|
-
/** Per-prototype "already patched" guard for driverPatcher / assertPatcher. */
|
|
124
|
-
export const PATCHED_SYMBOL = Symbol.for('@wdio/selenium-devtools/patched');
|
|
125
|
-
/** Per-prototype guard for the (currently disabled) node:assert patcher. */
|
|
126
|
-
export const ASSERT_PATCHED_SYMBOL = Symbol.for('@wdio/selenium-devtools/assert-patched');
|
|
127
|
-
/** node:assert methods the (currently disabled) assertPatcher would wrap. */
|
|
128
|
-
export const TRACKED_ASSERT_METHODS = [
|
|
129
|
-
'equal',
|
|
130
|
-
'strictEqual',
|
|
131
|
-
'deepEqual',
|
|
132
|
-
'deepStrictEqual',
|
|
133
|
-
'notEqual',
|
|
134
|
-
'notStrictEqual',
|
|
135
|
-
'notDeepEqual',
|
|
136
|
-
'notDeepStrictEqual',
|
|
137
|
-
'ok',
|
|
138
|
-
'fail',
|
|
139
|
-
'throws',
|
|
140
|
-
'doesNotThrow',
|
|
141
|
-
'rejects',
|
|
142
|
-
'doesNotReject',
|
|
143
|
-
'match',
|
|
144
|
-
'doesNotMatch'
|
|
145
|
-
];
|
|
146
|
-
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,aAAa;IACb,YAAY;IACZ,iBAAiB;IACjB,aAAa;IACb,SAAS;IACT,UAAU;IACV,QAAQ;IACR,UAAU;IACV,UAAU;IACV,SAAS;IACT,MAAM;IACN,OAAO;IACP,iBAAiB;IACjB,sBAAsB;IACtB,sBAAsB;IACtB,IAAI;IACJ,MAAM;IACN,aAAa;IACb,gBAAgB;IAChB,MAAM;IACN,YAAY;IACZ,6EAA6E;IAC7E,SAAS;IACT,eAAe;IACf,qBAAqB;IACrB,UAAU;IACV,+EAA+E;IAC/E,MAAM;IACN,OAAO;CACC,CAAA;AAEV;;;;GAIG;AACH,MAAM,CAAC,M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|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { DriverOriginals, DriverPatcherHooks, ElementOriginals } from './types.js';
|
|
2
|
-
export declare function getDriverOriginals(): DriverOriginals;
|
|
3
|
-
export declare function getElementOriginals(): ElementOriginals;
|
|
4
|
-
export declare function patchSelenium(hooks: DriverPatcherHooks): boolean;
|
package/dist/driverPatcher.js
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
import logger from '@wdio/logger';
|
|
3
|
-
import { INTERNAL_DRIVER_METHODS, PATCHED_SYMBOL, TRACKED_ELEMENT_METHODS } from './constants.js';
|
|
4
|
-
import { getCallSourceFromStack } from './helpers/utils.js';
|
|
5
|
-
const log = logger('@wdio/selenium-devtools:driverPatcher');
|
|
6
|
-
const originals = {};
|
|
7
|
-
const elementOriginals = {};
|
|
8
|
-
export function getDriverOriginals() {
|
|
9
|
-
return originals;
|
|
10
|
-
}
|
|
11
|
-
export function getElementOriginals() {
|
|
12
|
-
return elementOriginals;
|
|
13
|
-
}
|
|
14
|
-
// Resolve user's selenium-webdriver first, then fall back to our own.
|
|
15
|
-
function loadSeleniumWebdriver() {
|
|
16
|
-
try {
|
|
17
|
-
const userRequire = createRequire(`${process.cwd()}/`);
|
|
18
|
-
return userRequire('selenium-webdriver');
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
try {
|
|
22
|
-
const localRequire = createRequire(import.meta.url);
|
|
23
|
-
return localRequire('selenium-webdriver');
|
|
24
|
-
}
|
|
25
|
-
catch (err) {
|
|
26
|
-
log.warn(`selenium-webdriver not found — devtools auto-attach disabled. (${err.message})`);
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function isWebElementLike(v) {
|
|
32
|
-
return (v &&
|
|
33
|
-
typeof v === 'object' &&
|
|
34
|
-
typeof v.getId === 'function' &&
|
|
35
|
-
typeof v.click === 'function');
|
|
36
|
-
}
|
|
37
|
-
function safeSerialize(value) {
|
|
38
|
-
if (value === null || value === undefined) {
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
if (typeof value === 'function') {
|
|
42
|
-
return '[Function]';
|
|
43
|
-
}
|
|
44
|
-
if (isWebElementLike(value)) {
|
|
45
|
-
return webElementSummary(value);
|
|
46
|
-
}
|
|
47
|
-
if (typeof value === 'object' &&
|
|
48
|
-
'using' in value &&
|
|
49
|
-
'value' in value &&
|
|
50
|
-
Object.keys(value).length === 2) {
|
|
51
|
-
return `By.${value.using}(${JSON.stringify(value.value)})`;
|
|
52
|
-
}
|
|
53
|
-
if (Array.isArray(value)) {
|
|
54
|
-
if (value.length > 0 && value.every(isWebElementLike)) {
|
|
55
|
-
return `<WebElement[]> (count: ${value.length})`;
|
|
56
|
-
}
|
|
57
|
-
return value.map(safeSerialize);
|
|
58
|
-
}
|
|
59
|
-
if (typeof value === 'object') {
|
|
60
|
-
try {
|
|
61
|
-
return JSON.parse(JSON.stringify(value));
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
return String(value);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return value;
|
|
68
|
-
}
|
|
69
|
-
function webElementSummary(el) {
|
|
70
|
-
// `id_` is a Promise; some selenium versions stash the resolved value sync.
|
|
71
|
-
const peek = el?.id_?._value ?? el?.id_?.value ?? null;
|
|
72
|
-
return peek ? `<WebElement id=${peek}>` : '<WebElement>';
|
|
73
|
-
}
|
|
74
|
-
function wrapPrototype(proto, methodNames, fromElement, hooks) {
|
|
75
|
-
if (proto[PATCHED_SYMBOL]) {
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
;
|
|
79
|
-
proto[PATCHED_SYMBOL] = true;
|
|
80
|
-
const wrapped = [];
|
|
81
|
-
for (const methodName of methodNames) {
|
|
82
|
-
const original = proto[methodName];
|
|
83
|
-
if (typeof original !== 'function') {
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (methodName === 'constructor' || methodName.startsWith('__')) {
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
;
|
|
90
|
-
proto[methodName] = function (...args) {
|
|
91
|
-
const callInfo = getCallSourceFromStack();
|
|
92
|
-
const startedAt = Date.now();
|
|
93
|
-
const sanitizedArgs = args.map(safeSerialize);
|
|
94
|
-
const settle = (result, error) => {
|
|
95
|
-
try {
|
|
96
|
-
hooks.onCommand({
|
|
97
|
-
command: methodName,
|
|
98
|
-
args: sanitizedArgs,
|
|
99
|
-
result: error ? undefined : safeSerialize(result),
|
|
100
|
-
rawResult: error ? undefined : result,
|
|
101
|
-
error,
|
|
102
|
-
callSource: callInfo.callSource,
|
|
103
|
-
timestamp: startedAt,
|
|
104
|
-
fromElement
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
catch (hookErr) {
|
|
108
|
-
log.warn(`onCommand hook threw for ${methodName}: ${hookErr.message}`);
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
let result;
|
|
112
|
-
try {
|
|
113
|
-
result = original.apply(this, args);
|
|
114
|
-
}
|
|
115
|
-
catch (err) {
|
|
116
|
-
settle(undefined, err);
|
|
117
|
-
throw err;
|
|
118
|
-
}
|
|
119
|
-
// CRITICAL: return the original thenable. findElement returns a
|
|
120
|
-
// WebElementPromise that carries sendKeys/click for chaining; a plain
|
|
121
|
-
// Promise from `.then(...)` would break `findElement(...).sendKeys(...)`.
|
|
122
|
-
if (result && typeof result.then === 'function') {
|
|
123
|
-
result.then((v) => settle(v, undefined), (err) => settle(undefined, err));
|
|
124
|
-
return result;
|
|
125
|
-
}
|
|
126
|
-
settle(result, undefined);
|
|
127
|
-
return result;
|
|
128
|
-
};
|
|
129
|
-
wrapped.push(methodName);
|
|
130
|
-
}
|
|
131
|
-
return wrapped;
|
|
132
|
-
}
|
|
133
|
-
export function patchSelenium(hooks) {
|
|
134
|
-
const sw = loadSeleniumWebdriver();
|
|
135
|
-
if (!sw) {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
const Builder = sw.Builder;
|
|
139
|
-
const WebDriver = sw.WebDriver;
|
|
140
|
-
const WebElement = sw.WebElement;
|
|
141
|
-
if (!Builder || !WebDriver) {
|
|
142
|
-
log.warn('selenium-webdriver loaded but Builder/WebDriver missing — version unsupported?');
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
// Stash unwrapped originals before any patching.
|
|
146
|
-
const driverProto = WebDriver.prototype;
|
|
147
|
-
if (typeof driverProto.takeScreenshot === 'function') {
|
|
148
|
-
const orig = driverProto.takeScreenshot;
|
|
149
|
-
originals.takeScreenshot = (driver) => orig.call(driver);
|
|
150
|
-
}
|
|
151
|
-
if (typeof driverProto.executeScript === 'function') {
|
|
152
|
-
const orig = driverProto.executeScript;
|
|
153
|
-
originals.executeScript = (driver, script, ...args) => orig.call(driver, script, ...args);
|
|
154
|
-
}
|
|
155
|
-
if (typeof driverProto.manage === 'function') {
|
|
156
|
-
const orig = driverProto.manage;
|
|
157
|
-
originals.manage = (driver) => orig.call(driver);
|
|
158
|
-
}
|
|
159
|
-
const driverMethods = collectMethodNames(WebDriver.prototype);
|
|
160
|
-
const tracked = driverMethods.filter((m) => !INTERNAL_DRIVER_METHODS.includes(m));
|
|
161
|
-
const wrappedDriver = wrapPrototype(WebDriver.prototype, tracked,
|
|
162
|
-
/* fromElement */ false, hooks);
|
|
163
|
-
log.info(`Wrapped ${wrappedDriver.length} WebDriver method(s)`);
|
|
164
|
-
// Lets onBeforeQuit flush async cleanup before runners that `process.exit()`
|
|
165
|
-
// tear down (those bypass node's beforeExit).
|
|
166
|
-
if (typeof driverProto.quit === 'function') {
|
|
167
|
-
const originalQuit = driverProto.quit;
|
|
168
|
-
driverProto.quit = async function patchedQuit() {
|
|
169
|
-
if (hooks.onBeforeQuit) {
|
|
170
|
-
try {
|
|
171
|
-
await hooks.onBeforeQuit(this);
|
|
172
|
-
}
|
|
173
|
-
catch (err) {
|
|
174
|
-
log.warn(`onBeforeQuit hook threw: ${err.message}`);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return originalQuit.call(this);
|
|
178
|
-
};
|
|
179
|
-
log.info('Wrapped WebDriver.quit (cleanup hook)');
|
|
180
|
-
}
|
|
181
|
-
if (WebElement) {
|
|
182
|
-
const elProto = WebElement.prototype;
|
|
183
|
-
if (typeof elProto.getText === 'function') {
|
|
184
|
-
const orig = elProto.getText;
|
|
185
|
-
elementOriginals.getText = (el) => orig.call(el);
|
|
186
|
-
}
|
|
187
|
-
if (typeof elProto.getTagName === 'function') {
|
|
188
|
-
const orig = elProto.getTagName;
|
|
189
|
-
elementOriginals.getTagName = (el) => orig.call(el);
|
|
190
|
-
}
|
|
191
|
-
const wrappedEl = wrapPrototype(WebElement.prototype, TRACKED_ELEMENT_METHODS,
|
|
192
|
-
/* fromElement */ true, hooks);
|
|
193
|
-
log.info(`Wrapped ${wrappedEl.length} WebElement method(s)`);
|
|
194
|
-
}
|
|
195
|
-
if (!Builder.prototype[PATCHED_SYMBOL]) {
|
|
196
|
-
;
|
|
197
|
-
Builder.prototype[PATCHED_SYMBOL] = true;
|
|
198
|
-
const originalBuild = Builder.prototype.build;
|
|
199
|
-
Builder.prototype.build = function patchedBuild(...args) {
|
|
200
|
-
if (hooks.onBeforeBuild) {
|
|
201
|
-
try {
|
|
202
|
-
hooks.onBeforeBuild(this);
|
|
203
|
-
}
|
|
204
|
-
catch (err) {
|
|
205
|
-
log.warn(`onBeforeBuild hook threw: ${err.message}`);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
const driver = originalBuild.apply(this, args);
|
|
209
|
-
try {
|
|
210
|
-
const result = hooks.onDriverCreated(driver);
|
|
211
|
-
if (result && typeof result.then === 'function') {
|
|
212
|
-
;
|
|
213
|
-
result.catch((err) => log.warn(`onDriverCreated hook rejected: ${err.message}`));
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
catch (err) {
|
|
217
|
-
log.warn(`onDriverCreated hook threw: ${err.message}`);
|
|
218
|
-
}
|
|
219
|
-
// Selenium 4: WebDriver is thenable. Extend `.then` so `await Builder.build()`
|
|
220
|
-
// also waits for the dashboard to connect.
|
|
221
|
-
const isThenable = driver && typeof driver.then === 'function';
|
|
222
|
-
if (isThenable && hooks.waitForReady) {
|
|
223
|
-
const originalThen = driver.then.bind(driver);
|
|
224
|
-
driver.then = function patchedThen(onFulfilled, onRejected) {
|
|
225
|
-
return originalThen(async (resolved) => {
|
|
226
|
-
try {
|
|
227
|
-
await hooks.waitForReady();
|
|
228
|
-
}
|
|
229
|
-
catch {
|
|
230
|
-
/* fall through — don't block forever on UI failures */
|
|
231
|
-
}
|
|
232
|
-
return onFulfilled ? onFulfilled(resolved) : resolved;
|
|
233
|
-
}, onRejected);
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
return driver;
|
|
237
|
-
};
|
|
238
|
-
log.info('Patched Builder.prototype.build');
|
|
239
|
-
}
|
|
240
|
-
return true;
|
|
241
|
-
}
|
|
242
|
-
function collectMethodNames(proto) {
|
|
243
|
-
const names = new Set();
|
|
244
|
-
let current = proto;
|
|
245
|
-
while (current && current !== Object.prototype) {
|
|
246
|
-
for (const name of Object.getOwnPropertyNames(current)) {
|
|
247
|
-
const desc = Object.getOwnPropertyDescriptor(current, name);
|
|
248
|
-
if (desc && typeof desc.value === 'function') {
|
|
249
|
-
names.add(name);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
current = Object.getPrototypeOf(current);
|
|
253
|
-
}
|
|
254
|
-
return [...names];
|
|
255
|
-
}
|
|
256
|
-
//# sourceMappingURL=driverPatcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"driverPatcher.js","sourceRoot":"","sources":["../src/driverPatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,EACL,uBAAuB,EACvB,cAAc,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C,CAAA;YACjB,CAAC;QACH,CAAC;QACD,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;IAC1C,CAAC;IACD,OAAO,CAAC,GAAG,KAAK,CAAC,CAAA;AACnB,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import net from 'node:net';
|
|
2
|
-
import { spawn } from 'node:child_process';
|
|
3
|
-
import { createRequire } from 'node:module';
|
|
4
|
-
const require = createRequire(import.meta.url);
|
|
5
|
-
export async function startDetachedBackend(opts) {
|
|
6
|
-
const backendPath = require.resolve('@wdio/devtools-backend');
|
|
7
|
-
const code = `import(${JSON.stringify(backendPath)}).then(m => m.start({ port: ${opts.port}, hostname: ${JSON.stringify(opts.hostname)} })).catch(err => { console.error(err); process.exit(1) })`;
|
|
8
|
-
spawn(process.execPath, ['-e', code], {
|
|
9
|
-
detached: true,
|
|
10
|
-
stdio: 'ignore'
|
|
11
|
-
}).unref();
|
|
12
|
-
const deadline = Date.now() + (opts.readyTimeoutMs ?? 10000);
|
|
13
|
-
while (Date.now() < deadline) {
|
|
14
|
-
if (await canConnect(opts.port, opts.hostname)) {
|
|
15
|
-
return { port: opts.port };
|
|
16
|
-
}
|
|
17
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
18
|
-
}
|
|
19
|
-
throw new Error(`Detached backend never came up on ${opts.hostname}:${opts.port}`);
|
|
20
|
-
}
|
|
21
|
-
function canConnect(port, host) {
|
|
22
|
-
return new Promise((resolve) => {
|
|
23
|
-
const sock = net.connect(port, host);
|
|
24
|
-
sock.once('connect', () => {
|
|
25
|
-
sock.destroy();
|
|
26
|
-
resolve(true);
|
|
27
|
-
});
|
|
28
|
-
sock.once('error', () => {
|
|
29
|
-
sock.destroy();
|
|
30
|
-
resolve(false);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=detachedBackend.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":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AAC,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,CAClE,CAAA;AACH,CAAC;AAED,SAAS,UAAU,CAAC,IAAY,EAAE,IAAY;IAC5C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QACpC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;YACxB,IAAI,CAAC,OAAO,EAAE,CAAA;YACd,OAAO,CAAC,IAAI,CAAC,CAAA;QACf,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;YACtB,IAAI,CAAC,OAAO,EAAE,CAAA;YACd,OAAO,CAAC,KAAK,CAAC,CAAA;QAChB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/helpers/runtime.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
export function detectOwnVersion() {
|
|
3
|
-
try {
|
|
4
|
-
return createRequire(import.meta.url)('../../package.json').version;
|
|
5
|
-
}
|
|
6
|
-
catch {
|
|
7
|
-
return 'unknown';
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export function detectRunner() {
|
|
11
|
-
const argv = (process.argv[1] || '').toLowerCase();
|
|
12
|
-
if (argv.includes('mocha')) {
|
|
13
|
-
return 'mocha';
|
|
14
|
-
}
|
|
15
|
-
if (argv.includes('jest')) {
|
|
16
|
-
return 'jest';
|
|
17
|
-
}
|
|
18
|
-
if (argv.includes('jasmine')) {
|
|
19
|
-
return 'jasmine';
|
|
20
|
-
}
|
|
21
|
-
if (argv.includes('vitest')) {
|
|
22
|
-
return 'vitest';
|
|
23
|
-
}
|
|
24
|
-
if (argv.includes('cucumber')) {
|
|
25
|
-
return 'cucumber';
|
|
26
|
-
}
|
|
27
|
-
if (argv.endsWith('node') || argv.endsWith('node.exe')) {
|
|
28
|
-
return 'node';
|
|
29
|
-
}
|
|
30
|
-
return 'unknown';
|
|
31
|
-
}
|
|
32
|
-
export function detectSeleniumVersion() {
|
|
33
|
-
const tryRead = (req) => {
|
|
34
|
-
try {
|
|
35
|
-
return req('selenium-webdriver/package.json').version;
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const fromUser = tryRead(createRequire(`${process.cwd()}/`));
|
|
42
|
-
if (fromUser) {
|
|
43
|
-
return fromUser;
|
|
44
|
-
}
|
|
45
|
-
return tryRead(createRequire(import.meta.url));
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=runtime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/helpers/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,MAAM,UAAU,gBAAgB;IAC9B,IAAI,CAAC;QACH,OAAO,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAA;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;IAClD,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAA;IAChB,CAAC;IACD,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAA;IACf,CAAC;IACD,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7B,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,UAAU,CAAA;IACnB,CAAC;IACD,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACvD,OAAO,MAAM,CAAA;IACf,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,MAAM,UAAU,qBAAqB;IACnC,MAAM,OAAO,GAAG,CAAC,GAAgB,EAAsB,EAAE;QACvD,IAAI,CAAC;YACH,OAAO,GAAG,CAAC,iCAAiC,CAAC,CAAC,OAAO,CAAA;QACvD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAA;QAClB,CAAC;IACH,CAAC,CAAA;IACD,MAAM,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;IAC5D,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,OAAO,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAChD,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { SuiteStats, TestStats } from '../types.js';
|
|
2
|
-
import type { TestReporter } from '../reporter.js';
|
|
3
|
-
export declare class SuiteManager {
|
|
4
|
-
private testReporter;
|
|
5
|
-
private rootSuite;
|
|
6
|
-
private currentParent;
|
|
7
|
-
constructor(testReporter: TestReporter);
|
|
8
|
-
getOrCreateRootSuite(file: string, title: string): SuiteStats;
|
|
9
|
-
getRootSuite(): SuiteStats | null;
|
|
10
|
-
/** Where new tests are appended — root suite, or the open scenario sub-suite. */
|
|
11
|
-
getCurrentParent(): SuiteStats | null;
|
|
12
|
-
/** Open a Cucumber scenario as a sub-suite; steps attach until endScenarioSuite. */
|
|
13
|
-
startScenarioSuite(name: string, file: string, callSource?: string): SuiteStats | null;
|
|
14
|
-
endScenarioSuite(state: SuiteStats['state']): void;
|
|
15
|
-
setRootSuiteTitle(title: string, callSource?: string): void;
|
|
16
|
-
addTest(test: TestStats): void;
|
|
17
|
-
finalize(): void;
|
|
18
|
-
reset(): void;
|
|
19
|
-
}
|