webdriverio 9.2.5 → 9.2.6
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 +161 -161
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -150,13 +150,13 @@ var WebDriverError = class extends Error {
|
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
152
|
function getElement(selector, res, props = { isReactElement: false, isShadowElement: false }) {
|
|
153
|
-
const
|
|
153
|
+
const browser = getBrowserObject(this);
|
|
154
154
|
const browserCommandKeys = Object.keys(browser_exports);
|
|
155
155
|
const propertiesObject = {
|
|
156
156
|
/**
|
|
157
157
|
* filter out browser commands from object
|
|
158
158
|
*/
|
|
159
|
-
...Object.entries(clone(
|
|
159
|
+
...Object.entries(clone(browser.__propertiesObject__)).reduce((commands, [name, descriptor]) => {
|
|
160
160
|
if (!browserCommandKeys.includes(name)) {
|
|
161
161
|
commands[name] = descriptor;
|
|
162
162
|
}
|
|
@@ -188,19 +188,19 @@ function getElement(selector, res, props = { isReactElement: false, isShadowElem
|
|
|
188
188
|
const elementInstance = element(this.sessionId, elementErrorHandler(wrapCommand));
|
|
189
189
|
const origAddCommand = elementInstance.addCommand.bind(elementInstance);
|
|
190
190
|
elementInstance.addCommand = (name, fn) => {
|
|
191
|
-
|
|
191
|
+
browser.__propertiesObject__[name] = { value: fn };
|
|
192
192
|
origAddCommand(name, fn);
|
|
193
193
|
};
|
|
194
194
|
return elementInstance;
|
|
195
195
|
}
|
|
196
196
|
var getElements = function getElements2(selector, elemResponse, props = { isReactElement: false, isShadowElement: false }) {
|
|
197
|
-
const
|
|
197
|
+
const browser = getBrowserObject(this);
|
|
198
198
|
const browserCommandKeys = Object.keys(browser_exports);
|
|
199
199
|
const propertiesObject = {
|
|
200
200
|
/**
|
|
201
201
|
* filter out browser commands from object
|
|
202
202
|
*/
|
|
203
|
-
...Object.entries(clone(
|
|
203
|
+
...Object.entries(clone(browser.__propertiesObject__)).reduce((commands, [name, descriptor]) => {
|
|
204
204
|
if (!browserCommandKeys.includes(name)) {
|
|
205
205
|
commands[name] = descriptor;
|
|
206
206
|
}
|
|
@@ -239,7 +239,7 @@ var getElements = function getElements2(selector, elemResponse, props = { isReac
|
|
|
239
239
|
const elementInstance = element(this.sessionId, elementErrorHandler(wrapCommand));
|
|
240
240
|
const origAddCommand = elementInstance.addCommand.bind(elementInstance);
|
|
241
241
|
elementInstance.addCommand = (name, fn) => {
|
|
242
|
-
|
|
242
|
+
browser.__propertiesObject__[name] = { value: fn };
|
|
243
243
|
origAddCommand(name, fn);
|
|
244
244
|
};
|
|
245
245
|
return elementInstance;
|
|
@@ -1129,8 +1129,8 @@ var ClockManager = class {
|
|
|
1129
1129
|
#browser;
|
|
1130
1130
|
#resetFn = () => Promise.resolve();
|
|
1131
1131
|
#isInstalled = false;
|
|
1132
|
-
constructor(
|
|
1133
|
-
this.#browser =
|
|
1132
|
+
constructor(browser) {
|
|
1133
|
+
this.#browser = browser;
|
|
1134
1134
|
}
|
|
1135
1135
|
/**
|
|
1136
1136
|
* Install fake timers on the browser. If you call the `emulate` command, WebdriverIO will automatically install
|
|
@@ -2578,13 +2578,13 @@ var deviceDescriptorsSource = {
|
|
|
2578
2578
|
};
|
|
2579
2579
|
|
|
2580
2580
|
// src/commands/browser/emulate.ts
|
|
2581
|
-
function storeRestoreFunction(
|
|
2582
|
-
if (!restoreFunctions.has(
|
|
2583
|
-
restoreFunctions.set(
|
|
2581
|
+
function storeRestoreFunction(browser, scope, fn) {
|
|
2582
|
+
if (!restoreFunctions.has(browser)) {
|
|
2583
|
+
restoreFunctions.set(browser, /* @__PURE__ */ new Map());
|
|
2584
2584
|
}
|
|
2585
|
-
const restoreFunctionsList = restoreFunctions.get(
|
|
2585
|
+
const restoreFunctionsList = restoreFunctions.get(browser)?.get(scope);
|
|
2586
2586
|
const updatedList = restoreFunctionsList ? [...restoreFunctionsList, fn] : [fn];
|
|
2587
|
-
restoreFunctions.get(
|
|
2587
|
+
restoreFunctions.get(browser)?.set(scope, updatedList);
|
|
2588
2588
|
}
|
|
2589
2589
|
async function emulate(scope, options) {
|
|
2590
2590
|
if (!this.isBidi) {
|
|
@@ -2975,20 +2975,20 @@ var ReferenceValue = class {
|
|
|
2975
2975
|
|
|
2976
2976
|
// src/context.ts
|
|
2977
2977
|
var contextManager = /* @__PURE__ */ new Map();
|
|
2978
|
-
function getContextManager(
|
|
2979
|
-
const existingContextManager = contextManager.get(
|
|
2978
|
+
function getContextManager(browser) {
|
|
2979
|
+
const existingContextManager = contextManager.get(browser);
|
|
2980
2980
|
if (existingContextManager) {
|
|
2981
2981
|
return existingContextManager;
|
|
2982
2982
|
}
|
|
2983
|
-
const newContext = new ContextManager(
|
|
2984
|
-
contextManager.set(
|
|
2983
|
+
const newContext = new ContextManager(browser);
|
|
2984
|
+
contextManager.set(browser, newContext);
|
|
2985
2985
|
return newContext;
|
|
2986
2986
|
}
|
|
2987
2987
|
var ContextManager = class {
|
|
2988
2988
|
#browser;
|
|
2989
2989
|
#currentContext;
|
|
2990
|
-
constructor(
|
|
2991
|
-
this.#browser =
|
|
2990
|
+
constructor(browser) {
|
|
2991
|
+
this.#browser = browser;
|
|
2992
2992
|
if (!this.#isEnabled()) {
|
|
2993
2993
|
return;
|
|
2994
2994
|
}
|
|
@@ -3005,7 +3005,7 @@ var ContextManager = class {
|
|
|
3005
3005
|
* Only run this session helper if BiDi is enabled and we're not in unit tests.
|
|
3006
3006
|
*/
|
|
3007
3007
|
#isEnabled() {
|
|
3008
|
-
return !process.env.WDIO_UNIT_TESTS && browser.isBidi;
|
|
3008
|
+
return !process.env.WDIO_UNIT_TESTS && this.#browser.isBidi;
|
|
3009
3009
|
}
|
|
3010
3010
|
/**
|
|
3011
3011
|
* set context at the start of the session
|
|
@@ -3034,19 +3034,19 @@ import logger4 from "@wdio/logger";
|
|
|
3034
3034
|
var polyfillManager = /* @__PURE__ */ new Map();
|
|
3035
3035
|
var log4 = logger4("webdriverio:PolyfillManager");
|
|
3036
3036
|
var NAME_POLYFILL = "var __defProp = Object.defineProperty;var __name = function (target, value) { return __defProp(target, 'name', { value: value, configurable: true }); };var __globalThis = (typeof globalThis === 'object' && globalThis) || (typeof window === 'object' && window);__globalThis.__name = __name;";
|
|
3037
|
-
function getPolyfillManager(
|
|
3038
|
-
const existingPolyfillManager = polyfillManager.get(
|
|
3037
|
+
function getPolyfillManager(browser) {
|
|
3038
|
+
const existingPolyfillManager = polyfillManager.get(browser);
|
|
3039
3039
|
if (existingPolyfillManager) {
|
|
3040
3040
|
return existingPolyfillManager;
|
|
3041
3041
|
}
|
|
3042
|
-
const newContext = new PolyfillManager(
|
|
3043
|
-
polyfillManager.set(
|
|
3042
|
+
const newContext = new PolyfillManager(browser);
|
|
3043
|
+
polyfillManager.set(browser, newContext);
|
|
3044
3044
|
return newContext;
|
|
3045
3045
|
}
|
|
3046
3046
|
var PolyfillManager = class {
|
|
3047
3047
|
#initialize;
|
|
3048
|
-
constructor(
|
|
3049
|
-
if (!
|
|
3048
|
+
constructor(browser) {
|
|
3049
|
+
if (!browser.isBidi || process.env.WDIO_UNIT_TESTS || browser.options?.automationProtocol !== "webdriver") {
|
|
3050
3050
|
this.#initialize = Promise.resolve(true);
|
|
3051
3051
|
return;
|
|
3052
3052
|
}
|
|
@@ -3055,8 +3055,8 @@ var PolyfillManager = class {
|
|
|
3055
3055
|
return closure();
|
|
3056
3056
|
};
|
|
3057
3057
|
this.#initialize = Promise.all([
|
|
3058
|
-
|
|
3059
|
-
|
|
3058
|
+
browser.addInitScript(polyfill, NAME_POLYFILL),
|
|
3059
|
+
browser.execute(polyfill, NAME_POLYFILL)
|
|
3060
3060
|
]).then(() => {
|
|
3061
3061
|
log4.info("polyfill script added");
|
|
3062
3062
|
return true;
|
|
@@ -3073,8 +3073,8 @@ async function execute(script, ...args) {
|
|
|
3073
3073
|
throw new Error("number or type of arguments don't agree with execute protocol command");
|
|
3074
3074
|
}
|
|
3075
3075
|
if (this.isBidi && !this.isMultiremote) {
|
|
3076
|
-
const
|
|
3077
|
-
const contextManager2 = getContextManager(
|
|
3076
|
+
const browser = getBrowserObject2(this);
|
|
3077
|
+
const contextManager2 = getContextManager(browser);
|
|
3078
3078
|
const context = await contextManager2.getCurrentContext();
|
|
3079
3079
|
const userScript = typeof script === "string" ? new Function(script) : script;
|
|
3080
3080
|
const functionDeclaration = new Function(`
|
|
@@ -3088,7 +3088,7 @@ async function execute(script, ...args) {
|
|
|
3088
3088
|
context
|
|
3089
3089
|
}
|
|
3090
3090
|
};
|
|
3091
|
-
const result = await
|
|
3091
|
+
const result = await browser.scriptCallFunction(params);
|
|
3092
3092
|
return parseScriptResult(params, result);
|
|
3093
3093
|
}
|
|
3094
3094
|
if (typeof script === "function") {
|
|
@@ -3107,8 +3107,8 @@ async function executeAsync(script, ...args) {
|
|
|
3107
3107
|
throw new Error("number or type of arguments don't agree with execute protocol command");
|
|
3108
3108
|
}
|
|
3109
3109
|
if (this.isBidi && !this.isMultiremote) {
|
|
3110
|
-
const
|
|
3111
|
-
const contextManager2 = getContextManager(
|
|
3110
|
+
const browser = getBrowserObject3(this);
|
|
3111
|
+
const contextManager2 = getContextManager(browser);
|
|
3112
3112
|
const context = await contextManager2.getCurrentContext();
|
|
3113
3113
|
const userScript = typeof script === "string" ? new Function(script) : script;
|
|
3114
3114
|
const functionDeclaration = new Function(`
|
|
@@ -3130,7 +3130,7 @@ async function executeAsync(script, ...args) {
|
|
|
3130
3130
|
context
|
|
3131
3131
|
}
|
|
3132
3132
|
};
|
|
3133
|
-
const result = await
|
|
3133
|
+
const result = await browser.scriptCallFunction(params);
|
|
3134
3134
|
return parseScriptResult(params, result);
|
|
3135
3135
|
}
|
|
3136
3136
|
if (typeof script === "function") {
|
|
@@ -3281,8 +3281,8 @@ async function getPuppeteer() {
|
|
|
3281
3281
|
// src/commands/browser/getWindowSize.ts
|
|
3282
3282
|
import { getBrowserObject as getBrowserObject4 } from "@wdio/utils";
|
|
3283
3283
|
async function getWindowSize() {
|
|
3284
|
-
const
|
|
3285
|
-
const { width, height } = await
|
|
3284
|
+
const browser = getBrowserObject4(this);
|
|
3285
|
+
const { width, height } = await browser.getWindowRect();
|
|
3286
3286
|
return { width, height };
|
|
3287
3287
|
}
|
|
3288
3288
|
|
|
@@ -3491,18 +3491,18 @@ var WebDriverInterception = class _WebDriverInterception {
|
|
|
3491
3491
|
#requestOverwrites = [];
|
|
3492
3492
|
#respondOverwrites = [];
|
|
3493
3493
|
#calls = [];
|
|
3494
|
-
constructor(pattern, mockId, filterOptions,
|
|
3494
|
+
constructor(pattern, mockId, filterOptions, browser) {
|
|
3495
3495
|
this.#pattern = pattern;
|
|
3496
3496
|
this.#mockId = mockId;
|
|
3497
3497
|
this.#filterOptions = filterOptions;
|
|
3498
|
-
this.#browser =
|
|
3499
|
-
|
|
3500
|
-
|
|
3498
|
+
this.#browser = browser;
|
|
3499
|
+
browser.on("network.beforeRequestSent", this.#handleBeforeRequestSent.bind(this));
|
|
3500
|
+
browser.on("network.responseStarted", this.#handleResponseStarted.bind(this));
|
|
3501
3501
|
}
|
|
3502
|
-
static async initiate(url6, filterOptions,
|
|
3502
|
+
static async initiate(url6, filterOptions, browser) {
|
|
3503
3503
|
const pattern = parseUrlPattern(url6);
|
|
3504
3504
|
if (!hasSubscribedToEvents) {
|
|
3505
|
-
await
|
|
3505
|
+
await browser.sessionSubscribe({
|
|
3506
3506
|
events: [
|
|
3507
3507
|
"network.beforeRequestSent",
|
|
3508
3508
|
"network.responseStarted"
|
|
@@ -3511,7 +3511,7 @@ var WebDriverInterception = class _WebDriverInterception {
|
|
|
3511
3511
|
log7.info("subscribed to network events");
|
|
3512
3512
|
hasSubscribedToEvents = true;
|
|
3513
3513
|
}
|
|
3514
|
-
const interception = await
|
|
3514
|
+
const interception = await browser.networkAddIntercept({
|
|
3515
3515
|
phases: ["beforeRequestSent", "responseStarted"],
|
|
3516
3516
|
urlPatterns: [{
|
|
3517
3517
|
type: "pattern",
|
|
@@ -3522,7 +3522,7 @@ var WebDriverInterception = class _WebDriverInterception {
|
|
|
3522
3522
|
search: getPatternParam(pattern, "search")
|
|
3523
3523
|
}]
|
|
3524
3524
|
});
|
|
3525
|
-
return new _WebDriverInterception(pattern, interception.intercept, filterOptions,
|
|
3525
|
+
return new _WebDriverInterception(pattern, interception.intercept, filterOptions, browser);
|
|
3526
3526
|
}
|
|
3527
3527
|
#handleBeforeRequestSent(request) {
|
|
3528
3528
|
if (!this.#isRequestMatching(request)) {
|
|
@@ -3798,8 +3798,8 @@ async function mock(url6, filterOptions) {
|
|
|
3798
3798
|
if (!this.isBidi) {
|
|
3799
3799
|
throw new Error("Mocking is only supported when running tests using WebDriver Bidi");
|
|
3800
3800
|
}
|
|
3801
|
-
const
|
|
3802
|
-
const contextManager2 = getContextManager(
|
|
3801
|
+
const browser = getBrowserObject5(this);
|
|
3802
|
+
const contextManager2 = getContextManager(browser);
|
|
3803
3803
|
const context = await contextManager2.getCurrentContext();
|
|
3804
3804
|
if (!SESSION_MOCKS[context]) {
|
|
3805
3805
|
SESSION_MOCKS[context] = /* @__PURE__ */ new Set();
|
|
@@ -4021,8 +4021,8 @@ async function saveScreenshot(filepath) {
|
|
|
4021
4021
|
await assertDirectoryExists(absoluteFilepath);
|
|
4022
4022
|
let screenBuffer;
|
|
4023
4023
|
if (this.isBidi) {
|
|
4024
|
-
const
|
|
4025
|
-
const contextManager2 = getContextManager(
|
|
4024
|
+
const browser = getBrowserObject6(this);
|
|
4025
|
+
const contextManager2 = getContextManager(browser);
|
|
4026
4026
|
const context = await contextManager2.getCurrentContext();
|
|
4027
4027
|
const { data } = await this.browsingContextCaptureScreenshot({ context });
|
|
4028
4028
|
screenBuffer = data;
|
|
@@ -4132,8 +4132,8 @@ async function setWindowSize(width, height) {
|
|
|
4132
4132
|
if (width < minWindowSize2 || width > maxWindowSize2 || height < minWindowSize2 || height > maxWindowSize2) {
|
|
4133
4133
|
throw new Error("setWindowSize expects width and height to be a number in the 0 to 2^31 \u2212 1 range");
|
|
4134
4134
|
}
|
|
4135
|
-
const
|
|
4136
|
-
await
|
|
4135
|
+
const browser = getBrowserObject7(this);
|
|
4136
|
+
await browser.setWindowRect(null, null, width, height);
|
|
4137
4137
|
}
|
|
4138
4138
|
|
|
4139
4139
|
// src/commands/browser/switchWindow.ts
|
|
@@ -4319,18 +4319,18 @@ async function switchFrame(context) {
|
|
|
4319
4319
|
`Invalid type for context parameter: ${typeof context}, expected one of number, string or null. Check out our docs: https://webdriver.io/docs/api/browser/switchToFrame.html`
|
|
4320
4320
|
);
|
|
4321
4321
|
}
|
|
4322
|
-
function switchToFrameHelper(
|
|
4323
|
-
const sessionContext = getContextManager(
|
|
4322
|
+
function switchToFrameHelper(browser, context) {
|
|
4323
|
+
const sessionContext = getContextManager(browser);
|
|
4324
4324
|
sessionContext.setCurrentContext(context);
|
|
4325
4325
|
}
|
|
4326
|
-
async function switchToFrameUsingElement(
|
|
4327
|
-
const frame = await
|
|
4326
|
+
async function switchToFrameUsingElement(browser, element) {
|
|
4327
|
+
const frame = await browser.execute(
|
|
4328
4328
|
(iframe) => iframe.contentWindow,
|
|
4329
4329
|
element
|
|
4330
4330
|
);
|
|
4331
|
-
switchToFrameHelper(
|
|
4331
|
+
switchToFrameHelper(browser, frame.context);
|
|
4332
4332
|
const elementId = element[ELEMENT_KEY8];
|
|
4333
|
-
await switchToFrame(
|
|
4333
|
+
await switchToFrame(browser, { [ELEMENT_KEY8]: elementId });
|
|
4334
4334
|
return frame.context;
|
|
4335
4335
|
}
|
|
4336
4336
|
function byUrl(context, url6) {
|
|
@@ -4356,8 +4356,8 @@ function findContext(urlOrId, contexts, matcher) {
|
|
|
4356
4356
|
}
|
|
4357
4357
|
return void 0;
|
|
4358
4358
|
}
|
|
4359
|
-
async function getFlatContextTree(
|
|
4360
|
-
const tree = await
|
|
4359
|
+
async function getFlatContextTree(browser) {
|
|
4360
|
+
const tree = await browser.browsingContextGetTree({});
|
|
4361
4361
|
const mapContext = (context) => [
|
|
4362
4362
|
context.context,
|
|
4363
4363
|
...(context.children || []).map(mapContext)
|
|
@@ -4369,9 +4369,9 @@ async function getFlatContextTree(browser2) {
|
|
|
4369
4369
|
}, {});
|
|
4370
4370
|
return allContexts;
|
|
4371
4371
|
}
|
|
4372
|
-
function switchToFrame(
|
|
4372
|
+
function switchToFrame(browser, frame) {
|
|
4373
4373
|
process.env.DISABLE_WEBDRIVERIO_DEPRECATION_WARNINGS = "true";
|
|
4374
|
-
return
|
|
4374
|
+
return browser.switchToFrame(frame).finally(() => {
|
|
4375
4375
|
delete process.env.DISABLE_WEBDRIVERIO_DEPRECATION_WARNINGS;
|
|
4376
4376
|
});
|
|
4377
4377
|
}
|
|
@@ -4382,8 +4382,8 @@ import { getBrowserObject as getBrowserObject8 } from "@wdio/utils";
|
|
|
4382
4382
|
var log14 = logger14("webdriverio:throttle");
|
|
4383
4383
|
async function throttle(params) {
|
|
4384
4384
|
log14.warn('Command "throttle" is deprecated and will be removed with the next major version release! Use `throttleNetwork` instead.');
|
|
4385
|
-
const
|
|
4386
|
-
await
|
|
4385
|
+
const browser = getBrowserObject8(this);
|
|
4386
|
+
await browser.throttleNetwork(params);
|
|
4387
4387
|
}
|
|
4388
4388
|
|
|
4389
4389
|
// src/commands/browser/throttleCPU.ts
|
|
@@ -4482,8 +4482,8 @@ async function throttleNetwork(params) {
|
|
|
4482
4482
|
throw new Error(`Invalid parameter for "throttleNetwork". Expected it to be typeof object or one of the following values: ${NETWORK_PRESET_TYPES.join(", ")} but found "${params}"`);
|
|
4483
4483
|
}
|
|
4484
4484
|
if (this.isSauce) {
|
|
4485
|
-
const
|
|
4486
|
-
await
|
|
4485
|
+
const browser = getBrowserObject9(this);
|
|
4486
|
+
await browser.sauceThrottleNetwork(params);
|
|
4487
4487
|
return null;
|
|
4488
4488
|
}
|
|
4489
4489
|
const failedConnectionMessage = "No Puppeteer connection could be established which is required to use this command";
|
|
@@ -4528,13 +4528,13 @@ async function uploadFile(localPath) {
|
|
|
4528
4528
|
|
|
4529
4529
|
// src/networkManager.ts
|
|
4530
4530
|
var networkManager = /* @__PURE__ */ new Map();
|
|
4531
|
-
function getNetworkManager(
|
|
4532
|
-
const existingNetworkManager = networkManager.get(
|
|
4531
|
+
function getNetworkManager(browser) {
|
|
4532
|
+
const existingNetworkManager = networkManager.get(browser);
|
|
4533
4533
|
if (existingNetworkManager) {
|
|
4534
4534
|
return existingNetworkManager;
|
|
4535
4535
|
}
|
|
4536
|
-
const newContext = new NetworkManager(
|
|
4537
|
-
networkManager.set(
|
|
4536
|
+
const newContext = new NetworkManager(browser);
|
|
4537
|
+
networkManager.set(browser, newContext);
|
|
4538
4538
|
return newContext;
|
|
4539
4539
|
}
|
|
4540
4540
|
var UNKNOWN_NAVIGATION_ID = "UNKNOWN_NAVIGATION_ID";
|
|
@@ -4543,9 +4543,9 @@ var NetworkManager = class {
|
|
|
4543
4543
|
#initialize;
|
|
4544
4544
|
#requests = /* @__PURE__ */ new Map();
|
|
4545
4545
|
#lastNetworkId;
|
|
4546
|
-
constructor(
|
|
4547
|
-
this.#browser =
|
|
4548
|
-
if (!
|
|
4546
|
+
constructor(browser) {
|
|
4547
|
+
this.#browser = browser;
|
|
4548
|
+
if (!browser.isBidi || process.env.WDIO_UNIT_TESTS || browser.options?.automationProtocol !== "webdriver") {
|
|
4549
4549
|
this.#initialize = Promise.resolve(true);
|
|
4550
4550
|
return;
|
|
4551
4551
|
}
|
|
@@ -4934,9 +4934,9 @@ async function actionClick(element, options) {
|
|
|
4934
4934
|
if (!buttonValue.includes(button)) {
|
|
4935
4935
|
throw new Error("Button type not supported.");
|
|
4936
4936
|
}
|
|
4937
|
-
const
|
|
4937
|
+
const browser = getBrowserObject10(element);
|
|
4938
4938
|
if (x || y) {
|
|
4939
|
-
const { width, height } = await
|
|
4939
|
+
const { width, height } = await browser.getElementRect(element.elementId);
|
|
4940
4940
|
if (x && x < -Math.floor(width / 2) || x && x > Math.floor(width / 2)) {
|
|
4941
4941
|
log15.warn("x would cause a out of bounds error as it goes outside of element");
|
|
4942
4942
|
}
|
|
@@ -4945,7 +4945,7 @@ async function actionClick(element, options) {
|
|
|
4945
4945
|
}
|
|
4946
4946
|
}
|
|
4947
4947
|
const clickNested = async () => {
|
|
4948
|
-
await
|
|
4948
|
+
await browser.action("pointer", {
|
|
4949
4949
|
parameters: { pointerType: "mouse" }
|
|
4950
4950
|
}).move({ origin: element, x, y }).down({ button }).up({ button }).perform(skipRelease);
|
|
4951
4951
|
};
|
|
@@ -5005,8 +5005,8 @@ async function custom$2(strategyName, ...strategyArguments) {
|
|
|
5005
5005
|
// src/commands/element/doubleClick.ts
|
|
5006
5006
|
import { getBrowserObject as getBrowserObject13 } from "@wdio/utils";
|
|
5007
5007
|
async function doubleClick() {
|
|
5008
|
-
const
|
|
5009
|
-
return
|
|
5008
|
+
const browser = getBrowserObject13(this);
|
|
5009
|
+
return browser.action("pointer", { parameters: { pointerType: "mouse" } }).move({ origin: this }).down().up().pause(10).down().up().perform();
|
|
5010
5010
|
}
|
|
5011
5011
|
|
|
5012
5012
|
// src/commands/element/dragAndDrop.ts
|
|
@@ -5037,22 +5037,22 @@ async function dragAndDrop(target, { duration = 10 } = {}) {
|
|
|
5037
5037
|
const targetOrigin = isMovingToElement ? targetRef : "pointer";
|
|
5038
5038
|
const targetX = isMovingToElement ? 0 : moveToCoordinates.x;
|
|
5039
5039
|
const targetY = isMovingToElement ? 0 : moveToCoordinates.y;
|
|
5040
|
-
const
|
|
5041
|
-
return
|
|
5040
|
+
const browser = getBrowserObject14(this);
|
|
5041
|
+
return browser.action("pointer").move({ duration: 0, origin, x: 0, y: 0 }).down({ button: ACTION_BUTTON }).pause(10).move({ duration, origin: targetOrigin, x: targetX, y: targetY }).up({ button: ACTION_BUTTON }).perform();
|
|
5042
5042
|
}
|
|
5043
5043
|
|
|
5044
5044
|
// src/commands/element/execute.ts
|
|
5045
5045
|
import { getBrowserObject as getBrowserObject15 } from "@wdio/utils";
|
|
5046
5046
|
async function execute2(script, ...args) {
|
|
5047
|
-
const
|
|
5048
|
-
return
|
|
5047
|
+
const browser = getBrowserObject15(this);
|
|
5048
|
+
return browser.execute(script, this, ...args);
|
|
5049
5049
|
}
|
|
5050
5050
|
|
|
5051
5051
|
// src/commands/element/executeAsync.ts
|
|
5052
5052
|
import { getBrowserObject as getBrowserObject16 } from "@wdio/utils";
|
|
5053
5053
|
async function executeAsync2(script, ...args) {
|
|
5054
|
-
const
|
|
5055
|
-
return
|
|
5054
|
+
const browser = getBrowserObject16(this);
|
|
5055
|
+
return browser.executeAsync(script, this, ...args);
|
|
5056
5056
|
}
|
|
5057
5057
|
|
|
5058
5058
|
// src/commands/element/getAttribute.ts
|
|
@@ -5126,9 +5126,9 @@ function mergeEqualSymmetricalValue(cssValues) {
|
|
|
5126
5126
|
return newCssValues.join(" ");
|
|
5127
5127
|
}
|
|
5128
5128
|
async function getPseudoElementCSSValue(elem, options) {
|
|
5129
|
-
const
|
|
5129
|
+
const browser = getBrowserObject17(elem);
|
|
5130
5130
|
const { cssProperty, pseudoElement } = options;
|
|
5131
|
-
const cssValue2 = await
|
|
5131
|
+
const cssValue2 = await browser.execute(
|
|
5132
5132
|
(elem2, pseudoElement2, cssProperty2) => window.getComputedStyle(elem2, pseudoElement2)[cssProperty2],
|
|
5133
5133
|
elem,
|
|
5134
5134
|
pseudoElement,
|
|
@@ -5162,13 +5162,13 @@ import logger16 from "@wdio/logger";
|
|
|
5162
5162
|
import customElementWrapper from "./scripts/customElement.js";
|
|
5163
5163
|
var shadowRootManager = /* @__PURE__ */ new Map();
|
|
5164
5164
|
var log16 = logger16("webdriverio:ShadowRootManager");
|
|
5165
|
-
function getShadowRootManager(
|
|
5166
|
-
const existingShadowRootManager = shadowRootManager.get(
|
|
5165
|
+
function getShadowRootManager(browser) {
|
|
5166
|
+
const existingShadowRootManager = shadowRootManager.get(browser);
|
|
5167
5167
|
if (existingShadowRootManager) {
|
|
5168
5168
|
return existingShadowRootManager;
|
|
5169
5169
|
}
|
|
5170
|
-
const newContext = new ShadowRootManager(
|
|
5171
|
-
shadowRootManager.set(
|
|
5170
|
+
const newContext = new ShadowRootManager(browser);
|
|
5171
|
+
shadowRootManager.set(browser, newContext);
|
|
5172
5172
|
return newContext;
|
|
5173
5173
|
}
|
|
5174
5174
|
var ShadowRootManager = class {
|
|
@@ -5176,9 +5176,9 @@ var ShadowRootManager = class {
|
|
|
5176
5176
|
#initialize;
|
|
5177
5177
|
#shadowRoots = /* @__PURE__ */ new Map();
|
|
5178
5178
|
#frameDepth = 0;
|
|
5179
|
-
constructor(
|
|
5180
|
-
this.#browser =
|
|
5181
|
-
if (!
|
|
5179
|
+
constructor(browser) {
|
|
5180
|
+
this.#browser = browser;
|
|
5181
|
+
if (!browser.isBidi || process.env.WDIO_UNIT_TESTS || browser.options?.automationProtocol !== "webdriver") {
|
|
5182
5182
|
this.#initialize = Promise.resolve(true);
|
|
5183
5183
|
return;
|
|
5184
5184
|
}
|
|
@@ -5188,7 +5188,7 @@ var ShadowRootManager = class {
|
|
|
5188
5188
|
this.#browser.on("log.entryAdded", this.handleLogEntry.bind(this));
|
|
5189
5189
|
this.#browser.on("result", this.#commandResultHandler.bind(this));
|
|
5190
5190
|
this.#browser.on("bidiCommand", this.#handleBidiCommand.bind(this));
|
|
5191
|
-
|
|
5191
|
+
browser.scriptAddPreloadScript({
|
|
5192
5192
|
functionDeclaration: customElementWrapper.toString()
|
|
5193
5193
|
});
|
|
5194
5194
|
}
|
|
@@ -5418,7 +5418,7 @@ import getHTMLShadowScript from "./scripts/getHTMLShadow.js";
|
|
|
5418
5418
|
var SHADOW_ID_ATTR_NAME = "data-wdio-shadow-id";
|
|
5419
5419
|
var SHADOW_ID_ATTR = `[${SHADOW_ID_ATTR_NAME}]`;
|
|
5420
5420
|
async function getHTML(options = {}) {
|
|
5421
|
-
const
|
|
5421
|
+
const browser = getBrowserObject18(this);
|
|
5422
5422
|
if (typeof options !== "object" && typeof options === "boolean") {
|
|
5423
5423
|
options = { includeSelectorTag: options };
|
|
5424
5424
|
} else if (typeof options !== "object") {
|
|
@@ -5432,7 +5432,7 @@ async function getHTML(options = {}) {
|
|
|
5432
5432
|
excludeElements: []
|
|
5433
5433
|
}, options);
|
|
5434
5434
|
const basicGetHTML = (elementId, includeSelectorTag2) => {
|
|
5435
|
-
return
|
|
5435
|
+
return browser.execute(getHTMLScript, {
|
|
5436
5436
|
[ELEMENT_KEY12]: elementId,
|
|
5437
5437
|
// w3c compatible
|
|
5438
5438
|
ELEMENT: elementId
|
|
@@ -5448,12 +5448,12 @@ async function getHTML(options = {}) {
|
|
|
5448
5448
|
);
|
|
5449
5449
|
}
|
|
5450
5450
|
const { load } = await import("cheerio");
|
|
5451
|
-
const shadowRootManager2 = getShadowRootManager(
|
|
5452
|
-
const contextManager2 = getContextManager(
|
|
5451
|
+
const shadowRootManager2 = getShadowRootManager(browser);
|
|
5452
|
+
const contextManager2 = getContextManager(browser);
|
|
5453
5453
|
const context = await contextManager2.getCurrentContext();
|
|
5454
5454
|
const shadowRootElementPairs = shadowRootManager2.getShadowElementPairsByContextId(context, this.elementId);
|
|
5455
5455
|
const elementsWithShadowRootAndIdVerified = (await Promise.all(
|
|
5456
|
-
shadowRootElementPairs.map(([elemId, elem]) =>
|
|
5456
|
+
shadowRootElementPairs.map(([elemId, elem]) => browser.execute((elem2) => elem2.tagName, { [ELEMENT_KEY12]: elemId }).then(
|
|
5457
5457
|
() => [elemId, elem],
|
|
5458
5458
|
() => void 0
|
|
5459
5459
|
))
|
|
@@ -5462,7 +5462,7 @@ async function getHTML(options = {}) {
|
|
|
5462
5462
|
{ [ELEMENT_KEY12]: elemId },
|
|
5463
5463
|
shadowId ? { [ELEMENT_KEY12]: shadowId } : void 0
|
|
5464
5464
|
]);
|
|
5465
|
-
const { html, shadowElementHTML } = await
|
|
5465
|
+
const { html, shadowElementHTML } = await browser.execute(
|
|
5466
5466
|
getHTMLShadowScript,
|
|
5467
5467
|
{ [ELEMENT_KEY12]: this.elementId },
|
|
5468
5468
|
includeSelectorTag,
|
|
@@ -5572,8 +5572,8 @@ async function isClickable() {
|
|
|
5572
5572
|
if (this.isMobile && await this.getContext().catch(() => void 0) === "NATIVE_APP") {
|
|
5573
5573
|
throw new Error("Method not supported in mobile native environment. It is unlikely that you need to use this command.");
|
|
5574
5574
|
}
|
|
5575
|
-
const
|
|
5576
|
-
return
|
|
5575
|
+
const browser = getBrowserObject19(this);
|
|
5576
|
+
return browser.execute(isElementClickableScript, {
|
|
5577
5577
|
[ELEMENT_KEY13]: this.elementId,
|
|
5578
5578
|
// w3c compatible
|
|
5579
5579
|
ELEMENT: this.elementId
|
|
@@ -5586,12 +5586,12 @@ import { getBrowserObject as getBrowserObject20 } from "@wdio/utils";
|
|
|
5586
5586
|
import isElementDisplayedScript from "./scripts/isElementDisplayed.js";
|
|
5587
5587
|
import isElementInViewportScript from "./scripts/isElementInViewport.js";
|
|
5588
5588
|
async function isDisplayed(commandParams = { withinViewport: false }) {
|
|
5589
|
-
const
|
|
5589
|
+
const browser = getBrowserObject20(this);
|
|
5590
5590
|
if (!await hasElementId(this)) {
|
|
5591
5591
|
return false;
|
|
5592
5592
|
}
|
|
5593
|
-
const isNativeApplication = !
|
|
5594
|
-
if (
|
|
5593
|
+
const isNativeApplication = !browser.capabilities.browserName;
|
|
5594
|
+
if (browser.isMobile && isNativeApplication) {
|
|
5595
5595
|
if (commandParams?.withinViewport) {
|
|
5596
5596
|
throw new Error(
|
|
5597
5597
|
"Cannot determine element visibility within viewport for native mobile apps as it is not feasible to determine full vertical and horizontal application bounds. In most cases a basic visibility check should suffice."
|
|
@@ -5599,9 +5599,9 @@ async function isDisplayed(commandParams = { withinViewport: false }) {
|
|
|
5599
5599
|
}
|
|
5600
5600
|
return await this.isElementDisplayed(this.elementId);
|
|
5601
5601
|
}
|
|
5602
|
-
const isDisplayed2 = await
|
|
5602
|
+
const isDisplayed2 = await browser.execute(isElementDisplayedScript, this);
|
|
5603
5603
|
if (isDisplayed2 && commandParams?.withinViewport) {
|
|
5604
|
-
return
|
|
5604
|
+
return browser.execute(isElementInViewportScript, this);
|
|
5605
5605
|
}
|
|
5606
5606
|
return isDisplayed2;
|
|
5607
5607
|
}
|
|
@@ -5621,9 +5621,9 @@ var getWebElement = (el) => ({
|
|
|
5621
5621
|
// jsonwp compatible
|
|
5622
5622
|
});
|
|
5623
5623
|
async function isEqual(el) {
|
|
5624
|
-
const
|
|
5625
|
-
if (
|
|
5626
|
-
const context = await
|
|
5624
|
+
const browser = getBrowserObject21(this);
|
|
5625
|
+
if (browser.isMobile) {
|
|
5626
|
+
const context = await browser.getContext().catch(() => void 0);
|
|
5627
5627
|
const contextId = typeof context === "string" ? context : context?.id;
|
|
5628
5628
|
if (contextId && contextId.toLowerCase().includes("native")) {
|
|
5629
5629
|
return this.elementId === el.elementId;
|
|
@@ -5631,7 +5631,7 @@ async function isEqual(el) {
|
|
|
5631
5631
|
}
|
|
5632
5632
|
let result;
|
|
5633
5633
|
try {
|
|
5634
|
-
result = await
|
|
5634
|
+
result = await browser.execute(
|
|
5635
5635
|
/* istanbul ignore next */
|
|
5636
5636
|
function(el1, el2) {
|
|
5637
5637
|
return el1 === el2;
|
|
@@ -5662,8 +5662,8 @@ import { ELEMENT_KEY as ELEMENT_KEY15 } from "webdriver";
|
|
|
5662
5662
|
import { getBrowserObject as getBrowserObject22 } from "@wdio/utils";
|
|
5663
5663
|
import isFocusedScript from "./scripts/isFocused.js";
|
|
5664
5664
|
async function isFocused() {
|
|
5665
|
-
const
|
|
5666
|
-
return
|
|
5665
|
+
const browser = await getBrowserObject22(this);
|
|
5666
|
+
return browser.execute(isFocusedScript, {
|
|
5667
5667
|
[ELEMENT_KEY15]: this.elementId,
|
|
5668
5668
|
// w3c compatible
|
|
5669
5669
|
ELEMENT: this.elementId
|
|
@@ -5681,8 +5681,8 @@ import { ELEMENT_KEY as ELEMENT_KEY16 } from "webdriver";
|
|
|
5681
5681
|
import { getBrowserObject as getBrowserObject23 } from "@wdio/utils";
|
|
5682
5682
|
import isElementStable from "./scripts/isElementStable.js";
|
|
5683
5683
|
async function isStable() {
|
|
5684
|
-
const
|
|
5685
|
-
return await
|
|
5684
|
+
const browser = getBrowserObject23(this);
|
|
5685
|
+
return await browser.executeAsync(isElementStable, {
|
|
5686
5686
|
[ELEMENT_KEY16]: this.elementId,
|
|
5687
5687
|
// w3c compatible
|
|
5688
5688
|
ELEMENT: this.elementId
|
|
@@ -5695,9 +5695,9 @@ import logger17 from "@wdio/logger";
|
|
|
5695
5695
|
import { getBrowserObject as getBrowserObject24 } from "@wdio/utils";
|
|
5696
5696
|
var log17 = logger17("webdriver");
|
|
5697
5697
|
async function moveTo({ xOffset, yOffset } = {}) {
|
|
5698
|
-
const
|
|
5698
|
+
const browser = getBrowserObject24(this);
|
|
5699
5699
|
if (xOffset || yOffset) {
|
|
5700
|
-
const { width, height } = await
|
|
5700
|
+
const { width, height } = await browser.getElementRect(this.elementId);
|
|
5701
5701
|
if (xOffset && xOffset < -Math.floor(width / 2) || xOffset && xOffset > Math.floor(width / 2)) {
|
|
5702
5702
|
log17.warn("xOffset would cause a out of bounds error as it goes outside of element");
|
|
5703
5703
|
}
|
|
@@ -5706,7 +5706,7 @@ async function moveTo({ xOffset, yOffset } = {}) {
|
|
|
5706
5706
|
}
|
|
5707
5707
|
}
|
|
5708
5708
|
const moveToNested = async () => {
|
|
5709
|
-
await
|
|
5709
|
+
await browser.action("pointer", { parameters: { pointerType: "mouse" } }).move({ origin: this, x: xOffset || 0, y: yOffset || 0 }).perform();
|
|
5710
5710
|
};
|
|
5711
5711
|
try {
|
|
5712
5712
|
await moveToNested();
|
|
@@ -5758,10 +5758,10 @@ async function react$$2(selector, { props = {}, state = {} } = {}) {
|
|
|
5758
5758
|
const resqScriptPath = url4.fileURLToPath(await resolve3("resq", import.meta.url));
|
|
5759
5759
|
resqScript3 = (await fs8.readFile(resqScriptPath)).toString();
|
|
5760
5760
|
}
|
|
5761
|
-
const
|
|
5761
|
+
const browser = await getBrowserObject25(this);
|
|
5762
5762
|
await this.executeScript(resqScript3.toString(), []);
|
|
5763
|
-
await
|
|
5764
|
-
const res = await
|
|
5763
|
+
await browser.execute(waitToLoadReact3);
|
|
5764
|
+
const res = await browser.execute(
|
|
5765
5765
|
react$$Script2,
|
|
5766
5766
|
selector,
|
|
5767
5767
|
props,
|
|
@@ -5784,10 +5784,10 @@ async function react$2(selector, { props = {}, state = {} } = {}) {
|
|
|
5784
5784
|
const resqScriptPath = url5.fileURLToPath(await resolve4("resq", import.meta.url));
|
|
5785
5785
|
resqScript4 = (await fs9.readFile(resqScriptPath)).toString();
|
|
5786
5786
|
}
|
|
5787
|
-
const
|
|
5787
|
+
const browser = await getBrowserObject26(this);
|
|
5788
5788
|
await this.executeScript(resqScript4.toString(), []);
|
|
5789
|
-
await
|
|
5790
|
-
const res = await
|
|
5789
|
+
await browser.execute(waitToLoadReact4);
|
|
5790
|
+
const res = await browser.execute(
|
|
5791
5791
|
react$Script2,
|
|
5792
5792
|
selector,
|
|
5793
5793
|
props,
|
|
@@ -5817,8 +5817,8 @@ import { ELEMENT_KEY as ELEMENT_KEY17 } from "webdriver";
|
|
|
5817
5817
|
import { getBrowserObject as getBrowserObject27 } from "@wdio/utils";
|
|
5818
5818
|
var log18 = logger18("webdriverio");
|
|
5819
5819
|
function scrollIntoViewWeb(options = { block: "start", inline: "nearest" }) {
|
|
5820
|
-
const
|
|
5821
|
-
return
|
|
5820
|
+
const browser = getBrowserObject27(this);
|
|
5821
|
+
return browser.execute(
|
|
5822
5822
|
(elem, options2) => elem.scrollIntoView(options2),
|
|
5823
5823
|
{
|
|
5824
5824
|
[ELEMENT_KEY17]: this.elementId,
|
|
@@ -5830,14 +5830,14 @@ function scrollIntoViewWeb(options = { block: "start", inline: "nearest" }) {
|
|
|
5830
5830
|
);
|
|
5831
5831
|
}
|
|
5832
5832
|
async function scrollIntoView(options = { block: "start", inline: "nearest" }) {
|
|
5833
|
-
const
|
|
5834
|
-
if (
|
|
5833
|
+
const browser = getBrowserObject27(this);
|
|
5834
|
+
if (browser.isMobile) {
|
|
5835
5835
|
return scrollIntoViewWeb.call(this, options);
|
|
5836
5836
|
}
|
|
5837
5837
|
try {
|
|
5838
|
-
const elemRect = await
|
|
5839
|
-
const viewport = await
|
|
5840
|
-
let [scrollX, scrollY] = await
|
|
5838
|
+
const elemRect = await browser.getElementRect(this.elementId);
|
|
5839
|
+
const viewport = await browser.getWindowSize();
|
|
5840
|
+
let [scrollX, scrollY] = await browser.execute(() => [
|
|
5841
5841
|
window.scrollX,
|
|
5842
5842
|
window.scrollY
|
|
5843
5843
|
]);
|
|
@@ -5872,7 +5872,7 @@ async function scrollIntoView(options = { block: "start", inline: "nearest" }) {
|
|
|
5872
5872
|
}
|
|
5873
5873
|
deltaX = Math.round(deltaX - scrollX);
|
|
5874
5874
|
deltaY = Math.round(deltaY - scrollY);
|
|
5875
|
-
await
|
|
5875
|
+
await browser.action("wheel").scroll({ duration: 0, x: deltaX, y: deltaY, origin: this }).perform();
|
|
5876
5876
|
} catch (err) {
|
|
5877
5877
|
log18.warn(
|
|
5878
5878
|
`Failed to execute "scrollIntoView" using WebDriver Actions API: ${err.message}!
|
|
@@ -6269,11 +6269,11 @@ var createRoleBaseXpathSelector = (role) => {
|
|
|
6269
6269
|
// src/commands/element/shadow$$.ts
|
|
6270
6270
|
var log19 = logger19("webdriverio");
|
|
6271
6271
|
async function shadow$$(selector) {
|
|
6272
|
-
const
|
|
6272
|
+
const browser = getBrowserObject28(this);
|
|
6273
6273
|
try {
|
|
6274
|
-
const shadowRoot = await
|
|
6274
|
+
const shadowRoot = await browser.getElementShadowRoot(this.elementId);
|
|
6275
6275
|
const { using, value } = findStrategy(selector, this.isW3C, this.isMobile);
|
|
6276
|
-
const res = await
|
|
6276
|
+
const res = await browser.findElementsFromShadowRoot(shadowRoot[SHADOW_ELEMENT_KEY], using, value);
|
|
6277
6277
|
const elements = await getElements.call(this, selector, res, { isShadowElement: true });
|
|
6278
6278
|
return enhanceElementsArray(elements, this, selector);
|
|
6279
6279
|
} catch (err) {
|
|
@@ -6292,11 +6292,11 @@ import { shadowFnFactory as shadowFnFactory2 } from "./scripts/shadowFnFactory.j
|
|
|
6292
6292
|
import { getBrowserObject as getBrowserObject29 } from "@wdio/utils";
|
|
6293
6293
|
var log20 = logger20("webdriverio");
|
|
6294
6294
|
async function shadow$(selector) {
|
|
6295
|
-
const
|
|
6295
|
+
const browser = getBrowserObject29(this);
|
|
6296
6296
|
try {
|
|
6297
|
-
const shadowRoot = await
|
|
6297
|
+
const shadowRoot = await browser.getElementShadowRoot(this.elementId);
|
|
6298
6298
|
const { using, value } = findStrategy(selector, this.isW3C, this.isMobile);
|
|
6299
|
-
const res = await
|
|
6299
|
+
const res = await browser.findElementFromShadowRoot(shadowRoot[SHADOW_ELEMENT_KEY2], using, value);
|
|
6300
6300
|
return getElement.call(this, selector, res, { isShadowElement: true });
|
|
6301
6301
|
} catch (err) {
|
|
6302
6302
|
log20.warn(
|
|
@@ -6723,9 +6723,9 @@ function transformClassicToBidiSelector(using, value) {
|
|
|
6723
6723
|
throw new Error(`Can't transform classic selector ${using} to Bidi selector`);
|
|
6724
6724
|
}
|
|
6725
6725
|
async function findDeepElement(selector) {
|
|
6726
|
-
const
|
|
6727
|
-
const shadowRootManager2 = getShadowRootManager(
|
|
6728
|
-
const contextManager2 = getContextManager(
|
|
6726
|
+
const browser = getBrowserObject30(this);
|
|
6727
|
+
const shadowRootManager2 = getShadowRootManager(browser);
|
|
6728
|
+
const contextManager2 = getContextManager(browser);
|
|
6729
6729
|
const context = await contextManager2.getCurrentContext();
|
|
6730
6730
|
const shadowRoots = shadowRootManager2.getShadowElementsByContextId(
|
|
6731
6731
|
context,
|
|
@@ -6734,7 +6734,7 @@ async function findDeepElement(selector) {
|
|
|
6734
6734
|
const { using, value } = findStrategy(selector, this.isW3C, this.isMobile);
|
|
6735
6735
|
const locator = transformClassicToBidiSelector(using, value);
|
|
6736
6736
|
const startNodes = shadowRoots.length > 0 ? shadowRoots.map((shadowRootNodeId) => ({ sharedId: shadowRootNodeId })) : this.elementId ? [{ sharedId: this.elementId }] : void 0;
|
|
6737
|
-
const deepElementResult = await
|
|
6737
|
+
const deepElementResult = await browser.browsingContextLocateNodes({ locator, context, startNodes }).then(async (result) => {
|
|
6738
6738
|
const nodes = result.nodes.filter((node) => Boolean(node.sharedId)).map((node) => ({
|
|
6739
6739
|
[ELEMENT_KEY18]: node.sharedId,
|
|
6740
6740
|
locator
|
|
@@ -6743,7 +6743,7 @@ async function findDeepElement(selector) {
|
|
|
6743
6743
|
return nodes[0];
|
|
6744
6744
|
}
|
|
6745
6745
|
const scopedNodes = await Promise.all(nodes.map(async (node) => {
|
|
6746
|
-
const isIn = await
|
|
6746
|
+
const isIn = await browser.execute(
|
|
6747
6747
|
elementContains,
|
|
6748
6748
|
{ [ELEMENT_KEY18]: this.elementId },
|
|
6749
6749
|
node
|
|
@@ -6753,7 +6753,7 @@ async function findDeepElement(selector) {
|
|
|
6753
6753
|
return scopedNodes[0];
|
|
6754
6754
|
}, (err) => {
|
|
6755
6755
|
log21.warn(`Failed to execute browser.browsingContextLocateNodes({ ... }) due to ${err}, falling back to regular WebDriver Classic command`);
|
|
6756
|
-
return this && "elementId" in this && this.elementId ? this.findElementFromElement(this.elementId, using, value) :
|
|
6756
|
+
return this && "elementId" in this && this.elementId ? this.findElementFromElement(this.elementId, using, value) : browser.findElement(using, value);
|
|
6757
6757
|
});
|
|
6758
6758
|
if (!deepElementResult) {
|
|
6759
6759
|
return new Error(`Couldn't find element with selector "${selector}"`);
|
|
@@ -6761,9 +6761,9 @@ async function findDeepElement(selector) {
|
|
|
6761
6761
|
return deepElementResult;
|
|
6762
6762
|
}
|
|
6763
6763
|
async function findDeepElements(selector) {
|
|
6764
|
-
const
|
|
6765
|
-
const shadowRootManager2 = getShadowRootManager(
|
|
6766
|
-
const contextManager2 = getContextManager(
|
|
6764
|
+
const browser = getBrowserObject30(this);
|
|
6765
|
+
const shadowRootManager2 = getShadowRootManager(browser);
|
|
6766
|
+
const contextManager2 = getContextManager(browser);
|
|
6767
6767
|
const context = await contextManager2.getCurrentContext();
|
|
6768
6768
|
const shadowRoots = shadowRootManager2.getShadowElementsByContextId(
|
|
6769
6769
|
context,
|
|
@@ -6772,7 +6772,7 @@ async function findDeepElements(selector) {
|
|
|
6772
6772
|
const { using, value } = findStrategy(selector, this.isW3C, this.isMobile);
|
|
6773
6773
|
const locator = transformClassicToBidiSelector(using, value);
|
|
6774
6774
|
const startNodes = shadowRoots.length > 0 ? shadowRoots.map((shadowRootNodeId) => ({ sharedId: shadowRootNodeId })) : this.elementId ? [{ sharedId: this.elementId }] : void 0;
|
|
6775
|
-
const deepElementResult = await
|
|
6775
|
+
const deepElementResult = await browser.browsingContextLocateNodes({ locator, context, startNodes }).then(async (result) => {
|
|
6776
6776
|
const nodes = result.nodes.filter((node) => Boolean(node.sharedId)).map((node) => ({
|
|
6777
6777
|
[ELEMENT_KEY18]: node.sharedId,
|
|
6778
6778
|
locator
|
|
@@ -6781,7 +6781,7 @@ async function findDeepElements(selector) {
|
|
|
6781
6781
|
return nodes;
|
|
6782
6782
|
}
|
|
6783
6783
|
const scopedNodes = await Promise.all(nodes.map(async (node) => {
|
|
6784
|
-
const isIn = await
|
|
6784
|
+
const isIn = await browser.execute(
|
|
6785
6785
|
elementContains,
|
|
6786
6786
|
{ [ELEMENT_KEY18]: this.elementId },
|
|
6787
6787
|
node
|
|
@@ -6791,7 +6791,7 @@ async function findDeepElements(selector) {
|
|
|
6791
6791
|
return scopedNodes;
|
|
6792
6792
|
}, (err) => {
|
|
6793
6793
|
log21.warn(`Failed to execute browser.browsingContextLocateNodes({ ... }) due to ${err}, falling back to regular WebDriver Classic command`);
|
|
6794
|
-
return this && "elementId" in this && this.elementId ? this.findElementsFromElement(this.elementId, using, value) :
|
|
6794
|
+
return this && "elementId" in this && this.elementId ? this.findElementsFromElement(this.elementId, using, value) : browser.findElements(using, value);
|
|
6795
6795
|
});
|
|
6796
6796
|
return deepElementResult;
|
|
6797
6797
|
}
|
|
@@ -7291,7 +7291,7 @@ var NOOP2 = () => {
|
|
|
7291
7291
|
var ProtocolStub = class {
|
|
7292
7292
|
static async newSession(options) {
|
|
7293
7293
|
const capabilities = emulateSessionCapabilities(options.capabilities);
|
|
7294
|
-
const
|
|
7294
|
+
const browser = {
|
|
7295
7295
|
options,
|
|
7296
7296
|
capabilities,
|
|
7297
7297
|
requestedCapabilities: capabilities,
|
|
@@ -7305,9 +7305,9 @@ var ProtocolStub = class {
|
|
|
7305
7305
|
off: NOOP2,
|
|
7306
7306
|
...capabilitiesEnvironmentDetector(capabilities)
|
|
7307
7307
|
};
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
return
|
|
7308
|
+
browser.addCommand = (...args) => browser.customCommands.push(args);
|
|
7309
|
+
browser.overwriteCommand = (...args) => browser.overwrittenCommands.push(args);
|
|
7310
|
+
return browser;
|
|
7311
7311
|
}
|
|
7312
7312
|
/**
|
|
7313
7313
|
* added just in case user wants to somehow reload webdriver before it was started.
|
|
@@ -7355,22 +7355,22 @@ async function getProtocolDriver(options) {
|
|
|
7355
7355
|
|
|
7356
7356
|
// src/dialog.ts
|
|
7357
7357
|
var dialogManager = /* @__PURE__ */ new Map();
|
|
7358
|
-
function getDialogManager(
|
|
7359
|
-
const existingDialogManager = dialogManager.get(
|
|
7358
|
+
function getDialogManager(browser) {
|
|
7359
|
+
const existingDialogManager = dialogManager.get(browser);
|
|
7360
7360
|
if (existingDialogManager) {
|
|
7361
7361
|
return existingDialogManager;
|
|
7362
7362
|
}
|
|
7363
|
-
const newContext = new DialogManager(
|
|
7364
|
-
dialogManager.set(
|
|
7363
|
+
const newContext = new DialogManager(browser);
|
|
7364
|
+
dialogManager.set(browser, newContext);
|
|
7365
7365
|
return newContext;
|
|
7366
7366
|
}
|
|
7367
7367
|
var DialogManager = class {
|
|
7368
7368
|
#browser;
|
|
7369
7369
|
#initialize;
|
|
7370
7370
|
#autoHandleDialog = true;
|
|
7371
|
-
constructor(
|
|
7372
|
-
this.#browser =
|
|
7373
|
-
if (!
|
|
7371
|
+
constructor(browser) {
|
|
7372
|
+
this.#browser = browser;
|
|
7373
|
+
if (!browser.isBidi || process.env.WDIO_UNIT_TESTS || browser.options?.automationProtocol !== "webdriver") {
|
|
7374
7374
|
this.#initialize = Promise.resolve(true);
|
|
7375
7375
|
return;
|
|
7376
7376
|
}
|
|
@@ -7412,12 +7412,12 @@ var Dialog = class {
|
|
|
7412
7412
|
#message;
|
|
7413
7413
|
#defaultValue;
|
|
7414
7414
|
#type;
|
|
7415
|
-
constructor(event,
|
|
7415
|
+
constructor(event, browser) {
|
|
7416
7416
|
this.#message = event.message;
|
|
7417
7417
|
this.#defaultValue = event.defaultValue;
|
|
7418
7418
|
this.#type = event.type;
|
|
7419
7419
|
this.#context = event.context;
|
|
7420
|
-
this.#browser =
|
|
7420
|
+
this.#browser = browser;
|
|
7421
7421
|
}
|
|
7422
7422
|
message() {
|
|
7423
7423
|
return this.#message;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webdriverio",
|
|
3
3
|
"description": "Next-gen browser and mobile automation test framework for Node.js",
|
|
4
|
-
"version": "9.2.
|
|
4
|
+
"version": "9.2.6",
|
|
5
5
|
"homepage": "https://webdriver.io",
|
|
6
6
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"optional": true
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "2bbc5c904c711f88777b4d9f5daaa33b6ddb4c2e"
|
|
114
114
|
}
|