webdriverio 9.23.1 → 9.23.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -23,7 +23,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
23
23
  });
24
24
 
25
25
  // src/index.ts
26
- import logger27 from "@wdio/logger";
26
+ import logger29 from "@wdio/logger";
27
27
  import WebDriver, { DEFAULTS } from "webdriver";
28
28
  import { validateConfig } from "@wdio/config";
29
29
  import { enableFileLogging, wrapCommand as wrapCommand3, isBidi } from "@wdio/utils";
@@ -97,7 +97,7 @@ async function refetchElement(currentElement, commandName) {
97
97
  import cssValue from "css-value";
98
98
  import rgb2hex from "rgb2hex";
99
99
  import GraphemeSplitter from "grapheme-splitter";
100
- import logger26 from "@wdio/logger";
100
+ import logger28 from "@wdio/logger";
101
101
  import isPlainObject from "is-plain-obj";
102
102
  import { ELEMENT_KEY as ELEMENT_KEY20 } from "webdriver";
103
103
  import { UNICODE_CHARACTERS as UNICODE_CHARACTERS2, asyncIterators, getBrowserObject as getBrowserObject37 } from "@wdio/utils";
@@ -1141,40 +1141,75 @@ function debug(commandTimeout = 5e3) {
1141
1141
  }
1142
1142
 
1143
1143
  // src/commands/browser/deleteCookies.ts
1144
+ import logger2 from "@wdio/logger";
1145
+ var log2 = logger2("webdriverio");
1144
1146
  async function deleteCookies(filter) {
1145
1147
  const filterArray = typeof filter === "undefined" ? void 0 : Array.isArray(filter) ? filter : [filter];
1146
1148
  if (!this.isBidi) {
1147
- const names = filterArray == null ? void 0 : filterArray.map((f) => {
1148
- if (typeof f === "object") {
1149
- const name = f.name;
1150
- if (!name) {
1151
- throw new Error("In WebDriver Classic you can only filter for cookie names");
1152
- }
1153
- return name;
1154
- }
1149
+ await deleteCookiesClassic.call(this, getNamesForClassic(filterArray));
1150
+ return;
1151
+ }
1152
+ let url2;
1153
+ try {
1154
+ url2 = new URL(await this.getUrl());
1155
+ if (url2.origin === "null") {
1156
+ await deleteCookiesClassic.call(this, getNamesForClassic(filterArray));
1157
+ return;
1158
+ }
1159
+ } catch {
1160
+ await deleteCookiesClassic.call(this, getNamesForClassic(filterArray));
1161
+ return;
1162
+ }
1163
+ const partition = {
1164
+ type: "storageKey",
1165
+ sourceOrigin: url2.origin
1166
+ };
1167
+ try {
1168
+ const { cookies } = await this.storageGetCookies({ partition });
1169
+ if (cookies.length === 0 && !this.isMobile) {
1170
+ await deleteCookiesClassic.call(this, getNamesForClassic(filterArray));
1171
+ return;
1172
+ }
1173
+ } catch (err) {
1174
+ log2.warn("BiDi deleteCookies check failed, falling back to classic: ".concat(err.message));
1175
+ await deleteCookiesClassic.call(this, getNamesForClassic(filterArray));
1176
+ return;
1177
+ }
1178
+ try {
1179
+ if (!filterArray) {
1180
+ await this.storageDeleteCookies({ partition });
1181
+ return;
1182
+ }
1183
+ const bidiFilter = filterArray.map((f) => {
1155
1184
  if (typeof f === "string") {
1185
+ return { name: f };
1186
+ }
1187
+ if (typeof f === "object") {
1156
1188
  return f;
1157
1189
  }
1158
1190
  throw new Error("Invalid value for cookie filter, expected 'string' or 'remote.StorageCookieFilter' but found \"".concat(typeof f, '"'));
1159
1191
  });
1160
- await deleteCookiesClassic.call(this, names);
1161
- return;
1162
- }
1163
- if (!filterArray) {
1164
- await this.storageDeleteCookies({});
1165
- return;
1192
+ await Promise.all(bidiFilter.map((filter2) => this.storageDeleteCookies({ filter: filter2, partition })));
1193
+ } catch (err) {
1194
+ log2.warn("BiDi deleteCookies failed, falling back to classic: ".concat(err.message));
1195
+ await deleteCookiesClassic.call(this, getNamesForClassic(filterArray));
1166
1196
  }
1167
- const bidiFilter = filterArray.map((f) => {
1168
- if (typeof f === "string") {
1169
- return { name: f };
1170
- }
1197
+ return;
1198
+ }
1199
+ function getNamesForClassic(filterArray) {
1200
+ return filterArray == null ? void 0 : filterArray.map((f) => {
1171
1201
  if (typeof f === "object") {
1202
+ const name = f.name;
1203
+ if (!name) {
1204
+ throw new Error("In WebDriver Classic you can only filter for cookie names");
1205
+ }
1206
+ return name;
1207
+ }
1208
+ if (typeof f === "string") {
1172
1209
  return f;
1173
1210
  }
1174
1211
  throw new Error("Invalid value for cookie filter, expected 'string' or 'remote.StorageCookieFilter' but found \"".concat(typeof f, '"'));
1175
1212
  });
1176
- await Promise.all(bidiFilter.map((filter2) => this.storageDeleteCookies({ filter: filter2 })));
1177
- return;
1178
1213
  }
1179
1214
  function deleteCookiesClassic(names) {
1180
1215
  if (names === void 0) {
@@ -1193,8 +1228,8 @@ async function downloadFile(fileName, targetDirectory) {
1193
1228
  }
1194
1229
 
1195
1230
  // src/clock.ts
1196
- import logger2 from "@wdio/logger";
1197
- var log2 = logger2("webdriverio:ClockManager");
1231
+ import logger3 from "@wdio/logger";
1232
+ var log3 = logger3("webdriverio:ClockManager");
1198
1233
  function installFakeTimers(options) {
1199
1234
  window.__clock = window.__wdio_sinon.install(options);
1200
1235
  }
@@ -1219,7 +1254,7 @@ var ClockManager = class {
1219
1254
  */
1220
1255
  async install(options) {
1221
1256
  if (__privateGet(this, _isInstalled)) {
1222
- return log2.warn("Fake timers are already installed");
1257
+ return log3.warn("Fake timers are already installed");
1223
1258
  }
1224
1259
  if (globalThis.window) {
1225
1260
  return;
@@ -3017,7 +3052,7 @@ var ReferenceValue = class {
3017
3052
  };
3018
3053
 
3019
3054
  // src/session/context.ts
3020
- import logger3 from "@wdio/logger";
3055
+ import logger4 from "@wdio/logger";
3021
3056
 
3022
3057
  // src/session/session.ts
3023
3058
  var sessionManager = /* @__PURE__ */ new Map();
@@ -3141,7 +3176,7 @@ function validatePinchAndZoomOptions({ browser, gesture, options }) {
3141
3176
  }
3142
3177
 
3143
3178
  // src/session/context.ts
3144
- var log3 = logger3("webdriverio:context");
3179
+ var log4 = logger4("webdriverio:context");
3145
3180
  var COMMANDS_REQUIRING_RESET = ["deleteSession", "refresh", "switchToParentFrame"];
3146
3181
  function getContextManager(browser) {
3147
3182
  return SessionManager.getSessionManager(browser, ContextManager);
@@ -3206,7 +3241,7 @@ var _ContextManager = class _ContextManager extends SessionManager {
3206
3241
  }
3207
3242
  if (__privateGet(this, _browser3).isMobile && !__privateGet(this, _isNativeContext) && !__privateGet(this, _mobileContext) && __privateGet(this, _getContextSupport)) {
3208
3243
  const context = await __privateGet(this, _browser3).getContext().catch((err) => {
3209
- log3.warn(
3244
+ log4.warn(
3210
3245
  "Error getting context: ".concat(err, "\n\n") + "WebDriver capabilities: ".concat(JSON.stringify(__privateGet(this, _browser3).capabilities), "\n") + "Requested WebDriver capabilities: ".concat(JSON.stringify(__privateGet(this, _browser3).requestedCapabilities))
3211
3246
  );
3212
3247
  if (err.message.includes("Request failed with status code 405")) {
@@ -3475,19 +3510,46 @@ async function executeAsync(script, ...args) {
3475
3510
  }
3476
3511
 
3477
3512
  // src/commands/browser/getCookies.ts
3478
- import logger4 from "@wdio/logger";
3479
- var log4 = logger4("webdriverio");
3513
+ import logger5 from "@wdio/logger";
3514
+ var log5 = logger5("webdriverio");
3480
3515
  async function getCookies(filter) {
3481
3516
  const usesMultipleFilter = Array.isArray(filter) && filter.length > 1;
3482
3517
  if (!this.isBidi || usesMultipleFilter) {
3483
3518
  return getCookiesClassic.call(this, filter);
3484
3519
  }
3485
3520
  const cookieFilter = getCookieFilter(filter);
3486
- const { cookies } = await this.storageGetCookies({ filter: cookieFilter });
3487
- return cookies.map((cookie) => ({
3488
- ...cookie,
3489
- value: cookie.value.type === "base64" ? atob(cookie.value.value) : cookie.value.value
3490
- }));
3521
+ let url2;
3522
+ try {
3523
+ url2 = new URL(await this.getUrl());
3524
+ if (url2.origin === "null") {
3525
+ return getCookiesClassic.call(this, filter);
3526
+ }
3527
+ } catch {
3528
+ return getCookiesClassic.call(this, filter);
3529
+ }
3530
+ const params = {
3531
+ partition: {
3532
+ type: "storageKey",
3533
+ sourceOrigin: url2.origin
3534
+ }
3535
+ };
3536
+ if (typeof cookieFilter !== "undefined") {
3537
+ params.filter = cookieFilter;
3538
+ }
3539
+ try {
3540
+ const { cookies } = await this.storageGetCookies(params);
3541
+ if (cookies.length === 0) {
3542
+ log5.debug("BiDi getCookies returned empty, falling back to classic");
3543
+ return getCookiesClassic.call(this, filter);
3544
+ }
3545
+ return cookies.map((cookie) => ({
3546
+ ...cookie,
3547
+ value: cookie.value.type === "base64" ? Buffer.from(cookie.value.value, "base64").toString("utf-8") : cookie.value.value
3548
+ }));
3549
+ } catch (err) {
3550
+ log5.warn("BiDi getCookies failed, falling back to classic: ".concat(err.message));
3551
+ return getCookiesClassic.call(this, filter);
3552
+ }
3491
3553
  }
3492
3554
  async function getCookiesClassic(names) {
3493
3555
  if (!names) {
@@ -3495,7 +3557,7 @@ async function getCookiesClassic(names) {
3495
3557
  }
3496
3558
  const usesMultipleFilter = Array.isArray(names) && names.length > 1;
3497
3559
  if (usesMultipleFilter) {
3498
- log4.warn(
3560
+ log5.warn(
3499
3561
  "Passing a string array as filter for `getCookies` is deprecated and its support will be removed in an upcoming version of WebdriverIO!"
3500
3562
  );
3501
3563
  const allCookies2 = await this.getAllCookies();
@@ -3517,7 +3579,7 @@ function getCookieFilter(names) {
3517
3579
  }
3518
3580
  return (Array.isArray(names) ? names : [names]).map((filter) => {
3519
3581
  if (typeof filter === "string") {
3520
- log4.warn("Passing string values into `getCookie` is deprecated and its support will be removed in an upcoming version of WebdriverIO!");
3582
+ log5.warn("Passing string values into `getCookie` is deprecated and its support will be removed in an upcoming version of WebdriverIO!");
3521
3583
  return { name: filter };
3522
3584
  }
3523
3585
  return filter;
@@ -3525,9 +3587,9 @@ function getCookieFilter(names) {
3525
3587
  }
3526
3588
 
3527
3589
  // src/commands/browser/getPuppeteer.ts
3528
- import logger5 from "@wdio/logger";
3590
+ import logger6 from "@wdio/logger";
3529
3591
  import { userImport } from "@wdio/utils";
3530
- var log5 = logger5("webdriverio");
3592
+ var log6 = logger6("webdriverio");
3531
3593
  var DEBUG_PIPE_FLAG = "remote-debugging-pipe";
3532
3594
  async function getPuppeteer() {
3533
3595
  var _a, _b, _c, _d, _e, _f;
@@ -3541,7 +3603,7 @@ async function getPuppeteer() {
3541
3603
  );
3542
3604
  }
3543
3605
  if ((_a = this.puppeteer) == null ? void 0 : _a.connected) {
3544
- log5.debug("Reusing existing puppeteer session");
3606
+ log6.debug("Reusing existing puppeteer session");
3545
3607
  return this.puppeteer;
3546
3608
  }
3547
3609
  const { headers } = this.options;
@@ -3651,7 +3713,7 @@ async function keys(value) {
3651
3713
  import { getBrowserObject as getBrowserObject6 } from "@wdio/utils";
3652
3714
 
3653
3715
  // src/utils/interception/index.ts
3654
- import logger6 from "@wdio/logger";
3716
+ import logger7 from "@wdio/logger";
3655
3717
  import { URLPattern } from "urlpattern-polyfill";
3656
3718
 
3657
3719
  // src/utils/Timer.ts
@@ -3828,7 +3890,7 @@ function getPatternParam(pattern, key) {
3828
3890
  }
3829
3891
 
3830
3892
  // src/utils/interception/index.ts
3831
- var log6 = logger6("WebDriverInterception");
3893
+ var log7 = logger7("WebDriverInterception");
3832
3894
  var hasSubscribedToEvents = false;
3833
3895
  var _pattern, _mockId, _filterOptions, _browser4, _eventHandler, _restored, _requestOverwrites, _respondOverwrites, _calls, _responseBodies, _WebDriverInterception_instances, emit_fn, addEventHandler_fn, handleBeforeRequestSent_fn, handleResponseStarted_fn, handleNetworkProvideResponseError_fn, isRequestMatching_fn, matchesFilterOptions_fn, _setOverwrite, ensureNotRestored_fn;
3834
3896
  var _WebDriverInterception = class _WebDriverInterception {
@@ -3866,7 +3928,7 @@ var _WebDriverInterception = class _WebDriverInterception {
3866
3928
  "network.responseStarted"
3867
3929
  ]
3868
3930
  });
3869
- log6.info("subscribed to network events");
3931
+ log7.info("subscribed to network events");
3870
3932
  hasSubscribedToEvents = true;
3871
3933
  }
3872
3934
  const interception = await browser.networkAddIntercept({
@@ -3893,7 +3955,7 @@ var _WebDriverInterception = class _WebDriverInterception {
3893
3955
  return null;
3894
3956
  }
3895
3957
  if (/[^A-Za-z0-9+/=\s]/.test(body.value)) {
3896
- log6.warn("Invalid base64 data for request ".concat(requestId));
3958
+ log7.warn("Invalid base64 data for request ".concat(requestId));
3897
3959
  return null;
3898
3960
  }
3899
3961
  return Buffer.from(body.value, "base64");
@@ -3947,7 +4009,7 @@ var _WebDriverInterception = class _WebDriverInterception {
3947
4009
  __privateSet(this, _respondOverwrites, []);
3948
4010
  __privateSet(this, _restored, true);
3949
4011
  const handle = await __privateGet(this, _browser4).getWindowHandle();
3950
- log6.trace("Restoring mock for ".concat(handle));
4012
+ log7.trace("Restoring mock for ".concat(handle));
3951
4013
  SESSION_MOCKS[handle].delete(this);
3952
4014
  if (__privateGet(this, _mockId)) {
3953
4015
  await __privateGet(this, _browser4).networkRemoveIntercept({ intercept: __privateGet(this, _mockId) });
@@ -4240,11 +4302,11 @@ async function mock(url2, filterOptions) {
4240
4302
  }
4241
4303
 
4242
4304
  // src/commands/browser/mockClearAll.ts
4243
- import logger7 from "@wdio/logger";
4244
- var log7 = logger7("webdriverio:mockClearAll");
4305
+ import logger8 from "@wdio/logger";
4306
+ var log8 = logger8("webdriverio:mockClearAll");
4245
4307
  async function mockClearAll() {
4246
4308
  for (const [handle, mocks] of Object.entries(SESSION_MOCKS)) {
4247
- log7.trace("Clearing mocks for ".concat(handle));
4309
+ log8.trace("Clearing mocks for ".concat(handle));
4248
4310
  for (const mock2 of mocks) {
4249
4311
  mock2.clear();
4250
4312
  }
@@ -4252,11 +4314,11 @@ async function mockClearAll() {
4252
4314
  }
4253
4315
 
4254
4316
  // src/commands/browser/mockRestoreAll.ts
4255
- import logger8 from "@wdio/logger";
4256
- var log8 = logger8("webdriverio:mockRestoreAll");
4317
+ import logger9 from "@wdio/logger";
4318
+ var log9 = logger9("webdriverio:mockRestoreAll");
4257
4319
  async function mockRestoreAll() {
4258
4320
  for (const [handle, mocks] of Object.entries(SESSION_MOCKS)) {
4259
- log8.trace("Clearing mocks for ".concat(handle));
4321
+ log9.trace("Clearing mocks for ".concat(handle));
4260
4322
  for (const mock2 of mocks) {
4261
4323
  await mock2.restore();
4262
4324
  }
@@ -4272,8 +4334,8 @@ function newWindow(url2, windowName, windowFeatures) {
4272
4334
  }
4273
4335
 
4274
4336
  // src/commands/browser/newWindow.ts
4275
- import logger9 from "@wdio/logger";
4276
- var log9 = logger9("webdriverio:newWindow");
4337
+ import logger10 from "@wdio/logger";
4338
+ var log10 = logger10("webdriverio:newWindow");
4277
4339
  var WAIT_FOR_NEW_HANDLE_TIMEOUT = 3e3;
4278
4340
  async function newWindow2(url2, { type = "window", windowName = "", windowFeatures = "" } = {}) {
4279
4341
  if (typeof url2 !== "string") {
@@ -4283,7 +4345,7 @@ async function newWindow2(url2, { type = "window", windowName = "", windowFeatur
4283
4345
  throw new Error("Invalid type '".concat(type, "' provided to newWindow command. Use either 'tab' or 'window'"));
4284
4346
  }
4285
4347
  if (windowName || windowFeatures) {
4286
- log9.warn('The "windowName" and "windowFeatures" options are deprecated and only supported in WebDriver Classic sessions.');
4348
+ log10.warn('The "windowName" and "windowFeatures" options are deprecated and only supported in WebDriver Classic sessions.');
4287
4349
  }
4288
4350
  if (this.isMobile) {
4289
4351
  throw new Error("newWindow command is not supported on mobile platforms");
@@ -4388,14 +4450,14 @@ async function react$3(selector, { props = {}, state = {} } = {}) {
4388
4450
  }
4389
4451
 
4390
4452
  // src/commands/browser/reloadSession.ts
4391
- import logger12 from "@wdio/logger";
4453
+ import logger13 from "@wdio/logger";
4392
4454
 
4393
4455
  // src/session/polyfill.ts
4394
- import logger10 from "@wdio/logger";
4456
+ import logger11 from "@wdio/logger";
4395
4457
  function getPolyfillManager(browser) {
4396
4458
  return SessionManager.getSessionManager(browser, PolyfillManager);
4397
4459
  }
4398
- var log10 = logger10("webdriverio:PolyfillManager");
4460
+ var log11 = logger11("webdriverio:PolyfillManager");
4399
4461
  var _initialize, _browser5, _scriptsRegisteredInContexts, _registerScriptsListener, _PolyfillManager_instances, registerScripts_fn;
4400
4462
  var _PolyfillManager = class _PolyfillManager extends SessionManager {
4401
4463
  constructor(browser) {
@@ -4438,7 +4500,7 @@ registerScripts_fn = function(context) {
4438
4500
  return;
4439
4501
  }
4440
4502
  const functionDeclaration = createFunctionDeclarationFromString(polyfillFn);
4441
- log10.info("Adding polyfill script to context with id ".concat(context.context));
4503
+ log11.info("Adding polyfill script to context with id ".concat(context.context));
4442
4504
  __privateGet(this, _scriptsRegisteredInContexts).add(context.context);
4443
4505
  return Promise.all([
4444
4506
  !context.parent ? __privateGet(this, _browser5).scriptAddPreloadScript({
@@ -4457,7 +4519,7 @@ registerScripts_fn = function(context) {
4457
4519
  var PolyfillManager = _PolyfillManager;
4458
4520
 
4459
4521
  // src/session/shadowRoot.ts
4460
- import logger11 from "@wdio/logger";
4522
+ import logger12 from "@wdio/logger";
4461
4523
 
4462
4524
  // src/scripts/customElement.ts
4463
4525
  function customElementWrapper() {
@@ -4492,7 +4554,7 @@ function customElementWrapper() {
4492
4554
  }
4493
4555
 
4494
4556
  // src/session/shadowRoot.ts
4495
- var log11 = logger11("webdriverio:ShadowRootManager");
4557
+ var log12 = logger12("webdriverio:ShadowRootManager");
4496
4558
  function getShadowRootManager(browser) {
4497
4559
  return SessionManager.getSessionManager(browser, ShadowRootManager);
4498
4560
  }
@@ -4589,9 +4651,9 @@ var _ShadowRootManager = class _ShadowRootManager extends SessionManager {
4589
4651
  !((_b = (_a = shadowElem.value) == null ? void 0 : _a.shadowRoot) == null ? void 0 : _b.sharedId) || // we expect the shadow root to have a proper type
4590
4652
  ((_c = shadowElem.value.shadowRoot.value) == null ? void 0 : _c.nodeType) !== 11
4591
4653
  ) {
4592
- return log11.warn("Expected element with shadow root but found <".concat((_d = shadowElem.value) == null ? void 0 : _d.localName, " />"));
4654
+ return log12.warn("Expected element with shadow root but found <".concat((_d = shadowElem.value) == null ? void 0 : _d.localName, " />"));
4593
4655
  }
4594
- log11.info("Registered new shadow root for element <".concat(shadowElem.value.localName, " /> with id ").concat(shadowElem.value.shadowRoot.sharedId));
4656
+ log12.info("Registered new shadow root for element <".concat(shadowElem.value.localName, " /> with id ").concat(shadowElem.value.shadowRoot.sharedId));
4595
4657
  const newTree = new ShadowRootTree(
4596
4658
  shadowElem.sharedId,
4597
4659
  shadowElem.value.shadowRoot.sharedId,
@@ -4860,16 +4922,16 @@ _responseCompletedListener = new WeakMap();
4860
4922
  _beforeRequestSentListener = new WeakMap();
4861
4923
  _fetchErrorListener = new WeakMap();
4862
4924
  _NetworkManager_instances = new WeakSet();
4863
- beforeRequestSent_fn = function(log27) {
4925
+ beforeRequestSent_fn = function(log29) {
4864
4926
  var _a;
4865
- if (log27.navigation) {
4927
+ if (log29.navigation) {
4866
4928
  return;
4867
4929
  }
4868
- const request = __privateMethod(this, _NetworkManager_instances, findRootRequest_fn).call(this, log27.navigation);
4930
+ const request = __privateMethod(this, _NetworkManager_instances, findRootRequest_fn).call(this, log29.navigation);
4869
4931
  if (!request) {
4870
4932
  return;
4871
4933
  }
4872
- const { request: id, headers, cookies, url: url2 } = log27.request;
4934
+ const { request: id, headers, cookies, url: url2 } = log29.request;
4873
4935
  (_a = request.children) == null ? void 0 : _a.push({
4874
4936
  id,
4875
4937
  url: url2,
@@ -4885,52 +4947,52 @@ beforeRequestSent_fn = function(log27) {
4885
4947
  sameSite: cookie.sameSite,
4886
4948
  expiry: cookie.expiry
4887
4949
  })),
4888
- timestamp: log27.timestamp
4950
+ timestamp: log29.timestamp
4889
4951
  });
4890
4952
  };
4891
- navigationStarted_fn2 = function(log27) {
4953
+ navigationStarted_fn2 = function(log29) {
4892
4954
  if (
4893
4955
  /**
4894
4956
  * we need a navigation id to identify the request
4895
4957
  */
4896
- !log27.navigation || /**
4958
+ !log29.navigation || /**
4897
4959
  * ignore urls that users wouldn't navigate to
4898
4960
  */
4899
- !SUPPORTED_NAVIGATION_PROTOCOLS.some((protocol) => log27.url.startsWith(protocol))
4961
+ !SUPPORTED_NAVIGATION_PROTOCOLS.some((protocol) => log29.url.startsWith(protocol))
4900
4962
  ) {
4901
- if (log27.navigation === null && log27.url === "") {
4963
+ if (log29.navigation === null && log29.url === "") {
4902
4964
  __privateSet(this, _lastNetworkId, UNKNOWN_NAVIGATION_ID);
4903
4965
  return __privateGet(this, _requests).set(UNKNOWN_NAVIGATION_ID, {
4904
4966
  url: "",
4905
4967
  headers: {},
4906
- timestamp: log27.timestamp,
4968
+ timestamp: log29.timestamp,
4907
4969
  redirectChain: [],
4908
4970
  children: []
4909
4971
  });
4910
4972
  }
4911
4973
  return;
4912
4974
  }
4913
- __privateSet(this, _lastNetworkId, log27.navigation);
4914
- __privateGet(this, _requests).set(log27.navigation, {
4915
- url: log27.url,
4975
+ __privateSet(this, _lastNetworkId, log29.navigation);
4976
+ __privateGet(this, _requests).set(log29.navigation, {
4977
+ url: log29.url,
4916
4978
  headers: {},
4917
- timestamp: log27.timestamp,
4918
- navigation: log27.navigation,
4979
+ timestamp: log29.timestamp,
4980
+ navigation: log29.navigation,
4919
4981
  redirectChain: [],
4920
4982
  children: []
4921
4983
  });
4922
4984
  };
4923
- fetchError_fn = function(log27) {
4985
+ fetchError_fn = function(log29) {
4924
4986
  var _a;
4925
- const response = __privateMethod(this, _NetworkManager_instances, findRootRequest_fn).call(this, log27.navigation);
4987
+ const response = __privateMethod(this, _NetworkManager_instances, findRootRequest_fn).call(this, log29.navigation);
4926
4988
  if (!response) {
4927
4989
  return;
4928
4990
  }
4929
- const request = (_a = response.children) == null ? void 0 : _a.find((child) => child.id === log27.request.request);
4991
+ const request = (_a = response.children) == null ? void 0 : _a.find((child) => child.id === log29.request.request);
4930
4992
  if (!request) {
4931
4993
  return;
4932
4994
  }
4933
- request.error = log27.errorText;
4995
+ request.error = log29.errorText;
4934
4996
  };
4935
4997
  findRootRequest_fn = function(navigationId) {
4936
4998
  const response = __privateGet(this, _requests).get(navigationId || UNKNOWN_NAVIGATION_ID);
@@ -4940,23 +5002,23 @@ findRootRequest_fn = function(navigationId) {
4940
5002
  const firstRequest = __privateGet(this, _requests).values().next().value;
4941
5003
  return __privateGet(this, _lastNetworkId) ? __privateGet(this, _requests).get(__privateGet(this, _lastNetworkId)) || firstRequest : firstRequest;
4942
5004
  };
4943
- responseCompleted_fn = function(log27) {
5005
+ responseCompleted_fn = function(log29) {
4944
5006
  var _a, _b, _c;
4945
- const response = __privateMethod(this, _NetworkManager_instances, findRootRequest_fn).call(this, log27.navigation);
5007
+ const response = __privateMethod(this, _NetworkManager_instances, findRootRequest_fn).call(this, log29.navigation);
4946
5008
  if (!response) {
4947
5009
  return;
4948
5010
  }
4949
5011
  if (!response.navigation && response.url === "") {
4950
- response.url = log27.request.url;
4951
- response.navigation = log27.navigation;
5012
+ response.url = log29.request.url;
5013
+ response.navigation = log29.navigation;
4952
5014
  }
4953
- if (log27.navigation === response.navigation) {
4954
- if (response.url !== log27.response.url) {
5015
+ if (log29.navigation === response.navigation) {
5016
+ if (response.url !== log29.response.url) {
4955
5017
  (_a = response.redirectChain) == null ? void 0 : _a.push(response.url);
4956
5018
  }
4957
- response.url = log27.response.url;
4958
- const { headers: requestHeaders } = log27.request;
4959
- const { fromCache, headers: responseHeaders, mimeType, status } = log27.response;
5019
+ response.url = log29.response.url;
5020
+ const { headers: requestHeaders } = log29.request;
5021
+ const { fromCache, headers: responseHeaders, mimeType, status } = log29.response;
4960
5022
  response.headers = headerListToObject(requestHeaders), response.response = {
4961
5023
  fromCache,
4962
5024
  headers: headerListToObject(responseHeaders),
@@ -4965,15 +5027,15 @@ responseCompleted_fn = function(log27) {
4965
5027
  };
4966
5028
  return;
4967
5029
  }
4968
- const request = (_b = response.children) == null ? void 0 : _b.find((child) => child.id === log27.request.request);
5030
+ const request = (_b = response.children) == null ? void 0 : _b.find((child) => child.id === log29.request.request);
4969
5031
  if (!request) {
4970
5032
  return;
4971
5033
  }
4972
5034
  request.response = {
4973
- fromCache: log27.response.fromCache,
4974
- headers: headerListToObject(log27.response.headers),
4975
- mimeType: log27.response.mimeType,
4976
- status: log27.response.status
5035
+ fromCache: log29.response.fromCache,
5036
+ headers: headerListToObject(log29.response.headers),
5037
+ mimeType: log29.response.mimeType,
5038
+ status: log29.response.status
4977
5039
  };
4978
5040
  (_c = response.children) == null ? void 0 : _c.push(request);
4979
5041
  };
@@ -5025,12 +5087,12 @@ _initialize4 = new WeakMap();
5025
5087
  _autoHandleDialog = new WeakMap();
5026
5088
  _handleUserPromptListener = new WeakMap();
5027
5089
  _DialogManager_instances = new WeakSet();
5028
- handleUserPrompt_fn = async function(log27) {
5090
+ handleUserPrompt_fn = async function(log29) {
5029
5091
  if (__privateGet(this, _autoHandleDialog)) {
5030
5092
  try {
5031
5093
  return await __privateGet(this, _browser8).browsingContextHandleUserPrompt({
5032
5094
  accept: false,
5033
- context: log27.context
5095
+ context: log29.context
5034
5096
  });
5035
5097
  } catch (err) {
5036
5098
  if (err instanceof Error && err.message.includes("no such alert")) {
@@ -5039,7 +5101,7 @@ handleUserPrompt_fn = async function(log27) {
5039
5101
  throw err;
5040
5102
  }
5041
5103
  }
5042
- const dialog = new Dialog(log27, __privateGet(this, _browser8));
5104
+ const dialog = new Dialog(log29, __privateGet(this, _browser8));
5043
5105
  __privateGet(this, _browser8).emit("dialog", dialog);
5044
5106
  };
5045
5107
  /**
@@ -5128,7 +5190,7 @@ function registerSessionManager(instance) {
5128
5190
  }
5129
5191
 
5130
5192
  // src/commands/browser/reloadSession.ts
5131
- var log12 = logger12("webdriverio");
5193
+ var log13 = logger13("webdriverio");
5132
5194
  async function reloadSession(newCapabilities) {
5133
5195
  var _a;
5134
5196
  const oldSessionId = this.sessionId;
@@ -5136,11 +5198,11 @@ async function reloadSession(newCapabilities) {
5136
5198
  try {
5137
5199
  await this.deleteSession({ shutdownDriver });
5138
5200
  } catch (err) {
5139
- log12.warn("Suppressing error closing the session: ".concat(err.stack));
5201
+ log13.warn("Suppressing error closing the session: ".concat(err.stack));
5140
5202
  }
5141
5203
  if ((_a = this.puppeteer) == null ? void 0 : _a.connected) {
5142
5204
  this.puppeteer.disconnect();
5143
- log12.debug("Disconnected puppeteer session");
5205
+ log13.debug("Disconnected puppeteer session");
5144
5206
  }
5145
5207
  const ProtocolDriver = (await import(
5146
5208
  /* @vite-ignore */
@@ -5186,11 +5248,11 @@ async function saveScreenshot(filepath, options) {
5186
5248
  }
5187
5249
 
5188
5250
  // src/commands/browser/scroll.ts
5189
- import logger13 from "@wdio/logger";
5190
- var log13 = logger13("webdriverio");
5251
+ import logger14 from "@wdio/logger";
5252
+ var log14 = logger14("webdriverio");
5191
5253
  function scroll(x = 0, y = 0) {
5192
5254
  if (!x && !y) {
5193
- log13.warn('"scroll" command was called with no parameters, skipping execution');
5255
+ log14.warn('"scroll" command was called with no parameters, skipping execution');
5194
5256
  return Promise.resolve();
5195
5257
  }
5196
5258
  if (this.isMobile) {
@@ -5204,6 +5266,8 @@ function scroll(x = 0, y = 0) {
5204
5266
  }
5205
5267
 
5206
5268
  // src/commands/browser/setCookies.ts
5269
+ import logger15 from "@wdio/logger";
5270
+ var log15 = logger15("webdriverio");
5207
5271
  async function setCookies(cookieObjs) {
5208
5272
  const cookieObjsList = !Array.isArray(cookieObjs) ? [cookieObjs] : cookieObjs;
5209
5273
  if (cookieObjsList.some((obj) => typeof obj !== "object")) {
@@ -5213,20 +5277,36 @@ async function setCookies(cookieObjs) {
5213
5277
  await Promise.all(cookieObjsList.map((cookieObj) => this.addCookie(cookieObj)));
5214
5278
  return;
5215
5279
  }
5216
- let url2 = new URL("http://localhost");
5217
- if (cookieObjsList.some((cookie) => typeof cookie.domain !== "string")) {
5280
+ let url2;
5281
+ try {
5218
5282
  url2 = new URL(await this.getUrl());
5283
+ if (url2.origin === "null") {
5284
+ await Promise.all(cookieObjsList.map((cookieObj) => this.addCookie(cookieObj)));
5285
+ return;
5286
+ }
5287
+ } catch {
5288
+ await Promise.all(cookieObjsList.map((cookieObj) => this.addCookie(cookieObj)));
5289
+ return;
5219
5290
  }
5220
- await Promise.all(cookieObjsList.map((cookie) => this.storageSetCookie({
5221
- cookie: {
5222
- ...cookie,
5223
- domain: cookie.domain || url2.hostname,
5224
- value: {
5225
- type: "string",
5226
- value: cookie.value
5291
+ try {
5292
+ await Promise.all(cookieObjsList.map((cookie) => this.storageSetCookie({
5293
+ cookie: {
5294
+ ...cookie,
5295
+ domain: cookie.domain || url2.hostname,
5296
+ value: {
5297
+ type: "string",
5298
+ value: cookie.value
5299
+ }
5300
+ },
5301
+ partition: {
5302
+ type: "storageKey",
5303
+ sourceOrigin: url2.origin
5227
5304
  }
5228
- }
5229
- })));
5305
+ })));
5306
+ } catch (err) {
5307
+ log15.warn("BiDi setCookies failed, falling back to classic: ".concat(err.message));
5308
+ await Promise.all(cookieObjsList.map((cookieObj) => this.addCookie(cookieObj)));
5309
+ }
5230
5310
  return;
5231
5311
  }
5232
5312
 
@@ -5330,7 +5410,7 @@ async function switchWindow(matcher) {
5330
5410
  }
5331
5411
 
5332
5412
  // src/commands/browser/switchFrame.ts
5333
- import logger14 from "@wdio/logger";
5413
+ import logger16 from "@wdio/logger";
5334
5414
  import { ELEMENT_KEY as ELEMENT_KEY8 } from "webdriver";
5335
5415
 
5336
5416
  // src/scripts/shadowDom.ts
@@ -5358,7 +5438,7 @@ function findIframeInShadowDOM(fragment) {
5358
5438
  }
5359
5439
 
5360
5440
  // src/commands/browser/switchFrame.ts
5361
- var log14 = logger14("webdriverio:switchFrame");
5441
+ var log16 = logger16("webdriverio:switchFrame");
5362
5442
  async function switchFrame(context) {
5363
5443
  var _a;
5364
5444
  function isPossiblyUnresolvedElement(input) {
@@ -5398,13 +5478,13 @@ async function switchFrame(context) {
5398
5478
  const urlContextContaining = sessionContext.findContext(context, tree.contexts, "byUrlContaining");
5399
5479
  const contextIdContext = sessionContext.findContext(context, tree.contexts, "byContextId");
5400
5480
  if (urlContext) {
5401
- log14.info('Found context by url "'.concat(urlContext.url, '" with context id "').concat(urlContext.context, '"'));
5481
+ log16.info('Found context by url "'.concat(urlContext.url, '" with context id "').concat(urlContext.context, '"'));
5402
5482
  return urlContext.context;
5403
5483
  } else if (urlContextContaining) {
5404
- log14.info('Found context by url containing "'.concat(urlContextContaining.url, '" with context id "').concat(urlContextContaining.context, '"'));
5484
+ log16.info('Found context by url containing "'.concat(urlContextContaining.url, '" with context id "').concat(urlContextContaining.context, '"'));
5405
5485
  return urlContextContaining.context;
5406
5486
  } else if (contextIdContext) {
5407
- log14.info('Found context by id "'.concat(contextIdContext, '" with url "').concat(contextIdContext.url, '"'));
5487
+ log16.info('Found context by id "'.concat(contextIdContext, '" with url "').concat(contextIdContext.url, '"'));
5408
5488
  return contextIdContext.context;
5409
5489
  }
5410
5490
  return false;
@@ -5432,7 +5512,7 @@ async function switchFrame(context) {
5432
5512
  arguments: args.map((arg) => LocalValue.getArgument(arg)),
5433
5513
  target: { context: id }
5434
5514
  };
5435
- const result = await this.scriptCallFunction(params).catch((err) => log14.warn("Failed to identify frame context id: ".concat(err.message)));
5515
+ const result = await this.scriptCallFunction(params).catch((err) => log16.warn("Failed to identify frame context id: ".concat(err.message)));
5436
5516
  if (!result) {
5437
5517
  return [];
5438
5518
  }
@@ -5468,18 +5548,18 @@ async function switchFrame(context) {
5468
5548
  return this.switchFrame(iframeElement);
5469
5549
  }
5470
5550
  }
5471
- log14.warn('Shadow DOM iframe with src containing "'.concat(urlFragment, '" found, but could not be resolved into a WebdriverIO element.'));
5551
+ log16.warn('Shadow DOM iframe with src containing "'.concat(urlFragment, '" found, but could not be resolved into a WebdriverIO element.'));
5472
5552
  }
5473
5553
  let desiredFrame;
5474
5554
  let desiredContext = newContextId;
5475
5555
  const contextQueue = [];
5476
- log14.info("Available frames to switch to: ".concat(allFrames.length, ", desired context to switch: ").concat(desiredContext));
5556
+ log16.info("Available frames to switch to: ".concat(allFrames.length, ", desired context to switch: ").concat(desiredContext));
5477
5557
  while (desiredContext !== currentContext) {
5478
5558
  desiredFrame = allFrames.find(({ context: context2 }) => context2 === desiredContext);
5479
5559
  if (!desiredFrame) {
5480
5560
  break;
5481
5561
  }
5482
- log14.info(
5562
+ log16.info(
5483
5563
  contextQueue.length === 0 ? "Found desired frame with element id ".concat(desiredFrame.frameElement[ELEMENT_KEY8]) : "to switch to desired frame, we need to switch to ".concat(desiredFrame.context, " first")
5484
5564
  );
5485
5565
  contextQueue.unshift(desiredFrame);
@@ -5515,7 +5595,7 @@ async function switchFrame(context) {
5515
5595
  target: { context: contextId }
5516
5596
  };
5517
5597
  const result = await this.scriptCallFunction(params).catch((err) => {
5518
- log14.warn("switchFrame context callback threw error: ".concat(err.message));
5598
+ log16.warn("switchFrame context callback threw error: ".concat(err.message));
5519
5599
  return void 0;
5520
5600
  });
5521
5601
  if (result && result.type === "success" && result.result.type === "boolean" && result.result.value) {
@@ -5561,11 +5641,11 @@ function toggleDisableDeprecationWarning() {
5561
5641
  }
5562
5642
 
5563
5643
  // src/commands/browser/throttle.ts
5564
- import logger15 from "@wdio/logger";
5644
+ import logger17 from "@wdio/logger";
5565
5645
  import { getBrowserObject as getBrowserObject8 } from "@wdio/utils";
5566
- var log15 = logger15("webdriverio:throttle");
5646
+ var log17 = logger17("webdriverio:throttle");
5567
5647
  async function throttle(params) {
5568
- log15.warn('Command "throttle" is deprecated and will be removed with the next major version release! Use `throttleNetwork` instead.');
5648
+ log17.warn('Command "throttle" is deprecated and will be removed with the next major version release! Use `throttleNetwork` instead.');
5569
5649
  const browser = getBrowserObject8(this);
5570
5650
  await browser.throttleNetwork(params);
5571
5651
  }
@@ -5834,7 +5914,7 @@ function waitUntil(condition, {
5834
5914
  }
5835
5915
 
5836
5916
  // src/commands/mobile/swipe.ts
5837
- import logger16 from "@wdio/logger";
5917
+ import logger18 from "@wdio/logger";
5838
5918
 
5839
5919
  // src/types.ts
5840
5920
  var MobileScrollDirection = /* @__PURE__ */ ((MobileScrollDirection2) => {
@@ -5846,7 +5926,7 @@ var MobileScrollDirection = /* @__PURE__ */ ((MobileScrollDirection2) => {
5846
5926
  })(MobileScrollDirection || {});
5847
5927
 
5848
5928
  // src/commands/mobile/swipe.ts
5849
- var log16 = logger16("webdriverio");
5929
+ var log18 = logger18("webdriverio");
5850
5930
  var SWIPE_DEFAULTS = {
5851
5931
  DIRECTION: "up" /* Up */,
5852
5932
  DURATION: 1500,
@@ -5859,7 +5939,7 @@ async function swipe(options) {
5859
5939
  }
5860
5940
  let { scrollableElement, from, to } = options || {};
5861
5941
  if (scrollableElement && (from || to)) {
5862
- log16.warn("`scrollableElement` is provided, so `from` and `to` will be ignored.");
5942
+ log18.warn("`scrollableElement` is provided, so `from` and `to` will be ignored.");
5863
5943
  }
5864
5944
  if (!from || !to) {
5865
5945
  scrollableElement = scrollableElement || await getScrollableElement(browser);
@@ -5881,9 +5961,9 @@ async function calculateFromTo({
5881
5961
  let swipePercentage = SWIPE_DEFAULTS.PERCENT;
5882
5962
  if (percentage !== void 0) {
5883
5963
  if (isNaN(percentage)) {
5884
- log16.warn("The percentage to swipe should be a number.");
5964
+ log18.warn("The percentage to swipe should be a number.");
5885
5965
  } else if (percentage < 0 || percentage > 1) {
5886
- log16.warn("The percentage to swipe should be a number between 0 and 1.");
5966
+ log18.warn("The percentage to swipe should be a number between 0 and 1.");
5887
5967
  } else {
5888
5968
  swipePercentage = percentage;
5889
5969
  }
@@ -5949,9 +6029,9 @@ async function w3cSwipe({ browser, duration, from, to }) {
5949
6029
  }
5950
6030
 
5951
6031
  // src/commands/mobile/tap.ts
5952
- import logger17 from "@wdio/logger";
6032
+ import logger19 from "@wdio/logger";
5953
6033
  import { getBrowserObject as getBrowserObject11 } from "@wdio/utils";
5954
- var log17 = logger17("webdriver");
6034
+ var log19 = logger19("webdriver");
5955
6035
  async function tap(options) {
5956
6036
  const isElement2 = this.selector !== void 0;
5957
6037
  const element = isElement2 ? this : null;
@@ -5997,7 +6077,7 @@ async function elementTap(browser, element, options) {
5997
6077
  return await nativeTap(element, browser, options);
5998
6078
  }
5999
6079
  if (options) {
6000
- log17.warn("The options object is not supported in Web environments and will be ignored.");
6080
+ log19.warn("The options object is not supported in Web environments and will be ignored.");
6001
6081
  }
6002
6082
  return await webTap(element);
6003
6083
  }
@@ -6064,8 +6144,8 @@ async function screenTap(browser, options) {
6064
6144
  }
6065
6145
 
6066
6146
  // src/commands/mobile/getContext.ts
6067
- import logger18 from "@wdio/logger";
6068
- var log18 = logger18("webdriver");
6147
+ import logger20 from "@wdio/logger";
6148
+ var log20 = logger20("webdriver");
6069
6149
  async function getContext(options) {
6070
6150
  const browser = this;
6071
6151
  if (!browser.isMobile) {
@@ -6093,25 +6173,25 @@ async function getDetailedContext(browser, currentAppiumContext, options) {
6093
6173
  });
6094
6174
  const parsedContexts = detailedContexts.filter((context) => context.id === currentAppiumContext);
6095
6175
  if (parsedContexts.length > 1) {
6096
- log18.warn("We found more than 1 detailed context for the current context '".concat(currentAppiumContext, "'. We will return the first context."));
6176
+ log20.warn("We found more than 1 detailed context for the current context '".concat(currentAppiumContext, "'. We will return the first context."));
6097
6177
  return parsedContexts[0];
6098
6178
  } else if (parsedContexts.length === 0) {
6099
- log18.warn("We did not get back any detailed context for the current context '".concat(currentAppiumContext, "'. We will return the current context as a string."));
6179
+ log20.warn("We did not get back any detailed context for the current context '".concat(currentAppiumContext, "'. We will return the current context as a string."));
6100
6180
  return currentAppiumContext;
6101
6181
  }
6102
6182
  return parsedContexts[0];
6103
6183
  }
6104
6184
 
6105
6185
  // src/commands/mobile/getContexts.ts
6106
- import logger19 from "@wdio/logger";
6107
- var log19 = logger19("webdriver");
6186
+ import logger21 from "@wdio/logger";
6187
+ var log21 = logger21("webdriver");
6108
6188
  async function getContexts(options) {
6109
6189
  const browser = this;
6110
6190
  if (!browser.isMobile) {
6111
6191
  throw new Error("The `getContexts` command is only available for mobile platforms.");
6112
6192
  }
6113
6193
  if (!options || !options.returnDetailedContexts) {
6114
- log19.info("The standard Appium `contexts` method is used. If you want to get more detailed data, you can set `returnDetailedContexts` to `true`.");
6194
+ log21.info("The standard Appium `contexts` method is used. If you want to get more detailed data, you can set `returnDetailedContexts` to `true`.");
6115
6195
  return browser.getAppiumContexts();
6116
6196
  }
6117
6197
  const defaultOptions = {
@@ -6241,8 +6321,8 @@ async function getCurrentContexts({
6241
6321
  }
6242
6322
 
6243
6323
  // src/commands/mobile/switchContext.ts
6244
- import logger20 from "@wdio/logger";
6245
- var log20 = logger20("webdriver");
6324
+ import logger22 from "@wdio/logger";
6325
+ var log22 = logger22("webdriver");
6246
6326
  async function switchContext(options) {
6247
6327
  const browser = this;
6248
6328
  if (!browser.isMobile) {
@@ -6252,7 +6332,7 @@ async function switchContext(options) {
6252
6332
  throw new Error("You need to provide at least a context name to switch to. See https://webdriver.io/docs/api/mobile/switchContext for more information.");
6253
6333
  }
6254
6334
  if (typeof options === "string") {
6255
- log20.info("The standard Appium `context`-method is used. If you want to switch to a webview with a specific title or url, please provide an object with the `title` or `url` property. See https://webdriver.io/docs/api/mobile/switchContext for more information.");
6335
+ log22.info("The standard Appium `context`-method is used. If you want to switch to a webview with a specific title or url, please provide an object with the `title` or `url` property. See https://webdriver.io/docs/api/mobile/switchContext for more information.");
6256
6336
  return browser.switchAppiumContext(options);
6257
6337
  }
6258
6338
  if (!options.title && !options.url) {
@@ -6281,7 +6361,7 @@ async function switchToContext({ browser, options }) {
6281
6361
  if (!matchingContext) {
6282
6362
  throw new Error(reasons.join("\n"));
6283
6363
  }
6284
- log20.info("WebdriverIO found a matching context:", JSON.stringify(matchingContext, null, 2));
6364
+ log22.info("WebdriverIO found a matching context:", JSON.stringify(matchingContext, null, 2));
6285
6365
  if (!browser.isIOS) {
6286
6366
  const webviewName = "WEBVIEW_".concat(identifier);
6287
6367
  await browser.switchAppiumContext(webviewName);
@@ -6460,9 +6540,9 @@ function clearValue() {
6460
6540
  }
6461
6541
 
6462
6542
  // src/commands/element/click.ts
6463
- import logger21 from "@wdio/logger";
6543
+ import logger23 from "@wdio/logger";
6464
6544
  import { getBrowserObject as getBrowserObject12 } from "@wdio/utils";
6465
- var log21 = logger21("webdriver");
6545
+ var log23 = logger23("webdriver");
6466
6546
  function click(options) {
6467
6547
  if (typeof options !== "undefined") {
6468
6548
  if (typeof options !== "object" || Array.isArray(options)) {
@@ -6509,10 +6589,10 @@ async function actionClick(element, options) {
6509
6589
  if (x || y) {
6510
6590
  const { width, height } = await browser.getElementRect(element.elementId);
6511
6591
  if (x && x < -Math.floor(width / 2) || x && x > Math.floor(width / 2)) {
6512
- log21.warn("x would cause a out of bounds error as it goes outside of element");
6592
+ log23.warn("x would cause a out of bounds error as it goes outside of element");
6513
6593
  }
6514
6594
  if (y && y < -Math.floor(height / 2) || y && y > Math.floor(height / 2)) {
6515
- log21.warn("y would cause a out of bounds error as it goes outside of element");
6595
+ log23.warn("y would cause a out of bounds error as it goes outside of element");
6516
6596
  }
6517
6597
  }
6518
6598
  const clickNested = async () => {
@@ -6874,10 +6954,8 @@ function sanitizeHTML($3, options = {}) {
6874
6954
 
6875
6955
  // src/commands/element/getLocation.ts
6876
6956
  async function getLocation(prop) {
6877
- let location = {};
6878
- location = await getElementRect(this);
6879
- delete location.width;
6880
- delete location.height;
6957
+ const { x, y } = await getElementRect(this);
6958
+ const location = { x, y };
6881
6959
  if (prop === "x" || prop === "y") {
6882
6960
  return location[prop];
6883
6961
  }
@@ -7404,18 +7482,18 @@ async function isStable() {
7404
7482
  }
7405
7483
 
7406
7484
  // src/commands/element/moveTo.ts
7407
- import logger22 from "@wdio/logger";
7485
+ import logger24 from "@wdio/logger";
7408
7486
  import { getBrowserObject as getBrowserObject26 } from "@wdio/utils";
7409
- var log22 = logger22("webdriver");
7487
+ var log24 = logger24("webdriver");
7410
7488
  async function moveTo({ xOffset, yOffset } = {}) {
7411
7489
  const browser = getBrowserObject26(this);
7412
7490
  if (xOffset || yOffset) {
7413
7491
  const { width, height } = await browser.getElementRect(this.elementId);
7414
7492
  if (xOffset && xOffset < -Math.floor(width / 2) || xOffset && xOffset > Math.floor(width / 2)) {
7415
- log22.warn("xOffset would cause a out of bounds error as it goes outside of element");
7493
+ log24.warn("xOffset would cause a out of bounds error as it goes outside of element");
7416
7494
  }
7417
7495
  if (yOffset && yOffset < -Math.floor(height / 2) || yOffset && yOffset > Math.floor(height / 2)) {
7418
- log22.warn("yOffset would cause a out of bounds error as it goes outside of element");
7496
+ log24.warn("yOffset would cause a out of bounds error as it goes outside of element");
7419
7497
  }
7420
7498
  }
7421
7499
  const moveToNested = async () => {
@@ -7499,10 +7577,10 @@ async function saveScreenshot2(filepath) {
7499
7577
  }
7500
7578
 
7501
7579
  // src/commands/element/scrollIntoView.ts
7502
- import logger23 from "@wdio/logger";
7580
+ import logger25 from "@wdio/logger";
7503
7581
  import { ELEMENT_KEY as ELEMENT_KEY17 } from "webdriver";
7504
7582
  import { getBrowserObject as getBrowserObject29 } from "@wdio/utils";
7505
- var log23 = logger23("webdriverio");
7583
+ var log25 = logger25("webdriverio");
7506
7584
  async function scrollIntoView(options = { block: "start", inline: "nearest" }) {
7507
7585
  const browser = getBrowserObject29(this);
7508
7586
  if (browser.isMobile) {
@@ -7555,7 +7633,7 @@ async function scrollIntoView(options = { block: "start", inline: "nearest" }) {
7555
7633
  deltaY = Math.round(deltaY - scrollY);
7556
7634
  await browser.action("wheel").scroll({ duration: 0, x: deltaX, y: deltaY, origin: this }).perform();
7557
7635
  } catch (err) {
7558
- log23.warn(
7636
+ log25.warn(
7559
7637
  'Failed to execute "scrollIntoView" using WebDriver Actions API: '.concat(err.message, "!\n") + "Re-attempting using `Element.scrollIntoView` via Web API."
7560
7638
  );
7561
7639
  await scrollIntoViewWeb.call(this, options);
@@ -7706,7 +7784,7 @@ async function setValue(value, options) {
7706
7784
  }
7707
7785
 
7708
7786
  // src/commands/element/shadow$$.ts
7709
- import logger24 from "@wdio/logger";
7787
+ import logger26 from "@wdio/logger";
7710
7788
  import { getBrowserObject as getBrowserObject30 } from "@wdio/utils";
7711
7789
  import { SHADOW_ELEMENT_KEY } from "webdriver";
7712
7790
 
@@ -8042,7 +8120,7 @@ var createRoleBaseXpathSelector = (role) => {
8042
8120
  };
8043
8121
 
8044
8122
  // src/commands/element/shadow$$.ts
8045
- var log24 = logger24("webdriverio");
8123
+ var log26 = logger26("webdriverio");
8046
8124
  async function shadow$$(selector) {
8047
8125
  const browser = getBrowserObject30(this);
8048
8126
  try {
@@ -8052,7 +8130,7 @@ async function shadow$$(selector) {
8052
8130
  const elements = await getElements.call(this, selector, res, { isShadowElement: true });
8053
8131
  return enhanceElementsArray(elements, this, selector);
8054
8132
  } catch (err) {
8055
- log24.warn(
8133
+ log26.warn(
8056
8134
  "Failed to fetch element within shadow DOM using WebDriver command: ".concat(err.message, "!\n") + "Falling back to JavaScript shim."
8057
8135
  );
8058
8136
  return await this.$$(shadowFnFactory(selector, true));
@@ -8060,10 +8138,10 @@ async function shadow$$(selector) {
8060
8138
  }
8061
8139
 
8062
8140
  // src/commands/element/shadow$.ts
8063
- import logger25 from "@wdio/logger";
8141
+ import logger27 from "@wdio/logger";
8064
8142
  import { SHADOW_ELEMENT_KEY as SHADOW_ELEMENT_KEY2 } from "webdriver";
8065
8143
  import { getBrowserObject as getBrowserObject31 } from "@wdio/utils";
8066
- var log25 = logger25("webdriverio");
8144
+ var log27 = logger27("webdriverio");
8067
8145
  async function shadow$(selector) {
8068
8146
  const browser = getBrowserObject31(this);
8069
8147
  try {
@@ -8072,7 +8150,7 @@ async function shadow$(selector) {
8072
8150
  const res = await browser.findElementFromShadowRoot(shadowRoot[SHADOW_ELEMENT_KEY2], using, value);
8073
8151
  return getElement.call(this, selector, res, { isShadowElement: true });
8074
8152
  } catch (err) {
8075
- log25.warn(
8153
+ log27.warn(
8076
8154
  "Failed to fetch element within shadow DOM using WebDriver command: ".concat(err.message, "!\n") + "Falling back to JavaScript shim."
8077
8155
  );
8078
8156
  return this.$(shadowFnFactory(selector));
@@ -8092,8 +8170,9 @@ async function waitForClickable({
8092
8170
  reverse = false,
8093
8171
  timeoutMsg = 'element ("'.concat(this.selector, '") still ').concat(reverse ? "" : "not ", "clickable after ").concat(timeout, "ms")
8094
8172
  } = {}) {
8173
+ var _a;
8095
8174
  const browser = getBrowserObject32(this);
8096
- if (browser.isMobile && browser.isNativeContext) {
8175
+ if (browser.isMobile && browser.isNativeContext && !((_a = browser.capabilities) == null ? void 0 : _a.browserName)) {
8097
8176
  throw new Error("The `waitForClickable` command is only available for desktop and mobile browsers.");
8098
8177
  }
8099
8178
  return this.waitUntil(
@@ -8505,7 +8584,7 @@ function querySelectorAllDeep(findMany, s, r) {
8505
8584
  }
8506
8585
 
8507
8586
  // src/utils/index.ts
8508
- var log26 = logger26("webdriverio");
8587
+ var log28 = logger28("webdriverio");
8509
8588
  var INVALID_SELECTOR_ERROR = "selector needs to be typeof `string` or `function`";
8510
8589
  var IGNORED_COMMAND_FILE_EXPORTS = ["SESSION_MOCKS", "CDP_SESSIONS"];
8511
8590
  var scopes = {
@@ -8678,7 +8757,7 @@ async function findDeepElement(selector) {
8678
8757
  })).then((elems) => elems.filter(([isIn]) => isIn).map(([, elem]) => elem));
8679
8758
  return scopedNodes[0];
8680
8759
  }, (err) => {
8681
- log26.warn("Failed to execute browser.browsingContextLocateNodes({ ... }) due to ".concat(err, ", falling back to regular WebDriver Classic command"));
8760
+ log28.warn("Failed to execute browser.browsingContextLocateNodes({ ... }) due to ".concat(err, ", falling back to regular WebDriver Classic command"));
8682
8761
  return this && "elementId" in this && this.elementId ? this.findElementFromElement(this.elementId, using, value) : browser.findElement(using, value);
8683
8762
  });
8684
8763
  return deepElementResult;
@@ -8717,7 +8796,7 @@ async function findDeepElements(selector) {
8717
8796
  })).then((elems) => elems.filter(([isIn]) => isIn).map(([, elem]) => elem));
8718
8797
  return scopedNodes;
8719
8798
  }, (err) => {
8720
- log26.warn("Failed to execute browser.browsingContextLocateNodes({ ... }) due to ".concat(err, ", falling back to regular WebDriver Classic command"));
8799
+ log28.warn("Failed to execute browser.browsingContextLocateNodes({ ... }) due to ".concat(err, ", falling back to regular WebDriver Classic command"));
8721
8800
  return this && "elementId" in this && this.elementId ? this.findElementsFromElement(this.elementId, using, value) : browser.findElements(using, value);
8722
8801
  });
8723
8802
  return deepElementResult;
@@ -8851,7 +8930,7 @@ async function getElementRect(scope) {
8851
8930
  if (rectJs && typeof rectJs[key] === "number") {
8852
8931
  rect[key] = Math.floor(rectJs[key]);
8853
8932
  } else {
8854
- log26.error("getElementRect", { rect, rectJs, key });
8933
+ log28.error("getElementRect", { rect, rectJs, key });
8855
8934
  throw new Error("Failed to receive element rects via execute command");
8856
8935
  }
8857
8936
  });
@@ -9297,7 +9376,7 @@ var remote = async function(params, remoteModifier) {
9297
9376
  const keysToKeep = Object.keys(environment.value.variables.WDIO_WORKER_ID ? params : DEFAULTS);
9298
9377
  const config = validateConfig(WDIO_DEFAULTS, params, keysToKeep);
9299
9378
  await enableFileLogging(config.outputDir);
9300
- logger27.setLogLevelsConfig(config.logLevels, config.logLevel);
9379
+ logger29.setLogLevelsConfig(config.logLevels, config.logLevel);
9301
9380
  const modifier = (client, options2) => {
9302
9381
  Object.assign(options2, Object.entries(config).reduce((a, [k, v]) => typeof v === "undefined" ? a : { ...a, [k]: v }, {}));
9303
9382
  if (typeof remoteModifier === "function") {