webdriverio 9.0.6 → 9.0.7
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/commands/browser/execute.d.ts +1 -1
- package/build/commands/browser/execute.d.ts.map +1 -1
- package/build/commands/browser/executeAsync.d.ts +1 -1
- package/build/commands/browser/executeAsync.d.ts.map +1 -1
- package/build/commands/browser/saveScreenshot.d.ts.map +1 -1
- package/build/commands/element/execute.d.ts +1 -1
- package/build/commands/element/execute.d.ts.map +1 -1
- package/build/commands/element/executeAsync.d.ts.map +1 -1
- package/build/index.js +185 -173
- package/package.json +3 -3
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
* @type protocol
|
|
34
34
|
*
|
|
35
35
|
*/
|
|
36
|
-
export declare function execute<ReturnValue, InnerArguments extends any[]>(this: WebdriverIO.Browser | WebdriverIO.
|
|
36
|
+
export declare function execute<ReturnValue, InnerArguments extends any[]>(this: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser, script: string | ((...innerArgs: InnerArguments) => ReturnValue), ...args: InnerArguments): Promise<ReturnValue>;
|
|
37
37
|
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/execute.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/execute.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,OAAO,CAAC,WAAW,EAAE,cAAc,SAAS,GAAG,EAAE,EACnE,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB,EAC1D,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,SAAS,EAAE,cAAc,KAAK,WAAW,CAAC,EAChE,GAAG,IAAI,EAAE,cAAc,GACxB,OAAO,CAAC,WAAW,CAAC,CAgCtB"}
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
* @type protocol
|
|
42
42
|
*
|
|
43
43
|
*/
|
|
44
|
-
export declare function executeAsync<ReturnValue, InnerArguments extends any[]>(this: WebdriverIO.Browser | WebdriverIO.
|
|
44
|
+
export declare function executeAsync<ReturnValue, InnerArguments extends any[]>(this: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser, script: string | ((...args: [...innerArgs: InnerArguments, callback: (result?: ReturnValue) => void]) => void), ...args: InnerArguments): Promise<ReturnValue>;
|
|
45
45
|
//# sourceMappingURL=executeAsync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeAsync.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/executeAsync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"executeAsync.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/executeAsync.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAsB,YAAY,CAAC,WAAW,EAAE,cAAc,SAAS,GAAG,EAAE,EACxE,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB,EAC1D,MAAM,EACF,MAAM,GACN,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC,EACjG,GAAG,IAAI,EAAE,cAAc,GACxB,OAAO,CAAC,WAAW,CAAC,CAyCtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saveScreenshot.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/saveScreenshot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"saveScreenshot.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/saveScreenshot.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,cAAc,CAChC,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,QAAQ,EAAE,MAAM,mBA0BnB"}
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
* @type protocol
|
|
35
35
|
*
|
|
36
36
|
*/
|
|
37
|
-
export declare function execute<ReturnValue, InnerArguments extends any[]>(this: WebdriverIO.
|
|
37
|
+
export declare function execute<ReturnValue, InnerArguments extends any[]>(this: WebdriverIO.Element, script: string | ((...innerArgs: [WebdriverIO.Element, ...InnerArguments]) => ReturnValue), ...args: InnerArguments): Promise<ReturnValue>;
|
|
38
38
|
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/element/execute.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/element/execute.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAsB,OAAO,CAAC,WAAW,EAAE,cAAc,SAAS,GAAG,EAAE,EACnE,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,SAAS,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,KAAK,WAAW,CAAC,EAC1F,GAAG,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,CAgCjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeAsync.d.ts","sourceRoot":"","sources":["../../../src/commands/element/executeAsync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"executeAsync.d.ts","sourceRoot":"","sources":["../../../src/commands/element/executeAsync.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,wBAAsB,YAAY,CAAC,WAAW,EAAE,cAAc,SAAS,GAAG,EAAE,EACxE,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,EAC/C,MAAM,EACF,MAAM,GACN,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC,EAC3H,GAAG,IAAI,EAAE,cAAc,GACxB,OAAO,CAAC,WAAW,CAAC,CAyCtB"}
|
package/build/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import { webdriverMonad as webdriverMonad2, wrapCommand as wrapCommand2 } from "
|
|
|
17
17
|
|
|
18
18
|
// src/middlewares.ts
|
|
19
19
|
import { ELEMENT_KEY as ELEMENT_KEY18 } from "webdriver";
|
|
20
|
-
import { getBrowserObject as
|
|
20
|
+
import { getBrowserObject as getBrowserObject32 } from "@wdio/utils";
|
|
21
21
|
|
|
22
22
|
// src/utils/implicitWait.ts
|
|
23
23
|
import logger from "@wdio/logger";
|
|
@@ -81,7 +81,7 @@ import GraphemeSplitter from "grapheme-splitter";
|
|
|
81
81
|
import logger18 from "@wdio/logger";
|
|
82
82
|
import isPlainObject from "is-plain-obj";
|
|
83
83
|
import { ELEMENT_KEY as ELEMENT_KEY17 } from "webdriver";
|
|
84
|
-
import { UNICODE_CHARACTERS as UNICODE_CHARACTERS2, asyncIterators, getBrowserObject as
|
|
84
|
+
import { UNICODE_CHARACTERS as UNICODE_CHARACTERS2, asyncIterators, getBrowserObject as getBrowserObject31 } from "@wdio/utils";
|
|
85
85
|
|
|
86
86
|
// src/commands/browser.ts
|
|
87
87
|
var browser_exports = {};
|
|
@@ -149,13 +149,13 @@ var WebDriverError = class extends Error {
|
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
151
|
var getElement = function findElement(selector, res, props = { isReactElement: false, isShadowElement: false }) {
|
|
152
|
-
const
|
|
152
|
+
const browser = getBrowserObject(this);
|
|
153
153
|
const browserCommandKeys = Object.keys(browser_exports);
|
|
154
154
|
const propertiesObject = {
|
|
155
155
|
/**
|
|
156
156
|
* filter out browser commands from object
|
|
157
157
|
*/
|
|
158
|
-
...Object.entries(clone(
|
|
158
|
+
...Object.entries(clone(browser.__propertiesObject__)).reduce((commands, [name, descriptor]) => {
|
|
159
159
|
if (!browserCommandKeys.includes(name)) {
|
|
160
160
|
commands[name] = descriptor;
|
|
161
161
|
}
|
|
@@ -187,19 +187,19 @@ var getElement = function findElement(selector, res, props = { isReactElement: f
|
|
|
187
187
|
const elementInstance = element(this.sessionId, elementErrorHandler(wrapCommand));
|
|
188
188
|
const origAddCommand = elementInstance.addCommand.bind(elementInstance);
|
|
189
189
|
elementInstance.addCommand = (name, fn) => {
|
|
190
|
-
|
|
190
|
+
browser.__propertiesObject__[name] = { value: fn };
|
|
191
191
|
origAddCommand(name, fn);
|
|
192
192
|
};
|
|
193
193
|
return elementInstance;
|
|
194
194
|
};
|
|
195
195
|
var getElements = function getElements2(selector, elemResponse, props = { isReactElement: false, isShadowElement: false }) {
|
|
196
|
-
const
|
|
196
|
+
const browser = getBrowserObject(this);
|
|
197
197
|
const browserCommandKeys = Object.keys(browser_exports);
|
|
198
198
|
const propertiesObject = {
|
|
199
199
|
/**
|
|
200
200
|
* filter out browser commands from object
|
|
201
201
|
*/
|
|
202
|
-
...Object.entries(clone(
|
|
202
|
+
...Object.entries(clone(browser.__propertiesObject__)).reduce((commands, [name, descriptor]) => {
|
|
203
203
|
if (!browserCommandKeys.includes(name)) {
|
|
204
204
|
commands[name] = descriptor;
|
|
205
205
|
}
|
|
@@ -238,7 +238,7 @@ var getElements = function getElements2(selector, elemResponse, props = { isReac
|
|
|
238
238
|
const elementInstance = element(this.sessionId, elementErrorHandler(wrapCommand));
|
|
239
239
|
const origAddCommand = elementInstance.addCommand.bind(elementInstance);
|
|
240
240
|
elementInstance.addCommand = (name, fn) => {
|
|
241
|
-
|
|
241
|
+
browser.__propertiesObject__[name] = { value: fn };
|
|
242
242
|
origAddCommand(name, fn);
|
|
243
243
|
};
|
|
244
244
|
return elementInstance;
|
|
@@ -951,8 +951,8 @@ var ClockManager = class {
|
|
|
951
951
|
#browser;
|
|
952
952
|
#resetFn = () => Promise.resolve();
|
|
953
953
|
#isInstalled = false;
|
|
954
|
-
constructor(
|
|
955
|
-
this.#browser =
|
|
954
|
+
constructor(browser) {
|
|
955
|
+
this.#browser = browser;
|
|
956
956
|
}
|
|
957
957
|
/**
|
|
958
958
|
* Install fake timers on the browser. If you call the `emulate` command, WebdriverIO will automatically install
|
|
@@ -2400,13 +2400,13 @@ var deviceDescriptorsSource = {
|
|
|
2400
2400
|
};
|
|
2401
2401
|
|
|
2402
2402
|
// src/commands/browser/emulate.ts
|
|
2403
|
-
function storeRestoreFunction(
|
|
2404
|
-
if (!restoreFunctions.has(
|
|
2405
|
-
restoreFunctions.set(
|
|
2403
|
+
function storeRestoreFunction(browser, scope, fn) {
|
|
2404
|
+
if (!restoreFunctions.has(browser)) {
|
|
2405
|
+
restoreFunctions.set(browser, /* @__PURE__ */ new Map());
|
|
2406
2406
|
}
|
|
2407
|
-
const restoreFunctionsList = restoreFunctions.get(
|
|
2407
|
+
const restoreFunctionsList = restoreFunctions.get(browser)?.get(scope);
|
|
2408
2408
|
const updatedList = restoreFunctionsList ? [...restoreFunctionsList, fn] : [fn];
|
|
2409
|
-
restoreFunctions.get(
|
|
2409
|
+
restoreFunctions.get(browser)?.set(scope, updatedList);
|
|
2410
2410
|
}
|
|
2411
2411
|
async function emulate(scope, options) {
|
|
2412
2412
|
if (!this.isBidi) {
|
|
@@ -2535,6 +2535,9 @@ async function emulate(scope, options) {
|
|
|
2535
2535
|
throw new Error(`Invalid scope "${scope}", expected one of "geolocation", "userAgent", "colorScheme", "onLine", "device" or "clock"`);
|
|
2536
2536
|
}
|
|
2537
2537
|
|
|
2538
|
+
// src/commands/browser/execute.ts
|
|
2539
|
+
import { getBrowserObject as getBrowserObject2 } from "@wdio/utils";
|
|
2540
|
+
|
|
2538
2541
|
// src/utils/bidi/value.ts
|
|
2539
2542
|
import { ELEMENT_KEY as ELEMENT_KEY7 } from "webdriver";
|
|
2540
2543
|
var TYPE_CONSTANT = "type";
|
|
@@ -2796,22 +2799,22 @@ var ReferenceValue = class {
|
|
|
2796
2799
|
import logger4 from "@wdio/logger";
|
|
2797
2800
|
var contextManager = /* @__PURE__ */ new Map();
|
|
2798
2801
|
var log4 = logger4("webdriverio:ContextManager");
|
|
2799
|
-
function getContextManager(
|
|
2800
|
-
const existingContextManager = contextManager.get(
|
|
2802
|
+
function getContextManager(browser) {
|
|
2803
|
+
const existingContextManager = contextManager.get(browser);
|
|
2801
2804
|
if (existingContextManager) {
|
|
2802
2805
|
return existingContextManager;
|
|
2803
2806
|
}
|
|
2804
|
-
const newContext = new ContextManager(
|
|
2805
|
-
contextManager.set(
|
|
2807
|
+
const newContext = new ContextManager(browser);
|
|
2808
|
+
contextManager.set(browser, newContext);
|
|
2806
2809
|
return newContext;
|
|
2807
2810
|
}
|
|
2808
2811
|
var ContextManager = class {
|
|
2809
2812
|
#browser;
|
|
2810
2813
|
#initialize;
|
|
2811
2814
|
#currentContext;
|
|
2812
|
-
constructor(
|
|
2813
|
-
this.#browser =
|
|
2814
|
-
if (!
|
|
2815
|
+
constructor(browser) {
|
|
2816
|
+
this.#browser = browser;
|
|
2817
|
+
if (!browser.isBidi || process.env.VITEST_WORKER_ID || browser.options?.automationProtocol !== "webdriver") {
|
|
2815
2818
|
this.#initialize = Promise.resolve(true);
|
|
2816
2819
|
return;
|
|
2817
2820
|
}
|
|
@@ -2853,10 +2856,11 @@ async function execute(script, ...args) {
|
|
|
2853
2856
|
if (typeof script !== "string" && typeof script !== "function") {
|
|
2854
2857
|
throw new Error("number or type of arguments don't agree with execute protocol command");
|
|
2855
2858
|
}
|
|
2856
|
-
if (this.isBidi) {
|
|
2859
|
+
if (this.isBidi && !this.isMultiremote) {
|
|
2860
|
+
const browser = getBrowserObject2(this);
|
|
2857
2861
|
const contextManager2 = getContextManager(browser);
|
|
2858
2862
|
const context = await contextManager2.getCurrentContext();
|
|
2859
|
-
const result = await
|
|
2863
|
+
const result = await browser.scriptCallFunction({
|
|
2860
2864
|
functionDeclaration: script.toString(),
|
|
2861
2865
|
awaitPromise: false,
|
|
2862
2866
|
arguments: args.map((arg) => LocalValue.getArgument(arg)),
|
|
@@ -2873,11 +2877,13 @@ async function execute(script, ...args) {
|
|
|
2873
2877
|
}
|
|
2874
2878
|
|
|
2875
2879
|
// src/commands/browser/executeAsync.ts
|
|
2880
|
+
import { getBrowserObject as getBrowserObject3 } from "@wdio/utils";
|
|
2876
2881
|
async function executeAsync(script, ...args) {
|
|
2877
2882
|
if (typeof script !== "string" && typeof script !== "function") {
|
|
2878
2883
|
throw new Error("number or type of arguments don't agree with execute protocol command");
|
|
2879
2884
|
}
|
|
2880
|
-
if (this.isBidi) {
|
|
2885
|
+
if (this.isBidi && !this.isMultiremote) {
|
|
2886
|
+
const browser = getBrowserObject3(this);
|
|
2881
2887
|
const contextManager2 = getContextManager(browser);
|
|
2882
2888
|
const context = await contextManager2.getCurrentContext();
|
|
2883
2889
|
const functionDeclaration = `function (...args) {
|
|
@@ -2889,7 +2895,7 @@ async function executeAsync(script, ...args) {
|
|
|
2889
2895
|
}
|
|
2890
2896
|
})
|
|
2891
2897
|
}`;
|
|
2892
|
-
const result = await
|
|
2898
|
+
const result = await browser.scriptCallFunction({
|
|
2893
2899
|
functionDeclaration,
|
|
2894
2900
|
awaitPromise: true,
|
|
2895
2901
|
arguments: args.map((arg) => LocalValue.getArgument(arg)),
|
|
@@ -2998,10 +3004,10 @@ async function getPuppeteer() {
|
|
|
2998
3004
|
}
|
|
2999
3005
|
|
|
3000
3006
|
// src/commands/browser/getWindowSize.ts
|
|
3001
|
-
import { getBrowserObject as
|
|
3007
|
+
import { getBrowserObject as getBrowserObject4 } from "@wdio/utils";
|
|
3002
3008
|
async function getWindowSize() {
|
|
3003
|
-
const
|
|
3004
|
-
const { width, height } = await
|
|
3009
|
+
const browser = getBrowserObject4(this);
|
|
3010
|
+
const { width, height } = await browser.getWindowRect();
|
|
3005
3011
|
return { width, height };
|
|
3006
3012
|
}
|
|
3007
3013
|
|
|
@@ -3028,7 +3034,7 @@ async function keys(value) {
|
|
|
3028
3034
|
}
|
|
3029
3035
|
|
|
3030
3036
|
// src/commands/browser/mock.ts
|
|
3031
|
-
import { getBrowserObject as
|
|
3037
|
+
import { getBrowserObject as getBrowserObject5 } from "@wdio/utils";
|
|
3032
3038
|
|
|
3033
3039
|
// src/utils/interception/index.ts
|
|
3034
3040
|
import EventEmitter2 from "node:events";
|
|
@@ -3210,18 +3216,18 @@ var WebDriverInterception = class _WebDriverInterception {
|
|
|
3210
3216
|
#requestOverwrites = [];
|
|
3211
3217
|
#respondOverwrites = [];
|
|
3212
3218
|
#calls = [];
|
|
3213
|
-
constructor(pattern, mockId, filterOptions,
|
|
3219
|
+
constructor(pattern, mockId, filterOptions, browser) {
|
|
3214
3220
|
this.#pattern = pattern;
|
|
3215
3221
|
this.#mockId = mockId;
|
|
3216
3222
|
this.#filterOptions = filterOptions;
|
|
3217
|
-
this.#browser =
|
|
3218
|
-
|
|
3219
|
-
|
|
3223
|
+
this.#browser = browser;
|
|
3224
|
+
browser.on("network.beforeRequestSent", this.#handleBeforeRequestSent.bind(this));
|
|
3225
|
+
browser.on("network.responseStarted", this.#handleResponseStarted.bind(this));
|
|
3220
3226
|
}
|
|
3221
|
-
static async initiate(url6, filterOptions,
|
|
3227
|
+
static async initiate(url6, filterOptions, browser) {
|
|
3222
3228
|
const pattern = parseUrlPattern(url6);
|
|
3223
3229
|
if (!hasSubscribedToEvents) {
|
|
3224
|
-
await
|
|
3230
|
+
await browser.sessionSubscribe({
|
|
3225
3231
|
events: [
|
|
3226
3232
|
"network.beforeRequestSent",
|
|
3227
3233
|
"network.responseStarted"
|
|
@@ -3230,7 +3236,7 @@ var WebDriverInterception = class _WebDriverInterception {
|
|
|
3230
3236
|
log6.info("subscribed to network events");
|
|
3231
3237
|
hasSubscribedToEvents = true;
|
|
3232
3238
|
}
|
|
3233
|
-
const interception = await
|
|
3239
|
+
const interception = await browser.networkAddIntercept({
|
|
3234
3240
|
phases: ["beforeRequestSent", "responseStarted"],
|
|
3235
3241
|
urlPatterns: [{
|
|
3236
3242
|
type: "pattern",
|
|
@@ -3241,7 +3247,7 @@ var WebDriverInterception = class _WebDriverInterception {
|
|
|
3241
3247
|
search: getPatternParam(pattern, "search")
|
|
3242
3248
|
}]
|
|
3243
3249
|
});
|
|
3244
|
-
return new _WebDriverInterception(pattern, interception.intercept, filterOptions,
|
|
3250
|
+
return new _WebDriverInterception(pattern, interception.intercept, filterOptions, browser);
|
|
3245
3251
|
}
|
|
3246
3252
|
#handleBeforeRequestSent(request) {
|
|
3247
3253
|
if (!this.#isRequestMatching(request)) {
|
|
@@ -3517,8 +3523,8 @@ async function mock(url6, filterOptions) {
|
|
|
3517
3523
|
if (!this.isBidi) {
|
|
3518
3524
|
throw new Error("Mocking is only supported when running tests using WebDriver Bidi");
|
|
3519
3525
|
}
|
|
3520
|
-
const
|
|
3521
|
-
const contextManager2 = getContextManager(
|
|
3526
|
+
const browser = getBrowserObject5(this);
|
|
3527
|
+
const contextManager2 = getContextManager(browser);
|
|
3522
3528
|
const context = await contextManager2.getCurrentContext();
|
|
3523
3529
|
if (!SESSION_MOCKS[context]) {
|
|
3524
3530
|
SESSION_MOCKS[context] = /* @__PURE__ */ new Set();
|
|
@@ -3721,6 +3727,7 @@ async function saveRecordingScreen(filepath) {
|
|
|
3721
3727
|
|
|
3722
3728
|
// src/commands/browser/saveScreenshot.ts
|
|
3723
3729
|
import fs6 from "node:fs";
|
|
3730
|
+
import { getBrowserObject as getBrowserObject6 } from "@wdio/utils";
|
|
3724
3731
|
async function saveScreenshot(filepath) {
|
|
3725
3732
|
if (typeof filepath !== "string" || !filepath.endsWith(".png")) {
|
|
3726
3733
|
throw new Error('saveScreenshot expects a filepath of type string and ".png" file ending');
|
|
@@ -3729,6 +3736,7 @@ async function saveScreenshot(filepath) {
|
|
|
3729
3736
|
await assertDirectoryExists(absoluteFilepath);
|
|
3730
3737
|
let screenBuffer;
|
|
3731
3738
|
if (this.isBidi) {
|
|
3739
|
+
const browser = getBrowserObject6(this);
|
|
3732
3740
|
const contextManager2 = getContextManager(browser);
|
|
3733
3741
|
const context = await contextManager2.getCurrentContext();
|
|
3734
3742
|
const { data } = await this.browsingContextCaptureScreenshot({ context });
|
|
@@ -3787,7 +3795,7 @@ async function setTimeout2(timeouts) {
|
|
|
3787
3795
|
}
|
|
3788
3796
|
|
|
3789
3797
|
// src/commands/browser/setViewport.ts
|
|
3790
|
-
import { getBrowserObject as
|
|
3798
|
+
import { getBrowserObject as getBrowserObject7 } from "@wdio/utils";
|
|
3791
3799
|
var minWindowSize = 0;
|
|
3792
3800
|
var maxWindowSize = Number.MAX_SAFE_INTEGER;
|
|
3793
3801
|
async function setViewport(options) {
|
|
@@ -3800,10 +3808,10 @@ async function setViewport(options) {
|
|
|
3800
3808
|
if (options.devicePixelRatio && (typeof options.devicePixelRatio !== "number" || options.devicePixelRatio < 0)) {
|
|
3801
3809
|
throw new Error("setViewport expects devicePixelRatio to be a number in the 0 to 2^31 \u2212 1 range");
|
|
3802
3810
|
}
|
|
3803
|
-
const
|
|
3804
|
-
const contextManager2 = getContextManager(
|
|
3811
|
+
const browser = getBrowserObject7(this);
|
|
3812
|
+
const contextManager2 = getContextManager(browser);
|
|
3805
3813
|
const context = await contextManager2.getCurrentContext();
|
|
3806
|
-
await
|
|
3814
|
+
await browser.browsingContextSetViewport({
|
|
3807
3815
|
context,
|
|
3808
3816
|
devicePixelRatio: options.devicePixelRatio || 1,
|
|
3809
3817
|
viewport: {
|
|
@@ -3814,7 +3822,7 @@ async function setViewport(options) {
|
|
|
3814
3822
|
}
|
|
3815
3823
|
|
|
3816
3824
|
// src/commands/browser/setWindowSize.ts
|
|
3817
|
-
import { getBrowserObject as
|
|
3825
|
+
import { getBrowserObject as getBrowserObject8 } from "@wdio/utils";
|
|
3818
3826
|
var minWindowSize2 = 0;
|
|
3819
3827
|
var maxWindowSize2 = Number.MAX_SAFE_INTEGER;
|
|
3820
3828
|
async function setWindowSize(width, height) {
|
|
@@ -3824,8 +3832,8 @@ async function setWindowSize(width, height) {
|
|
|
3824
3832
|
if (width < minWindowSize2 || width > maxWindowSize2 || height < minWindowSize2 || height > maxWindowSize2) {
|
|
3825
3833
|
throw new Error("setWindowSize expects width and height to be a number in the 0 to 2^31 \u2212 1 range");
|
|
3826
3834
|
}
|
|
3827
|
-
const
|
|
3828
|
-
await
|
|
3835
|
+
const browser = getBrowserObject8(this);
|
|
3836
|
+
await browser.setWindowRect(null, null, width, height);
|
|
3829
3837
|
}
|
|
3830
3838
|
|
|
3831
3839
|
// src/commands/browser/switchWindow.ts
|
|
@@ -3863,12 +3871,12 @@ async function switchWindow(matcher) {
|
|
|
3863
3871
|
|
|
3864
3872
|
// src/commands/browser/throttle.ts
|
|
3865
3873
|
import logger11 from "@wdio/logger";
|
|
3866
|
-
import { getBrowserObject as
|
|
3874
|
+
import { getBrowserObject as getBrowserObject9 } from "@wdio/utils";
|
|
3867
3875
|
var log11 = logger11("webdriverio:throttle");
|
|
3868
3876
|
async function throttle(params) {
|
|
3869
3877
|
log11.warn('Command "throttle" is deprecated and will be removed with the next major version release! Use `throttleNetwork` instead.');
|
|
3870
|
-
const
|
|
3871
|
-
await
|
|
3878
|
+
const browser = getBrowserObject9(this);
|
|
3879
|
+
await browser.throttleNetwork(params);
|
|
3872
3880
|
}
|
|
3873
3881
|
|
|
3874
3882
|
// src/commands/browser/throttleCPU.ts
|
|
@@ -3890,7 +3898,7 @@ async function throttleCPU(factor) {
|
|
|
3890
3898
|
}
|
|
3891
3899
|
|
|
3892
3900
|
// src/commands/browser/throttleNetwork.ts
|
|
3893
|
-
import { getBrowserObject as
|
|
3901
|
+
import { getBrowserObject as getBrowserObject10 } from "@wdio/utils";
|
|
3894
3902
|
var NETWORK_PRESETS = {
|
|
3895
3903
|
"offline": {
|
|
3896
3904
|
offline: true,
|
|
@@ -3967,8 +3975,8 @@ async function throttleNetwork(params) {
|
|
|
3967
3975
|
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}"`);
|
|
3968
3976
|
}
|
|
3969
3977
|
if (this.isSauce) {
|
|
3970
|
-
const
|
|
3971
|
-
await
|
|
3978
|
+
const browser = getBrowserObject10(this);
|
|
3979
|
+
await browser.sauceThrottleNetwork(params);
|
|
3972
3980
|
return null;
|
|
3973
3981
|
}
|
|
3974
3982
|
const failedConnectionMessage = "No Puppeteer connection could be established which is required to use this command";
|
|
@@ -4084,22 +4092,22 @@ async function uploadFile(localPath) {
|
|
|
4084
4092
|
|
|
4085
4093
|
// src/networkManager.ts
|
|
4086
4094
|
var networkManager = /* @__PURE__ */ new Map();
|
|
4087
|
-
function getNetworkManager(
|
|
4088
|
-
const existingNetworkManager = networkManager.get(
|
|
4095
|
+
function getNetworkManager(browser) {
|
|
4096
|
+
const existingNetworkManager = networkManager.get(browser);
|
|
4089
4097
|
if (existingNetworkManager) {
|
|
4090
4098
|
return existingNetworkManager;
|
|
4091
4099
|
}
|
|
4092
|
-
const newContext = new NetworkManager(
|
|
4093
|
-
networkManager.set(
|
|
4100
|
+
const newContext = new NetworkManager(browser);
|
|
4101
|
+
networkManager.set(browser, newContext);
|
|
4094
4102
|
return newContext;
|
|
4095
4103
|
}
|
|
4096
4104
|
var NetworkManager = class {
|
|
4097
4105
|
#browser;
|
|
4098
4106
|
#initialize;
|
|
4099
4107
|
#requests = /* @__PURE__ */ new Map();
|
|
4100
|
-
constructor(
|
|
4101
|
-
this.#browser =
|
|
4102
|
-
if (!
|
|
4108
|
+
constructor(browser) {
|
|
4109
|
+
this.#browser = browser;
|
|
4110
|
+
if (!browser.isBidi || process.env.VITEST_WORKER_ID || browser.options?.automationProtocol !== "webdriver") {
|
|
4103
4111
|
this.#initialize = Promise.resolve(true);
|
|
4104
4112
|
return;
|
|
4105
4113
|
}
|
|
@@ -4426,7 +4434,7 @@ function clearValue() {
|
|
|
4426
4434
|
|
|
4427
4435
|
// src/commands/element/click.ts
|
|
4428
4436
|
import logger12 from "@wdio/logger";
|
|
4429
|
-
import { getBrowserObject as
|
|
4437
|
+
import { getBrowserObject as getBrowserObject11 } from "@wdio/utils";
|
|
4430
4438
|
var log12 = logger12("webdriver");
|
|
4431
4439
|
function click(options) {
|
|
4432
4440
|
if (typeof options !== "undefined") {
|
|
@@ -4469,9 +4477,9 @@ async function actionClick(element, options) {
|
|
|
4469
4477
|
if (!buttonValue.includes(button)) {
|
|
4470
4478
|
throw new Error("Button type not supported.");
|
|
4471
4479
|
}
|
|
4472
|
-
const
|
|
4480
|
+
const browser = getBrowserObject11(element);
|
|
4473
4481
|
if (x || y) {
|
|
4474
|
-
const { width, height } = await
|
|
4482
|
+
const { width, height } = await browser.getElementRect(element.elementId);
|
|
4475
4483
|
if (x && x < -Math.floor(width / 2) || x && x > Math.floor(width / 2)) {
|
|
4476
4484
|
log12.warn("x would cause a out of bounds error as it goes outside of element");
|
|
4477
4485
|
}
|
|
@@ -4480,7 +4488,7 @@ async function actionClick(element, options) {
|
|
|
4480
4488
|
}
|
|
4481
4489
|
}
|
|
4482
4490
|
const clickNested = async () => {
|
|
4483
|
-
await
|
|
4491
|
+
await browser.action("pointer", {
|
|
4484
4492
|
parameters: { pointerType: "mouse" }
|
|
4485
4493
|
}).move({ origin: element, x, y }).down({ button }).up({ button }).perform(skipRelease);
|
|
4486
4494
|
};
|
|
@@ -4494,9 +4502,9 @@ async function actionClick(element, options) {
|
|
|
4494
4502
|
|
|
4495
4503
|
// src/commands/element/custom$$.ts
|
|
4496
4504
|
import { ELEMENT_KEY as ELEMENT_KEY8 } from "webdriver";
|
|
4497
|
-
import { getBrowserObject as
|
|
4505
|
+
import { getBrowserObject as getBrowserObject12 } from "@wdio/utils";
|
|
4498
4506
|
async function custom$$2(strategyName, ...strategyArguments) {
|
|
4499
|
-
const browserObject =
|
|
4507
|
+
const browserObject = getBrowserObject12(this);
|
|
4500
4508
|
const strategy = browserObject.strategies.get(strategyName);
|
|
4501
4509
|
if (!strategy) {
|
|
4502
4510
|
throw Error("No strategy found for " + strategyName);
|
|
@@ -4516,9 +4524,9 @@ async function custom$$2(strategyName, ...strategyArguments) {
|
|
|
4516
4524
|
|
|
4517
4525
|
// src/commands/element/custom$.ts
|
|
4518
4526
|
import { ELEMENT_KEY as ELEMENT_KEY9 } from "webdriver";
|
|
4519
|
-
import { getBrowserObject as
|
|
4527
|
+
import { getBrowserObject as getBrowserObject13 } from "@wdio/utils";
|
|
4520
4528
|
async function custom$2(strategyName, ...strategyArguments) {
|
|
4521
|
-
const browserObject =
|
|
4529
|
+
const browserObject = getBrowserObject13(this);
|
|
4522
4530
|
const strategy = browserObject.strategies.get(strategyName);
|
|
4523
4531
|
if (!strategy) {
|
|
4524
4532
|
throw Error("No strategy found for " + strategyName);
|
|
@@ -4538,15 +4546,15 @@ async function custom$2(strategyName, ...strategyArguments) {
|
|
|
4538
4546
|
}
|
|
4539
4547
|
|
|
4540
4548
|
// src/commands/element/doubleClick.ts
|
|
4541
|
-
import { getBrowserObject as
|
|
4549
|
+
import { getBrowserObject as getBrowserObject14 } from "@wdio/utils";
|
|
4542
4550
|
async function doubleClick() {
|
|
4543
|
-
const
|
|
4544
|
-
return
|
|
4551
|
+
const browser = getBrowserObject14(this);
|
|
4552
|
+
return browser.action("pointer", { parameters: { pointerType: "mouse" } }).move({ origin: this }).down().up().pause(10).down().up().perform();
|
|
4545
4553
|
}
|
|
4546
4554
|
|
|
4547
4555
|
// src/commands/element/dragAndDrop.ts
|
|
4548
4556
|
import { ELEMENT_KEY as ELEMENT_KEY10 } from "webdriver";
|
|
4549
|
-
import { getBrowserObject as
|
|
4557
|
+
import { getBrowserObject as getBrowserObject15 } from "@wdio/utils";
|
|
4550
4558
|
var ACTION_BUTTON = 0;
|
|
4551
4559
|
async function dragAndDrop(target, { duration = 10 } = {}) {
|
|
4552
4560
|
const moveToCoordinates = target;
|
|
@@ -4572,19 +4580,21 @@ async function dragAndDrop(target, { duration = 10 } = {}) {
|
|
|
4572
4580
|
const targetOrigin = isMovingToElement ? targetRef : "pointer";
|
|
4573
4581
|
const targetX = isMovingToElement ? 0 : moveToCoordinates.x;
|
|
4574
4582
|
const targetY = isMovingToElement ? 0 : moveToCoordinates.y;
|
|
4575
|
-
const
|
|
4576
|
-
return
|
|
4583
|
+
const browser = getBrowserObject15(this);
|
|
4584
|
+
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();
|
|
4577
4585
|
}
|
|
4578
4586
|
|
|
4579
4587
|
// src/commands/element/execute.ts
|
|
4588
|
+
import { getBrowserObject as getBrowserObject16 } from "@wdio/utils";
|
|
4580
4589
|
async function execute2(script, ...args) {
|
|
4581
4590
|
if (typeof script !== "string" && typeof script !== "function") {
|
|
4582
4591
|
throw new Error("number or type of arguments don't agree with execute protocol command");
|
|
4583
4592
|
}
|
|
4584
4593
|
if (this.isBidi) {
|
|
4594
|
+
const browser = getBrowserObject16(this);
|
|
4585
4595
|
const contextManager2 = getContextManager(browser);
|
|
4586
4596
|
const context = await contextManager2.getCurrentContext();
|
|
4587
|
-
const result = await
|
|
4597
|
+
const result = await browser.scriptCallFunction({
|
|
4588
4598
|
functionDeclaration: script.toString(),
|
|
4589
4599
|
awaitPromise: false,
|
|
4590
4600
|
arguments: [this, ...args].map((arg) => LocalValue.getArgument(arg)),
|
|
@@ -4601,11 +4611,13 @@ async function execute2(script, ...args) {
|
|
|
4601
4611
|
}
|
|
4602
4612
|
|
|
4603
4613
|
// src/commands/element/executeAsync.ts
|
|
4614
|
+
import { getBrowserObject as getBrowserObject17 } from "@wdio/utils";
|
|
4604
4615
|
async function executeAsync2(script, ...args) {
|
|
4605
4616
|
if (typeof script !== "string" && typeof script !== "function") {
|
|
4606
4617
|
throw new Error("number or type of arguments don't agree with execute protocol command");
|
|
4607
4618
|
}
|
|
4608
4619
|
if (this.isBidi) {
|
|
4620
|
+
const browser = getBrowserObject17(this);
|
|
4609
4621
|
const contextManager2 = getContextManager(browser);
|
|
4610
4622
|
const context = await contextManager2.getCurrentContext();
|
|
4611
4623
|
const functionDeclaration = `function (...args) {
|
|
@@ -4617,7 +4629,7 @@ async function executeAsync2(script, ...args) {
|
|
|
4617
4629
|
}
|
|
4618
4630
|
})
|
|
4619
4631
|
}`;
|
|
4620
|
-
const result = await
|
|
4632
|
+
const result = await browser.scriptCallFunction({
|
|
4621
4633
|
functionDeclaration,
|
|
4622
4634
|
awaitPromise: true,
|
|
4623
4635
|
arguments: [this, ...args].map((arg) => LocalValue.getArgument(arg)),
|
|
@@ -4640,7 +4652,7 @@ function getAttribute(attributeName) {
|
|
|
4640
4652
|
|
|
4641
4653
|
// src/commands/element/getCSSProperty.ts
|
|
4642
4654
|
import cssShorthandProps from "css-shorthand-properties";
|
|
4643
|
-
import { getBrowserObject as
|
|
4655
|
+
import { getBrowserObject as getBrowserObject18 } from "@wdio/utils";
|
|
4644
4656
|
async function getCSSProperty(cssProperty, pseudoElement) {
|
|
4645
4657
|
const getCSSProperty2 = cssShorthandProps.isShorthand(cssProperty) ? getShorthandPropertyCSSValue : getPropertyCSSValue;
|
|
4646
4658
|
const cssValue2 = await getCSSProperty2.call(
|
|
@@ -4704,9 +4716,9 @@ function mergeEqualSymmetricalValue(cssValues) {
|
|
|
4704
4716
|
return newCssValues.join(" ");
|
|
4705
4717
|
}
|
|
4706
4718
|
async function getPseudoElementCSSValue(elem, options) {
|
|
4707
|
-
const
|
|
4719
|
+
const browser = getBrowserObject18(elem);
|
|
4708
4720
|
const { cssProperty, pseudoElement } = options;
|
|
4709
|
-
const cssValue2 = await
|
|
4721
|
+
const cssValue2 = await browser.execute(
|
|
4710
4722
|
(elem2, pseudoElement2, cssProperty2) => window.getComputedStyle(elem2, pseudoElement2)[cssProperty2],
|
|
4711
4723
|
elem,
|
|
4712
4724
|
pseudoElement,
|
|
@@ -4733,20 +4745,20 @@ async function getElement2() {
|
|
|
4733
4745
|
// src/commands/element/getHTML.ts
|
|
4734
4746
|
import { ELEMENT_KEY as ELEMENT_KEY11 } from "webdriver";
|
|
4735
4747
|
import { prettify as prettifyFn } from "htmlfy";
|
|
4736
|
-
import { getBrowserObject as
|
|
4748
|
+
import { getBrowserObject as getBrowserObject19 } from "@wdio/utils";
|
|
4737
4749
|
|
|
4738
4750
|
// src/shadowRoot.ts
|
|
4739
4751
|
import logger13 from "@wdio/logger";
|
|
4740
4752
|
import customElementWrapper from "./scripts/customElement.js";
|
|
4741
4753
|
var shadowRootManager = /* @__PURE__ */ new Map();
|
|
4742
4754
|
var log13 = logger13("webdriverio:ShadowRootManager");
|
|
4743
|
-
function getShadowRootManager(
|
|
4744
|
-
const existingShadowRootManager = shadowRootManager.get(
|
|
4755
|
+
function getShadowRootManager(browser) {
|
|
4756
|
+
const existingShadowRootManager = shadowRootManager.get(browser);
|
|
4745
4757
|
if (existingShadowRootManager) {
|
|
4746
4758
|
return existingShadowRootManager;
|
|
4747
4759
|
}
|
|
4748
|
-
const newContext = new ShadowRootManager(
|
|
4749
|
-
shadowRootManager.set(
|
|
4760
|
+
const newContext = new ShadowRootManager(browser);
|
|
4761
|
+
shadowRootManager.set(browser, newContext);
|
|
4750
4762
|
return newContext;
|
|
4751
4763
|
}
|
|
4752
4764
|
var ShadowRootManager = class {
|
|
@@ -4754,9 +4766,9 @@ var ShadowRootManager = class {
|
|
|
4754
4766
|
#initialize;
|
|
4755
4767
|
#shadowRoots = /* @__PURE__ */ new Map();
|
|
4756
4768
|
#frameDepth = 0;
|
|
4757
|
-
constructor(
|
|
4758
|
-
this.#browser =
|
|
4759
|
-
if (!
|
|
4769
|
+
constructor(browser) {
|
|
4770
|
+
this.#browser = browser;
|
|
4771
|
+
if (!browser.isBidi || process.env.VITEST_WORKER_ID || browser.options?.automationProtocol !== "webdriver") {
|
|
4760
4772
|
this.#initialize = Promise.resolve(true);
|
|
4761
4773
|
return;
|
|
4762
4774
|
}
|
|
@@ -4765,7 +4777,7 @@ var ShadowRootManager = class {
|
|
|
4765
4777
|
}).then(() => true, () => false);
|
|
4766
4778
|
this.#browser.on("log.entryAdded", this.handleLogEntry.bind(this));
|
|
4767
4779
|
this.#browser.on("result", this.#commandResultHandler.bind(this));
|
|
4768
|
-
|
|
4780
|
+
browser.scriptAddPreloadScript({
|
|
4769
4781
|
functionDeclaration: customElementWrapper.toString()
|
|
4770
4782
|
});
|
|
4771
4783
|
}
|
|
@@ -4983,7 +4995,7 @@ import getHTMLShadowScript from "./scripts/getHTMLShadow.js";
|
|
|
4983
4995
|
var SHADOW_ID_ATTR_NAME = "data-wdio-shadow-id";
|
|
4984
4996
|
var SHADOW_ID_ATTR = `[${SHADOW_ID_ATTR_NAME}]`;
|
|
4985
4997
|
async function getHTML(options = {}) {
|
|
4986
|
-
const
|
|
4998
|
+
const browser = getBrowserObject19(this);
|
|
4987
4999
|
if (typeof options !== "object" && typeof options === "boolean") {
|
|
4988
5000
|
options = { includeSelectorTag: options };
|
|
4989
5001
|
} else if (typeof options !== "object") {
|
|
@@ -4997,7 +5009,7 @@ async function getHTML(options = {}) {
|
|
|
4997
5009
|
excludeElements: []
|
|
4998
5010
|
}, options);
|
|
4999
5011
|
const basicGetHTML = (elementId, includeSelectorTag2) => {
|
|
5000
|
-
return
|
|
5012
|
+
return browser.execute(getHTMLScript, {
|
|
5001
5013
|
[ELEMENT_KEY11]: elementId,
|
|
5002
5014
|
// w3c compatible
|
|
5003
5015
|
ELEMENT: elementId
|
|
@@ -5013,12 +5025,12 @@ async function getHTML(options = {}) {
|
|
|
5013
5025
|
);
|
|
5014
5026
|
}
|
|
5015
5027
|
const { load } = await import("cheerio");
|
|
5016
|
-
const shadowRootManager2 = getShadowRootManager(
|
|
5017
|
-
const contextManager2 = getContextManager(
|
|
5028
|
+
const shadowRootManager2 = getShadowRootManager(browser);
|
|
5029
|
+
const contextManager2 = getContextManager(browser);
|
|
5018
5030
|
const context = await contextManager2.getCurrentContext();
|
|
5019
5031
|
const shadowRootElementPairs = shadowRootManager2.getShadowElementPairsByContextId(context, this.elementId);
|
|
5020
5032
|
const elementsWithShadowRootAndIdVerified = (await Promise.all(
|
|
5021
|
-
shadowRootElementPairs.map(([elemId, elem]) =>
|
|
5033
|
+
shadowRootElementPairs.map(([elemId, elem]) => browser.execute((elem2) => elem2.tagName, { [ELEMENT_KEY11]: elemId }).then(
|
|
5022
5034
|
() => [elemId, elem],
|
|
5023
5035
|
() => void 0
|
|
5024
5036
|
))
|
|
@@ -5027,7 +5039,7 @@ async function getHTML(options = {}) {
|
|
|
5027
5039
|
{ [ELEMENT_KEY11]: elemId },
|
|
5028
5040
|
shadowId ? { [ELEMENT_KEY11]: shadowId } : void 0
|
|
5029
5041
|
]);
|
|
5030
|
-
const { html, shadowElementHTML } = await
|
|
5042
|
+
const { html, shadowElementHTML } = await browser.execute(
|
|
5031
5043
|
getHTMLShadowScript,
|
|
5032
5044
|
{ [ELEMENT_KEY11]: this.elementId },
|
|
5033
5045
|
includeSelectorTag,
|
|
@@ -5128,7 +5140,7 @@ function getValue() {
|
|
|
5128
5140
|
|
|
5129
5141
|
// src/commands/element/isClickable.ts
|
|
5130
5142
|
import { ELEMENT_KEY as ELEMENT_KEY12 } from "webdriver";
|
|
5131
|
-
import { getBrowserObject as
|
|
5143
|
+
import { getBrowserObject as getBrowserObject20 } from "@wdio/utils";
|
|
5132
5144
|
import isElementClickableScript from "./scripts/isElementClickable.js";
|
|
5133
5145
|
async function isClickable() {
|
|
5134
5146
|
if (!await this.isDisplayed()) {
|
|
@@ -5137,8 +5149,8 @@ async function isClickable() {
|
|
|
5137
5149
|
if (this.isMobile && await this.getContext().catch(() => void 0) === "NATIVE_APP") {
|
|
5138
5150
|
throw new Error("Method not supported in mobile native environment. It is unlikely that you need to use this command.");
|
|
5139
5151
|
}
|
|
5140
|
-
const
|
|
5141
|
-
return
|
|
5152
|
+
const browser = getBrowserObject20(this);
|
|
5153
|
+
return browser.execute(isElementClickableScript, {
|
|
5142
5154
|
[ELEMENT_KEY12]: this.elementId,
|
|
5143
5155
|
// w3c compatible
|
|
5144
5156
|
ELEMENT: this.elementId
|
|
@@ -5147,16 +5159,16 @@ async function isClickable() {
|
|
|
5147
5159
|
}
|
|
5148
5160
|
|
|
5149
5161
|
// src/commands/element/isDisplayed.ts
|
|
5150
|
-
import { getBrowserObject as
|
|
5162
|
+
import { getBrowserObject as getBrowserObject21 } from "@wdio/utils";
|
|
5151
5163
|
import isElementDisplayedScript from "./scripts/isElementDisplayed.js";
|
|
5152
5164
|
import isElementInViewportScript from "./scripts/isElementInViewport.js";
|
|
5153
5165
|
async function isDisplayed(commandParams = { withinViewport: false }) {
|
|
5154
|
-
const
|
|
5166
|
+
const browser = getBrowserObject21(this);
|
|
5155
5167
|
if (!await hasElementId(this)) {
|
|
5156
5168
|
return false;
|
|
5157
5169
|
}
|
|
5158
|
-
const isNativeApplication = !
|
|
5159
|
-
if (
|
|
5170
|
+
const isNativeApplication = !browser.capabilities.browserName;
|
|
5171
|
+
if (browser.isMobile && isNativeApplication) {
|
|
5160
5172
|
if (commandParams?.withinViewport) {
|
|
5161
5173
|
throw new Error(
|
|
5162
5174
|
"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."
|
|
@@ -5164,9 +5176,9 @@ async function isDisplayed(commandParams = { withinViewport: false }) {
|
|
|
5164
5176
|
}
|
|
5165
5177
|
return await this.isElementDisplayed(this.elementId);
|
|
5166
5178
|
}
|
|
5167
|
-
const isDisplayed2 = await
|
|
5179
|
+
const isDisplayed2 = await browser.execute(isElementDisplayedScript, this);
|
|
5168
5180
|
if (isDisplayed2 && commandParams?.withinViewport) {
|
|
5169
|
-
return
|
|
5181
|
+
return browser.execute(isElementInViewportScript, this);
|
|
5170
5182
|
}
|
|
5171
5183
|
return isDisplayed2;
|
|
5172
5184
|
}
|
|
@@ -5178,7 +5190,7 @@ function isEnabled() {
|
|
|
5178
5190
|
|
|
5179
5191
|
// src/commands/element/isEqual.ts
|
|
5180
5192
|
import { ELEMENT_KEY as ELEMENT_KEY13 } from "webdriver";
|
|
5181
|
-
import { getBrowserObject as
|
|
5193
|
+
import { getBrowserObject as getBrowserObject22 } from "@wdio/utils";
|
|
5182
5194
|
var getWebElement = (el) => ({
|
|
5183
5195
|
[ELEMENT_KEY13]: el.elementId,
|
|
5184
5196
|
// w3c compatible
|
|
@@ -5186,9 +5198,9 @@ var getWebElement = (el) => ({
|
|
|
5186
5198
|
// jsonwp compatible
|
|
5187
5199
|
});
|
|
5188
5200
|
async function isEqual(el) {
|
|
5189
|
-
const
|
|
5190
|
-
if (
|
|
5191
|
-
const context = await
|
|
5201
|
+
const browser = getBrowserObject22(this);
|
|
5202
|
+
if (browser.isMobile) {
|
|
5203
|
+
const context = await browser.getContext().catch(() => void 0);
|
|
5192
5204
|
const contextId = typeof context === "string" ? context : context?.id;
|
|
5193
5205
|
if (contextId && contextId.toLowerCase().includes("native")) {
|
|
5194
5206
|
return this.elementId === el.elementId;
|
|
@@ -5196,7 +5208,7 @@ async function isEqual(el) {
|
|
|
5196
5208
|
}
|
|
5197
5209
|
let result;
|
|
5198
5210
|
try {
|
|
5199
|
-
result = await
|
|
5211
|
+
result = await browser.execute(
|
|
5200
5212
|
/* istanbul ignore next */
|
|
5201
5213
|
function(el1, el2) {
|
|
5202
5214
|
return el1 === el2;
|
|
@@ -5224,11 +5236,11 @@ async function isExisting() {
|
|
|
5224
5236
|
|
|
5225
5237
|
// src/commands/element/isFocused.ts
|
|
5226
5238
|
import { ELEMENT_KEY as ELEMENT_KEY14 } from "webdriver";
|
|
5227
|
-
import { getBrowserObject as
|
|
5239
|
+
import { getBrowserObject as getBrowserObject23 } from "@wdio/utils";
|
|
5228
5240
|
import isFocusedScript from "./scripts/isFocused.js";
|
|
5229
5241
|
async function isFocused() {
|
|
5230
|
-
const
|
|
5231
|
-
return
|
|
5242
|
+
const browser = await getBrowserObject23(this);
|
|
5243
|
+
return browser.execute(isFocusedScript, {
|
|
5232
5244
|
[ELEMENT_KEY14]: this.elementId,
|
|
5233
5245
|
// w3c compatible
|
|
5234
5246
|
ELEMENT: this.elementId
|
|
@@ -5243,11 +5255,11 @@ function isSelected() {
|
|
|
5243
5255
|
|
|
5244
5256
|
// src/commands/element/isStable.ts
|
|
5245
5257
|
import { ELEMENT_KEY as ELEMENT_KEY15 } from "webdriver";
|
|
5246
|
-
import { getBrowserObject as
|
|
5258
|
+
import { getBrowserObject as getBrowserObject24 } from "@wdio/utils";
|
|
5247
5259
|
import isElementStable from "./scripts/isElementStable.js";
|
|
5248
5260
|
async function isStable() {
|
|
5249
|
-
const
|
|
5250
|
-
return await
|
|
5261
|
+
const browser = getBrowserObject24(this);
|
|
5262
|
+
return await browser.executeAsync(isElementStable, {
|
|
5251
5263
|
[ELEMENT_KEY15]: this.elementId,
|
|
5252
5264
|
// w3c compatible
|
|
5253
5265
|
ELEMENT: this.elementId
|
|
@@ -5257,12 +5269,12 @@ async function isStable() {
|
|
|
5257
5269
|
|
|
5258
5270
|
// src/commands/element/moveTo.ts
|
|
5259
5271
|
import logger14 from "@wdio/logger";
|
|
5260
|
-
import { getBrowserObject as
|
|
5272
|
+
import { getBrowserObject as getBrowserObject25 } from "@wdio/utils";
|
|
5261
5273
|
var log14 = logger14("webdriver");
|
|
5262
5274
|
async function moveTo({ xOffset, yOffset } = {}) {
|
|
5263
|
-
const
|
|
5275
|
+
const browser = getBrowserObject25(this);
|
|
5264
5276
|
if (xOffset || yOffset) {
|
|
5265
|
-
const { width, height } = await
|
|
5277
|
+
const { width, height } = await browser.getElementRect(this.elementId);
|
|
5266
5278
|
if (xOffset && xOffset < -Math.floor(width / 2) || xOffset && xOffset > Math.floor(width / 2)) {
|
|
5267
5279
|
log14.warn("xOffset would cause a out of bounds error as it goes outside of element");
|
|
5268
5280
|
}
|
|
@@ -5271,7 +5283,7 @@ async function moveTo({ xOffset, yOffset } = {}) {
|
|
|
5271
5283
|
}
|
|
5272
5284
|
}
|
|
5273
5285
|
const moveToNested = async () => {
|
|
5274
|
-
await
|
|
5286
|
+
await browser.action("pointer", { parameters: { pointerType: "mouse" } }).move({ origin: this, x: xOffset || 0, y: yOffset || 0 }).perform();
|
|
5275
5287
|
};
|
|
5276
5288
|
try {
|
|
5277
5289
|
await moveToNested();
|
|
@@ -5315,7 +5327,7 @@ function previousElement() {
|
|
|
5315
5327
|
import fs8 from "node:fs/promises";
|
|
5316
5328
|
import url4 from "node:url";
|
|
5317
5329
|
import { resolve as resolve3 } from "import-meta-resolve";
|
|
5318
|
-
import { getBrowserObject as
|
|
5330
|
+
import { getBrowserObject as getBrowserObject26 } from "@wdio/utils";
|
|
5319
5331
|
import { waitToLoadReact as waitToLoadReact3, react$$ as react$$Script2 } from "./scripts/resq.js";
|
|
5320
5332
|
var resqScript3;
|
|
5321
5333
|
async function react$$2(selector, { props = {}, state = {} } = {}) {
|
|
@@ -5323,10 +5335,10 @@ async function react$$2(selector, { props = {}, state = {} } = {}) {
|
|
|
5323
5335
|
const resqScriptPath = url4.fileURLToPath(await resolve3("resq", import.meta.url));
|
|
5324
5336
|
resqScript3 = (await fs8.readFile(resqScriptPath)).toString();
|
|
5325
5337
|
}
|
|
5326
|
-
const
|
|
5338
|
+
const browser = await getBrowserObject26(this);
|
|
5327
5339
|
await this.executeScript(resqScript3.toString(), []);
|
|
5328
|
-
await
|
|
5329
|
-
const res = await
|
|
5340
|
+
await browser.execute(waitToLoadReact3);
|
|
5341
|
+
const res = await browser.execute(
|
|
5330
5342
|
react$$Script2,
|
|
5331
5343
|
selector,
|
|
5332
5344
|
props,
|
|
@@ -5341,7 +5353,7 @@ async function react$$2(selector, { props = {}, state = {} } = {}) {
|
|
|
5341
5353
|
import fs9 from "node:fs/promises";
|
|
5342
5354
|
import url5 from "node:url";
|
|
5343
5355
|
import { resolve as resolve4 } from "import-meta-resolve";
|
|
5344
|
-
import { getBrowserObject as
|
|
5356
|
+
import { getBrowserObject as getBrowserObject27 } from "@wdio/utils";
|
|
5345
5357
|
import { waitToLoadReact as waitToLoadReact4, react$ as react$Script2 } from "./scripts/resq.js";
|
|
5346
5358
|
var resqScript4;
|
|
5347
5359
|
async function react$2(selector, { props = {}, state = {} } = {}) {
|
|
@@ -5349,10 +5361,10 @@ async function react$2(selector, { props = {}, state = {} } = {}) {
|
|
|
5349
5361
|
const resqScriptPath = url5.fileURLToPath(await resolve4("resq", import.meta.url));
|
|
5350
5362
|
resqScript4 = (await fs9.readFile(resqScriptPath)).toString();
|
|
5351
5363
|
}
|
|
5352
|
-
const
|
|
5364
|
+
const browser = await getBrowserObject27(this);
|
|
5353
5365
|
await this.executeScript(resqScript4.toString(), []);
|
|
5354
|
-
await
|
|
5355
|
-
const res = await
|
|
5366
|
+
await browser.execute(waitToLoadReact4);
|
|
5367
|
+
const res = await browser.execute(
|
|
5356
5368
|
react$Script2,
|
|
5357
5369
|
selector,
|
|
5358
5370
|
props,
|
|
@@ -5379,11 +5391,11 @@ async function saveScreenshot2(filepath) {
|
|
|
5379
5391
|
// src/commands/element/scrollIntoView.ts
|
|
5380
5392
|
import logger15 from "@wdio/logger";
|
|
5381
5393
|
import { ELEMENT_KEY as ELEMENT_KEY16 } from "webdriver";
|
|
5382
|
-
import { getBrowserObject as
|
|
5394
|
+
import { getBrowserObject as getBrowserObject28 } from "@wdio/utils";
|
|
5383
5395
|
var log15 = logger15("webdriverio");
|
|
5384
5396
|
function scrollIntoViewWeb(options = { block: "start", inline: "nearest" }) {
|
|
5385
|
-
const
|
|
5386
|
-
return
|
|
5397
|
+
const browser = getBrowserObject28(this);
|
|
5398
|
+
return browser.execute(
|
|
5387
5399
|
(elem, options2) => elem.scrollIntoView(options2),
|
|
5388
5400
|
{
|
|
5389
5401
|
[ELEMENT_KEY16]: this.elementId,
|
|
@@ -5395,14 +5407,14 @@ function scrollIntoViewWeb(options = { block: "start", inline: "nearest" }) {
|
|
|
5395
5407
|
);
|
|
5396
5408
|
}
|
|
5397
5409
|
async function scrollIntoView(options = { block: "start", inline: "nearest" }) {
|
|
5398
|
-
const
|
|
5399
|
-
if (
|
|
5410
|
+
const browser = getBrowserObject28(this);
|
|
5411
|
+
if (browser.isMobile) {
|
|
5400
5412
|
return scrollIntoViewWeb.call(this, options);
|
|
5401
5413
|
}
|
|
5402
5414
|
try {
|
|
5403
|
-
const elemRect = await
|
|
5404
|
-
const viewport = await
|
|
5405
|
-
let [scrollX, scrollY] = await
|
|
5415
|
+
const elemRect = await browser.getElementRect(this.elementId);
|
|
5416
|
+
const viewport = await browser.getWindowSize();
|
|
5417
|
+
let [scrollX, scrollY] = await browser.execute(() => [
|
|
5406
5418
|
window.scrollX,
|
|
5407
5419
|
window.scrollY
|
|
5408
5420
|
]);
|
|
@@ -5437,7 +5449,7 @@ async function scrollIntoView(options = { block: "start", inline: "nearest" }) {
|
|
|
5437
5449
|
}
|
|
5438
5450
|
deltaX = Math.round(deltaX - scrollX);
|
|
5439
5451
|
deltaY = Math.round(deltaY - scrollY);
|
|
5440
|
-
await
|
|
5452
|
+
await browser.action("wheel").scroll({ duration: 0, x: deltaX, y: deltaY, origin: this }).perform();
|
|
5441
5453
|
} catch (err) {
|
|
5442
5454
|
log15.warn(
|
|
5443
5455
|
`Failed to execute "scrollIntoView" using WebDriver Actions API: ${err.message}!
|
|
@@ -5505,7 +5517,7 @@ async function setValue(value) {
|
|
|
5505
5517
|
|
|
5506
5518
|
// src/commands/element/shadow$$.ts
|
|
5507
5519
|
import logger16 from "@wdio/logger";
|
|
5508
|
-
import { getBrowserObject as
|
|
5520
|
+
import { getBrowserObject as getBrowserObject29 } from "@wdio/utils";
|
|
5509
5521
|
import { SHADOW_ELEMENT_KEY } from "webdriver";
|
|
5510
5522
|
import { shadowFnFactory } from "./scripts/shadowFnFactory.js";
|
|
5511
5523
|
|
|
@@ -5833,11 +5845,11 @@ var createRoleBaseXpathSelector = (role) => {
|
|
|
5833
5845
|
// src/commands/element/shadow$$.ts
|
|
5834
5846
|
var log16 = logger16("webdriverio");
|
|
5835
5847
|
async function shadow$$(selector) {
|
|
5836
|
-
const
|
|
5848
|
+
const browser = getBrowserObject29(this);
|
|
5837
5849
|
try {
|
|
5838
|
-
const shadowRoot = await
|
|
5850
|
+
const shadowRoot = await browser.getElementShadowRoot(this.elementId);
|
|
5839
5851
|
const { using, value } = findStrategy(selector, this.isW3C, this.isMobile);
|
|
5840
|
-
const res = await
|
|
5852
|
+
const res = await browser.findElementsFromShadowRoot(shadowRoot[SHADOW_ELEMENT_KEY], using, value);
|
|
5841
5853
|
const elements = await getElements.call(this, selector, res, { isShadowElement: true });
|
|
5842
5854
|
return enhanceElementsArray(elements, this, selector);
|
|
5843
5855
|
} catch (err) {
|
|
@@ -5853,14 +5865,14 @@ Falling back to JavaScript shim.`
|
|
|
5853
5865
|
import logger17 from "@wdio/logger";
|
|
5854
5866
|
import { SHADOW_ELEMENT_KEY as SHADOW_ELEMENT_KEY2 } from "webdriver";
|
|
5855
5867
|
import { shadowFnFactory as shadowFnFactory2 } from "./scripts/shadowFnFactory.js";
|
|
5856
|
-
import { getBrowserObject as
|
|
5868
|
+
import { getBrowserObject as getBrowserObject30 } from "@wdio/utils";
|
|
5857
5869
|
var log17 = logger17("webdriverio");
|
|
5858
5870
|
async function shadow$(selector) {
|
|
5859
|
-
const
|
|
5871
|
+
const browser = getBrowserObject30(this);
|
|
5860
5872
|
try {
|
|
5861
|
-
const shadowRoot = await
|
|
5873
|
+
const shadowRoot = await browser.getElementShadowRoot(this.elementId);
|
|
5862
5874
|
const { using, value } = findStrategy(selector, this.isW3C, this.isMobile);
|
|
5863
|
-
const res = await
|
|
5875
|
+
const res = await browser.findElementFromShadowRoot(shadowRoot[SHADOW_ELEMENT_KEY2], using, value);
|
|
5864
5876
|
return getElement.call(this, selector, res, { isShadowElement: true });
|
|
5865
5877
|
} catch (err) {
|
|
5866
5878
|
log17.warn(
|
|
@@ -6256,7 +6268,7 @@ function fetchElementByJSFunction(selector, scope, referenceId) {
|
|
|
6256
6268
|
if (referenceId) {
|
|
6257
6269
|
args.push(referenceId);
|
|
6258
6270
|
}
|
|
6259
|
-
return
|
|
6271
|
+
return getBrowserObject31(scope).executeScript(`return (${script}).apply(null, arguments)`, args);
|
|
6260
6272
|
}
|
|
6261
6273
|
function isElement(o) {
|
|
6262
6274
|
return typeof HTMLElement === "object" ? o instanceof HTMLElement : o && typeof o === "object" && o !== null && o.nodeType === 1 && typeof o.nodeName === "string";
|
|
@@ -6286,9 +6298,9 @@ function transformClassicToBidiSelector(using, value) {
|
|
|
6286
6298
|
throw new Error(`Can't transform classic selector ${using} to Bidi selector`);
|
|
6287
6299
|
}
|
|
6288
6300
|
async function findDeepElement(selector) {
|
|
6289
|
-
const
|
|
6290
|
-
const shadowRootManager2 = getShadowRootManager(
|
|
6291
|
-
const contextManager2 = getContextManager(
|
|
6301
|
+
const browser = getBrowserObject31(this);
|
|
6302
|
+
const shadowRootManager2 = getShadowRootManager(browser);
|
|
6303
|
+
const contextManager2 = getContextManager(browser);
|
|
6292
6304
|
const context = await contextManager2.getCurrentContext();
|
|
6293
6305
|
const shadowRoots = shadowRootManager2.getShadowElementsByContextId(
|
|
6294
6306
|
context,
|
|
@@ -6297,7 +6309,7 @@ async function findDeepElement(selector) {
|
|
|
6297
6309
|
const { using, value } = findStrategy(selector, this.isW3C, this.isMobile);
|
|
6298
6310
|
const locator = transformClassicToBidiSelector(using, value);
|
|
6299
6311
|
const startNodes = shadowRoots.length > 0 ? shadowRoots.map((shadowRootNodeId) => ({ sharedId: shadowRootNodeId })) : this.elementId ? [{ sharedId: this.elementId }] : void 0;
|
|
6300
|
-
const deepElementResult = await
|
|
6312
|
+
const deepElementResult = await browser.browsingContextLocateNodes({ locator, context, startNodes }).then(async (result) => {
|
|
6301
6313
|
const nodes = result.nodes.filter((node) => Boolean(node.sharedId)).map((node) => ({
|
|
6302
6314
|
[ELEMENT_KEY17]: node.sharedId,
|
|
6303
6315
|
locator
|
|
@@ -6306,7 +6318,7 @@ async function findDeepElement(selector) {
|
|
|
6306
6318
|
return nodes[0];
|
|
6307
6319
|
}
|
|
6308
6320
|
const scopedNodes = await Promise.all(nodes.map(async (node) => {
|
|
6309
|
-
const isIn = await
|
|
6321
|
+
const isIn = await browser.execute(
|
|
6310
6322
|
elementContains,
|
|
6311
6323
|
{ [ELEMENT_KEY17]: this.elementId },
|
|
6312
6324
|
node
|
|
@@ -6316,7 +6328,7 @@ async function findDeepElement(selector) {
|
|
|
6316
6328
|
return scopedNodes[0];
|
|
6317
6329
|
}, (err) => {
|
|
6318
6330
|
log18.warn(`Failed to execute browser.browsingContextLocateNodes({ ... }) due to ${err}, falling back to regular WebDriver Classic command`);
|
|
6319
|
-
return
|
|
6331
|
+
return browser.findElement(using, value);
|
|
6320
6332
|
});
|
|
6321
6333
|
if (!deepElementResult) {
|
|
6322
6334
|
return new Error(`Couldn't find element with selector "${selector}"`);
|
|
@@ -6324,9 +6336,9 @@ async function findDeepElement(selector) {
|
|
|
6324
6336
|
return deepElementResult;
|
|
6325
6337
|
}
|
|
6326
6338
|
async function findDeepElements(selector) {
|
|
6327
|
-
const
|
|
6328
|
-
const shadowRootManager2 = getShadowRootManager(
|
|
6329
|
-
const contextManager2 = getContextManager(
|
|
6339
|
+
const browser = getBrowserObject31(this);
|
|
6340
|
+
const shadowRootManager2 = getShadowRootManager(browser);
|
|
6341
|
+
const contextManager2 = getContextManager(browser);
|
|
6330
6342
|
const context = await contextManager2.getCurrentContext();
|
|
6331
6343
|
const shadowRoots = shadowRootManager2.getShadowElementsByContextId(
|
|
6332
6344
|
context,
|
|
@@ -6335,7 +6347,7 @@ async function findDeepElements(selector) {
|
|
|
6335
6347
|
const { using, value } = findStrategy(selector, this.isW3C, this.isMobile);
|
|
6336
6348
|
const locator = transformClassicToBidiSelector(using, value);
|
|
6337
6349
|
const startNodes = shadowRoots.length > 0 ? shadowRoots.map((shadowRootNodeId) => ({ sharedId: shadowRootNodeId })) : this.elementId ? [{ sharedId: this.elementId }] : void 0;
|
|
6338
|
-
const deepElementResult = await
|
|
6350
|
+
const deepElementResult = await browser.browsingContextLocateNodes({ locator, context, startNodes }).then(async (result) => {
|
|
6339
6351
|
const nodes = result.nodes.filter((node) => Boolean(node.sharedId)).map((node) => ({
|
|
6340
6352
|
[ELEMENT_KEY17]: node.sharedId,
|
|
6341
6353
|
locator
|
|
@@ -6344,7 +6356,7 @@ async function findDeepElements(selector) {
|
|
|
6344
6356
|
return nodes;
|
|
6345
6357
|
}
|
|
6346
6358
|
const scopedNodes = await Promise.all(nodes.map(async (node) => {
|
|
6347
|
-
const isIn = await
|
|
6359
|
+
const isIn = await browser.execute(
|
|
6348
6360
|
elementContains,
|
|
6349
6361
|
{ [ELEMENT_KEY17]: this.elementId },
|
|
6350
6362
|
node
|
|
@@ -6354,12 +6366,12 @@ async function findDeepElements(selector) {
|
|
|
6354
6366
|
return scopedNodes;
|
|
6355
6367
|
}, (err) => {
|
|
6356
6368
|
log18.warn(`Failed to execute browser.browsingContextLocateNodes({ ... }) due to ${err}, falling back to regular WebDriver Classic command`);
|
|
6357
|
-
return
|
|
6369
|
+
return browser.findElements(using, value);
|
|
6358
6370
|
});
|
|
6359
6371
|
return deepElementResult;
|
|
6360
6372
|
}
|
|
6361
6373
|
async function findElement2(selector) {
|
|
6362
|
-
const browserObject =
|
|
6374
|
+
const browserObject = getBrowserObject31(this);
|
|
6363
6375
|
const shadowRootManager2 = getShadowRootManager(browserObject);
|
|
6364
6376
|
if (this.isBidi && typeof selector === "string" && !selector.startsWith(DEEP_SELECTOR) && !shadowRootManager2.isWithinFrame()) {
|
|
6365
6377
|
return findDeepElement.call(this, selector);
|
|
@@ -6413,7 +6425,7 @@ async function findElement2(selector) {
|
|
|
6413
6425
|
throw new Error(`${INVALID_SELECTOR_ERROR}, but found: \`${typeof selector}\``);
|
|
6414
6426
|
}
|
|
6415
6427
|
async function findElements(selector) {
|
|
6416
|
-
const browserObject =
|
|
6428
|
+
const browserObject = getBrowserObject31(this);
|
|
6417
6429
|
if (typeof selector === "string" && selector.startsWith(DEEP_SELECTOR)) {
|
|
6418
6430
|
const elems = await browserObject.execute(
|
|
6419
6431
|
`return (${querySelectorAllDeep}).apply(null, arguments)`,
|
|
@@ -6462,7 +6474,7 @@ async function getElementRect(scope) {
|
|
|
6462
6474
|
const rect = await scope.getElementRect(scope.elementId);
|
|
6463
6475
|
const defaults = { x: 0, y: 0, width: 0, height: 0 };
|
|
6464
6476
|
if (Object.keys(defaults).some((key) => rect[key] === void 0)) {
|
|
6465
|
-
const rectJs = await
|
|
6477
|
+
const rectJs = await getBrowserObject31(scope).execute(function(el) {
|
|
6466
6478
|
if (!el || !el.getBoundingClientRect) {
|
|
6467
6479
|
return;
|
|
6468
6480
|
}
|
|
@@ -6559,7 +6571,7 @@ var elementErrorHandler = (fn) => (commandName, commandFn) => {
|
|
|
6559
6571
|
this[ELEMENT_KEY18] = element.elementId;
|
|
6560
6572
|
try {
|
|
6561
6573
|
const result = await fn(commandName, commandFn).apply(this, args);
|
|
6562
|
-
const caps =
|
|
6574
|
+
const caps = getBrowserObject32(this).capabilities;
|
|
6563
6575
|
if (caps?.browserName === "safari" && result?.error === "no such element") {
|
|
6564
6576
|
const errorName = "stale element reference";
|
|
6565
6577
|
const err = new Error(errorName);
|
|
@@ -6855,7 +6867,7 @@ import { capabilitiesEnvironmentDetector } from "@wdio/utils";
|
|
|
6855
6867
|
var ProtocolStub = class {
|
|
6856
6868
|
static async newSession(options) {
|
|
6857
6869
|
const capabilities = emulateSessionCapabilities(options.capabilities);
|
|
6858
|
-
const
|
|
6870
|
+
const browser = {
|
|
6859
6871
|
options,
|
|
6860
6872
|
capabilities,
|
|
6861
6873
|
requestedCapabilities: capabilities,
|
|
@@ -6866,9 +6878,9 @@ var ProtocolStub = class {
|
|
|
6866
6878
|
commandList: [],
|
|
6867
6879
|
...capabilitiesEnvironmentDetector(capabilities)
|
|
6868
6880
|
};
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
return
|
|
6881
|
+
browser.addCommand = (...args) => browser.customCommands.push(args);
|
|
6882
|
+
browser.overwriteCommand = (...args) => browser.overwrittenCommands.push(args);
|
|
6883
|
+
return browser;
|
|
6872
6884
|
}
|
|
6873
6885
|
/**
|
|
6874
6886
|
* added just in case user wants to somehow reload webdriver before it was started.
|
|
@@ -6916,22 +6928,22 @@ async function getProtocolDriver(options) {
|
|
|
6916
6928
|
|
|
6917
6929
|
// src/dialog.ts
|
|
6918
6930
|
var dialogManager = /* @__PURE__ */ new Map();
|
|
6919
|
-
function getDialogManager(
|
|
6920
|
-
const existingDialogManager = dialogManager.get(
|
|
6931
|
+
function getDialogManager(browser) {
|
|
6932
|
+
const existingDialogManager = dialogManager.get(browser);
|
|
6921
6933
|
if (existingDialogManager) {
|
|
6922
6934
|
return existingDialogManager;
|
|
6923
6935
|
}
|
|
6924
|
-
const newContext = new DialogManager(
|
|
6925
|
-
dialogManager.set(
|
|
6936
|
+
const newContext = new DialogManager(browser);
|
|
6937
|
+
dialogManager.set(browser, newContext);
|
|
6926
6938
|
return newContext;
|
|
6927
6939
|
}
|
|
6928
6940
|
var DialogManager = class {
|
|
6929
6941
|
#browser;
|
|
6930
6942
|
#initialize;
|
|
6931
6943
|
#autoHandleDialog = true;
|
|
6932
|
-
constructor(
|
|
6933
|
-
this.#browser =
|
|
6934
|
-
if (!
|
|
6944
|
+
constructor(browser) {
|
|
6945
|
+
this.#browser = browser;
|
|
6946
|
+
if (!browser.isBidi || process.env.VITEST_WORKER_ID || browser.options?.automationProtocol !== "webdriver") {
|
|
6935
6947
|
this.#initialize = Promise.resolve(true);
|
|
6936
6948
|
return;
|
|
6937
6949
|
}
|
|
@@ -6973,12 +6985,12 @@ var Dialog = class {
|
|
|
6973
6985
|
#message;
|
|
6974
6986
|
#defaultValue;
|
|
6975
6987
|
#type;
|
|
6976
|
-
constructor(event,
|
|
6988
|
+
constructor(event, browser) {
|
|
6977
6989
|
this.#message = event.message;
|
|
6978
6990
|
this.#defaultValue = event.defaultValue;
|
|
6979
6991
|
this.#type = event.type;
|
|
6980
6992
|
this.#context = event.context;
|
|
6981
|
-
this.#browser =
|
|
6993
|
+
this.#browser = browser;
|
|
6982
6994
|
}
|
|
6983
6995
|
message() {
|
|
6984
6996
|
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.0.
|
|
4
|
+
"version": "9.0.7",
|
|
5
5
|
"homepage": "https://webdriver.io",
|
|
6
6
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"rgb2hex": "0.2.5",
|
|
101
101
|
"serialize-error": "^11.0.3",
|
|
102
102
|
"urlpattern-polyfill": "^10.0.0",
|
|
103
|
-
"webdriver": "9.0.
|
|
103
|
+
"webdriver": "9.0.7"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
106
|
"puppeteer-core": "^22.3.0"
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"optional": true
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "ce6d35e1277f13345ecf36f23e9fed27d7d6699b"
|
|
114
114
|
}
|