webdriverio 9.0.5 → 9.0.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/commands/browser/execute.d.ts.map +1 -1
- package/build/commands/browser/executeAsync.d.ts.map +1 -1
- package/build/commands/browser/mock.d.ts.map +1 -1
- package/build/commands/browser/saveScreenshot.d.ts.map +1 -1
- package/build/commands/browser/setViewport.d.ts.map +1 -1
- package/build/commands/browser/url.d.ts.map +1 -1
- package/build/commands/element/execute.d.ts.map +1 -1
- package/build/commands/element/executeAsync.d.ts.map +1 -1
- package/build/commands/element/getHTML.d.ts.map +1 -1
- package/build/context.d.ts +13 -0
- package/build/context.d.ts.map +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +296 -227
- package/build/scripts/customElement.d.ts.map +1 -1
- package/build/scripts/customElement.js +14 -14
- package/build/utils/index.d.ts.map +1 -1
- package/package.json +5 -5
package/build/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
|
8
|
-
import
|
|
8
|
+
import logger19 from "@wdio/logger";
|
|
9
9
|
import WebDriver, { DEFAULTS } from "webdriver";
|
|
10
10
|
import { validateConfig } from "@wdio/config";
|
|
11
11
|
import { enableFileLogging, wrapCommand as wrapCommand3 } from "@wdio/utils";
|
|
@@ -78,7 +78,7 @@ import { URL as URL2 } from "node:url";
|
|
|
78
78
|
import cssValue from "css-value";
|
|
79
79
|
import rgb2hex from "rgb2hex";
|
|
80
80
|
import GraphemeSplitter from "grapheme-splitter";
|
|
81
|
-
import
|
|
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
84
|
import { UNICODE_CHARACTERS as UNICODE_CHARACTERS2, asyncIterators, getBrowserObject as getBrowserObject26 } from "@wdio/utils";
|
|
@@ -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 browser2 = 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(browser2.__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
|
+
browser2.__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 browser2 = 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(browser2.__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
|
+
browser2.__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(browser2) {
|
|
955
|
+
this.#browser = browser2;
|
|
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(browser2, scope, fn) {
|
|
2404
|
+
if (!restoreFunctions.has(browser2)) {
|
|
2405
|
+
restoreFunctions.set(browser2, /* @__PURE__ */ new Map());
|
|
2406
2406
|
}
|
|
2407
|
-
const restoreFunctionsList = restoreFunctions.get(
|
|
2407
|
+
const restoreFunctionsList = restoreFunctions.get(browser2)?.get(scope);
|
|
2408
2408
|
const updatedList = restoreFunctionsList ? [...restoreFunctionsList, fn] : [fn];
|
|
2409
|
-
restoreFunctions.get(
|
|
2409
|
+
restoreFunctions.get(browser2)?.set(scope, updatedList);
|
|
2410
2410
|
}
|
|
2411
2411
|
async function emulate(scope, options) {
|
|
2412
2412
|
if (!this.isBidi) {
|
|
@@ -2792,13 +2792,70 @@ var ReferenceValue = class {
|
|
|
2792
2792
|
}
|
|
2793
2793
|
};
|
|
2794
2794
|
|
|
2795
|
+
// src/context.ts
|
|
2796
|
+
import logger4 from "@wdio/logger";
|
|
2797
|
+
var contextManager = /* @__PURE__ */ new Map();
|
|
2798
|
+
var log4 = logger4("webdriverio:ContextManager");
|
|
2799
|
+
function getContextManager(browser2) {
|
|
2800
|
+
const existingContextManager = contextManager.get(browser2);
|
|
2801
|
+
if (existingContextManager) {
|
|
2802
|
+
return existingContextManager;
|
|
2803
|
+
}
|
|
2804
|
+
const newContext = new ContextManager(browser2);
|
|
2805
|
+
contextManager.set(browser2, newContext);
|
|
2806
|
+
return newContext;
|
|
2807
|
+
}
|
|
2808
|
+
var ContextManager = class {
|
|
2809
|
+
#browser;
|
|
2810
|
+
#initialize;
|
|
2811
|
+
#currentContext;
|
|
2812
|
+
constructor(browser2) {
|
|
2813
|
+
this.#browser = browser2;
|
|
2814
|
+
if (!browser2.isBidi || process.env.VITEST_WORKER_ID || browser2.options?.automationProtocol !== "webdriver") {
|
|
2815
|
+
this.#initialize = Promise.resolve(true);
|
|
2816
|
+
return;
|
|
2817
|
+
}
|
|
2818
|
+
this.#initialize = this.#browser.sessionSubscribe({
|
|
2819
|
+
events: ["browsingContext.navigationStarted"]
|
|
2820
|
+
}).then(() => true, () => false);
|
|
2821
|
+
this.#browser.on("browsingContext.navigationStarted", this.#handleNavigationStarted.bind(this));
|
|
2822
|
+
}
|
|
2823
|
+
async initialize() {
|
|
2824
|
+
return this.#initialize;
|
|
2825
|
+
}
|
|
2826
|
+
/**
|
|
2827
|
+
* We use this handler to observe the current context which is used to navigate to a certain url.
|
|
2828
|
+
* This is most likely the context that the user is using. However if a frame was loaded on the page
|
|
2829
|
+
* then this handler is triggered with the context of the frame. To find out which context we are in
|
|
2830
|
+
* we use the `getWindowHandle` method to validate our assumption before setting the `#currentContext`
|
|
2831
|
+
* value.
|
|
2832
|
+
*
|
|
2833
|
+
* @param {local.BrowsingContextNavigationInfo} context browsing context used to navigate
|
|
2834
|
+
*/
|
|
2835
|
+
#handleNavigationStarted(context) {
|
|
2836
|
+
this.#browser.getWindowHandle().then((windowHandle) => {
|
|
2837
|
+
if (context.context === windowHandle) {
|
|
2838
|
+
log4.info(`Update current context: ${context.context}`);
|
|
2839
|
+
this.#currentContext = context.context;
|
|
2840
|
+
}
|
|
2841
|
+
});
|
|
2842
|
+
}
|
|
2843
|
+
async getCurrentContext() {
|
|
2844
|
+
if (!this.#currentContext) {
|
|
2845
|
+
this.#currentContext = await this.#browser.getWindowHandle();
|
|
2846
|
+
}
|
|
2847
|
+
return this.#currentContext;
|
|
2848
|
+
}
|
|
2849
|
+
};
|
|
2850
|
+
|
|
2795
2851
|
// src/commands/browser/execute.ts
|
|
2796
2852
|
async function execute(script, ...args) {
|
|
2797
2853
|
if (typeof script !== "string" && typeof script !== "function") {
|
|
2798
2854
|
throw new Error("number or type of arguments don't agree with execute protocol command");
|
|
2799
2855
|
}
|
|
2800
2856
|
if (this.isBidi) {
|
|
2801
|
-
const
|
|
2857
|
+
const contextManager2 = getContextManager(browser);
|
|
2858
|
+
const context = await contextManager2.getCurrentContext();
|
|
2802
2859
|
const result = await this.scriptCallFunction({
|
|
2803
2860
|
functionDeclaration: script.toString(),
|
|
2804
2861
|
awaitPromise: false,
|
|
@@ -2821,7 +2878,8 @@ async function executeAsync(script, ...args) {
|
|
|
2821
2878
|
throw new Error("number or type of arguments don't agree with execute protocol command");
|
|
2822
2879
|
}
|
|
2823
2880
|
if (this.isBidi) {
|
|
2824
|
-
const
|
|
2881
|
+
const contextManager2 = getContextManager(browser);
|
|
2882
|
+
const context = await contextManager2.getCurrentContext();
|
|
2825
2883
|
const functionDeclaration = `function (...args) {
|
|
2826
2884
|
return new Promise(async (resolve, reject) => {
|
|
2827
2885
|
try {
|
|
@@ -2861,9 +2919,9 @@ async function getCookies(names) {
|
|
|
2861
2919
|
}
|
|
2862
2920
|
|
|
2863
2921
|
// src/commands/browser/getPuppeteer.ts
|
|
2864
|
-
import
|
|
2922
|
+
import logger5 from "@wdio/logger";
|
|
2865
2923
|
import { userImport } from "@wdio/utils";
|
|
2866
|
-
var
|
|
2924
|
+
var log5 = logger5("webdriverio");
|
|
2867
2925
|
async function getPuppeteer() {
|
|
2868
2926
|
const puppeteer = await userImport("puppeteer-core");
|
|
2869
2927
|
if (!puppeteer) {
|
|
@@ -2872,7 +2930,7 @@ async function getPuppeteer() {
|
|
|
2872
2930
|
);
|
|
2873
2931
|
}
|
|
2874
2932
|
if (this.puppeteer?.connected) {
|
|
2875
|
-
|
|
2933
|
+
log5.debug("Reusing existing puppeteer session");
|
|
2876
2934
|
return this.puppeteer;
|
|
2877
2935
|
}
|
|
2878
2936
|
const { headers } = this.options;
|
|
@@ -2942,8 +3000,8 @@ async function getPuppeteer() {
|
|
|
2942
3000
|
// src/commands/browser/getWindowSize.ts
|
|
2943
3001
|
import { getBrowserObject as getBrowserObject2 } from "@wdio/utils";
|
|
2944
3002
|
async function getWindowSize() {
|
|
2945
|
-
const
|
|
2946
|
-
const { width, height } = await
|
|
3003
|
+
const browser2 = getBrowserObject2(this);
|
|
3004
|
+
const { width, height } = await browser2.getWindowRect();
|
|
2947
3005
|
return { width, height };
|
|
2948
3006
|
}
|
|
2949
3007
|
|
|
@@ -2974,7 +3032,7 @@ import { getBrowserObject as getBrowserObject3 } from "@wdio/utils";
|
|
|
2974
3032
|
|
|
2975
3033
|
// src/utils/interception/index.ts
|
|
2976
3034
|
import EventEmitter2 from "node:events";
|
|
2977
|
-
import
|
|
3035
|
+
import logger6 from "@wdio/logger";
|
|
2978
3036
|
import { URLPattern } from "urlpattern-polyfill";
|
|
2979
3037
|
|
|
2980
3038
|
// src/utils/Timer.ts
|
|
@@ -3140,7 +3198,7 @@ function getPatternParam(pattern, key) {
|
|
|
3140
3198
|
}
|
|
3141
3199
|
|
|
3142
3200
|
// src/utils/interception/index.ts
|
|
3143
|
-
var
|
|
3201
|
+
var log6 = logger6("WebDriverInterception");
|
|
3144
3202
|
var hasSubscribedToEvents = false;
|
|
3145
3203
|
var WebDriverInterception = class _WebDriverInterception {
|
|
3146
3204
|
#pattern;
|
|
@@ -3152,27 +3210,27 @@ var WebDriverInterception = class _WebDriverInterception {
|
|
|
3152
3210
|
#requestOverwrites = [];
|
|
3153
3211
|
#respondOverwrites = [];
|
|
3154
3212
|
#calls = [];
|
|
3155
|
-
constructor(pattern, mockId, filterOptions,
|
|
3213
|
+
constructor(pattern, mockId, filterOptions, browser2) {
|
|
3156
3214
|
this.#pattern = pattern;
|
|
3157
3215
|
this.#mockId = mockId;
|
|
3158
3216
|
this.#filterOptions = filterOptions;
|
|
3159
|
-
this.#browser =
|
|
3160
|
-
|
|
3161
|
-
|
|
3217
|
+
this.#browser = browser2;
|
|
3218
|
+
browser2.on("network.beforeRequestSent", this.#handleBeforeRequestSent.bind(this));
|
|
3219
|
+
browser2.on("network.responseStarted", this.#handleResponseStarted.bind(this));
|
|
3162
3220
|
}
|
|
3163
|
-
static async initiate(url6, filterOptions,
|
|
3221
|
+
static async initiate(url6, filterOptions, browser2) {
|
|
3164
3222
|
const pattern = parseUrlPattern(url6);
|
|
3165
3223
|
if (!hasSubscribedToEvents) {
|
|
3166
|
-
await
|
|
3224
|
+
await browser2.sessionSubscribe({
|
|
3167
3225
|
events: [
|
|
3168
3226
|
"network.beforeRequestSent",
|
|
3169
3227
|
"network.responseStarted"
|
|
3170
3228
|
]
|
|
3171
3229
|
});
|
|
3172
|
-
|
|
3230
|
+
log6.info("subscribed to network events");
|
|
3173
3231
|
hasSubscribedToEvents = true;
|
|
3174
3232
|
}
|
|
3175
|
-
const interception = await
|
|
3233
|
+
const interception = await browser2.networkAddIntercept({
|
|
3176
3234
|
phases: ["beforeRequestSent", "responseStarted"],
|
|
3177
3235
|
urlPatterns: [{
|
|
3178
3236
|
type: "pattern",
|
|
@@ -3183,7 +3241,7 @@ var WebDriverInterception = class _WebDriverInterception {
|
|
|
3183
3241
|
search: getPatternParam(pattern, "search")
|
|
3184
3242
|
}]
|
|
3185
3243
|
});
|
|
3186
|
-
return new _WebDriverInterception(pattern, interception.intercept, filterOptions,
|
|
3244
|
+
return new _WebDriverInterception(pattern, interception.intercept, filterOptions, browser2);
|
|
3187
3245
|
}
|
|
3188
3246
|
#handleBeforeRequestSent(request) {
|
|
3189
3247
|
if (!this.#isRequestMatching(request)) {
|
|
@@ -3331,7 +3389,7 @@ var WebDriverInterception = class _WebDriverInterception {
|
|
|
3331
3389
|
this.#respondOverwrites = [];
|
|
3332
3390
|
this.#restored = true;
|
|
3333
3391
|
const handle = await this.#browser.getWindowHandle();
|
|
3334
|
-
|
|
3392
|
+
log6.trace(`Restoring mock for ${handle}`);
|
|
3335
3393
|
SESSION_MOCKS[handle].delete(this);
|
|
3336
3394
|
if (this.#mockId) {
|
|
3337
3395
|
await this.#browser.networkRemoveIntercept({ intercept: this.#mockId });
|
|
@@ -3459,22 +3517,23 @@ async function mock(url6, filterOptions) {
|
|
|
3459
3517
|
if (!this.isBidi) {
|
|
3460
3518
|
throw new Error("Mocking is only supported when running tests using WebDriver Bidi");
|
|
3461
3519
|
}
|
|
3462
|
-
const
|
|
3463
|
-
const
|
|
3464
|
-
|
|
3465
|
-
|
|
3520
|
+
const browser2 = getBrowserObject3(this);
|
|
3521
|
+
const contextManager2 = getContextManager(browser2);
|
|
3522
|
+
const context = await contextManager2.getCurrentContext();
|
|
3523
|
+
if (!SESSION_MOCKS[context]) {
|
|
3524
|
+
SESSION_MOCKS[context] = /* @__PURE__ */ new Set();
|
|
3466
3525
|
}
|
|
3467
3526
|
const networkInterception = await WebDriverInterception.initiate(url6, filterOptions || {}, this);
|
|
3468
|
-
SESSION_MOCKS[
|
|
3527
|
+
SESSION_MOCKS[context].add(networkInterception);
|
|
3469
3528
|
return networkInterception;
|
|
3470
3529
|
}
|
|
3471
3530
|
|
|
3472
3531
|
// src/commands/browser/mockClearAll.ts
|
|
3473
|
-
import
|
|
3474
|
-
var
|
|
3532
|
+
import logger7 from "@wdio/logger";
|
|
3533
|
+
var log7 = logger7("webdriverio:mockClearAll");
|
|
3475
3534
|
async function mockClearAll() {
|
|
3476
3535
|
for (const [handle, mocks] of Object.entries(SESSION_MOCKS)) {
|
|
3477
|
-
|
|
3536
|
+
log7.trace(`Clearing mocks for ${handle}`);
|
|
3478
3537
|
for (const mock2 of mocks) {
|
|
3479
3538
|
mock2.clear();
|
|
3480
3539
|
}
|
|
@@ -3482,11 +3541,11 @@ async function mockClearAll() {
|
|
|
3482
3541
|
}
|
|
3483
3542
|
|
|
3484
3543
|
// src/commands/browser/mockRestoreAll.ts
|
|
3485
|
-
import
|
|
3486
|
-
var
|
|
3544
|
+
import logger8 from "@wdio/logger";
|
|
3545
|
+
var log8 = logger8("webdriverio:mockRestoreAll");
|
|
3487
3546
|
async function mockRestoreAll() {
|
|
3488
3547
|
for (const [handle, mocks] of Object.entries(SESSION_MOCKS)) {
|
|
3489
|
-
|
|
3548
|
+
log8.trace(`Clearing mocks for ${handle}`);
|
|
3490
3549
|
for (const mock2 of mocks) {
|
|
3491
3550
|
await mock2.restore();
|
|
3492
3551
|
}
|
|
@@ -3579,19 +3638,19 @@ async function react$(selector, { props = {}, state = {} } = {}) {
|
|
|
3579
3638
|
}
|
|
3580
3639
|
|
|
3581
3640
|
// src/commands/browser/reloadSession.ts
|
|
3582
|
-
import
|
|
3583
|
-
var
|
|
3641
|
+
import logger9 from "@wdio/logger";
|
|
3642
|
+
var log9 = logger9("webdriverio");
|
|
3584
3643
|
async function reloadSession(newCapabilities) {
|
|
3585
3644
|
const oldSessionId = this.sessionId;
|
|
3586
3645
|
const shutdownDriver = Boolean(newCapabilities?.browserName);
|
|
3587
3646
|
try {
|
|
3588
3647
|
await this.deleteSession({ shutdownDriver });
|
|
3589
3648
|
} catch (err) {
|
|
3590
|
-
|
|
3649
|
+
log9.warn(`Suppressing error closing the session: ${err.stack}`);
|
|
3591
3650
|
}
|
|
3592
3651
|
if (this.puppeteer?.connected) {
|
|
3593
3652
|
this.puppeteer.disconnect();
|
|
3594
|
-
|
|
3653
|
+
log9.debug("Disconnected puppeteer session");
|
|
3595
3654
|
}
|
|
3596
3655
|
const ProtocolDriver = (await import(
|
|
3597
3656
|
/* @vite-ignore */
|
|
@@ -3670,7 +3729,8 @@ async function saveScreenshot(filepath) {
|
|
|
3670
3729
|
await assertDirectoryExists(absoluteFilepath);
|
|
3671
3730
|
let screenBuffer;
|
|
3672
3731
|
if (this.isBidi) {
|
|
3673
|
-
const
|
|
3732
|
+
const contextManager2 = getContextManager(browser);
|
|
3733
|
+
const context = await contextManager2.getCurrentContext();
|
|
3674
3734
|
const { data } = await this.browsingContextCaptureScreenshot({ context });
|
|
3675
3735
|
screenBuffer = data;
|
|
3676
3736
|
} else {
|
|
@@ -3682,11 +3742,11 @@ async function saveScreenshot(filepath) {
|
|
|
3682
3742
|
}
|
|
3683
3743
|
|
|
3684
3744
|
// src/commands/browser/scroll.ts
|
|
3685
|
-
import
|
|
3686
|
-
var
|
|
3745
|
+
import logger10 from "@wdio/logger";
|
|
3746
|
+
var log10 = logger10("webdriverio");
|
|
3687
3747
|
function scroll(x = 0, y = 0) {
|
|
3688
3748
|
if (!x && !y) {
|
|
3689
|
-
return
|
|
3749
|
+
return log10.warn('"scroll" command was called with no parameters, skipping execution');
|
|
3690
3750
|
}
|
|
3691
3751
|
if (this.isMobile) {
|
|
3692
3752
|
return this.execute((x2, y2) => window.scrollBy(x2, y2), x, y);
|
|
@@ -3740,9 +3800,10 @@ async function setViewport(options) {
|
|
|
3740
3800
|
if (options.devicePixelRatio && (typeof options.devicePixelRatio !== "number" || options.devicePixelRatio < 0)) {
|
|
3741
3801
|
throw new Error("setViewport expects devicePixelRatio to be a number in the 0 to 2^31 \u2212 1 range");
|
|
3742
3802
|
}
|
|
3743
|
-
const
|
|
3744
|
-
const
|
|
3745
|
-
await
|
|
3803
|
+
const browser2 = getBrowserObject4(this);
|
|
3804
|
+
const contextManager2 = getContextManager(browser2);
|
|
3805
|
+
const context = await contextManager2.getCurrentContext();
|
|
3806
|
+
await browser2.browsingContextSetViewport({
|
|
3746
3807
|
context,
|
|
3747
3808
|
devicePixelRatio: options.devicePixelRatio || 1,
|
|
3748
3809
|
viewport: {
|
|
@@ -3763,8 +3824,8 @@ async function setWindowSize(width, height) {
|
|
|
3763
3824
|
if (width < minWindowSize2 || width > maxWindowSize2 || height < minWindowSize2 || height > maxWindowSize2) {
|
|
3764
3825
|
throw new Error("setWindowSize expects width and height to be a number in the 0 to 2^31 \u2212 1 range");
|
|
3765
3826
|
}
|
|
3766
|
-
const
|
|
3767
|
-
await
|
|
3827
|
+
const browser2 = getBrowserObject5(this);
|
|
3828
|
+
await browser2.setWindowRect(null, null, width, height);
|
|
3768
3829
|
}
|
|
3769
3830
|
|
|
3770
3831
|
// src/commands/browser/switchWindow.ts
|
|
@@ -3801,13 +3862,13 @@ async function switchWindow(matcher) {
|
|
|
3801
3862
|
}
|
|
3802
3863
|
|
|
3803
3864
|
// src/commands/browser/throttle.ts
|
|
3804
|
-
import
|
|
3865
|
+
import logger11 from "@wdio/logger";
|
|
3805
3866
|
import { getBrowserObject as getBrowserObject6 } from "@wdio/utils";
|
|
3806
|
-
var
|
|
3867
|
+
var log11 = logger11("webdriverio:throttle");
|
|
3807
3868
|
async function throttle(params) {
|
|
3808
|
-
|
|
3809
|
-
const
|
|
3810
|
-
await
|
|
3869
|
+
log11.warn('Command "throttle" is deprecated and will be removed with the next major version release! Use `throttleNetwork` instead.');
|
|
3870
|
+
const browser2 = getBrowserObject6(this);
|
|
3871
|
+
await browser2.throttleNetwork(params);
|
|
3811
3872
|
}
|
|
3812
3873
|
|
|
3813
3874
|
// src/commands/browser/throttleCPU.ts
|
|
@@ -3906,8 +3967,8 @@ async function throttleNetwork(params) {
|
|
|
3906
3967
|
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}"`);
|
|
3907
3968
|
}
|
|
3908
3969
|
if (this.isSauce) {
|
|
3909
|
-
const
|
|
3910
|
-
await
|
|
3970
|
+
const browser2 = getBrowserObject7(this);
|
|
3971
|
+
await browser2.sauceThrottleNetwork(params);
|
|
3911
3972
|
return null;
|
|
3912
3973
|
}
|
|
3913
3974
|
const failedConnectionMessage = "No Puppeteer connection could be established which is required to use this command";
|
|
@@ -4023,22 +4084,22 @@ async function uploadFile(localPath) {
|
|
|
4023
4084
|
|
|
4024
4085
|
// src/networkManager.ts
|
|
4025
4086
|
var networkManager = /* @__PURE__ */ new Map();
|
|
4026
|
-
function getNetworkManager(
|
|
4027
|
-
const existingNetworkManager = networkManager.get(
|
|
4087
|
+
function getNetworkManager(browser2) {
|
|
4088
|
+
const existingNetworkManager = networkManager.get(browser2);
|
|
4028
4089
|
if (existingNetworkManager) {
|
|
4029
4090
|
return existingNetworkManager;
|
|
4030
4091
|
}
|
|
4031
|
-
const newContext = new NetworkManager(
|
|
4032
|
-
networkManager.set(
|
|
4092
|
+
const newContext = new NetworkManager(browser2);
|
|
4093
|
+
networkManager.set(browser2, newContext);
|
|
4033
4094
|
return newContext;
|
|
4034
4095
|
}
|
|
4035
4096
|
var NetworkManager = class {
|
|
4036
4097
|
#browser;
|
|
4037
4098
|
#initialize;
|
|
4038
4099
|
#requests = /* @__PURE__ */ new Map();
|
|
4039
|
-
constructor(
|
|
4040
|
-
this.#browser =
|
|
4041
|
-
if (!
|
|
4100
|
+
constructor(browser2) {
|
|
4101
|
+
this.#browser = browser2;
|
|
4102
|
+
if (!browser2.isBidi || process.env.VITEST_WORKER_ID || browser2.options?.automationProtocol !== "webdriver") {
|
|
4042
4103
|
this.#initialize = Promise.resolve(true);
|
|
4043
4104
|
return;
|
|
4044
4105
|
}
|
|
@@ -4058,15 +4119,15 @@ var NetworkManager = class {
|
|
|
4058
4119
|
async initialize() {
|
|
4059
4120
|
return this.#initialize;
|
|
4060
4121
|
}
|
|
4061
|
-
#beforeRequestSent(
|
|
4062
|
-
if (
|
|
4122
|
+
#beforeRequestSent(log19) {
|
|
4123
|
+
if (log19.navigation) {
|
|
4063
4124
|
return;
|
|
4064
4125
|
}
|
|
4065
|
-
const request =
|
|
4126
|
+
const request = log19.context ? this.#requests.get(log19.context) : void 0;
|
|
4066
4127
|
if (!request) {
|
|
4067
4128
|
return;
|
|
4068
4129
|
}
|
|
4069
|
-
const { request: id, headers, cookies, url: url6 } =
|
|
4130
|
+
const { request: id, headers, cookies, url: url6 } = log19.request;
|
|
4070
4131
|
request.children?.push({
|
|
4071
4132
|
id,
|
|
4072
4133
|
url: url6,
|
|
@@ -4082,66 +4143,66 @@ var NetworkManager = class {
|
|
|
4082
4143
|
sameSite: cookie.sameSite,
|
|
4083
4144
|
expiry: cookie.expiry
|
|
4084
4145
|
})),
|
|
4085
|
-
timestamp:
|
|
4146
|
+
timestamp: log19.timestamp
|
|
4086
4147
|
});
|
|
4087
4148
|
}
|
|
4088
|
-
#navigationStarted(
|
|
4149
|
+
#navigationStarted(log19) {
|
|
4089
4150
|
if (
|
|
4090
4151
|
/**
|
|
4091
4152
|
* we need a navigation id to identify the request
|
|
4092
4153
|
*/
|
|
4093
|
-
!
|
|
4154
|
+
!log19.navigation || /**
|
|
4094
4155
|
* ignore urls that do not start with http
|
|
4095
4156
|
*/
|
|
4096
|
-
!
|
|
4157
|
+
!log19.url.startsWith("http")
|
|
4097
4158
|
) {
|
|
4098
|
-
if (
|
|
4099
|
-
return this.#requests.set(
|
|
4159
|
+
if (log19.navigation === null && log19.url === "") {
|
|
4160
|
+
return this.#requests.set(log19.context, {
|
|
4100
4161
|
url: "",
|
|
4101
4162
|
headers: {},
|
|
4102
|
-
timestamp:
|
|
4163
|
+
timestamp: log19.timestamp,
|
|
4103
4164
|
redirectChain: [],
|
|
4104
4165
|
children: []
|
|
4105
4166
|
});
|
|
4106
4167
|
}
|
|
4107
4168
|
return;
|
|
4108
4169
|
}
|
|
4109
|
-
this.#requests.set(
|
|
4110
|
-
url:
|
|
4170
|
+
this.#requests.set(log19.context, {
|
|
4171
|
+
url: log19.url,
|
|
4111
4172
|
headers: {},
|
|
4112
|
-
timestamp:
|
|
4113
|
-
navigation:
|
|
4173
|
+
timestamp: log19.timestamp,
|
|
4174
|
+
navigation: log19.navigation,
|
|
4114
4175
|
redirectChain: [],
|
|
4115
4176
|
children: []
|
|
4116
4177
|
});
|
|
4117
4178
|
}
|
|
4118
|
-
#fetchError(
|
|
4119
|
-
const response =
|
|
4179
|
+
#fetchError(log19) {
|
|
4180
|
+
const response = log19.context ? this.#requests.get(log19.context) : void 0;
|
|
4120
4181
|
if (!response) {
|
|
4121
4182
|
return;
|
|
4122
4183
|
}
|
|
4123
|
-
const request = response.children?.find((child) => child.id ===
|
|
4184
|
+
const request = response.children?.find((child) => child.id === log19.request.request);
|
|
4124
4185
|
if (!request) {
|
|
4125
4186
|
return;
|
|
4126
4187
|
}
|
|
4127
|
-
request.error =
|
|
4188
|
+
request.error = log19.errorText;
|
|
4128
4189
|
}
|
|
4129
|
-
#responseCompleted(
|
|
4130
|
-
const response =
|
|
4190
|
+
#responseCompleted(log19) {
|
|
4191
|
+
const response = log19.context ? this.#requests.get(log19.context) : void 0;
|
|
4131
4192
|
if (!response) {
|
|
4132
4193
|
return;
|
|
4133
4194
|
}
|
|
4134
4195
|
if (!response.navigation && response.url === "") {
|
|
4135
|
-
response.url =
|
|
4136
|
-
response.navigation =
|
|
4196
|
+
response.url = log19.request.url;
|
|
4197
|
+
response.navigation = log19.navigation;
|
|
4137
4198
|
}
|
|
4138
|
-
if (
|
|
4139
|
-
if (response.url !==
|
|
4199
|
+
if (log19.navigation === response.navigation) {
|
|
4200
|
+
if (response.url !== log19.response.url) {
|
|
4140
4201
|
response.redirectChain?.push(response.url);
|
|
4141
4202
|
}
|
|
4142
|
-
response.url =
|
|
4143
|
-
const { headers: requestHeaders } =
|
|
4144
|
-
const { fromCache, headers: responseHeaders, mimeType, status } =
|
|
4203
|
+
response.url = log19.response.url;
|
|
4204
|
+
const { headers: requestHeaders } = log19.request;
|
|
4205
|
+
const { fromCache, headers: responseHeaders, mimeType, status } = log19.response;
|
|
4145
4206
|
response.headers = headerListToObject(requestHeaders), response.response = {
|
|
4146
4207
|
fromCache,
|
|
4147
4208
|
headers: headerListToObject(responseHeaders),
|
|
@@ -4150,15 +4211,15 @@ var NetworkManager = class {
|
|
|
4150
4211
|
};
|
|
4151
4212
|
return;
|
|
4152
4213
|
}
|
|
4153
|
-
const request = response.children?.find((child) => child.id ===
|
|
4214
|
+
const request = response.children?.find((child) => child.id === log19.request.request);
|
|
4154
4215
|
if (!request) {
|
|
4155
4216
|
return;
|
|
4156
4217
|
}
|
|
4157
4218
|
request.response = {
|
|
4158
|
-
fromCache:
|
|
4159
|
-
headers: headerListToObject(
|
|
4160
|
-
mimeType:
|
|
4161
|
-
status:
|
|
4219
|
+
fromCache: log19.response.fromCache,
|
|
4220
|
+
headers: headerListToObject(log19.response.headers),
|
|
4221
|
+
mimeType: log19.response.mimeType,
|
|
4222
|
+
status: log19.response.status
|
|
4162
4223
|
};
|
|
4163
4224
|
response.children?.push(request);
|
|
4164
4225
|
}
|
|
@@ -4206,7 +4267,8 @@ async function url3(path4, options = {}) {
|
|
|
4206
4267
|
}
|
|
4207
4268
|
if (this.isBidi) {
|
|
4208
4269
|
let resetPreloadScript;
|
|
4209
|
-
const
|
|
4270
|
+
const contextManager2 = getContextManager(this);
|
|
4271
|
+
const context = await contextManager2.getCurrentContext();
|
|
4210
4272
|
if (options.onBeforeLoad) {
|
|
4211
4273
|
if (typeof options.onBeforeLoad !== "function") {
|
|
4212
4274
|
throw new Error(`Option "onBeforeLoad" must be a function, but received: ${typeof options.onBeforeLoad}`);
|
|
@@ -4363,9 +4425,9 @@ function clearValue() {
|
|
|
4363
4425
|
}
|
|
4364
4426
|
|
|
4365
4427
|
// src/commands/element/click.ts
|
|
4366
|
-
import
|
|
4428
|
+
import logger12 from "@wdio/logger";
|
|
4367
4429
|
import { getBrowserObject as getBrowserObject8 } from "@wdio/utils";
|
|
4368
|
-
var
|
|
4430
|
+
var log12 = logger12("webdriver");
|
|
4369
4431
|
function click(options) {
|
|
4370
4432
|
if (typeof options !== "undefined") {
|
|
4371
4433
|
if (typeof options !== "object" || Array.isArray(options)) {
|
|
@@ -4407,18 +4469,18 @@ async function actionClick(element, options) {
|
|
|
4407
4469
|
if (!buttonValue.includes(button)) {
|
|
4408
4470
|
throw new Error("Button type not supported.");
|
|
4409
4471
|
}
|
|
4410
|
-
const
|
|
4472
|
+
const browser2 = getBrowserObject8(element);
|
|
4411
4473
|
if (x || y) {
|
|
4412
|
-
const { width, height } = await
|
|
4474
|
+
const { width, height } = await browser2.getElementRect(element.elementId);
|
|
4413
4475
|
if (x && x < -Math.floor(width / 2) || x && x > Math.floor(width / 2)) {
|
|
4414
|
-
|
|
4476
|
+
log12.warn("x would cause a out of bounds error as it goes outside of element");
|
|
4415
4477
|
}
|
|
4416
4478
|
if (y && y < -Math.floor(height / 2) || y && y > Math.floor(height / 2)) {
|
|
4417
|
-
|
|
4479
|
+
log12.warn("y would cause a out of bounds error as it goes outside of element");
|
|
4418
4480
|
}
|
|
4419
4481
|
}
|
|
4420
4482
|
const clickNested = async () => {
|
|
4421
|
-
await
|
|
4483
|
+
await browser2.action("pointer", {
|
|
4422
4484
|
parameters: { pointerType: "mouse" }
|
|
4423
4485
|
}).move({ origin: element, x, y }).down({ button }).up({ button }).perform(skipRelease);
|
|
4424
4486
|
};
|
|
@@ -4478,8 +4540,8 @@ async function custom$2(strategyName, ...strategyArguments) {
|
|
|
4478
4540
|
// src/commands/element/doubleClick.ts
|
|
4479
4541
|
import { getBrowserObject as getBrowserObject11 } from "@wdio/utils";
|
|
4480
4542
|
async function doubleClick() {
|
|
4481
|
-
const
|
|
4482
|
-
return
|
|
4543
|
+
const browser2 = getBrowserObject11(this);
|
|
4544
|
+
return browser2.action("pointer", { parameters: { pointerType: "mouse" } }).move({ origin: this }).down().up().pause(10).down().up().perform();
|
|
4483
4545
|
}
|
|
4484
4546
|
|
|
4485
4547
|
// src/commands/element/dragAndDrop.ts
|
|
@@ -4510,8 +4572,8 @@ async function dragAndDrop(target, { duration = 10 } = {}) {
|
|
|
4510
4572
|
const targetOrigin = isMovingToElement ? targetRef : "pointer";
|
|
4511
4573
|
const targetX = isMovingToElement ? 0 : moveToCoordinates.x;
|
|
4512
4574
|
const targetY = isMovingToElement ? 0 : moveToCoordinates.y;
|
|
4513
|
-
const
|
|
4514
|
-
return
|
|
4575
|
+
const browser2 = getBrowserObject12(this);
|
|
4576
|
+
return browser2.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();
|
|
4515
4577
|
}
|
|
4516
4578
|
|
|
4517
4579
|
// src/commands/element/execute.ts
|
|
@@ -4520,7 +4582,8 @@ async function execute2(script, ...args) {
|
|
|
4520
4582
|
throw new Error("number or type of arguments don't agree with execute protocol command");
|
|
4521
4583
|
}
|
|
4522
4584
|
if (this.isBidi) {
|
|
4523
|
-
const
|
|
4585
|
+
const contextManager2 = getContextManager(browser);
|
|
4586
|
+
const context = await contextManager2.getCurrentContext();
|
|
4524
4587
|
const result = await this.scriptCallFunction({
|
|
4525
4588
|
functionDeclaration: script.toString(),
|
|
4526
4589
|
awaitPromise: false,
|
|
@@ -4543,7 +4606,8 @@ async function executeAsync2(script, ...args) {
|
|
|
4543
4606
|
throw new Error("number or type of arguments don't agree with execute protocol command");
|
|
4544
4607
|
}
|
|
4545
4608
|
if (this.isBidi) {
|
|
4546
|
-
const
|
|
4609
|
+
const contextManager2 = getContextManager(browser);
|
|
4610
|
+
const context = await contextManager2.getCurrentContext();
|
|
4547
4611
|
const functionDeclaration = `function (...args) {
|
|
4548
4612
|
return new Promise(async (resolve, reject) => {
|
|
4549
4613
|
try {
|
|
@@ -4640,9 +4704,9 @@ function mergeEqualSymmetricalValue(cssValues) {
|
|
|
4640
4704
|
return newCssValues.join(" ");
|
|
4641
4705
|
}
|
|
4642
4706
|
async function getPseudoElementCSSValue(elem, options) {
|
|
4643
|
-
const
|
|
4707
|
+
const browser2 = getBrowserObject13(elem);
|
|
4644
4708
|
const { cssProperty, pseudoElement } = options;
|
|
4645
|
-
const cssValue2 = await
|
|
4709
|
+
const cssValue2 = await browser2.execute(
|
|
4646
4710
|
(elem2, pseudoElement2, cssProperty2) => window.getComputedStyle(elem2, pseudoElement2)[cssProperty2],
|
|
4647
4711
|
elem,
|
|
4648
4712
|
pseudoElement,
|
|
@@ -4672,17 +4736,17 @@ import { prettify as prettifyFn } from "htmlfy";
|
|
|
4672
4736
|
import { getBrowserObject as getBrowserObject14 } from "@wdio/utils";
|
|
4673
4737
|
|
|
4674
4738
|
// src/shadowRoot.ts
|
|
4675
|
-
import
|
|
4739
|
+
import logger13 from "@wdio/logger";
|
|
4676
4740
|
import customElementWrapper from "./scripts/customElement.js";
|
|
4677
4741
|
var shadowRootManager = /* @__PURE__ */ new Map();
|
|
4678
|
-
var
|
|
4679
|
-
function getShadowRootManager(
|
|
4680
|
-
const existingShadowRootManager = shadowRootManager.get(
|
|
4742
|
+
var log13 = logger13("webdriverio:ShadowRootManager");
|
|
4743
|
+
function getShadowRootManager(browser2) {
|
|
4744
|
+
const existingShadowRootManager = shadowRootManager.get(browser2);
|
|
4681
4745
|
if (existingShadowRootManager) {
|
|
4682
4746
|
return existingShadowRootManager;
|
|
4683
4747
|
}
|
|
4684
|
-
const newContext = new ShadowRootManager(
|
|
4685
|
-
shadowRootManager.set(
|
|
4748
|
+
const newContext = new ShadowRootManager(browser2);
|
|
4749
|
+
shadowRootManager.set(browser2, newContext);
|
|
4686
4750
|
return newContext;
|
|
4687
4751
|
}
|
|
4688
4752
|
var ShadowRootManager = class {
|
|
@@ -4690,9 +4754,9 @@ var ShadowRootManager = class {
|
|
|
4690
4754
|
#initialize;
|
|
4691
4755
|
#shadowRoots = /* @__PURE__ */ new Map();
|
|
4692
4756
|
#frameDepth = 0;
|
|
4693
|
-
constructor(
|
|
4694
|
-
this.#browser =
|
|
4695
|
-
if (!
|
|
4757
|
+
constructor(browser2) {
|
|
4758
|
+
this.#browser = browser2;
|
|
4759
|
+
if (!browser2.isBidi || process.env.VITEST_WORKER_ID || browser2.options?.automationProtocol !== "webdriver") {
|
|
4696
4760
|
this.#initialize = Promise.resolve(true);
|
|
4697
4761
|
return;
|
|
4698
4762
|
}
|
|
@@ -4701,7 +4765,7 @@ var ShadowRootManager = class {
|
|
|
4701
4765
|
}).then(() => true, () => false);
|
|
4702
4766
|
this.#browser.on("log.entryAdded", this.handleLogEntry.bind(this));
|
|
4703
4767
|
this.#browser.on("result", this.#commandResultHandler.bind(this));
|
|
4704
|
-
|
|
4768
|
+
browser2.scriptAddPreloadScript({
|
|
4705
4769
|
functionDeclaration: customElementWrapper.toString()
|
|
4706
4770
|
});
|
|
4707
4771
|
}
|
|
@@ -4772,9 +4836,9 @@ var ShadowRootManager = class {
|
|
|
4772
4836
|
!shadowElem.value?.shadowRoot?.sharedId || // we expect the shadow root to have a proper type
|
|
4773
4837
|
shadowElem.value.shadowRoot.value?.nodeType !== 11
|
|
4774
4838
|
) {
|
|
4775
|
-
return
|
|
4839
|
+
return log13.warn(`Expected element with shadow root but found <${shadowElem.value?.localName} />`);
|
|
4776
4840
|
}
|
|
4777
|
-
|
|
4841
|
+
log13.info(`Registered new shadow root for element <${shadowElem.value.localName} /> with id ${shadowElem.value.shadowRoot.sharedId}`);
|
|
4778
4842
|
const newTree = new ShadowRootTree(
|
|
4779
4843
|
shadowElem.sharedId,
|
|
4780
4844
|
shadowElem.value.shadowRoot.sharedId,
|
|
@@ -4919,7 +4983,7 @@ import getHTMLShadowScript from "./scripts/getHTMLShadow.js";
|
|
|
4919
4983
|
var SHADOW_ID_ATTR_NAME = "data-wdio-shadow-id";
|
|
4920
4984
|
var SHADOW_ID_ATTR = `[${SHADOW_ID_ATTR_NAME}]`;
|
|
4921
4985
|
async function getHTML(options = {}) {
|
|
4922
|
-
const
|
|
4986
|
+
const browser2 = getBrowserObject14(this);
|
|
4923
4987
|
if (typeof options !== "object" && typeof options === "boolean") {
|
|
4924
4988
|
options = { includeSelectorTag: options };
|
|
4925
4989
|
} else if (typeof options !== "object") {
|
|
@@ -4933,7 +4997,7 @@ async function getHTML(options = {}) {
|
|
|
4933
4997
|
excludeElements: []
|
|
4934
4998
|
}, options);
|
|
4935
4999
|
const basicGetHTML = (elementId, includeSelectorTag2) => {
|
|
4936
|
-
return
|
|
5000
|
+
return browser2.execute(getHTMLScript, {
|
|
4937
5001
|
[ELEMENT_KEY11]: elementId,
|
|
4938
5002
|
// w3c compatible
|
|
4939
5003
|
ELEMENT: elementId
|
|
@@ -4949,11 +5013,12 @@ async function getHTML(options = {}) {
|
|
|
4949
5013
|
);
|
|
4950
5014
|
}
|
|
4951
5015
|
const { load } = await import("cheerio");
|
|
4952
|
-
const shadowRootManager2 = getShadowRootManager(
|
|
4953
|
-
const
|
|
4954
|
-
const
|
|
5016
|
+
const shadowRootManager2 = getShadowRootManager(browser2);
|
|
5017
|
+
const contextManager2 = getContextManager(browser2);
|
|
5018
|
+
const context = await contextManager2.getCurrentContext();
|
|
5019
|
+
const shadowRootElementPairs = shadowRootManager2.getShadowElementPairsByContextId(context, this.elementId);
|
|
4955
5020
|
const elementsWithShadowRootAndIdVerified = (await Promise.all(
|
|
4956
|
-
shadowRootElementPairs.map(([elemId, elem]) =>
|
|
5021
|
+
shadowRootElementPairs.map(([elemId, elem]) => browser2.execute((elem2) => elem2.tagName, { [ELEMENT_KEY11]: elemId }).then(
|
|
4957
5022
|
() => [elemId, elem],
|
|
4958
5023
|
() => void 0
|
|
4959
5024
|
))
|
|
@@ -4962,7 +5027,7 @@ async function getHTML(options = {}) {
|
|
|
4962
5027
|
{ [ELEMENT_KEY11]: elemId },
|
|
4963
5028
|
shadowId ? { [ELEMENT_KEY11]: shadowId } : void 0
|
|
4964
5029
|
]);
|
|
4965
|
-
const { html, shadowElementHTML } = await
|
|
5030
|
+
const { html, shadowElementHTML } = await browser2.execute(
|
|
4966
5031
|
getHTMLShadowScript,
|
|
4967
5032
|
{ [ELEMENT_KEY11]: this.elementId },
|
|
4968
5033
|
includeSelectorTag,
|
|
@@ -4972,7 +5037,7 @@ async function getHTML(options = {}) {
|
|
|
4972
5037
|
populateHTML($3, shadowElementHTML.map(({ id, ...props }) => ({
|
|
4973
5038
|
...props,
|
|
4974
5039
|
id,
|
|
4975
|
-
mode: shadowRootManager2.getShadowRootModeById(
|
|
5040
|
+
mode: shadowRootManager2.getShadowRootModeById(context, id) || "open"
|
|
4976
5041
|
})));
|
|
4977
5042
|
return sanitizeHTML($3, { removeCommentNodes, prettify, excludeElements });
|
|
4978
5043
|
}
|
|
@@ -5072,8 +5137,8 @@ async function isClickable() {
|
|
|
5072
5137
|
if (this.isMobile && await this.getContext().catch(() => void 0) === "NATIVE_APP") {
|
|
5073
5138
|
throw new Error("Method not supported in mobile native environment. It is unlikely that you need to use this command.");
|
|
5074
5139
|
}
|
|
5075
|
-
const
|
|
5076
|
-
return
|
|
5140
|
+
const browser2 = getBrowserObject15(this);
|
|
5141
|
+
return browser2.execute(isElementClickableScript, {
|
|
5077
5142
|
[ELEMENT_KEY12]: this.elementId,
|
|
5078
5143
|
// w3c compatible
|
|
5079
5144
|
ELEMENT: this.elementId
|
|
@@ -5086,12 +5151,12 @@ import { getBrowserObject as getBrowserObject16 } from "@wdio/utils";
|
|
|
5086
5151
|
import isElementDisplayedScript from "./scripts/isElementDisplayed.js";
|
|
5087
5152
|
import isElementInViewportScript from "./scripts/isElementInViewport.js";
|
|
5088
5153
|
async function isDisplayed(commandParams = { withinViewport: false }) {
|
|
5089
|
-
const
|
|
5154
|
+
const browser2 = getBrowserObject16(this);
|
|
5090
5155
|
if (!await hasElementId(this)) {
|
|
5091
5156
|
return false;
|
|
5092
5157
|
}
|
|
5093
|
-
const isNativeApplication = !
|
|
5094
|
-
if (
|
|
5158
|
+
const isNativeApplication = !browser2.capabilities.browserName;
|
|
5159
|
+
if (browser2.isMobile && isNativeApplication) {
|
|
5095
5160
|
if (commandParams?.withinViewport) {
|
|
5096
5161
|
throw new Error(
|
|
5097
5162
|
"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."
|
|
@@ -5099,9 +5164,9 @@ async function isDisplayed(commandParams = { withinViewport: false }) {
|
|
|
5099
5164
|
}
|
|
5100
5165
|
return await this.isElementDisplayed(this.elementId);
|
|
5101
5166
|
}
|
|
5102
|
-
const isDisplayed2 = await
|
|
5167
|
+
const isDisplayed2 = await browser2.execute(isElementDisplayedScript, this);
|
|
5103
5168
|
if (isDisplayed2 && commandParams?.withinViewport) {
|
|
5104
|
-
return
|
|
5169
|
+
return browser2.execute(isElementInViewportScript, this);
|
|
5105
5170
|
}
|
|
5106
5171
|
return isDisplayed2;
|
|
5107
5172
|
}
|
|
@@ -5121,9 +5186,9 @@ var getWebElement = (el) => ({
|
|
|
5121
5186
|
// jsonwp compatible
|
|
5122
5187
|
});
|
|
5123
5188
|
async function isEqual(el) {
|
|
5124
|
-
const
|
|
5125
|
-
if (
|
|
5126
|
-
const context = await
|
|
5189
|
+
const browser2 = getBrowserObject17(this);
|
|
5190
|
+
if (browser2.isMobile) {
|
|
5191
|
+
const context = await browser2.getContext().catch(() => void 0);
|
|
5127
5192
|
const contextId = typeof context === "string" ? context : context?.id;
|
|
5128
5193
|
if (contextId && contextId.toLowerCase().includes("native")) {
|
|
5129
5194
|
return this.elementId === el.elementId;
|
|
@@ -5131,7 +5196,7 @@ async function isEqual(el) {
|
|
|
5131
5196
|
}
|
|
5132
5197
|
let result;
|
|
5133
5198
|
try {
|
|
5134
|
-
result = await
|
|
5199
|
+
result = await browser2.execute(
|
|
5135
5200
|
/* istanbul ignore next */
|
|
5136
5201
|
function(el1, el2) {
|
|
5137
5202
|
return el1 === el2;
|
|
@@ -5162,8 +5227,8 @@ import { ELEMENT_KEY as ELEMENT_KEY14 } from "webdriver";
|
|
|
5162
5227
|
import { getBrowserObject as getBrowserObject18 } from "@wdio/utils";
|
|
5163
5228
|
import isFocusedScript from "./scripts/isFocused.js";
|
|
5164
5229
|
async function isFocused() {
|
|
5165
|
-
const
|
|
5166
|
-
return
|
|
5230
|
+
const browser2 = await getBrowserObject18(this);
|
|
5231
|
+
return browser2.execute(isFocusedScript, {
|
|
5167
5232
|
[ELEMENT_KEY14]: this.elementId,
|
|
5168
5233
|
// w3c compatible
|
|
5169
5234
|
ELEMENT: this.elementId
|
|
@@ -5181,8 +5246,8 @@ import { ELEMENT_KEY as ELEMENT_KEY15 } from "webdriver";
|
|
|
5181
5246
|
import { getBrowserObject as getBrowserObject19 } from "@wdio/utils";
|
|
5182
5247
|
import isElementStable from "./scripts/isElementStable.js";
|
|
5183
5248
|
async function isStable() {
|
|
5184
|
-
const
|
|
5185
|
-
return await
|
|
5249
|
+
const browser2 = getBrowserObject19(this);
|
|
5250
|
+
return await browser2.executeAsync(isElementStable, {
|
|
5186
5251
|
[ELEMENT_KEY15]: this.elementId,
|
|
5187
5252
|
// w3c compatible
|
|
5188
5253
|
ELEMENT: this.elementId
|
|
@@ -5191,22 +5256,22 @@ async function isStable() {
|
|
|
5191
5256
|
}
|
|
5192
5257
|
|
|
5193
5258
|
// src/commands/element/moveTo.ts
|
|
5194
|
-
import
|
|
5259
|
+
import logger14 from "@wdio/logger";
|
|
5195
5260
|
import { getBrowserObject as getBrowserObject20 } from "@wdio/utils";
|
|
5196
|
-
var
|
|
5261
|
+
var log14 = logger14("webdriver");
|
|
5197
5262
|
async function moveTo({ xOffset, yOffset } = {}) {
|
|
5198
|
-
const
|
|
5263
|
+
const browser2 = getBrowserObject20(this);
|
|
5199
5264
|
if (xOffset || yOffset) {
|
|
5200
|
-
const { width, height } = await
|
|
5265
|
+
const { width, height } = await browser2.getElementRect(this.elementId);
|
|
5201
5266
|
if (xOffset && xOffset < -Math.floor(width / 2) || xOffset && xOffset > Math.floor(width / 2)) {
|
|
5202
|
-
|
|
5267
|
+
log14.warn("xOffset would cause a out of bounds error as it goes outside of element");
|
|
5203
5268
|
}
|
|
5204
5269
|
if (yOffset && yOffset < -Math.floor(height / 2) || yOffset && yOffset > Math.floor(height / 2)) {
|
|
5205
|
-
|
|
5270
|
+
log14.warn("yOffset would cause a out of bounds error as it goes outside of element");
|
|
5206
5271
|
}
|
|
5207
5272
|
}
|
|
5208
5273
|
const moveToNested = async () => {
|
|
5209
|
-
await
|
|
5274
|
+
await browser2.action("pointer", { parameters: { pointerType: "mouse" } }).move({ origin: this, x: xOffset || 0, y: yOffset || 0 }).perform();
|
|
5210
5275
|
};
|
|
5211
5276
|
try {
|
|
5212
5277
|
await moveToNested();
|
|
@@ -5258,10 +5323,10 @@ async function react$$2(selector, { props = {}, state = {} } = {}) {
|
|
|
5258
5323
|
const resqScriptPath = url4.fileURLToPath(await resolve3("resq", import.meta.url));
|
|
5259
5324
|
resqScript3 = (await fs8.readFile(resqScriptPath)).toString();
|
|
5260
5325
|
}
|
|
5261
|
-
const
|
|
5326
|
+
const browser2 = await getBrowserObject21(this);
|
|
5262
5327
|
await this.executeScript(resqScript3.toString(), []);
|
|
5263
|
-
await
|
|
5264
|
-
const res = await
|
|
5328
|
+
await browser2.execute(waitToLoadReact3);
|
|
5329
|
+
const res = await browser2.execute(
|
|
5265
5330
|
react$$Script2,
|
|
5266
5331
|
selector,
|
|
5267
5332
|
props,
|
|
@@ -5284,10 +5349,10 @@ async function react$2(selector, { props = {}, state = {} } = {}) {
|
|
|
5284
5349
|
const resqScriptPath = url5.fileURLToPath(await resolve4("resq", import.meta.url));
|
|
5285
5350
|
resqScript4 = (await fs9.readFile(resqScriptPath)).toString();
|
|
5286
5351
|
}
|
|
5287
|
-
const
|
|
5352
|
+
const browser2 = await getBrowserObject22(this);
|
|
5288
5353
|
await this.executeScript(resqScript4.toString(), []);
|
|
5289
|
-
await
|
|
5290
|
-
const res = await
|
|
5354
|
+
await browser2.execute(waitToLoadReact4);
|
|
5355
|
+
const res = await browser2.execute(
|
|
5291
5356
|
react$Script2,
|
|
5292
5357
|
selector,
|
|
5293
5358
|
props,
|
|
@@ -5312,13 +5377,13 @@ async function saveScreenshot2(filepath) {
|
|
|
5312
5377
|
}
|
|
5313
5378
|
|
|
5314
5379
|
// src/commands/element/scrollIntoView.ts
|
|
5315
|
-
import
|
|
5380
|
+
import logger15 from "@wdio/logger";
|
|
5316
5381
|
import { ELEMENT_KEY as ELEMENT_KEY16 } from "webdriver";
|
|
5317
5382
|
import { getBrowserObject as getBrowserObject23 } from "@wdio/utils";
|
|
5318
|
-
var
|
|
5383
|
+
var log15 = logger15("webdriverio");
|
|
5319
5384
|
function scrollIntoViewWeb(options = { block: "start", inline: "nearest" }) {
|
|
5320
|
-
const
|
|
5321
|
-
return
|
|
5385
|
+
const browser2 = getBrowserObject23(this);
|
|
5386
|
+
return browser2.execute(
|
|
5322
5387
|
(elem, options2) => elem.scrollIntoView(options2),
|
|
5323
5388
|
{
|
|
5324
5389
|
[ELEMENT_KEY16]: this.elementId,
|
|
@@ -5330,14 +5395,14 @@ function scrollIntoViewWeb(options = { block: "start", inline: "nearest" }) {
|
|
|
5330
5395
|
);
|
|
5331
5396
|
}
|
|
5332
5397
|
async function scrollIntoView(options = { block: "start", inline: "nearest" }) {
|
|
5333
|
-
const
|
|
5334
|
-
if (
|
|
5398
|
+
const browser2 = getBrowserObject23(this);
|
|
5399
|
+
if (browser2.isMobile) {
|
|
5335
5400
|
return scrollIntoViewWeb.call(this, options);
|
|
5336
5401
|
}
|
|
5337
5402
|
try {
|
|
5338
|
-
const elemRect = await
|
|
5339
|
-
const viewport = await
|
|
5340
|
-
let [scrollX, scrollY] = await
|
|
5403
|
+
const elemRect = await browser2.getElementRect(this.elementId);
|
|
5404
|
+
const viewport = await browser2.getWindowSize();
|
|
5405
|
+
let [scrollX, scrollY] = await browser2.execute(() => [
|
|
5341
5406
|
window.scrollX,
|
|
5342
5407
|
window.scrollY
|
|
5343
5408
|
]);
|
|
@@ -5372,9 +5437,9 @@ async function scrollIntoView(options = { block: "start", inline: "nearest" }) {
|
|
|
5372
5437
|
}
|
|
5373
5438
|
deltaX = Math.round(deltaX - scrollX);
|
|
5374
5439
|
deltaY = Math.round(deltaY - scrollY);
|
|
5375
|
-
await
|
|
5440
|
+
await browser2.action("wheel").scroll({ duration: 0, x: deltaX, y: deltaY, origin: this }).perform();
|
|
5376
5441
|
} catch (err) {
|
|
5377
|
-
|
|
5442
|
+
log15.warn(
|
|
5378
5443
|
`Failed to execute "scrollIntoView" using WebDriver Actions API: ${err.message}!
|
|
5379
5444
|
Re-attempting using \`Element.scrollIntoView\` via Web API.`
|
|
5380
5445
|
);
|
|
@@ -5439,7 +5504,7 @@ async function setValue(value) {
|
|
|
5439
5504
|
}
|
|
5440
5505
|
|
|
5441
5506
|
// src/commands/element/shadow$$.ts
|
|
5442
|
-
import
|
|
5507
|
+
import logger16 from "@wdio/logger";
|
|
5443
5508
|
import { getBrowserObject as getBrowserObject24 } from "@wdio/utils";
|
|
5444
5509
|
import { SHADOW_ELEMENT_KEY } from "webdriver";
|
|
5445
5510
|
import { shadowFnFactory } from "./scripts/shadowFnFactory.js";
|
|
@@ -5766,17 +5831,17 @@ var createRoleBaseXpathSelector = (role) => {
|
|
|
5766
5831
|
};
|
|
5767
5832
|
|
|
5768
5833
|
// src/commands/element/shadow$$.ts
|
|
5769
|
-
var
|
|
5834
|
+
var log16 = logger16("webdriverio");
|
|
5770
5835
|
async function shadow$$(selector) {
|
|
5771
|
-
const
|
|
5836
|
+
const browser2 = getBrowserObject24(this);
|
|
5772
5837
|
try {
|
|
5773
|
-
const shadowRoot = await
|
|
5838
|
+
const shadowRoot = await browser2.getElementShadowRoot(this.elementId);
|
|
5774
5839
|
const { using, value } = findStrategy(selector, this.isW3C, this.isMobile);
|
|
5775
|
-
const res = await
|
|
5840
|
+
const res = await browser2.findElementsFromShadowRoot(shadowRoot[SHADOW_ELEMENT_KEY], using, value);
|
|
5776
5841
|
const elements = await getElements.call(this, selector, res, { isShadowElement: true });
|
|
5777
5842
|
return enhanceElementsArray(elements, this, selector);
|
|
5778
5843
|
} catch (err) {
|
|
5779
|
-
|
|
5844
|
+
log16.warn(
|
|
5780
5845
|
`Failed to fetch element within shadow DOM using WebDriver command: ${err.message}!
|
|
5781
5846
|
Falling back to JavaScript shim.`
|
|
5782
5847
|
);
|
|
@@ -5785,20 +5850,20 @@ Falling back to JavaScript shim.`
|
|
|
5785
5850
|
}
|
|
5786
5851
|
|
|
5787
5852
|
// src/commands/element/shadow$.ts
|
|
5788
|
-
import
|
|
5853
|
+
import logger17 from "@wdio/logger";
|
|
5789
5854
|
import { SHADOW_ELEMENT_KEY as SHADOW_ELEMENT_KEY2 } from "webdriver";
|
|
5790
5855
|
import { shadowFnFactory as shadowFnFactory2 } from "./scripts/shadowFnFactory.js";
|
|
5791
5856
|
import { getBrowserObject as getBrowserObject25 } from "@wdio/utils";
|
|
5792
|
-
var
|
|
5857
|
+
var log17 = logger17("webdriverio");
|
|
5793
5858
|
async function shadow$(selector) {
|
|
5794
|
-
const
|
|
5859
|
+
const browser2 = getBrowserObject25(this);
|
|
5795
5860
|
try {
|
|
5796
|
-
const shadowRoot = await
|
|
5861
|
+
const shadowRoot = await browser2.getElementShadowRoot(this.elementId);
|
|
5797
5862
|
const { using, value } = findStrategy(selector, this.isW3C, this.isMobile);
|
|
5798
|
-
const res = await
|
|
5863
|
+
const res = await browser2.findElementFromShadowRoot(shadowRoot[SHADOW_ELEMENT_KEY2], using, value);
|
|
5799
5864
|
return getElement.call(this, selector, res, { isShadowElement: true });
|
|
5800
5865
|
} catch (err) {
|
|
5801
|
-
|
|
5866
|
+
log17.warn(
|
|
5802
5867
|
`Failed to fetch element within shadow DOM using WebDriver command: ${err.message}!
|
|
5803
5868
|
Falling back to JavaScript shim.`
|
|
5804
5869
|
);
|
|
@@ -6097,7 +6162,7 @@ function querySelectorAllDeep(findMany, s, r) {
|
|
|
6097
6162
|
}
|
|
6098
6163
|
|
|
6099
6164
|
// src/utils/index.ts
|
|
6100
|
-
var
|
|
6165
|
+
var log18 = logger18("webdriverio");
|
|
6101
6166
|
var INVALID_SELECTOR_ERROR = "selector needs to be typeof `string` or `function`";
|
|
6102
6167
|
var IGNORED_COMMAND_FILE_EXPORTS = ["SESSION_MOCKS", "CDP_SESSIONS"];
|
|
6103
6168
|
var scopes = {
|
|
@@ -6221,9 +6286,10 @@ function transformClassicToBidiSelector(using, value) {
|
|
|
6221
6286
|
throw new Error(`Can't transform classic selector ${using} to Bidi selector`);
|
|
6222
6287
|
}
|
|
6223
6288
|
async function findDeepElement(selector) {
|
|
6224
|
-
const
|
|
6225
|
-
const shadowRootManager2 = getShadowRootManager(
|
|
6226
|
-
const
|
|
6289
|
+
const browser2 = getBrowserObject26(this);
|
|
6290
|
+
const shadowRootManager2 = getShadowRootManager(browser2);
|
|
6291
|
+
const contextManager2 = getContextManager(browser2);
|
|
6292
|
+
const context = await contextManager2.getCurrentContext();
|
|
6227
6293
|
const shadowRoots = shadowRootManager2.getShadowElementsByContextId(
|
|
6228
6294
|
context,
|
|
6229
6295
|
this.elementId
|
|
@@ -6231,7 +6297,7 @@ async function findDeepElement(selector) {
|
|
|
6231
6297
|
const { using, value } = findStrategy(selector, this.isW3C, this.isMobile);
|
|
6232
6298
|
const locator = transformClassicToBidiSelector(using, value);
|
|
6233
6299
|
const startNodes = shadowRoots.length > 0 ? shadowRoots.map((shadowRootNodeId) => ({ sharedId: shadowRootNodeId })) : this.elementId ? [{ sharedId: this.elementId }] : void 0;
|
|
6234
|
-
const deepElementResult = await
|
|
6300
|
+
const deepElementResult = await browser2.browsingContextLocateNodes({ locator, context, startNodes }).then(async (result) => {
|
|
6235
6301
|
const nodes = result.nodes.filter((node) => Boolean(node.sharedId)).map((node) => ({
|
|
6236
6302
|
[ELEMENT_KEY17]: node.sharedId,
|
|
6237
6303
|
locator
|
|
@@ -6240,7 +6306,7 @@ async function findDeepElement(selector) {
|
|
|
6240
6306
|
return nodes[0];
|
|
6241
6307
|
}
|
|
6242
6308
|
const scopedNodes = await Promise.all(nodes.map(async (node) => {
|
|
6243
|
-
const isIn = await
|
|
6309
|
+
const isIn = await browser2.execute(
|
|
6244
6310
|
elementContains,
|
|
6245
6311
|
{ [ELEMENT_KEY17]: this.elementId },
|
|
6246
6312
|
node
|
|
@@ -6249,8 +6315,8 @@ async function findDeepElement(selector) {
|
|
|
6249
6315
|
})).then((elems) => elems.filter(([isIn]) => isIn).map(([, elem]) => elem));
|
|
6250
6316
|
return scopedNodes[0];
|
|
6251
6317
|
}, (err) => {
|
|
6252
|
-
|
|
6253
|
-
return
|
|
6318
|
+
log18.warn(`Failed to execute browser.browsingContextLocateNodes({ ... }) due to ${err}, falling back to regular WebDriver Classic command`);
|
|
6319
|
+
return browser2.findElement(using, value);
|
|
6254
6320
|
});
|
|
6255
6321
|
if (!deepElementResult) {
|
|
6256
6322
|
return new Error(`Couldn't find element with selector "${selector}"`);
|
|
@@ -6258,9 +6324,10 @@ async function findDeepElement(selector) {
|
|
|
6258
6324
|
return deepElementResult;
|
|
6259
6325
|
}
|
|
6260
6326
|
async function findDeepElements(selector) {
|
|
6261
|
-
const
|
|
6262
|
-
const shadowRootManager2 = getShadowRootManager(
|
|
6263
|
-
const
|
|
6327
|
+
const browser2 = getBrowserObject26(this);
|
|
6328
|
+
const shadowRootManager2 = getShadowRootManager(browser2);
|
|
6329
|
+
const contextManager2 = getContextManager(browser2);
|
|
6330
|
+
const context = await contextManager2.getCurrentContext();
|
|
6264
6331
|
const shadowRoots = shadowRootManager2.getShadowElementsByContextId(
|
|
6265
6332
|
context,
|
|
6266
6333
|
this.elementId
|
|
@@ -6268,7 +6335,7 @@ async function findDeepElements(selector) {
|
|
|
6268
6335
|
const { using, value } = findStrategy(selector, this.isW3C, this.isMobile);
|
|
6269
6336
|
const locator = transformClassicToBidiSelector(using, value);
|
|
6270
6337
|
const startNodes = shadowRoots.length > 0 ? shadowRoots.map((shadowRootNodeId) => ({ sharedId: shadowRootNodeId })) : this.elementId ? [{ sharedId: this.elementId }] : void 0;
|
|
6271
|
-
const deepElementResult = await
|
|
6338
|
+
const deepElementResult = await browser2.browsingContextLocateNodes({ locator, context, startNodes }).then(async (result) => {
|
|
6272
6339
|
const nodes = result.nodes.filter((node) => Boolean(node.sharedId)).map((node) => ({
|
|
6273
6340
|
[ELEMENT_KEY17]: node.sharedId,
|
|
6274
6341
|
locator
|
|
@@ -6277,7 +6344,7 @@ async function findDeepElements(selector) {
|
|
|
6277
6344
|
return nodes;
|
|
6278
6345
|
}
|
|
6279
6346
|
const scopedNodes = await Promise.all(nodes.map(async (node) => {
|
|
6280
|
-
const isIn = await
|
|
6347
|
+
const isIn = await browser2.execute(
|
|
6281
6348
|
elementContains,
|
|
6282
6349
|
{ [ELEMENT_KEY17]: this.elementId },
|
|
6283
6350
|
node
|
|
@@ -6286,8 +6353,8 @@ async function findDeepElements(selector) {
|
|
|
6286
6353
|
})).then((elems) => elems.filter(([isIn]) => isIn).map(([, elem]) => elem));
|
|
6287
6354
|
return scopedNodes;
|
|
6288
6355
|
}, (err) => {
|
|
6289
|
-
|
|
6290
|
-
return
|
|
6356
|
+
log18.warn(`Failed to execute browser.browsingContextLocateNodes({ ... }) due to ${err}, falling back to regular WebDriver Classic command`);
|
|
6357
|
+
return browser2.findElements(using, value);
|
|
6291
6358
|
});
|
|
6292
6359
|
return deepElementResult;
|
|
6293
6360
|
}
|
|
@@ -6414,7 +6481,7 @@ async function getElementRect(scope) {
|
|
|
6414
6481
|
if (rectJs && typeof rectJs[key] === "number") {
|
|
6415
6482
|
rect[key] = Math.floor(rectJs[key]);
|
|
6416
6483
|
} else {
|
|
6417
|
-
|
|
6484
|
+
log18.error("getElementRect", { rect, rectJs, key });
|
|
6418
6485
|
throw new Error("Failed to receive element rects via execute command");
|
|
6419
6486
|
}
|
|
6420
6487
|
});
|
|
@@ -6788,7 +6855,7 @@ import { capabilitiesEnvironmentDetector } from "@wdio/utils";
|
|
|
6788
6855
|
var ProtocolStub = class {
|
|
6789
6856
|
static async newSession(options) {
|
|
6790
6857
|
const capabilities = emulateSessionCapabilities(options.capabilities);
|
|
6791
|
-
const
|
|
6858
|
+
const browser2 = {
|
|
6792
6859
|
options,
|
|
6793
6860
|
capabilities,
|
|
6794
6861
|
requestedCapabilities: capabilities,
|
|
@@ -6799,9 +6866,9 @@ var ProtocolStub = class {
|
|
|
6799
6866
|
commandList: [],
|
|
6800
6867
|
...capabilitiesEnvironmentDetector(capabilities)
|
|
6801
6868
|
};
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
return
|
|
6869
|
+
browser2.addCommand = (...args) => browser2.customCommands.push(args);
|
|
6870
|
+
browser2.overwriteCommand = (...args) => browser2.overwrittenCommands.push(args);
|
|
6871
|
+
return browser2;
|
|
6805
6872
|
}
|
|
6806
6873
|
/**
|
|
6807
6874
|
* added just in case user wants to somehow reload webdriver before it was started.
|
|
@@ -6849,22 +6916,22 @@ async function getProtocolDriver(options) {
|
|
|
6849
6916
|
|
|
6850
6917
|
// src/dialog.ts
|
|
6851
6918
|
var dialogManager = /* @__PURE__ */ new Map();
|
|
6852
|
-
function getDialogManager(
|
|
6853
|
-
const existingDialogManager = dialogManager.get(
|
|
6919
|
+
function getDialogManager(browser2) {
|
|
6920
|
+
const existingDialogManager = dialogManager.get(browser2);
|
|
6854
6921
|
if (existingDialogManager) {
|
|
6855
6922
|
return existingDialogManager;
|
|
6856
6923
|
}
|
|
6857
|
-
const newContext = new DialogManager(
|
|
6858
|
-
dialogManager.set(
|
|
6924
|
+
const newContext = new DialogManager(browser2);
|
|
6925
|
+
dialogManager.set(browser2, newContext);
|
|
6859
6926
|
return newContext;
|
|
6860
6927
|
}
|
|
6861
6928
|
var DialogManager = class {
|
|
6862
6929
|
#browser;
|
|
6863
6930
|
#initialize;
|
|
6864
6931
|
#autoHandleDialog = true;
|
|
6865
|
-
constructor(
|
|
6866
|
-
this.#browser =
|
|
6867
|
-
if (!
|
|
6932
|
+
constructor(browser2) {
|
|
6933
|
+
this.#browser = browser2;
|
|
6934
|
+
if (!browser2.isBidi || process.env.VITEST_WORKER_ID || browser2.options?.automationProtocol !== "webdriver") {
|
|
6868
6935
|
this.#initialize = Promise.resolve(true);
|
|
6869
6936
|
return;
|
|
6870
6937
|
}
|
|
@@ -6881,14 +6948,14 @@ var DialogManager = class {
|
|
|
6881
6948
|
/**
|
|
6882
6949
|
* capture shadow root elements propagated through console.debug
|
|
6883
6950
|
*/
|
|
6884
|
-
async #handleUserPrompt(
|
|
6951
|
+
async #handleUserPrompt(log19) {
|
|
6885
6952
|
if (this.#autoHandleDialog) {
|
|
6886
6953
|
return this.#browser.browsingContextHandleUserPrompt({
|
|
6887
6954
|
accept: false,
|
|
6888
|
-
context:
|
|
6955
|
+
context: log19.context
|
|
6889
6956
|
});
|
|
6890
6957
|
}
|
|
6891
|
-
const dialog = new Dialog(
|
|
6958
|
+
const dialog = new Dialog(log19, this.#browser);
|
|
6892
6959
|
this.#browser.emit("dialog", dialog);
|
|
6893
6960
|
}
|
|
6894
6961
|
/**
|
|
@@ -6906,12 +6973,12 @@ var Dialog = class {
|
|
|
6906
6973
|
#message;
|
|
6907
6974
|
#defaultValue;
|
|
6908
6975
|
#type;
|
|
6909
|
-
constructor(event,
|
|
6976
|
+
constructor(event, browser2) {
|
|
6910
6977
|
this.#message = event.message;
|
|
6911
6978
|
this.#defaultValue = event.defaultValue;
|
|
6912
6979
|
this.#type = event.type;
|
|
6913
6980
|
this.#context = event.context;
|
|
6914
|
-
this.#browser =
|
|
6981
|
+
this.#browser = browser2;
|
|
6915
6982
|
}
|
|
6916
6983
|
message() {
|
|
6917
6984
|
return this.#message;
|
|
@@ -6951,7 +7018,7 @@ var remote = async function(params, remoteModifier) {
|
|
|
6951
7018
|
const keysToKeep = Object.keys(process.env.WDIO_WORKER_ID ? params : DEFAULTS);
|
|
6952
7019
|
const config = validateConfig(WDIO_DEFAULTS, params, keysToKeep);
|
|
6953
7020
|
await enableFileLogging(config.outputDir);
|
|
6954
|
-
|
|
7021
|
+
logger19.setLogLevelsConfig(config.logLevels, config.logLevel);
|
|
6955
7022
|
const modifier = (client, options2) => {
|
|
6956
7023
|
Object.assign(options2, Object.entries(config).reduce((a, [k, v]) => typeof v === "undefined" ? a : { ...a, [k]: v }, {}));
|
|
6957
7024
|
if (typeof remoteModifier === "function") {
|
|
@@ -6972,7 +7039,8 @@ var remote = async function(params, remoteModifier) {
|
|
|
6972
7039
|
await Promise.all([
|
|
6973
7040
|
getShadowRootManager(instance).initialize(),
|
|
6974
7041
|
getNetworkManager(instance).initialize(),
|
|
6975
|
-
getDialogManager(instance).initialize()
|
|
7042
|
+
getDialogManager(instance).initialize(),
|
|
7043
|
+
getContextManager(instance).initialize()
|
|
6976
7044
|
]);
|
|
6977
7045
|
return instance;
|
|
6978
7046
|
};
|
|
@@ -6996,7 +7064,8 @@ var attach = async function(attachOptions) {
|
|
|
6996
7064
|
await driver._bidiHandler?.connect().then(() => Promise.all([
|
|
6997
7065
|
getShadowRootManager(driver).initialize(),
|
|
6998
7066
|
getNetworkManager(driver).initialize(),
|
|
6999
|
-
getDialogManager(driver).initialize()
|
|
7067
|
+
getDialogManager(driver).initialize(),
|
|
7068
|
+
getContextManager(driver).initialize()
|
|
7000
7069
|
]));
|
|
7001
7070
|
return driver;
|
|
7002
7071
|
};
|