webdriverio 7.20.7 → 7.20.8-alpha.504
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/cjs/index.d.ts +3 -0
- package/build/cjs/index.d.ts.map +1 -0
- package/build/cjs/index.js +13 -0
- package/build/cjs/package.json +3 -0
- package/build/commands/browser/$$.d.ts +10 -1
- package/build/commands/browser/$$.d.ts.map +1 -1
- package/build/commands/browser/$$.js +16 -9
- package/build/commands/browser/$.js +8 -11
- package/build/commands/browser/action.d.ts +132 -0
- package/build/commands/browser/action.d.ts.map +1 -0
- package/build/commands/browser/action.js +13 -0
- package/build/commands/browser/actions.d.ts +29 -0
- package/build/commands/browser/actions.d.ts.map +1 -0
- package/build/commands/browser/actions.js +30 -0
- package/build/commands/browser/addCommand.d.ts +1 -1
- package/build/commands/browser/addCommand.js +1 -1
- package/build/commands/browser/call.d.ts +7 -5
- package/build/commands/browser/call.d.ts.map +1 -1
- package/build/commands/browser/call.js +8 -9
- package/build/commands/browser/custom$$.js +7 -10
- package/build/commands/browser/custom$.d.ts +1 -1
- package/build/commands/browser/custom$.js +6 -9
- package/build/commands/browser/debug.js +8 -14
- package/build/commands/browser/deleteCookies.d.ts +3 -3
- package/build/commands/browser/deleteCookies.js +4 -7
- package/build/commands/browser/execute.d.ts +2 -2
- package/build/commands/browser/execute.js +5 -8
- package/build/commands/browser/executeAsync.js +3 -6
- package/build/commands/browser/getCookies.d.ts +2 -2
- package/build/commands/browser/getCookies.js +3 -6
- package/build/commands/browser/getPuppeteer.d.ts +1 -1
- package/build/commands/browser/getPuppeteer.d.ts.map +1 -1
- package/build/commands/browser/getPuppeteer.js +14 -21
- package/build/commands/browser/getWindowSize.js +3 -6
- package/build/commands/browser/keys.d.ts +20 -10
- package/build/commands/browser/keys.d.ts.map +1 -1
- package/build/commands/browser/keys.js +29 -24
- package/build/commands/browser/mock.d.ts +5 -4
- package/build/commands/browser/mock.d.ts.map +1 -1
- package/build/commands/browser/mock.js +16 -22
- package/build/commands/browser/mockClearAll.js +5 -11
- package/build/commands/browser/mockRestoreAll.js +5 -11
- package/build/commands/browser/newWindow.js +5 -11
- package/build/commands/browser/pause.js +1 -4
- package/build/commands/browser/react$$.d.ts.map +1 -1
- package/build/commands/browser/react$$.js +16 -17
- package/build/commands/browser/react$.d.ts.map +1 -1
- package/build/commands/browser/react$.js +13 -14
- package/build/commands/browser/reloadSession.js +5 -12
- package/build/commands/browser/savePDF.d.ts +14 -14
- package/build/commands/browser/savePDF.js +21 -27
- package/build/commands/browser/saveRecordingScreen.js +6 -12
- package/build/commands/browser/saveScreenshot.js +6 -12
- package/build/commands/browser/scroll.d.ts +25 -0
- package/build/commands/browser/scroll.d.ts.map +1 -0
- package/build/commands/browser/scroll.js +41 -0
- package/build/commands/browser/setCookies.d.ts +1 -1
- package/build/commands/browser/setCookies.d.ts.map +1 -1
- package/build/commands/browser/setCookies.js +5 -7
- package/build/commands/browser/setTimeout.js +1 -4
- package/build/commands/browser/setWindowSize.js +3 -6
- package/build/commands/browser/switchWindow.js +1 -4
- package/build/commands/browser/throttle.js +3 -6
- package/build/commands/browser/touchAction.d.ts +1 -1
- package/build/commands/browser/touchAction.d.ts.map +1 -1
- package/build/commands/browser/touchAction.js +3 -6
- package/build/commands/browser/uploadFile.d.ts +1 -1
- package/build/commands/browser/uploadFile.d.ts.map +1 -1
- package/build/commands/browser/uploadFile.js +10 -15
- package/build/commands/browser/url.js +3 -6
- package/build/commands/browser/waitUntil.d.ts +1 -2
- package/build/commands/browser/waitUntil.d.ts.map +1 -1
- package/build/commands/browser/waitUntil.js +4 -11
- package/build/commands/browser.d.ts +37 -69
- package/build/commands/browser.d.ts.map +1 -1
- package/build/commands/browser.js +37 -44
- package/build/commands/constant.d.ts +1 -1
- package/build/commands/constant.d.ts.map +1 -1
- package/build/commands/constant.js +6 -12
- package/build/commands/element/$$.d.ts +1 -1
- package/build/commands/element/$$.d.ts.map +1 -1
- package/build/commands/element/$$.js +2 -7
- package/build/commands/element/$.d.ts +1 -1
- package/build/commands/element/$.d.ts.map +1 -1
- package/build/commands/element/$.js +2 -7
- package/build/commands/element/addValue.d.ts +10 -14
- package/build/commands/element/addValue.d.ts.map +1 -1
- package/build/commands/element/addValue.js +23 -27
- package/build/commands/element/clearValue.d.ts +1 -1
- package/build/commands/element/clearValue.js +2 -5
- package/build/commands/element/click.d.ts +1 -1
- package/build/commands/element/click.d.ts.map +1 -1
- package/build/commands/element/click.js +19 -34
- package/build/commands/element/custom$$.js +9 -11
- package/build/commands/element/custom$.js +8 -10
- package/build/commands/element/doubleClick.d.ts.map +1 -1
- package/build/commands/element/doubleClick.js +11 -17
- package/build/commands/element/dragAndDrop.d.ts.map +1 -1
- package/build/commands/element/dragAndDrop.js +13 -19
- package/build/commands/element/getAttribute.js +1 -4
- package/build/commands/element/getCSSProperty.d.ts +1 -1
- package/build/commands/element/getCSSProperty.d.ts.map +1 -1
- package/build/commands/element/getCSSProperty.js +7 -13
- package/build/commands/element/getComputedLabel.js +1 -4
- package/build/commands/element/getComputedRole.js +1 -4
- package/build/commands/element/getHTML.js +7 -13
- package/build/commands/element/getLocation.js +3 -5
- package/build/commands/element/getProperty.d.ts +5 -5
- package/build/commands/element/getProperty.d.ts.map +1 -1
- package/build/commands/element/getProperty.js +5 -11
- package/build/commands/element/getSize.js +3 -5
- package/build/commands/element/getTagName.js +1 -4
- package/build/commands/element/getText.js +1 -4
- package/build/commands/element/getValue.js +1 -4
- package/build/commands/element/isClickable.d.ts.map +1 -1
- package/build/commands/element/isClickable.js +10 -13
- package/build/commands/element/isDisplayed.js +9 -16
- package/build/commands/element/isDisplayedInViewport.js +7 -13
- package/build/commands/element/isEnabled.js +1 -4
- package/build/commands/element/isEqual.d.ts.map +1 -1
- package/build/commands/element/isEqual.js +9 -9
- package/build/commands/element/isExisting.js +1 -4
- package/build/commands/element/isFocused.js +7 -13
- package/build/commands/element/isSelected.js +1 -4
- package/build/commands/element/moveTo.d.ts.map +1 -1
- package/build/commands/element/moveTo.js +8 -13
- package/build/commands/element/nextElement.js +2 -5
- package/build/commands/element/parentElement.js +2 -5
- package/build/commands/element/previousElement.js +2 -5
- package/build/commands/element/react$$.d.ts.map +1 -1
- package/build/commands/element/react$$.js +16 -16
- package/build/commands/element/react$.d.ts.map +1 -1
- package/build/commands/element/react$.js +15 -14
- package/build/commands/element/saveScreenshot.js +6 -12
- package/build/commands/element/scrollIntoView.d.ts +4 -2
- package/build/commands/element/scrollIntoView.d.ts.map +1 -1
- package/build/commands/element/scrollIntoView.js +33 -12
- package/build/commands/element/selectByAttribute.js +3 -6
- package/build/commands/element/selectByIndex.js +3 -6
- package/build/commands/element/selectByVisibleText.js +3 -6
- package/build/commands/element/setValue.d.ts +13 -14
- package/build/commands/element/setValue.d.ts.map +1 -1
- package/build/commands/element/setValue.js +14 -17
- package/build/commands/element/shadow$$.d.ts +1 -1
- package/build/commands/element/shadow$$.d.ts.map +1 -1
- package/build/commands/element/shadow$$.js +3 -6
- package/build/commands/element/shadow$.js +3 -6
- package/build/commands/element/touchAction.js +3 -6
- package/build/commands/element/waitForClickable.js +1 -4
- package/build/commands/element/waitForDisplayed.js +1 -4
- package/build/commands/element/waitForEnabled.js +1 -4
- package/build/commands/element/waitForExist.js +1 -4
- package/build/commands/element/waitUntil.d.ts +2 -3
- package/build/commands/element/waitUntil.d.ts.map +1 -1
- package/build/commands/element/waitUntil.js +3 -9
- package/build/commands/element.d.ts +49 -99
- package/build/commands/element.d.ts.map +1 -1
- package/build/commands/element.js +49 -63
- package/build/constants.d.ts +67 -0
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +105 -12
- package/build/index.d.ts +65 -6
- package/build/index.d.ts.map +1 -1
- package/build/index.js +48 -86
- package/build/middlewares.d.ts +1 -1
- package/build/middlewares.js +11 -19
- package/build/multiremote.js +18 -24
- package/build/protocol-stub.d.ts.map +1 -1
- package/build/protocol-stub.js +4 -6
- package/build/scripts/getHTML.js +1 -4
- package/build/scripts/getProperty.d.ts +5 -5
- package/build/scripts/getProperty.d.ts.map +1 -1
- package/build/scripts/getProperty.js +1 -4
- package/build/scripts/isElementClickable.js +1 -4
- package/build/scripts/isElementDisplayed.js +2 -5
- package/build/scripts/isElementInViewport.js +1 -4
- package/build/scripts/isFocused.js +1 -4
- package/build/scripts/newWindow.js +1 -4
- package/build/scripts/resq.js +3 -9
- package/build/scripts/shadowFnFactory.js +2 -6
- package/build/types.d.ts +5 -9
- package/build/types.d.ts.map +1 -1
- package/build/types.js +1 -2
- package/build/utils/SevereServiceError.js +1 -4
- package/build/utils/Timer.d.ts.map +1 -1
- package/build/utils/Timer.js +13 -29
- package/build/utils/actions/base.d.ts +32 -0
- package/build/utils/actions/base.d.ts.map +1 -0
- package/build/utils/actions/base.js +66 -0
- package/build/utils/actions/index.d.ts +6 -0
- package/build/utils/actions/index.d.ts.map +1 -0
- package/build/utils/actions/index.js +5 -0
- package/build/utils/actions/key.d.ts +15 -0
- package/build/utils/actions/key.d.ts.map +1 -0
- package/build/utils/actions/key.js +22 -0
- package/build/utils/actions/pointer.d.ts +62 -0
- package/build/utils/actions/pointer.d.ts.map +1 -0
- package/build/utils/actions/pointer.js +76 -0
- package/build/utils/actions/wheel.d.ts +36 -0
- package/build/utils/actions/wheel.d.ts.map +1 -0
- package/build/utils/actions/wheel.js +20 -0
- package/build/utils/detectBackend.d.ts +1 -1
- package/build/utils/detectBackend.d.ts.map +1 -1
- package/build/utils/detectBackend.js +3 -7
- package/build/utils/findStrategy.d.ts.map +1 -1
- package/build/utils/findStrategy.js +50 -19
- package/build/utils/getElementObject.d.ts +1 -1
- package/build/utils/getElementObject.d.ts.map +1 -1
- package/build/utils/getElementObject.js +51 -32
- package/build/utils/implicitWait.js +3 -9
- package/build/utils/index.d.ts +8 -7
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +125 -148
- package/build/utils/interception/devtools.d.ts +1 -1
- package/build/utils/interception/devtools.d.ts.map +1 -1
- package/build/utils/interception/devtools.js +17 -36
- package/build/utils/interception/index.d.ts +2 -2
- package/build/utils/interception/index.d.ts.map +1 -1
- package/build/utils/interception/index.js +10 -13
- package/build/utils/interception/types.d.ts +1 -1
- package/build/utils/interception/types.d.ts.map +1 -1
- package/build/utils/interception/types.js +1 -2
- package/build/utils/interception/webdriver.d.ts +1 -1
- package/build/utils/interception/webdriver.d.ts.map +1 -1
- package/build/utils/interception/webdriver.js +6 -11
- package/build/utils/refetchElement.js +3 -9
- package/package.json +27 -17
- package/async.d.ts +0 -24
- package/sync.d.ts +0 -24
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const _1 = __importDefault(require("."));
|
|
10
|
-
const __1 = require("..");
|
|
11
|
-
const constants_1 = require("../../constants");
|
|
12
|
-
const log = (0, logger_1.default)('webdriverio');
|
|
13
|
-
class DevtoolsInterception extends _1.default {
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import logger from '@wdio/logger';
|
|
4
|
+
import Interception from './index.js';
|
|
5
|
+
import { containsHeaderObject } from '../index.js';
|
|
6
|
+
import { ERROR_REASON } from '../../constants.js';
|
|
7
|
+
const log = logger('webdriverio');
|
|
8
|
+
export default class DevtoolsInterception extends Interception {
|
|
14
9
|
static handleRequestInterception(client, mocks) {
|
|
15
10
|
return async (event) => {
|
|
16
11
|
// responseHeaders and responseStatusCode are only present in Response stage
|
|
@@ -36,7 +31,7 @@ class DevtoolsInterception extends _1.default {
|
|
|
36
31
|
/**
|
|
37
32
|
* match mock url
|
|
38
33
|
*/
|
|
39
|
-
if (!
|
|
34
|
+
if (!Interception.isMatchingRequest(mock.url, request.url)) {
|
|
40
35
|
continue;
|
|
41
36
|
}
|
|
42
37
|
/**
|
|
@@ -94,9 +89,10 @@ class DevtoolsInterception extends _1.default {
|
|
|
94
89
|
/**
|
|
95
90
|
* check if local file and load it
|
|
96
91
|
*/
|
|
97
|
-
const responseFilePath =
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
const responseFilePath = path.isAbsolute(newBody) ? newBody : path.join(process.cwd(), newBody);
|
|
93
|
+
const responseFileAccessible = await fs.access(responseFilePath).then(() => true, () => false);
|
|
94
|
+
if (newBody.length > 0 && responseFileAccessible) {
|
|
95
|
+
newBody = (await fs.readFile(responseFilePath));
|
|
100
96
|
}
|
|
101
97
|
else if (newBody.startsWith('http')) {
|
|
102
98
|
responseCode = 301;
|
|
@@ -169,8 +165,8 @@ class DevtoolsInterception extends _1.default {
|
|
|
169
165
|
* @param {string} errorCode error code of the response
|
|
170
166
|
*/
|
|
171
167
|
abort(errorReason, sticky = true) {
|
|
172
|
-
if (typeof errorReason !== 'string' || !
|
|
173
|
-
throw new Error(`Invalid value for errorReason, allowed are: ${
|
|
168
|
+
if (typeof errorReason !== 'string' || !ERROR_REASON.includes(errorReason)) {
|
|
169
|
+
throw new Error(`Invalid value for errorReason, allowed are: ${ERROR_REASON.join(', ')}`);
|
|
174
170
|
}
|
|
175
171
|
this.respondOverwrites.push({ errorReason, sticky });
|
|
176
172
|
}
|
|
@@ -182,7 +178,6 @@ class DevtoolsInterception extends _1.default {
|
|
|
182
178
|
this.abort(errorReason, false);
|
|
183
179
|
}
|
|
184
180
|
}
|
|
185
|
-
exports.default = DevtoolsInterception;
|
|
186
181
|
const filterMethod = (method, expected) => {
|
|
187
182
|
if (typeof expected === 'undefined') {
|
|
188
183
|
return false;
|
|
@@ -199,7 +194,7 @@ const filterHeaders = (responseHeaders, expected) => {
|
|
|
199
194
|
if (typeof expected === 'function') {
|
|
200
195
|
return expected(responseHeaders) !== true;
|
|
201
196
|
}
|
|
202
|
-
return !
|
|
197
|
+
return !containsHeaderObject(responseHeaders, expected);
|
|
203
198
|
};
|
|
204
199
|
const filterRequest = (postData, expected) => {
|
|
205
200
|
if (typeof expected === 'undefined') {
|
|
@@ -219,20 +214,6 @@ const filterStatusCode = (statusCode, expected) => {
|
|
|
219
214
|
}
|
|
220
215
|
return statusCode !== expected;
|
|
221
216
|
};
|
|
222
|
-
/**
|
|
223
|
-
* Helper utility to check file access
|
|
224
|
-
* @param {String} file file to check access for
|
|
225
|
-
* @return Promise<true> if file can be accessed
|
|
226
|
-
*/
|
|
227
|
-
const canAccess = async (filepath) => {
|
|
228
|
-
try {
|
|
229
|
-
await fs_extra_1.default.access(filepath);
|
|
230
|
-
return true;
|
|
231
|
-
}
|
|
232
|
-
catch {
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
217
|
const tryParseJson = (body) => {
|
|
237
218
|
try {
|
|
238
219
|
return JSON.parse(body) || body;
|
|
@@ -243,5 +224,5 @@ const tryParseJson = (body) => {
|
|
|
243
224
|
};
|
|
244
225
|
const logFetchError = (err) => {
|
|
245
226
|
/* istanbul ignore next */
|
|
246
|
-
log.debug(err
|
|
227
|
+
log.debug(err?.message);
|
|
247
228
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { WaitForOptions } from '../../types';
|
|
2
|
-
import { MockFilterOptions, MockOverwrite, MockResponseParams, Matches } from './types';
|
|
1
|
+
import type { WaitForOptions } from '../../types';
|
|
2
|
+
import type { MockFilterOptions, MockOverwrite, MockResponseParams, Matches } from './types';
|
|
3
3
|
import type Protocol from 'devtools-protocol';
|
|
4
4
|
export default abstract class Interception {
|
|
5
5
|
url: string | RegExp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/interception/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/interception/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE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M,CAAC,iBAAiB,CAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM;CAU5E"}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import minimatch from 'minimatch';
|
|
2
|
+
import Timer from '../Timer.js';
|
|
3
|
+
export default class Interception {
|
|
4
|
+
url;
|
|
5
|
+
filterOptions;
|
|
6
|
+
browser;
|
|
7
|
+
respondOverwrites = [];
|
|
8
|
+
matches = [];
|
|
9
9
|
constructor(url, filterOptions = {}, browser) {
|
|
10
10
|
this.url = url;
|
|
11
11
|
this.filterOptions = filterOptions;
|
|
12
12
|
this.browser = browser;
|
|
13
|
-
this.respondOverwrites = [];
|
|
14
|
-
this.matches = [];
|
|
15
13
|
}
|
|
16
14
|
waitForResponse({ timeout = this.browser.options.waitforTimeout, interval = this.browser.options.waitforInterval, timeoutMsg, } = {}) {
|
|
17
15
|
/*!
|
|
@@ -25,7 +23,7 @@ class Interception {
|
|
|
25
23
|
}
|
|
26
24
|
/* istanbul ignore next */
|
|
27
25
|
const fn = async () => this.calls && (await this.calls).length > 0;
|
|
28
|
-
const timer = new
|
|
26
|
+
const timer = new Timer(interval, timeout, fn, true);
|
|
29
27
|
return this.browser.call(() => timer.catch((e) => {
|
|
30
28
|
if (e.message === 'timeout') {
|
|
31
29
|
if (typeof timeoutMsg === 'string') {
|
|
@@ -38,7 +36,7 @@ class Interception {
|
|
|
38
36
|
}
|
|
39
37
|
static isMatchingRequest(expectedUrl, actualUrl) {
|
|
40
38
|
if (typeof expectedUrl === 'string') {
|
|
41
|
-
return (
|
|
39
|
+
return minimatch(actualUrl, expectedUrl);
|
|
42
40
|
}
|
|
43
41
|
if (expectedUrl instanceof RegExp) {
|
|
44
42
|
return Boolean(actualUrl.match(expectedUrl));
|
|
@@ -46,4 +44,3 @@ class Interception {
|
|
|
46
44
|
throw new Error(`Unexpected type for mock url: ${expectedUrl}`);
|
|
47
45
|
}
|
|
48
46
|
}
|
|
49
|
-
exports.default = Interception;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { CDPSession } from 'puppeteer-core/lib/cjs/puppeteer/common/Connection';
|
|
3
|
-
import { JsonCompatible } from '@wdio/types';
|
|
3
|
+
import type { JsonCompatible } from '@wdio/types';
|
|
4
4
|
/**
|
|
5
5
|
* HTTP request data. (copied from the puppeteer-core package as there is currently
|
|
6
6
|
* no way to access these types otherwise)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/interception/types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oDAAoD,CAAA;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/interception/types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oDAAoD,CAAA;AACpF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD;;;GAGG;AACH,oBAAY,gBAAgB,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAA;AACjF,oBAAY,gBAAgB,GAAG,WAAW,GAAG,sBAAsB,GAAG,MAAM,CAAA;AAC5E,oBAAY,cAAc,GAAG,YAAY,GAAG,4BAA4B,GAAG,aAAa,GAAG,QAAQ,GAAG,0BAA0B,GAAG,aAAa,GAAG,eAAe,GAAG,iCAAiC,CAAA;AACtM,MAAM,WAAW,OAAO;IACpB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;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CAClB;AACD,oBAAY,eAAe,GAAG,cAAc,GAAG,cAAc,CAAA"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webdriver.d.ts","sourceRoot":"","sources":["../../../src/utils/interception/webdriver.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"webdriver.d.ts","sourceRoot":"","sources":["../../../src/utils/interception/webdriver.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,YAAY,CAAA;AAErC,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEzE;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,YAAY;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAA;IAET,IAAI;IAQV;;OAEG;IACH,IAAI,KAAK,mCAIR;IAED;;OAEG;IACH,KAAK;IAKL;;;OAGG;IACH,OAAO;IAKP;;;;OAIG;IACH,OAAO,CAAE,SAAS,EAAE,aAAa,EAAE,MAAM,GAAE,kBAAuB;IASlE;;;;OAIG;IACH,WAAW,CAAE,SAAS,EAAE,aAAa,EAAE,MAAM,GAAE,kBAAuB;IAStE;;;OAGG;IACH,KAAK,CAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAE,OAAc;IAYlD;;;OAGG;IACH,SAAS,CAAE,WAAW,EAAE,MAAM;CAGjC"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const _1 = __importDefault(require("."));
|
|
7
|
-
const constants_1 = require("../../constants");
|
|
1
|
+
import Interception from './index.js';
|
|
2
|
+
import { ERROR_REASON } from '../../constants.js';
|
|
8
3
|
/**
|
|
9
4
|
* Network interception class based on a WebDriver compliant endpoint.
|
|
10
5
|
* Instead of directly using the CDP with Puppeteer this version of the
|
|
11
6
|
* class uses a WebDriver extension to trigger the same behavior on a
|
|
12
7
|
* compliant backend.
|
|
13
8
|
*/
|
|
14
|
-
class WebDriverInterception extends
|
|
9
|
+
export default class WebDriverInterception extends Interception {
|
|
10
|
+
mockId;
|
|
15
11
|
async init() {
|
|
16
12
|
if (this.url instanceof RegExp) {
|
|
17
13
|
throw new Error('Regular Expressions as mock url are not supported');
|
|
@@ -59,8 +55,8 @@ class WebDriverInterception extends _1.default {
|
|
|
59
55
|
* @param {string} errorCode error code of the response
|
|
60
56
|
*/
|
|
61
57
|
abort(errorReason, sticky = true) {
|
|
62
|
-
if (typeof errorReason !== 'string' || !
|
|
63
|
-
throw new Error(`Invalid value for errorReason, allowed are: ${
|
|
58
|
+
if (typeof errorReason !== 'string' || !ERROR_REASON.includes(errorReason)) {
|
|
59
|
+
throw new Error(`Invalid value for errorReason, allowed are: ${ERROR_REASON.join(', ')}`);
|
|
64
60
|
}
|
|
65
61
|
return this.browser.call(async () => this.browser.respondMock(this.mockId, { errorReason, sticky }));
|
|
66
62
|
}
|
|
@@ -72,4 +68,3 @@ class WebDriverInterception extends _1.default {
|
|
|
72
68
|
return this.abort(errorReason, false);
|
|
73
69
|
}
|
|
74
70
|
}
|
|
75
|
-
exports.default = WebDriverInterception;
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const implicitWait_1 = __importDefault(require("./implicitWait"));
|
|
1
|
+
import implicitWait from './implicitWait.js';
|
|
7
2
|
/**
|
|
8
3
|
* helper utility to refetch an element and all its parent elements when running
|
|
9
4
|
* into stale element exception errors
|
|
10
5
|
*/
|
|
11
|
-
async function refetchElement(currentElement, commandName) {
|
|
6
|
+
export default async function refetchElement(currentElement, commandName) {
|
|
12
7
|
let selectors = [];
|
|
13
8
|
//Crawl back to the browser object, and cache all selectors
|
|
14
9
|
while (currentElement.elementId && currentElement.parent) {
|
|
@@ -26,7 +21,6 @@ async function refetchElement(currentElement, commandName) {
|
|
|
26
21
|
* For error purposes, changing command name to '$' if we aren't
|
|
27
22
|
* on the last element of the array
|
|
28
23
|
*/
|
|
29
|
-
return await (
|
|
24
|
+
return await implicitWait(nextElement, currentIndex + 1 < length ? '$' : commandName);
|
|
30
25
|
}, Promise.resolve(currentElement));
|
|
31
26
|
}
|
|
32
|
-
exports.default = refetchElement;
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webdriverio",
|
|
3
3
|
"description": "Next-gen browser and mobile automation test framework for Node.js",
|
|
4
|
-
"version": "7.20.
|
|
4
|
+
"version": "7.20.8-alpha.504+428a9d729",
|
|
5
5
|
"homepage": "https://webdriver.io",
|
|
6
6
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"main": "./build/index.js",
|
|
9
8
|
"repository": {
|
|
10
9
|
"type": "git",
|
|
11
|
-
"url": "git://github.com/webdriverio/webdriverio.git"
|
|
10
|
+
"url": "git://github.com/webdriverio/webdriverio.git",
|
|
11
|
+
"directory": "packages/webdriverio"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/webdriverio/webdriverio/issues"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
17
|
+
"node": "^16.13 || >=18"
|
|
18
18
|
},
|
|
19
19
|
"tags": [
|
|
20
20
|
"webdriver",
|
|
@@ -44,11 +44,22 @@
|
|
|
44
44
|
"cucumber",
|
|
45
45
|
"testingbot"
|
|
46
46
|
],
|
|
47
|
+
"main": "./build/cjs/index.js",
|
|
48
|
+
"type": "module",
|
|
49
|
+
"module": "./build/index.js",
|
|
50
|
+
"exports": {
|
|
51
|
+
".": [
|
|
52
|
+
{
|
|
53
|
+
"import": "./build/index.js",
|
|
54
|
+
"require": "./build/cjs/index.js"
|
|
55
|
+
},
|
|
56
|
+
"./build/cjs/index.js"
|
|
57
|
+
]
|
|
58
|
+
},
|
|
47
59
|
"types": "./build/index.d.ts",
|
|
48
60
|
"typeScriptVersion": "3.8.3",
|
|
49
61
|
"devDependencies": {
|
|
50
62
|
"@types/archiver": "^5.1.0",
|
|
51
|
-
"@types/fs-extra": "^9.0.2",
|
|
52
63
|
"@types/lodash.clonedeep": "^4.5.6",
|
|
53
64
|
"@types/lodash.isobject": "^3.0.6",
|
|
54
65
|
"@types/lodash.isplainobject": "^4.0.6",
|
|
@@ -57,31 +68,30 @@
|
|
|
57
68
|
"dependencies": {
|
|
58
69
|
"@types/aria-query": "^5.0.0",
|
|
59
70
|
"@types/node": "^18.0.0",
|
|
60
|
-
"@wdio/config": "7.20.
|
|
61
|
-
"@wdio/logger": "7.
|
|
62
|
-
"@wdio/protocols": "7.20.
|
|
63
|
-
"@wdio/repl": "7.20.
|
|
64
|
-
"@wdio/types": "7.20.
|
|
65
|
-
"@wdio/utils": "7.20.
|
|
71
|
+
"@wdio/config": "7.20.8-alpha.504+428a9d729",
|
|
72
|
+
"@wdio/logger": "7.20.8-alpha.504+428a9d729",
|
|
73
|
+
"@wdio/protocols": "7.20.8-alpha.504+428a9d729",
|
|
74
|
+
"@wdio/repl": "7.20.8-alpha.504+428a9d729",
|
|
75
|
+
"@wdio/types": "7.20.8-alpha.504+428a9d729",
|
|
76
|
+
"@wdio/utils": "7.20.8-alpha.504+428a9d729",
|
|
66
77
|
"archiver": "^5.0.0",
|
|
67
78
|
"aria-query": "^5.0.0",
|
|
68
79
|
"css-shorthand-properties": "^1.1.1",
|
|
69
80
|
"css-value": "^0.0.1",
|
|
70
|
-
"devtools": "7.20.
|
|
71
|
-
"devtools-protocol": "^0.0.
|
|
72
|
-
"fs-extra": "^10.0.0",
|
|
81
|
+
"devtools": "7.20.8-alpha.504+428a9d729",
|
|
82
|
+
"devtools-protocol": "^0.0.1065144",
|
|
73
83
|
"grapheme-splitter": "^1.0.2",
|
|
74
84
|
"lodash.clonedeep": "^4.5.0",
|
|
75
85
|
"lodash.isobject": "^3.0.2",
|
|
76
86
|
"lodash.isplainobject": "^4.0.6",
|
|
77
87
|
"lodash.zip": "^4.2.0",
|
|
78
88
|
"minimatch": "^5.0.0",
|
|
79
|
-
"puppeteer-core": "
|
|
89
|
+
"puppeteer-core": "19.2.0",
|
|
80
90
|
"query-selector-shadow-dom": "^1.0.0",
|
|
81
91
|
"resq": "^1.9.1",
|
|
82
92
|
"rgb2hex": "0.2.5",
|
|
83
93
|
"serialize-error": "^8.0.0",
|
|
84
|
-
"webdriver": "7.20.
|
|
94
|
+
"webdriver": "7.20.8-alpha.504+428a9d729"
|
|
85
95
|
},
|
|
86
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "428a9d729ae6231968a60908732fa3f607d195e9"
|
|
87
97
|
}
|
package/async.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
type BrowserSync = import('./build/types').Browser<'async'>
|
|
2
|
-
type ElementSync = import('./build/types').Element<'async'>
|
|
3
|
-
type MultiRemoteBrowserAsync = import('./build/types').MultiRemoteBrowser<'async'>
|
|
4
|
-
type ElementArrayImport = import('./build/types').ElementArray
|
|
5
|
-
|
|
6
|
-
declare namespace WebdriverIOAsync {
|
|
7
|
-
interface Browser {}
|
|
8
|
-
interface Element {}
|
|
9
|
-
interface MultiRemoteBrowser {}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare namespace WebdriverIO {
|
|
13
|
-
interface Browser extends BrowserSync, WebdriverIOAsync.Browser { }
|
|
14
|
-
interface Element extends ElementSync, WebdriverIOAsync.Element { }
|
|
15
|
-
// @ts-expect-error
|
|
16
|
-
interface MultiRemoteBrowser extends MultiRemoteBrowserAsync, WebdriverIOAsync.MultiRemoteBrowser { }
|
|
17
|
-
interface ElementArray extends ElementArrayImport {}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
declare function $(...args: Parameters<WebdriverIO.Browser['$']>): ReturnType<WebdriverIO.Browser['$']>
|
|
21
|
-
declare function $$(...args: Parameters<WebdriverIO.Browser['$$']>): ReturnType<WebdriverIO.Browser['$$']>
|
|
22
|
-
declare const browser: WebdriverIO.Browser
|
|
23
|
-
declare const driver: WebdriverIO.Browser
|
|
24
|
-
declare const multiremotebrowser: WebdriverIO.MultiRemoteBrowser
|
package/sync.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
type BrowserSync = import('./build/types').Browser<'sync'>
|
|
2
|
-
type ElementSync = import('./build/types').Element<'sync'>
|
|
3
|
-
type MultiRemoteBrowserSync = import('./build/types').MultiRemoteBrowser<'sync'>
|
|
4
|
-
type ElementArrayImport = import('./build/types').ElementArray
|
|
5
|
-
|
|
6
|
-
declare namespace WebdriverIOSync {
|
|
7
|
-
interface Browser {}
|
|
8
|
-
interface Element {}
|
|
9
|
-
interface MultiRemoteBrowser {}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare namespace WebdriverIO {
|
|
13
|
-
interface Browser extends BrowserSync, WebdriverIOSync.Browser { }
|
|
14
|
-
interface Element extends ElementSync, WebdriverIOSync.Element { }
|
|
15
|
-
// @ts-expect-error
|
|
16
|
-
interface MultiRemoteBrowser extends MultiRemoteBrowserSync, WebdriverIOSync.MultiRemoteBrowser { }
|
|
17
|
-
interface ElementArray extends ElementArrayImport {}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
declare function $(...args: Parameters<WebdriverIO.Browser['$']>): ReturnType<WebdriverIO.Browser['$']>
|
|
21
|
-
declare function $$(...args: Parameters<WebdriverIO.Browser['$$']>): ReturnType<WebdriverIO.Browser['$$']>
|
|
22
|
-
declare const browser: WebdriverIO.Browser
|
|
23
|
-
declare const driver: WebdriverIO.Browser
|
|
24
|
-
declare const multiremotebrowser: WebdriverIO.MultiRemoteBrowser
|