webdriverio 9.23.2 → 9.24.0
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/deleteCookies.d.ts.map +1 -1
- package/build/commands/browser/getCookies.d.ts.map +1 -1
- package/build/commands/browser/savePDF.d.ts +2 -2
- package/build/commands/browser/savePDF.d.ts.map +1 -1
- package/build/commands/browser/setCookies.d.ts.map +1 -1
- package/build/commands/element/getAttribute.d.ts +1 -1
- package/build/commands/element/getAttribute.d.ts.map +1 -1
- package/build/commands/element/getLocation.d.ts +27 -1
- package/build/commands/element/getLocation.d.ts.map +1 -1
- package/build/commands/element/getSize.d.ts +27 -1
- package/build/commands/element/getSize.d.ts.map +1 -1
- package/build/commands/element/getValue.d.ts +1 -1
- package/build/commands/element/getValue.d.ts.map +1 -1
- package/build/commands/element/waitForClickable.d.ts.map +1 -1
- package/build/index.js +253 -174
- package/build/node/savePDF.d.ts +1 -1
- package/build/node/savePDF.d.ts.map +1 -1
- package/build/node.js +249 -171
- package/build/types.d.ts +8 -3
- package/build/types.d.ts.map +1 -1
- package/package.json +7 -7
package/build/node.js
CHANGED
|
@@ -616,7 +616,7 @@ async function saveElementScreenshot(filepath) {
|
|
|
616
616
|
}
|
|
617
617
|
|
|
618
618
|
// src/index.ts
|
|
619
|
-
import
|
|
619
|
+
import logger30 from "@wdio/logger";
|
|
620
620
|
import WebDriver, { DEFAULTS } from "webdriver";
|
|
621
621
|
import { validateConfig } from "@wdio/config";
|
|
622
622
|
import { enableFileLogging, wrapCommand as wrapCommand3, isBidi } from "@wdio/utils";
|
|
@@ -689,7 +689,7 @@ async function refetchElement(currentElement, commandName) {
|
|
|
689
689
|
import cssValue from "css-value";
|
|
690
690
|
import rgb2hex from "rgb2hex";
|
|
691
691
|
import GraphemeSplitter from "grapheme-splitter";
|
|
692
|
-
import
|
|
692
|
+
import logger29 from "@wdio/logger";
|
|
693
693
|
import isPlainObject from "is-plain-obj";
|
|
694
694
|
import { ELEMENT_KEY as ELEMENT_KEY20 } from "webdriver";
|
|
695
695
|
import { UNICODE_CHARACTERS as UNICODE_CHARACTERS2, asyncIterators, getBrowserObject as getBrowserObject38 } from "@wdio/utils";
|
|
@@ -1685,40 +1685,75 @@ function debug(commandTimeout = 5e3) {
|
|
|
1685
1685
|
}
|
|
1686
1686
|
|
|
1687
1687
|
// src/commands/browser/deleteCookies.ts
|
|
1688
|
+
import logger4 from "@wdio/logger";
|
|
1689
|
+
var log4 = logger4("webdriverio");
|
|
1688
1690
|
async function deleteCookies(filter) {
|
|
1689
1691
|
const filterArray = typeof filter === "undefined" ? void 0 : Array.isArray(filter) ? filter : [filter];
|
|
1690
1692
|
if (!this.isBidi) {
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1693
|
+
await deleteCookiesClassic.call(this, getNamesForClassic(filterArray));
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
let url2;
|
|
1697
|
+
try {
|
|
1698
|
+
url2 = new URL(await this.getUrl());
|
|
1699
|
+
if (url2.origin === "null") {
|
|
1700
|
+
await deleteCookiesClassic.call(this, getNamesForClassic(filterArray));
|
|
1701
|
+
return;
|
|
1702
|
+
}
|
|
1703
|
+
} catch {
|
|
1704
|
+
await deleteCookiesClassic.call(this, getNamesForClassic(filterArray));
|
|
1705
|
+
return;
|
|
1706
|
+
}
|
|
1707
|
+
const partition = {
|
|
1708
|
+
type: "storageKey",
|
|
1709
|
+
sourceOrigin: url2.origin
|
|
1710
|
+
};
|
|
1711
|
+
try {
|
|
1712
|
+
const { cookies } = await this.storageGetCookies({ partition });
|
|
1713
|
+
if (cookies.length === 0 && !this.isMobile) {
|
|
1714
|
+
await deleteCookiesClassic.call(this, getNamesForClassic(filterArray));
|
|
1715
|
+
return;
|
|
1716
|
+
}
|
|
1717
|
+
} catch (err) {
|
|
1718
|
+
log4.warn(`BiDi deleteCookies check failed, falling back to classic: ${err.message}`);
|
|
1719
|
+
await deleteCookiesClassic.call(this, getNamesForClassic(filterArray));
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
try {
|
|
1723
|
+
if (!filterArray) {
|
|
1724
|
+
await this.storageDeleteCookies({ partition });
|
|
1725
|
+
return;
|
|
1726
|
+
}
|
|
1727
|
+
const bidiFilter = filterArray.map((f) => {
|
|
1699
1728
|
if (typeof f === "string") {
|
|
1729
|
+
return { name: f };
|
|
1730
|
+
}
|
|
1731
|
+
if (typeof f === "object") {
|
|
1700
1732
|
return f;
|
|
1701
1733
|
}
|
|
1702
1734
|
throw new Error(`Invalid value for cookie filter, expected 'string' or 'remote.StorageCookieFilter' but found "${typeof f}"`);
|
|
1703
1735
|
});
|
|
1704
|
-
await
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
await this.storageDeleteCookies({});
|
|
1709
|
-
return;
|
|
1736
|
+
await Promise.all(bidiFilter.map((filter2) => this.storageDeleteCookies({ filter: filter2, partition })));
|
|
1737
|
+
} catch (err) {
|
|
1738
|
+
log4.warn(`BiDi deleteCookies failed, falling back to classic: ${err.message}`);
|
|
1739
|
+
await deleteCookiesClassic.call(this, getNamesForClassic(filterArray));
|
|
1710
1740
|
}
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1741
|
+
return;
|
|
1742
|
+
}
|
|
1743
|
+
function getNamesForClassic(filterArray) {
|
|
1744
|
+
return filterArray?.map((f) => {
|
|
1715
1745
|
if (typeof f === "object") {
|
|
1746
|
+
const name = f.name;
|
|
1747
|
+
if (!name) {
|
|
1748
|
+
throw new Error("In WebDriver Classic you can only filter for cookie names");
|
|
1749
|
+
}
|
|
1750
|
+
return name;
|
|
1751
|
+
}
|
|
1752
|
+
if (typeof f === "string") {
|
|
1716
1753
|
return f;
|
|
1717
1754
|
}
|
|
1718
1755
|
throw new Error(`Invalid value for cookie filter, expected 'string' or 'remote.StorageCookieFilter' but found "${typeof f}"`);
|
|
1719
1756
|
});
|
|
1720
|
-
await Promise.all(bidiFilter.map((filter2) => this.storageDeleteCookies({ filter: filter2 })));
|
|
1721
|
-
return;
|
|
1722
1757
|
}
|
|
1723
1758
|
function deleteCookiesClassic(names) {
|
|
1724
1759
|
if (names === void 0) {
|
|
@@ -1737,8 +1772,8 @@ async function downloadFile2(fileName, targetDirectory) {
|
|
|
1737
1772
|
}
|
|
1738
1773
|
|
|
1739
1774
|
// src/clock.ts
|
|
1740
|
-
import
|
|
1741
|
-
var
|
|
1775
|
+
import logger5 from "@wdio/logger";
|
|
1776
|
+
var log5 = logger5("webdriverio:ClockManager");
|
|
1742
1777
|
function installFakeTimers(options) {
|
|
1743
1778
|
window.__clock = window.__wdio_sinon.install(options);
|
|
1744
1779
|
}
|
|
@@ -1762,7 +1797,7 @@ var ClockManager = class {
|
|
|
1762
1797
|
*/
|
|
1763
1798
|
async install(options) {
|
|
1764
1799
|
if (this.#isInstalled) {
|
|
1765
|
-
return
|
|
1800
|
+
return log5.warn("Fake timers are already installed");
|
|
1766
1801
|
}
|
|
1767
1802
|
if (globalThis.window) {
|
|
1768
1803
|
return;
|
|
@@ -3666,19 +3701,46 @@ async function executeAsync(script, ...args) {
|
|
|
3666
3701
|
}
|
|
3667
3702
|
|
|
3668
3703
|
// src/commands/browser/getCookies.ts
|
|
3669
|
-
import
|
|
3670
|
-
var
|
|
3704
|
+
import logger6 from "@wdio/logger";
|
|
3705
|
+
var log6 = logger6("webdriverio");
|
|
3671
3706
|
async function getCookies(filter) {
|
|
3672
3707
|
const usesMultipleFilter = Array.isArray(filter) && filter.length > 1;
|
|
3673
3708
|
if (!this.isBidi || usesMultipleFilter) {
|
|
3674
3709
|
return getCookiesClassic.call(this, filter);
|
|
3675
3710
|
}
|
|
3676
3711
|
const cookieFilter = getCookieFilter(filter);
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3712
|
+
let url2;
|
|
3713
|
+
try {
|
|
3714
|
+
url2 = new URL(await this.getUrl());
|
|
3715
|
+
if (url2.origin === "null") {
|
|
3716
|
+
return getCookiesClassic.call(this, filter);
|
|
3717
|
+
}
|
|
3718
|
+
} catch {
|
|
3719
|
+
return getCookiesClassic.call(this, filter);
|
|
3720
|
+
}
|
|
3721
|
+
const params = {
|
|
3722
|
+
partition: {
|
|
3723
|
+
type: "storageKey",
|
|
3724
|
+
sourceOrigin: url2.origin
|
|
3725
|
+
}
|
|
3726
|
+
};
|
|
3727
|
+
if (typeof cookieFilter !== "undefined") {
|
|
3728
|
+
params.filter = cookieFilter;
|
|
3729
|
+
}
|
|
3730
|
+
try {
|
|
3731
|
+
const { cookies } = await this.storageGetCookies(params);
|
|
3732
|
+
if (cookies.length === 0) {
|
|
3733
|
+
log6.debug("BiDi getCookies returned empty, falling back to classic");
|
|
3734
|
+
return getCookiesClassic.call(this, filter);
|
|
3735
|
+
}
|
|
3736
|
+
return cookies.map((cookie) => ({
|
|
3737
|
+
...cookie,
|
|
3738
|
+
value: cookie.value.type === "base64" ? Buffer.from(cookie.value.value, "base64").toString("utf-8") : cookie.value.value
|
|
3739
|
+
}));
|
|
3740
|
+
} catch (err) {
|
|
3741
|
+
log6.warn(`BiDi getCookies failed, falling back to classic: ${err.message}`);
|
|
3742
|
+
return getCookiesClassic.call(this, filter);
|
|
3743
|
+
}
|
|
3682
3744
|
}
|
|
3683
3745
|
async function getCookiesClassic(names) {
|
|
3684
3746
|
if (!names) {
|
|
@@ -3686,7 +3748,7 @@ async function getCookiesClassic(names) {
|
|
|
3686
3748
|
}
|
|
3687
3749
|
const usesMultipleFilter = Array.isArray(names) && names.length > 1;
|
|
3688
3750
|
if (usesMultipleFilter) {
|
|
3689
|
-
|
|
3751
|
+
log6.warn(
|
|
3690
3752
|
"Passing a string array as filter for `getCookies` is deprecated and its support will be removed in an upcoming version of WebdriverIO!"
|
|
3691
3753
|
);
|
|
3692
3754
|
const allCookies2 = await this.getAllCookies();
|
|
@@ -3705,7 +3767,7 @@ function getCookieFilter(names) {
|
|
|
3705
3767
|
}
|
|
3706
3768
|
return (Array.isArray(names) ? names : [names]).map((filter) => {
|
|
3707
3769
|
if (typeof filter === "string") {
|
|
3708
|
-
|
|
3770
|
+
log6.warn("Passing string values into `getCookie` is deprecated and its support will be removed in an upcoming version of WebdriverIO!");
|
|
3709
3771
|
return { name: filter };
|
|
3710
3772
|
}
|
|
3711
3773
|
return filter;
|
|
@@ -3713,9 +3775,9 @@ function getCookieFilter(names) {
|
|
|
3713
3775
|
}
|
|
3714
3776
|
|
|
3715
3777
|
// src/commands/browser/getPuppeteer.ts
|
|
3716
|
-
import
|
|
3778
|
+
import logger7 from "@wdio/logger";
|
|
3717
3779
|
import { userImport } from "@wdio/utils";
|
|
3718
|
-
var
|
|
3780
|
+
var log7 = logger7("webdriverio");
|
|
3719
3781
|
var DEBUG_PIPE_FLAG = "remote-debugging-pipe";
|
|
3720
3782
|
async function getPuppeteer() {
|
|
3721
3783
|
if (globalThis.wdio) {
|
|
@@ -3728,7 +3790,7 @@ async function getPuppeteer() {
|
|
|
3728
3790
|
);
|
|
3729
3791
|
}
|
|
3730
3792
|
if (this.puppeteer?.connected) {
|
|
3731
|
-
|
|
3793
|
+
log7.debug("Reusing existing puppeteer session");
|
|
3732
3794
|
return this.puppeteer;
|
|
3733
3795
|
}
|
|
3734
3796
|
const { headers } = this.options;
|
|
@@ -3838,7 +3900,7 @@ async function keys(value) {
|
|
|
3838
3900
|
import { getBrowserObject as getBrowserObject7 } from "@wdio/utils";
|
|
3839
3901
|
|
|
3840
3902
|
// src/utils/interception/index.ts
|
|
3841
|
-
import
|
|
3903
|
+
import logger8 from "@wdio/logger";
|
|
3842
3904
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3843
3905
|
|
|
3844
3906
|
// src/utils/Timer.ts
|
|
@@ -4009,7 +4071,7 @@ function getPatternParam(pattern, key) {
|
|
|
4009
4071
|
}
|
|
4010
4072
|
|
|
4011
4073
|
// src/utils/interception/index.ts
|
|
4012
|
-
var
|
|
4074
|
+
var log8 = logger8("WebDriverInterception");
|
|
4013
4075
|
var hasSubscribedToEvents = false;
|
|
4014
4076
|
var WebDriverInterception = class _WebDriverInterception {
|
|
4015
4077
|
#pattern;
|
|
@@ -4039,7 +4101,7 @@ var WebDriverInterception = class _WebDriverInterception {
|
|
|
4039
4101
|
"network.responseStarted"
|
|
4040
4102
|
]
|
|
4041
4103
|
});
|
|
4042
|
-
|
|
4104
|
+
log8.info("subscribed to network events");
|
|
4043
4105
|
hasSubscribedToEvents = true;
|
|
4044
4106
|
}
|
|
4045
4107
|
const interception = await browser.networkAddIntercept({
|
|
@@ -4165,7 +4227,7 @@ var WebDriverInterception = class _WebDriverInterception {
|
|
|
4165
4227
|
return null;
|
|
4166
4228
|
}
|
|
4167
4229
|
if (/[^A-Za-z0-9+/=\s]/.test(body.value)) {
|
|
4168
|
-
|
|
4230
|
+
log8.warn(`Invalid base64 data for request ${requestId}`);
|
|
4169
4231
|
return null;
|
|
4170
4232
|
}
|
|
4171
4233
|
return Buffer.from(body.value, "base64");
|
|
@@ -4263,7 +4325,7 @@ var WebDriverInterception = class _WebDriverInterception {
|
|
|
4263
4325
|
this.#respondOverwrites = [];
|
|
4264
4326
|
this.#restored = true;
|
|
4265
4327
|
const handle = await this.#browser.getWindowHandle();
|
|
4266
|
-
|
|
4328
|
+
log8.trace(`Restoring mock for ${handle}`);
|
|
4267
4329
|
SESSION_MOCKS[handle].delete(this);
|
|
4268
4330
|
if (this.#mockId) {
|
|
4269
4331
|
await this.#browser.networkRemoveIntercept({ intercept: this.#mockId });
|
|
@@ -4404,11 +4466,11 @@ async function mock(url2, filterOptions) {
|
|
|
4404
4466
|
}
|
|
4405
4467
|
|
|
4406
4468
|
// src/commands/browser/mockClearAll.ts
|
|
4407
|
-
import
|
|
4408
|
-
var
|
|
4469
|
+
import logger9 from "@wdio/logger";
|
|
4470
|
+
var log9 = logger9("webdriverio:mockClearAll");
|
|
4409
4471
|
async function mockClearAll() {
|
|
4410
4472
|
for (const [handle, mocks] of Object.entries(SESSION_MOCKS)) {
|
|
4411
|
-
|
|
4473
|
+
log9.trace(`Clearing mocks for ${handle}`);
|
|
4412
4474
|
for (const mock2 of mocks) {
|
|
4413
4475
|
mock2.clear();
|
|
4414
4476
|
}
|
|
@@ -4416,11 +4478,11 @@ async function mockClearAll() {
|
|
|
4416
4478
|
}
|
|
4417
4479
|
|
|
4418
4480
|
// src/commands/browser/mockRestoreAll.ts
|
|
4419
|
-
import
|
|
4420
|
-
var
|
|
4481
|
+
import logger10 from "@wdio/logger";
|
|
4482
|
+
var log10 = logger10("webdriverio:mockRestoreAll");
|
|
4421
4483
|
async function mockRestoreAll() {
|
|
4422
4484
|
for (const [handle, mocks] of Object.entries(SESSION_MOCKS)) {
|
|
4423
|
-
|
|
4485
|
+
log10.trace(`Clearing mocks for ${handle}`);
|
|
4424
4486
|
for (const mock2 of mocks) {
|
|
4425
4487
|
await mock2.restore();
|
|
4426
4488
|
}
|
|
@@ -4430,8 +4492,8 @@ async function mockRestoreAll() {
|
|
|
4430
4492
|
// src/commands/browser/newWindow.ts
|
|
4431
4493
|
import { sleep } from "@wdio/utils";
|
|
4432
4494
|
import newWindowHelper from "./scripts/newWindow.js";
|
|
4433
|
-
import
|
|
4434
|
-
var
|
|
4495
|
+
import logger11 from "@wdio/logger";
|
|
4496
|
+
var log11 = logger11("webdriverio:newWindow");
|
|
4435
4497
|
var WAIT_FOR_NEW_HANDLE_TIMEOUT = 3e3;
|
|
4436
4498
|
async function newWindow(url2, { type = "window", windowName = "", windowFeatures = "" } = {}) {
|
|
4437
4499
|
if (typeof url2 !== "string") {
|
|
@@ -4441,7 +4503,7 @@ async function newWindow(url2, { type = "window", windowName = "", windowFeature
|
|
|
4441
4503
|
throw new Error(`Invalid type '${type}' provided to newWindow command. Use either 'tab' or 'window'`);
|
|
4442
4504
|
}
|
|
4443
4505
|
if (windowName || windowFeatures) {
|
|
4444
|
-
|
|
4506
|
+
log11.warn('The "windowName" and "windowFeatures" options are deprecated and only supported in WebDriver Classic sessions.');
|
|
4445
4507
|
}
|
|
4446
4508
|
if (this.isMobile) {
|
|
4447
4509
|
throw new Error("newWindow command is not supported on mobile platforms");
|
|
@@ -4507,15 +4569,15 @@ async function react$(selector, { props = {}, state = {} } = {}) {
|
|
|
4507
4569
|
}
|
|
4508
4570
|
|
|
4509
4571
|
// src/commands/browser/reloadSession.ts
|
|
4510
|
-
import
|
|
4572
|
+
import logger14 from "@wdio/logger";
|
|
4511
4573
|
|
|
4512
4574
|
// src/session/polyfill.ts
|
|
4513
|
-
import
|
|
4575
|
+
import logger12 from "@wdio/logger";
|
|
4514
4576
|
import { polyfillFn as polyfillFn3 } from "./scripts/polyfill.js";
|
|
4515
4577
|
function getPolyfillManager(browser) {
|
|
4516
4578
|
return SessionManager.getSessionManager(browser, PolyfillManager);
|
|
4517
4579
|
}
|
|
4518
|
-
var
|
|
4580
|
+
var log12 = logger12("webdriverio:PolyfillManager");
|
|
4519
4581
|
var PolyfillManager = class _PolyfillManager extends SessionManager {
|
|
4520
4582
|
#initialize;
|
|
4521
4583
|
#browser;
|
|
@@ -4547,7 +4609,7 @@ var PolyfillManager = class _PolyfillManager extends SessionManager {
|
|
|
4547
4609
|
return;
|
|
4548
4610
|
}
|
|
4549
4611
|
const functionDeclaration = createFunctionDeclarationFromString(polyfillFn3);
|
|
4550
|
-
|
|
4612
|
+
log12.info(`Adding polyfill script to context with id ${context.context}`);
|
|
4551
4613
|
this.#scriptsRegisteredInContexts.add(context.context);
|
|
4552
4614
|
return Promise.all([
|
|
4553
4615
|
!context.parent ? this.#browser.scriptAddPreloadScript({
|
|
@@ -4569,9 +4631,9 @@ var PolyfillManager = class _PolyfillManager extends SessionManager {
|
|
|
4569
4631
|
};
|
|
4570
4632
|
|
|
4571
4633
|
// src/session/shadowRoot.ts
|
|
4572
|
-
import
|
|
4634
|
+
import logger13 from "@wdio/logger";
|
|
4573
4635
|
import customElementWrapper from "./scripts/customElement.js";
|
|
4574
|
-
var
|
|
4636
|
+
var log13 = logger13("webdriverio:ShadowRootManager");
|
|
4575
4637
|
function getShadowRootManager(browser) {
|
|
4576
4638
|
return SessionManager.getSessionManager(browser, ShadowRootManager);
|
|
4577
4639
|
}
|
|
@@ -4687,9 +4749,9 @@ var ShadowRootManager = class _ShadowRootManager extends SessionManager {
|
|
|
4687
4749
|
!shadowElem.value?.shadowRoot?.sharedId || // we expect the shadow root to have a proper type
|
|
4688
4750
|
shadowElem.value.shadowRoot.value?.nodeType !== 11
|
|
4689
4751
|
) {
|
|
4690
|
-
return
|
|
4752
|
+
return log13.warn(`Expected element with shadow root but found <${shadowElem.value?.localName} />`);
|
|
4691
4753
|
}
|
|
4692
|
-
|
|
4754
|
+
log13.info(`Registered new shadow root for element <${shadowElem.value.localName} /> with id ${shadowElem.value.shadowRoot.sharedId}`);
|
|
4693
4755
|
const newTree = new ShadowRootTree(
|
|
4694
4756
|
shadowElem.sharedId,
|
|
4695
4757
|
shadowElem.value.shadowRoot.sharedId,
|
|
@@ -4888,15 +4950,15 @@ var NetworkManager = class _NetworkManager extends SessionManager {
|
|
|
4888
4950
|
async initialize() {
|
|
4889
4951
|
return this.#initialize;
|
|
4890
4952
|
}
|
|
4891
|
-
#beforeRequestSent(
|
|
4892
|
-
if (
|
|
4953
|
+
#beforeRequestSent(log30) {
|
|
4954
|
+
if (log30.navigation) {
|
|
4893
4955
|
return;
|
|
4894
4956
|
}
|
|
4895
|
-
const request = this.#findRootRequest(
|
|
4957
|
+
const request = this.#findRootRequest(log30.navigation);
|
|
4896
4958
|
if (!request) {
|
|
4897
4959
|
return;
|
|
4898
4960
|
}
|
|
4899
|
-
const { request: id, headers, cookies, url: url2 } =
|
|
4961
|
+
const { request: id, headers, cookies, url: url2 } = log30.request;
|
|
4900
4962
|
request.children?.push({
|
|
4901
4963
|
id,
|
|
4902
4964
|
url: url2,
|
|
@@ -4912,51 +4974,51 @@ var NetworkManager = class _NetworkManager extends SessionManager {
|
|
|
4912
4974
|
sameSite: cookie.sameSite,
|
|
4913
4975
|
expiry: cookie.expiry
|
|
4914
4976
|
})),
|
|
4915
|
-
timestamp:
|
|
4977
|
+
timestamp: log30.timestamp
|
|
4916
4978
|
});
|
|
4917
4979
|
}
|
|
4918
|
-
#navigationStarted(
|
|
4980
|
+
#navigationStarted(log30) {
|
|
4919
4981
|
if (
|
|
4920
4982
|
/**
|
|
4921
4983
|
* we need a navigation id to identify the request
|
|
4922
4984
|
*/
|
|
4923
|
-
!
|
|
4985
|
+
!log30.navigation || /**
|
|
4924
4986
|
* ignore urls that users wouldn't navigate to
|
|
4925
4987
|
*/
|
|
4926
|
-
!SUPPORTED_NAVIGATION_PROTOCOLS.some((protocol) =>
|
|
4988
|
+
!SUPPORTED_NAVIGATION_PROTOCOLS.some((protocol) => log30.url.startsWith(protocol))
|
|
4927
4989
|
) {
|
|
4928
|
-
if (
|
|
4990
|
+
if (log30.navigation === null && log30.url === "") {
|
|
4929
4991
|
this.#lastNetworkId = UNKNOWN_NAVIGATION_ID;
|
|
4930
4992
|
return this.#requests.set(UNKNOWN_NAVIGATION_ID, {
|
|
4931
4993
|
url: "",
|
|
4932
4994
|
headers: {},
|
|
4933
|
-
timestamp:
|
|
4995
|
+
timestamp: log30.timestamp,
|
|
4934
4996
|
redirectChain: [],
|
|
4935
4997
|
children: []
|
|
4936
4998
|
});
|
|
4937
4999
|
}
|
|
4938
5000
|
return;
|
|
4939
5001
|
}
|
|
4940
|
-
this.#lastNetworkId =
|
|
4941
|
-
this.#requests.set(
|
|
4942
|
-
url:
|
|
5002
|
+
this.#lastNetworkId = log30.navigation;
|
|
5003
|
+
this.#requests.set(log30.navigation, {
|
|
5004
|
+
url: log30.url,
|
|
4943
5005
|
headers: {},
|
|
4944
|
-
timestamp:
|
|
4945
|
-
navigation:
|
|
5006
|
+
timestamp: log30.timestamp,
|
|
5007
|
+
navigation: log30.navigation,
|
|
4946
5008
|
redirectChain: [],
|
|
4947
5009
|
children: []
|
|
4948
5010
|
});
|
|
4949
5011
|
}
|
|
4950
|
-
#fetchError(
|
|
4951
|
-
const response = this.#findRootRequest(
|
|
5012
|
+
#fetchError(log30) {
|
|
5013
|
+
const response = this.#findRootRequest(log30.navigation);
|
|
4952
5014
|
if (!response) {
|
|
4953
5015
|
return;
|
|
4954
5016
|
}
|
|
4955
|
-
const request = response.children?.find((child) => child.id ===
|
|
5017
|
+
const request = response.children?.find((child) => child.id === log30.request.request);
|
|
4956
5018
|
if (!request) {
|
|
4957
5019
|
return;
|
|
4958
5020
|
}
|
|
4959
|
-
request.error =
|
|
5021
|
+
request.error = log30.errorText;
|
|
4960
5022
|
}
|
|
4961
5023
|
#findRootRequest(navigationId) {
|
|
4962
5024
|
const response = this.#requests.get(navigationId || UNKNOWN_NAVIGATION_ID);
|
|
@@ -4966,22 +5028,22 @@ var NetworkManager = class _NetworkManager extends SessionManager {
|
|
|
4966
5028
|
const firstRequest = this.#requests.values().next().value;
|
|
4967
5029
|
return this.#lastNetworkId ? this.#requests.get(this.#lastNetworkId) || firstRequest : firstRequest;
|
|
4968
5030
|
}
|
|
4969
|
-
#responseCompleted(
|
|
4970
|
-
const response = this.#findRootRequest(
|
|
5031
|
+
#responseCompleted(log30) {
|
|
5032
|
+
const response = this.#findRootRequest(log30.navigation);
|
|
4971
5033
|
if (!response) {
|
|
4972
5034
|
return;
|
|
4973
5035
|
}
|
|
4974
5036
|
if (!response.navigation && response.url === "") {
|
|
4975
|
-
response.url =
|
|
4976
|
-
response.navigation =
|
|
5037
|
+
response.url = log30.request.url;
|
|
5038
|
+
response.navigation = log30.navigation;
|
|
4977
5039
|
}
|
|
4978
|
-
if (
|
|
4979
|
-
if (response.url !==
|
|
5040
|
+
if (log30.navigation === response.navigation) {
|
|
5041
|
+
if (response.url !== log30.response.url) {
|
|
4980
5042
|
response.redirectChain?.push(response.url);
|
|
4981
5043
|
}
|
|
4982
|
-
response.url =
|
|
4983
|
-
const { headers: requestHeaders } =
|
|
4984
|
-
const { fromCache, headers: responseHeaders, mimeType, status } =
|
|
5044
|
+
response.url = log30.response.url;
|
|
5045
|
+
const { headers: requestHeaders } = log30.request;
|
|
5046
|
+
const { fromCache, headers: responseHeaders, mimeType, status } = log30.response;
|
|
4985
5047
|
response.headers = headerListToObject(requestHeaders), response.response = {
|
|
4986
5048
|
fromCache,
|
|
4987
5049
|
headers: headerListToObject(responseHeaders),
|
|
@@ -4990,15 +5052,15 @@ var NetworkManager = class _NetworkManager extends SessionManager {
|
|
|
4990
5052
|
};
|
|
4991
5053
|
return;
|
|
4992
5054
|
}
|
|
4993
|
-
const request = response.children?.find((child) => child.id ===
|
|
5055
|
+
const request = response.children?.find((child) => child.id === log30.request.request);
|
|
4994
5056
|
if (!request) {
|
|
4995
5057
|
return;
|
|
4996
5058
|
}
|
|
4997
5059
|
request.response = {
|
|
4998
|
-
fromCache:
|
|
4999
|
-
headers: headerListToObject(
|
|
5000
|
-
mimeType:
|
|
5001
|
-
status:
|
|
5060
|
+
fromCache: log30.response.fromCache,
|
|
5061
|
+
headers: headerListToObject(log30.response.headers),
|
|
5062
|
+
mimeType: log30.response.mimeType,
|
|
5063
|
+
status: log30.response.status
|
|
5002
5064
|
};
|
|
5003
5065
|
response.children?.push(request);
|
|
5004
5066
|
}
|
|
@@ -5069,12 +5131,12 @@ var DialogManager = class _DialogManager extends SessionManager {
|
|
|
5069
5131
|
/**
|
|
5070
5132
|
* capture shadow root elements propagated through console.debug
|
|
5071
5133
|
*/
|
|
5072
|
-
async #handleUserPrompt(
|
|
5134
|
+
async #handleUserPrompt(log30) {
|
|
5073
5135
|
if (this.#autoHandleDialog) {
|
|
5074
5136
|
try {
|
|
5075
5137
|
return await this.#browser.browsingContextHandleUserPrompt({
|
|
5076
5138
|
accept: false,
|
|
5077
|
-
context:
|
|
5139
|
+
context: log30.context
|
|
5078
5140
|
});
|
|
5079
5141
|
} catch (err) {
|
|
5080
5142
|
if (err instanceof Error && err.message.includes("no such alert")) {
|
|
@@ -5083,7 +5145,7 @@ var DialogManager = class _DialogManager extends SessionManager {
|
|
|
5083
5145
|
throw err;
|
|
5084
5146
|
}
|
|
5085
5147
|
}
|
|
5086
|
-
const dialog = new Dialog(
|
|
5148
|
+
const dialog = new Dialog(log30, this.#browser);
|
|
5087
5149
|
this.#browser.emit("dialog", dialog);
|
|
5088
5150
|
}
|
|
5089
5151
|
/**
|
|
@@ -5166,18 +5228,18 @@ function registerSessionManager(instance) {
|
|
|
5166
5228
|
}
|
|
5167
5229
|
|
|
5168
5230
|
// src/commands/browser/reloadSession.ts
|
|
5169
|
-
var
|
|
5231
|
+
var log14 = logger14("webdriverio");
|
|
5170
5232
|
async function reloadSession(newCapabilities) {
|
|
5171
5233
|
const oldSessionId = this.sessionId;
|
|
5172
5234
|
const shutdownDriver = Boolean(newCapabilities?.browserName);
|
|
5173
5235
|
try {
|
|
5174
5236
|
await this.deleteSession({ shutdownDriver });
|
|
5175
5237
|
} catch (err) {
|
|
5176
|
-
|
|
5238
|
+
log14.warn(`Suppressing error closing the session: ${err.stack}`);
|
|
5177
5239
|
}
|
|
5178
5240
|
if (this.puppeteer?.connected) {
|
|
5179
5241
|
this.puppeteer.disconnect();
|
|
5180
|
-
|
|
5242
|
+
log14.debug("Disconnected puppeteer session");
|
|
5181
5243
|
}
|
|
5182
5244
|
const ProtocolDriver = (await import(
|
|
5183
5245
|
/* @vite-ignore */
|
|
@@ -5223,11 +5285,11 @@ async function saveScreenshot2(filepath, options) {
|
|
|
5223
5285
|
}
|
|
5224
5286
|
|
|
5225
5287
|
// src/commands/browser/scroll.ts
|
|
5226
|
-
import
|
|
5227
|
-
var
|
|
5288
|
+
import logger15 from "@wdio/logger";
|
|
5289
|
+
var log15 = logger15("webdriverio");
|
|
5228
5290
|
function scroll(x = 0, y = 0) {
|
|
5229
5291
|
if (!x && !y) {
|
|
5230
|
-
|
|
5292
|
+
log15.warn('"scroll" command was called with no parameters, skipping execution');
|
|
5231
5293
|
return Promise.resolve();
|
|
5232
5294
|
}
|
|
5233
5295
|
if (this.isMobile) {
|
|
@@ -5241,6 +5303,8 @@ function scroll(x = 0, y = 0) {
|
|
|
5241
5303
|
}
|
|
5242
5304
|
|
|
5243
5305
|
// src/commands/browser/setCookies.ts
|
|
5306
|
+
import logger16 from "@wdio/logger";
|
|
5307
|
+
var log16 = logger16("webdriverio");
|
|
5244
5308
|
async function setCookies(cookieObjs) {
|
|
5245
5309
|
const cookieObjsList = !Array.isArray(cookieObjs) ? [cookieObjs] : cookieObjs;
|
|
5246
5310
|
if (cookieObjsList.some((obj) => typeof obj !== "object")) {
|
|
@@ -5250,20 +5314,36 @@ async function setCookies(cookieObjs) {
|
|
|
5250
5314
|
await Promise.all(cookieObjsList.map((cookieObj) => this.addCookie(cookieObj)));
|
|
5251
5315
|
return;
|
|
5252
5316
|
}
|
|
5253
|
-
let url2
|
|
5254
|
-
|
|
5317
|
+
let url2;
|
|
5318
|
+
try {
|
|
5255
5319
|
url2 = new URL(await this.getUrl());
|
|
5320
|
+
if (url2.origin === "null") {
|
|
5321
|
+
await Promise.all(cookieObjsList.map((cookieObj) => this.addCookie(cookieObj)));
|
|
5322
|
+
return;
|
|
5323
|
+
}
|
|
5324
|
+
} catch {
|
|
5325
|
+
await Promise.all(cookieObjsList.map((cookieObj) => this.addCookie(cookieObj)));
|
|
5326
|
+
return;
|
|
5256
5327
|
}
|
|
5257
|
-
|
|
5258
|
-
cookie
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5328
|
+
try {
|
|
5329
|
+
await Promise.all(cookieObjsList.map((cookie) => this.storageSetCookie({
|
|
5330
|
+
cookie: {
|
|
5331
|
+
...cookie,
|
|
5332
|
+
domain: cookie.domain || url2.hostname,
|
|
5333
|
+
value: {
|
|
5334
|
+
type: "string",
|
|
5335
|
+
value: cookie.value
|
|
5336
|
+
}
|
|
5337
|
+
},
|
|
5338
|
+
partition: {
|
|
5339
|
+
type: "storageKey",
|
|
5340
|
+
sourceOrigin: url2.origin
|
|
5264
5341
|
}
|
|
5265
|
-
}
|
|
5266
|
-
})
|
|
5342
|
+
})));
|
|
5343
|
+
} catch (err) {
|
|
5344
|
+
log16.warn(`BiDi setCookies failed, falling back to classic: ${err.message}`);
|
|
5345
|
+
await Promise.all(cookieObjsList.map((cookieObj) => this.addCookie(cookieObj)));
|
|
5346
|
+
}
|
|
5267
5347
|
return;
|
|
5268
5348
|
}
|
|
5269
5349
|
|
|
@@ -5367,10 +5447,10 @@ async function switchWindow(matcher) {
|
|
|
5367
5447
|
}
|
|
5368
5448
|
|
|
5369
5449
|
// src/commands/browser/switchFrame.ts
|
|
5370
|
-
import
|
|
5450
|
+
import logger17 from "@wdio/logger";
|
|
5371
5451
|
import { ELEMENT_KEY as ELEMENT_KEY8 } from "webdriver";
|
|
5372
5452
|
import findIframeInShadowDOM from "./scripts/shadowDom.js";
|
|
5373
|
-
var
|
|
5453
|
+
var log17 = logger17("webdriverio:switchFrame");
|
|
5374
5454
|
async function switchFrame(context) {
|
|
5375
5455
|
function isPossiblyUnresolvedElement(input) {
|
|
5376
5456
|
return Boolean(input) && typeof input === "object" && typeof input.getElement === "function";
|
|
@@ -5409,13 +5489,13 @@ async function switchFrame(context) {
|
|
|
5409
5489
|
const urlContextContaining = sessionContext.findContext(context, tree.contexts, "byUrlContaining");
|
|
5410
5490
|
const contextIdContext = sessionContext.findContext(context, tree.contexts, "byContextId");
|
|
5411
5491
|
if (urlContext) {
|
|
5412
|
-
|
|
5492
|
+
log17.info(`Found context by url "${urlContext.url}" with context id "${urlContext.context}"`);
|
|
5413
5493
|
return urlContext.context;
|
|
5414
5494
|
} else if (urlContextContaining) {
|
|
5415
|
-
|
|
5495
|
+
log17.info(`Found context by url containing "${urlContextContaining.url}" with context id "${urlContextContaining.context}"`);
|
|
5416
5496
|
return urlContextContaining.context;
|
|
5417
5497
|
} else if (contextIdContext) {
|
|
5418
|
-
|
|
5498
|
+
log17.info(`Found context by id "${contextIdContext}" with url "${contextIdContext.url}"`);
|
|
5419
5499
|
return contextIdContext.context;
|
|
5420
5500
|
}
|
|
5421
5501
|
return false;
|
|
@@ -5444,7 +5524,7 @@ async function switchFrame(context) {
|
|
|
5444
5524
|
arguments: args.map((arg) => LocalValue.getArgument(arg)),
|
|
5445
5525
|
target: { context: id }
|
|
5446
5526
|
};
|
|
5447
|
-
const result = await this.scriptCallFunction(params).catch((err) =>
|
|
5527
|
+
const result = await this.scriptCallFunction(params).catch((err) => log17.warn(`Failed to identify frame context id: ${err.message}`));
|
|
5448
5528
|
if (!result) {
|
|
5449
5529
|
return [];
|
|
5450
5530
|
}
|
|
@@ -5480,18 +5560,18 @@ async function switchFrame(context) {
|
|
|
5480
5560
|
return this.switchFrame(iframeElement);
|
|
5481
5561
|
}
|
|
5482
5562
|
}
|
|
5483
|
-
|
|
5563
|
+
log17.warn(`Shadow DOM iframe with src containing "${urlFragment}" found, but could not be resolved into a WebdriverIO element.`);
|
|
5484
5564
|
}
|
|
5485
5565
|
let desiredFrame;
|
|
5486
5566
|
let desiredContext = newContextId;
|
|
5487
5567
|
const contextQueue = [];
|
|
5488
|
-
|
|
5568
|
+
log17.info(`Available frames to switch to: ${allFrames.length}, desired context to switch: ${desiredContext}`);
|
|
5489
5569
|
while (desiredContext !== currentContext) {
|
|
5490
5570
|
desiredFrame = allFrames.find(({ context: context2 }) => context2 === desiredContext);
|
|
5491
5571
|
if (!desiredFrame) {
|
|
5492
5572
|
break;
|
|
5493
5573
|
}
|
|
5494
|
-
|
|
5574
|
+
log17.info(
|
|
5495
5575
|
contextQueue.length === 0 ? `Found desired frame with element id ${desiredFrame.frameElement[ELEMENT_KEY8]}` : `to switch to desired frame, we need to switch to ${desiredFrame.context} first`
|
|
5496
5576
|
);
|
|
5497
5577
|
contextQueue.unshift(desiredFrame);
|
|
@@ -5530,7 +5610,7 @@ async function switchFrame(context) {
|
|
|
5530
5610
|
target: { context: contextId }
|
|
5531
5611
|
};
|
|
5532
5612
|
const result = await this.scriptCallFunction(params).catch((err) => {
|
|
5533
|
-
|
|
5613
|
+
log17.warn(`switchFrame context callback threw error: ${err.message}`);
|
|
5534
5614
|
return void 0;
|
|
5535
5615
|
});
|
|
5536
5616
|
if (result && result.type === "success" && result.result.type === "boolean" && result.result.value) {
|
|
@@ -5576,11 +5656,11 @@ function toggleDisableDeprecationWarning() {
|
|
|
5576
5656
|
}
|
|
5577
5657
|
|
|
5578
5658
|
// src/commands/browser/throttle.ts
|
|
5579
|
-
import
|
|
5659
|
+
import logger18 from "@wdio/logger";
|
|
5580
5660
|
import { getBrowserObject as getBrowserObject9 } from "@wdio/utils";
|
|
5581
|
-
var
|
|
5661
|
+
var log18 = logger18("webdriverio:throttle");
|
|
5582
5662
|
async function throttle(params) {
|
|
5583
|
-
|
|
5663
|
+
log18.warn('Command "throttle" is deprecated and will be removed with the next major version release! Use `throttleNetwork` instead.');
|
|
5584
5664
|
const browser = getBrowserObject9(this);
|
|
5585
5665
|
await browser.throttleNetwork(params);
|
|
5586
5666
|
}
|
|
@@ -5849,7 +5929,7 @@ function waitUntil(condition, {
|
|
|
5849
5929
|
}
|
|
5850
5930
|
|
|
5851
5931
|
// src/commands/mobile/swipe.ts
|
|
5852
|
-
import
|
|
5932
|
+
import logger19 from "@wdio/logger";
|
|
5853
5933
|
|
|
5854
5934
|
// src/types.ts
|
|
5855
5935
|
var MobileScrollDirection = /* @__PURE__ */ ((MobileScrollDirection2) => {
|
|
@@ -5861,7 +5941,7 @@ var MobileScrollDirection = /* @__PURE__ */ ((MobileScrollDirection2) => {
|
|
|
5861
5941
|
})(MobileScrollDirection || {});
|
|
5862
5942
|
|
|
5863
5943
|
// src/commands/mobile/swipe.ts
|
|
5864
|
-
var
|
|
5944
|
+
var log19 = logger19("webdriverio");
|
|
5865
5945
|
var SWIPE_DEFAULTS = {
|
|
5866
5946
|
DIRECTION: "up" /* Up */,
|
|
5867
5947
|
DURATION: 1500,
|
|
@@ -5874,7 +5954,7 @@ async function swipe(options) {
|
|
|
5874
5954
|
}
|
|
5875
5955
|
let { scrollableElement, from, to } = options || {};
|
|
5876
5956
|
if (scrollableElement && (from || to)) {
|
|
5877
|
-
|
|
5957
|
+
log19.warn("`scrollableElement` is provided, so `from` and `to` will be ignored.");
|
|
5878
5958
|
}
|
|
5879
5959
|
if (!from || !to) {
|
|
5880
5960
|
scrollableElement = scrollableElement || await getScrollableElement(browser);
|
|
@@ -5896,9 +5976,9 @@ async function calculateFromTo({
|
|
|
5896
5976
|
let swipePercentage = SWIPE_DEFAULTS.PERCENT;
|
|
5897
5977
|
if (percentage !== void 0) {
|
|
5898
5978
|
if (isNaN(percentage)) {
|
|
5899
|
-
|
|
5979
|
+
log19.warn("The percentage to swipe should be a number.");
|
|
5900
5980
|
} else if (percentage < 0 || percentage > 1) {
|
|
5901
|
-
|
|
5981
|
+
log19.warn("The percentage to swipe should be a number between 0 and 1.");
|
|
5902
5982
|
} else {
|
|
5903
5983
|
swipePercentage = percentage;
|
|
5904
5984
|
}
|
|
@@ -5968,9 +6048,9 @@ async function w3cSwipe({ browser, duration, from, to }) {
|
|
|
5968
6048
|
}
|
|
5969
6049
|
|
|
5970
6050
|
// src/commands/mobile/tap.ts
|
|
5971
|
-
import
|
|
6051
|
+
import logger20 from "@wdio/logger";
|
|
5972
6052
|
import { getBrowserObject as getBrowserObject12 } from "@wdio/utils";
|
|
5973
|
-
var
|
|
6053
|
+
var log20 = logger20("webdriver");
|
|
5974
6054
|
async function tap(options) {
|
|
5975
6055
|
const isElement2 = this.selector !== void 0;
|
|
5976
6056
|
const element = isElement2 ? this : null;
|
|
@@ -6016,7 +6096,7 @@ async function elementTap(browser, element, options) {
|
|
|
6016
6096
|
return await nativeTap(element, browser, options);
|
|
6017
6097
|
}
|
|
6018
6098
|
if (options) {
|
|
6019
|
-
|
|
6099
|
+
log20.warn("The options object is not supported in Web environments and will be ignored.");
|
|
6020
6100
|
}
|
|
6021
6101
|
return await webTap(element);
|
|
6022
6102
|
}
|
|
@@ -6097,8 +6177,8 @@ async function screenTap(browser, options) {
|
|
|
6097
6177
|
}
|
|
6098
6178
|
|
|
6099
6179
|
// src/commands/mobile/getContext.ts
|
|
6100
|
-
import
|
|
6101
|
-
var
|
|
6180
|
+
import logger21 from "@wdio/logger";
|
|
6181
|
+
var log21 = logger21("webdriver");
|
|
6102
6182
|
async function getContext(options) {
|
|
6103
6183
|
const browser = this;
|
|
6104
6184
|
if (!browser.isMobile) {
|
|
@@ -6126,25 +6206,25 @@ async function getDetailedContext(browser, currentAppiumContext, options) {
|
|
|
6126
6206
|
});
|
|
6127
6207
|
const parsedContexts = detailedContexts.filter((context) => context.id === currentAppiumContext);
|
|
6128
6208
|
if (parsedContexts.length > 1) {
|
|
6129
|
-
|
|
6209
|
+
log21.warn(`We found more than 1 detailed context for the current context '${currentAppiumContext}'. We will return the first context.`);
|
|
6130
6210
|
return parsedContexts[0];
|
|
6131
6211
|
} else if (parsedContexts.length === 0) {
|
|
6132
|
-
|
|
6212
|
+
log21.warn(`We did not get back any detailed context for the current context '${currentAppiumContext}'. We will return the current context as a string.`);
|
|
6133
6213
|
return currentAppiumContext;
|
|
6134
6214
|
}
|
|
6135
6215
|
return parsedContexts[0];
|
|
6136
6216
|
}
|
|
6137
6217
|
|
|
6138
6218
|
// src/commands/mobile/getContexts.ts
|
|
6139
|
-
import
|
|
6140
|
-
var
|
|
6219
|
+
import logger22 from "@wdio/logger";
|
|
6220
|
+
var log22 = logger22("webdriver");
|
|
6141
6221
|
async function getContexts(options) {
|
|
6142
6222
|
const browser = this;
|
|
6143
6223
|
if (!browser.isMobile) {
|
|
6144
6224
|
throw new Error("The `getContexts` command is only available for mobile platforms.");
|
|
6145
6225
|
}
|
|
6146
6226
|
if (!options || !options.returnDetailedContexts) {
|
|
6147
|
-
|
|
6227
|
+
log22.info("The standard Appium `contexts` method is used. If you want to get more detailed data, you can set `returnDetailedContexts` to `true`.");
|
|
6148
6228
|
return browser.getAppiumContexts();
|
|
6149
6229
|
}
|
|
6150
6230
|
const defaultOptions = {
|
|
@@ -6271,8 +6351,8 @@ async function getCurrentContexts({
|
|
|
6271
6351
|
}
|
|
6272
6352
|
|
|
6273
6353
|
// src/commands/mobile/switchContext.ts
|
|
6274
|
-
import
|
|
6275
|
-
var
|
|
6354
|
+
import logger23 from "@wdio/logger";
|
|
6355
|
+
var log23 = logger23("webdriver");
|
|
6276
6356
|
async function switchContext(options) {
|
|
6277
6357
|
const browser = this;
|
|
6278
6358
|
if (!browser.isMobile) {
|
|
@@ -6282,7 +6362,7 @@ async function switchContext(options) {
|
|
|
6282
6362
|
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.");
|
|
6283
6363
|
}
|
|
6284
6364
|
if (typeof options === "string") {
|
|
6285
|
-
|
|
6365
|
+
log23.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.");
|
|
6286
6366
|
return browser.switchAppiumContext(options);
|
|
6287
6367
|
}
|
|
6288
6368
|
if (!options.title && !options.url) {
|
|
@@ -6310,7 +6390,7 @@ async function switchToContext({ browser, options }) {
|
|
|
6310
6390
|
if (!matchingContext) {
|
|
6311
6391
|
throw new Error(reasons.join("\n"));
|
|
6312
6392
|
}
|
|
6313
|
-
|
|
6393
|
+
log23.info("WebdriverIO found a matching context:", JSON.stringify(matchingContext, null, 2));
|
|
6314
6394
|
if (!browser.isIOS) {
|
|
6315
6395
|
const webviewName = `WEBVIEW_${identifier}`;
|
|
6316
6396
|
await browser.switchAppiumContext(webviewName);
|
|
@@ -6488,9 +6568,9 @@ function clearValue() {
|
|
|
6488
6568
|
}
|
|
6489
6569
|
|
|
6490
6570
|
// src/commands/element/click.ts
|
|
6491
|
-
import
|
|
6571
|
+
import logger24 from "@wdio/logger";
|
|
6492
6572
|
import { getBrowserObject as getBrowserObject13 } from "@wdio/utils";
|
|
6493
|
-
var
|
|
6573
|
+
var log24 = logger24("webdriver");
|
|
6494
6574
|
function click(options) {
|
|
6495
6575
|
if (typeof options !== "undefined") {
|
|
6496
6576
|
if (typeof options !== "object" || Array.isArray(options)) {
|
|
@@ -6537,10 +6617,10 @@ async function actionClick(element, options) {
|
|
|
6537
6617
|
if (x || y) {
|
|
6538
6618
|
const { width, height } = await browser.getElementRect(element.elementId);
|
|
6539
6619
|
if (x && x < -Math.floor(width / 2) || x && x > Math.floor(width / 2)) {
|
|
6540
|
-
|
|
6620
|
+
log24.warn("x would cause a out of bounds error as it goes outside of element");
|
|
6541
6621
|
}
|
|
6542
6622
|
if (y && y < -Math.floor(height / 2) || y && y > Math.floor(height / 2)) {
|
|
6543
|
-
|
|
6623
|
+
log24.warn("y would cause a out of bounds error as it goes outside of element");
|
|
6544
6624
|
}
|
|
6545
6625
|
}
|
|
6546
6626
|
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
|
-
|
|
6878
|
-
location =
|
|
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
|
}
|
|
@@ -7088,18 +7166,18 @@ async function isStable() {
|
|
|
7088
7166
|
}
|
|
7089
7167
|
|
|
7090
7168
|
// src/commands/element/moveTo.ts
|
|
7091
|
-
import
|
|
7169
|
+
import logger25 from "@wdio/logger";
|
|
7092
7170
|
import { getBrowserObject as getBrowserObject27 } from "@wdio/utils";
|
|
7093
|
-
var
|
|
7171
|
+
var log25 = logger25("webdriver");
|
|
7094
7172
|
async function moveTo({ xOffset, yOffset } = {}) {
|
|
7095
7173
|
const browser = getBrowserObject27(this);
|
|
7096
7174
|
if (xOffset || yOffset) {
|
|
7097
7175
|
const { width, height } = await browser.getElementRect(this.elementId);
|
|
7098
7176
|
if (xOffset && xOffset < -Math.floor(width / 2) || xOffset && xOffset > Math.floor(width / 2)) {
|
|
7099
|
-
|
|
7177
|
+
log25.warn("xOffset would cause a out of bounds error as it goes outside of element");
|
|
7100
7178
|
}
|
|
7101
7179
|
if (yOffset && yOffset < -Math.floor(height / 2) || yOffset && yOffset > Math.floor(height / 2)) {
|
|
7102
|
-
|
|
7180
|
+
log25.warn("yOffset would cause a out of bounds error as it goes outside of element");
|
|
7103
7181
|
}
|
|
7104
7182
|
}
|
|
7105
7183
|
const moveToNested = async () => {
|
|
@@ -7185,10 +7263,10 @@ async function saveScreenshot3(filepath) {
|
|
|
7185
7263
|
}
|
|
7186
7264
|
|
|
7187
7265
|
// src/commands/element/scrollIntoView.ts
|
|
7188
|
-
import
|
|
7266
|
+
import logger26 from "@wdio/logger";
|
|
7189
7267
|
import { ELEMENT_KEY as ELEMENT_KEY17 } from "webdriver";
|
|
7190
7268
|
import { getBrowserObject as getBrowserObject30 } from "@wdio/utils";
|
|
7191
|
-
var
|
|
7269
|
+
var log26 = logger26("webdriverio");
|
|
7192
7270
|
async function scrollIntoView(options = { block: "start", inline: "nearest" }) {
|
|
7193
7271
|
const browser = getBrowserObject30(this);
|
|
7194
7272
|
if (browser.isMobile) {
|
|
@@ -7241,7 +7319,7 @@ async function scrollIntoView(options = { block: "start", inline: "nearest" }) {
|
|
|
7241
7319
|
deltaY = Math.round(deltaY - scrollY);
|
|
7242
7320
|
await browser.action("wheel").scroll({ duration: 0, x: deltaX, y: deltaY, origin: this }).perform();
|
|
7243
7321
|
} catch (err) {
|
|
7244
|
-
|
|
7322
|
+
log26.warn(
|
|
7245
7323
|
`Failed to execute "scrollIntoView" using WebDriver Actions API: ${err.message}!
|
|
7246
7324
|
Re-attempting using \`Element.scrollIntoView\` via Web API.`
|
|
7247
7325
|
);
|
|
@@ -7400,7 +7478,7 @@ async function setValue(value, options) {
|
|
|
7400
7478
|
}
|
|
7401
7479
|
|
|
7402
7480
|
// src/commands/element/shadow$$.ts
|
|
7403
|
-
import
|
|
7481
|
+
import logger27 from "@wdio/logger";
|
|
7404
7482
|
import { getBrowserObject as getBrowserObject31 } from "@wdio/utils";
|
|
7405
7483
|
import { SHADOW_ELEMENT_KEY } from "webdriver";
|
|
7406
7484
|
import { shadowFnFactory } from "./scripts/shadowFnFactory.js";
|
|
@@ -7727,7 +7805,7 @@ var createRoleBaseXpathSelector = (role) => {
|
|
|
7727
7805
|
};
|
|
7728
7806
|
|
|
7729
7807
|
// src/commands/element/shadow$$.ts
|
|
7730
|
-
var
|
|
7808
|
+
var log27 = logger27("webdriverio");
|
|
7731
7809
|
async function shadow$$(selector) {
|
|
7732
7810
|
const browser = getBrowserObject31(this);
|
|
7733
7811
|
try {
|
|
@@ -7737,7 +7815,7 @@ async function shadow$$(selector) {
|
|
|
7737
7815
|
const elements = await getElements.call(this, selector, res, { isShadowElement: true });
|
|
7738
7816
|
return enhanceElementsArray(elements, this, selector);
|
|
7739
7817
|
} catch (err) {
|
|
7740
|
-
|
|
7818
|
+
log27.warn(
|
|
7741
7819
|
`Failed to fetch element within shadow DOM using WebDriver command: ${err.message}!
|
|
7742
7820
|
Falling back to JavaScript shim.`
|
|
7743
7821
|
);
|
|
@@ -7746,11 +7824,11 @@ Falling back to JavaScript shim.`
|
|
|
7746
7824
|
}
|
|
7747
7825
|
|
|
7748
7826
|
// src/commands/element/shadow$.ts
|
|
7749
|
-
import
|
|
7827
|
+
import logger28 from "@wdio/logger";
|
|
7750
7828
|
import { SHADOW_ELEMENT_KEY as SHADOW_ELEMENT_KEY2 } from "webdriver";
|
|
7751
7829
|
import { shadowFnFactory as shadowFnFactory2 } from "./scripts/shadowFnFactory.js";
|
|
7752
7830
|
import { getBrowserObject as getBrowserObject32 } from "@wdio/utils";
|
|
7753
|
-
var
|
|
7831
|
+
var log28 = logger28("webdriverio");
|
|
7754
7832
|
async function shadow$(selector) {
|
|
7755
7833
|
const browser = getBrowserObject32(this);
|
|
7756
7834
|
try {
|
|
@@ -7759,7 +7837,7 @@ async function shadow$(selector) {
|
|
|
7759
7837
|
const res = await browser.findElementFromShadowRoot(shadowRoot[SHADOW_ELEMENT_KEY2], using, value);
|
|
7760
7838
|
return getElement.call(this, selector, res, { isShadowElement: true });
|
|
7761
7839
|
} catch (err) {
|
|
7762
|
-
|
|
7840
|
+
log28.warn(
|
|
7763
7841
|
`Failed to fetch element within shadow DOM using WebDriver command: ${err.message}!
|
|
7764
7842
|
Falling back to JavaScript shim.`
|
|
7765
7843
|
);
|
|
@@ -7781,7 +7859,7 @@ async function waitForClickable({
|
|
|
7781
7859
|
timeoutMsg = `element ("${this.selector}") still ${reverse ? "" : "not "}clickable after ${timeout}ms`
|
|
7782
7860
|
} = {}) {
|
|
7783
7861
|
const browser = getBrowserObject33(this);
|
|
7784
|
-
if (browser.isMobile && browser.isNativeContext) {
|
|
7862
|
+
if (browser.isMobile && browser.isNativeContext && !browser.capabilities?.browserName) {
|
|
7785
7863
|
throw new Error("The `waitForClickable` command is only available for desktop and mobile browsers.");
|
|
7786
7864
|
}
|
|
7787
7865
|
return this.waitUntil(
|
|
@@ -8178,7 +8256,7 @@ function querySelectorAllDeep(findMany, s, r) {
|
|
|
8178
8256
|
}
|
|
8179
8257
|
|
|
8180
8258
|
// src/utils/index.ts
|
|
8181
|
-
var
|
|
8259
|
+
var log29 = logger29("webdriverio");
|
|
8182
8260
|
var INVALID_SELECTOR_ERROR = "selector needs to be typeof `string` or `function`";
|
|
8183
8261
|
var IGNORED_COMMAND_FILE_EXPORTS = ["SESSION_MOCKS", "CDP_SESSIONS"];
|
|
8184
8262
|
var scopes = {
|
|
@@ -8350,7 +8428,7 @@ async function findDeepElement(selector) {
|
|
|
8350
8428
|
})).then((elems) => elems.filter(([isIn]) => isIn).map(([, elem]) => elem));
|
|
8351
8429
|
return scopedNodes[0];
|
|
8352
8430
|
}, (err) => {
|
|
8353
|
-
|
|
8431
|
+
log29.warn(`Failed to execute browser.browsingContextLocateNodes({ ... }) due to ${err}, falling back to regular WebDriver Classic command`);
|
|
8354
8432
|
return this && "elementId" in this && this.elementId ? this.findElementFromElement(this.elementId, using, value) : browser.findElement(using, value);
|
|
8355
8433
|
});
|
|
8356
8434
|
return deepElementResult;
|
|
@@ -8389,7 +8467,7 @@ async function findDeepElements(selector) {
|
|
|
8389
8467
|
})).then((elems) => elems.filter(([isIn]) => isIn).map(([, elem]) => elem));
|
|
8390
8468
|
return scopedNodes;
|
|
8391
8469
|
}, (err) => {
|
|
8392
|
-
|
|
8470
|
+
log29.warn(`Failed to execute browser.browsingContextLocateNodes({ ... }) due to ${err}, falling back to regular WebDriver Classic command`);
|
|
8393
8471
|
return this && "elementId" in this && this.elementId ? this.findElementsFromElement(this.elementId, using, value) : browser.findElements(using, value);
|
|
8394
8472
|
});
|
|
8395
8473
|
return deepElementResult;
|
|
@@ -8523,7 +8601,7 @@ async function getElementRect(scope) {
|
|
|
8523
8601
|
if (rectJs && typeof rectJs[key] === "number") {
|
|
8524
8602
|
rect[key] = Math.floor(rectJs[key]);
|
|
8525
8603
|
} else {
|
|
8526
|
-
|
|
8604
|
+
log29.error("getElementRect", { rect, rectJs, key });
|
|
8527
8605
|
throw new Error("Failed to receive element rects via execute command");
|
|
8528
8606
|
}
|
|
8529
8607
|
});
|
|
@@ -8967,7 +9045,7 @@ var remote = async function(params, remoteModifier) {
|
|
|
8967
9045
|
const keysToKeep = Object.keys(environment.value.variables.WDIO_WORKER_ID ? params : DEFAULTS);
|
|
8968
9046
|
const config = validateConfig(WDIO_DEFAULTS, params, keysToKeep);
|
|
8969
9047
|
await enableFileLogging(config.outputDir);
|
|
8970
|
-
|
|
9048
|
+
logger30.setLogLevelsConfig(config.logLevels, config.logLevel);
|
|
8971
9049
|
const modifier = (client, options2) => {
|
|
8972
9050
|
Object.assign(options2, Object.entries(config).reduce((a, [k, v]) => typeof v === "undefined" ? a : { ...a, [k]: v }, {}));
|
|
8973
9051
|
if (typeof remoteModifier === "function") {
|