webdriverio 9.2.8 → 9.2.12
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/switchFrame.d.ts.map +1 -1
- package/build/commands/browser/switchWindow.d.ts +7 -1
- package/build/commands/browser/switchWindow.d.ts.map +1 -1
- package/build/index.js +33 -6
- package/build/scripts/customElement.js +2 -2
- package/build/shadowRoot.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchFrame.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/switchFrame.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,KAAK,EAAe,MAAM,WAAW,CAAA;AAOhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAE7D,KAAK,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,EAAE,UAAU,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAG3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAsB,WAAW,CAC7B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,uBAAuB,GAAG,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,eAAe,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"switchFrame.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/switchFrame.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,KAAK,EAAe,MAAM,WAAW,CAAA;AAOhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAE7D,KAAK,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,EAAE,UAAU,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAG3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAsB,WAAW,CAC7B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,OAAO,EAAE,WAAW,CAAC,OAAO,GAAG,uBAAuB,GAAG,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,eAAe,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,0BA4OnI"}
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
// open url
|
|
9
9
|
await browser.url('https://google.com')
|
|
10
10
|
|
|
11
|
+
// get window handle
|
|
12
|
+
const handle = await browser.getWindowHandle()
|
|
13
|
+
|
|
11
14
|
// create new window
|
|
12
15
|
await browser.newWindow('https://webdriver.io')
|
|
13
16
|
|
|
@@ -16,10 +19,13 @@
|
|
|
16
19
|
|
|
17
20
|
// switch back via title match
|
|
18
21
|
await browser.switchWindow('Next-gen browser and mobile automation test framework for Node.js')
|
|
22
|
+
|
|
23
|
+
// switch back via window handle
|
|
24
|
+
await browser.switchWindow(handle)
|
|
19
25
|
});
|
|
20
26
|
* </example>
|
|
21
27
|
*
|
|
22
|
-
* @param {String|RegExp} matcher String or regular expression that matches the title
|
|
28
|
+
* @param {String|RegExp} matcher String or regular expression that matches either the page title or URL, the window name, or the window handle
|
|
23
29
|
*
|
|
24
30
|
* @uses protocol/getWindowHandles, protocol/switchToWindow, protocol/getUrl, protocol/getTitle
|
|
25
31
|
* @alias browser.switchTab
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchWindow.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/switchWindow.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"switchWindow.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/switchWindow.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,YAAY,CAC9B,IAAI,EAAE,WAAW,CAAC,OAAO,EACzB,OAAO,EAAE,MAAM,GAAG,MAAM,mBAkE3B"}
|
package/build/index.js
CHANGED
|
@@ -4139,17 +4139,25 @@ async function setWindowSize(width, height) {
|
|
|
4139
4139
|
// src/commands/browser/switchWindow.ts
|
|
4140
4140
|
async function switchWindow(matcher) {
|
|
4141
4141
|
if (typeof matcher !== "string" && !(matcher instanceof RegExp)) {
|
|
4142
|
-
throw new Error('Unsupported parameter for switchWindow, required is "string" or
|
|
4142
|
+
throw new Error('Unsupported parameter for switchWindow, required is "string" or a RegExp');
|
|
4143
4143
|
}
|
|
4144
4144
|
const currentWindow = await this.getWindowHandle();
|
|
4145
|
+
if (typeof matcher === "string" && currentWindow === matcher) {
|
|
4146
|
+
return currentWindow;
|
|
4147
|
+
}
|
|
4148
|
+
const contextManager2 = getContextManager(this);
|
|
4145
4149
|
const tabs = await this.getWindowHandles();
|
|
4150
|
+
if (typeof matcher === "string" && tabs.includes(matcher)) {
|
|
4151
|
+
await this.switchToWindow(matcher);
|
|
4152
|
+
contextManager2.setCurrentContext(matcher);
|
|
4153
|
+
return matcher;
|
|
4154
|
+
}
|
|
4146
4155
|
const matchesTarget = (target) => {
|
|
4147
4156
|
if (typeof matcher === "string") {
|
|
4148
4157
|
return target.includes(matcher);
|
|
4149
4158
|
}
|
|
4150
4159
|
return !!target.match(matcher);
|
|
4151
4160
|
};
|
|
4152
|
-
const contextManager2 = getContextManager(this);
|
|
4153
4161
|
for (const tab of tabs) {
|
|
4154
4162
|
await this.switchToWindow(tab);
|
|
4155
4163
|
contextManager2.setCurrentContext(tab);
|
|
@@ -4170,7 +4178,7 @@ async function switchWindow(matcher) {
|
|
|
4170
4178
|
}
|
|
4171
4179
|
}
|
|
4172
4180
|
await this.switchToWindow(currentWindow);
|
|
4173
|
-
throw new Error(`No window found with title, url or
|
|
4181
|
+
throw new Error(`No window found with title, url, name or window handle matching "${matcher}"`);
|
|
4174
4182
|
}
|
|
4175
4183
|
|
|
4176
4184
|
// src/commands/browser/switchFrame.ts
|
|
@@ -4178,6 +4186,9 @@ import logger13 from "@wdio/logger";
|
|
|
4178
4186
|
import { ELEMENT_KEY as ELEMENT_KEY8 } from "webdriver";
|
|
4179
4187
|
var log13 = logger13("webdriverio:switchFrame");
|
|
4180
4188
|
async function switchFrame(context) {
|
|
4189
|
+
function isPossiblyUnresolvedElement(input) {
|
|
4190
|
+
return Boolean(input) && typeof input === "object" && typeof input.getElement === "function";
|
|
4191
|
+
}
|
|
4181
4192
|
if (!this.isBidi) {
|
|
4182
4193
|
if (typeof context === "function") {
|
|
4183
4194
|
throw new Error("Cannot use a function to fetch a context in WebDriver Classic");
|
|
@@ -4185,6 +4196,13 @@ async function switchFrame(context) {
|
|
|
4185
4196
|
if (typeof context === "string") {
|
|
4186
4197
|
throw new Error("Cannot use a string to fetch a context in WebDriver Classic");
|
|
4187
4198
|
}
|
|
4199
|
+
if (isPossiblyUnresolvedElement(context)) {
|
|
4200
|
+
const element = await context.getElement();
|
|
4201
|
+
await element.waitForExist({
|
|
4202
|
+
timeoutMsg: `Can't switch to frame with selector ${element.selector} because it doesn't exist`
|
|
4203
|
+
});
|
|
4204
|
+
return switchToFrame(this, element);
|
|
4205
|
+
}
|
|
4188
4206
|
return switchToFrame(this, context);
|
|
4189
4207
|
}
|
|
4190
4208
|
if (context === null) {
|
|
@@ -4289,7 +4307,7 @@ async function switchFrame(context) {
|
|
|
4289
4307
|
}
|
|
4290
4308
|
return newContextId;
|
|
4291
4309
|
}
|
|
4292
|
-
if (
|
|
4310
|
+
if (isPossiblyUnresolvedElement(context)) {
|
|
4293
4311
|
const element = await context.getElement();
|
|
4294
4312
|
await element.waitForExist({
|
|
4295
4313
|
timeoutMsg: `Can't switch to frame with selector ${element.selector} because it doesn't exist`
|
|
@@ -5178,6 +5196,7 @@ var ShadowRootManager = class {
|
|
|
5178
5196
|
#browser;
|
|
5179
5197
|
#initialize;
|
|
5180
5198
|
#shadowRoots = /* @__PURE__ */ new Map();
|
|
5199
|
+
#documentElement;
|
|
5181
5200
|
#frameDepth = 0;
|
|
5182
5201
|
constructor(browser) {
|
|
5183
5202
|
this.#browser = browser;
|
|
@@ -5246,7 +5265,8 @@ var ShadowRootManager = class {
|
|
|
5246
5265
|
,
|
|
5247
5266
|
shadowElem,
|
|
5248
5267
|
rootElem,
|
|
5249
|
-
isDocument
|
|
5268
|
+
isDocument,
|
|
5269
|
+
documentElement
|
|
5250
5270
|
] = args;
|
|
5251
5271
|
if (!this.#shadowRoots.has(logEntry.source.context)) {
|
|
5252
5272
|
if (!rootElem.sharedId) {
|
|
@@ -5262,6 +5282,7 @@ var ShadowRootManager = class {
|
|
|
5262
5282
|
this.#shadowRoots.set(logEntry.source.context, new ShadowRootTree(rootElem.sharedId));
|
|
5263
5283
|
}
|
|
5264
5284
|
}
|
|
5285
|
+
this.#documentElement = documentElement;
|
|
5265
5286
|
const tree = this.#shadowRoots.get(logEntry.source.context);
|
|
5266
5287
|
if (!tree) {
|
|
5267
5288
|
throw new Error(`Couldn't find tree for context id ${logEntry.source.context}`);
|
|
@@ -5297,14 +5318,20 @@ var ShadowRootManager = class {
|
|
|
5297
5318
|
if (!tree) {
|
|
5298
5319
|
return [];
|
|
5299
5320
|
}
|
|
5321
|
+
let documentElement;
|
|
5300
5322
|
if (scope) {
|
|
5301
5323
|
const subTree = tree.find(scope);
|
|
5302
5324
|
if (subTree) {
|
|
5303
5325
|
tree = subTree;
|
|
5304
5326
|
}
|
|
5327
|
+
} else {
|
|
5328
|
+
documentElement = this.#documentElement?.sharedId;
|
|
5305
5329
|
}
|
|
5306
5330
|
const elements = tree.getAllLookupScopes();
|
|
5307
|
-
return [
|
|
5331
|
+
return [
|
|
5332
|
+
...documentElement ? [documentElement] : [],
|
|
5333
|
+
...new Set(elements).values()
|
|
5334
|
+
];
|
|
5308
5335
|
}
|
|
5309
5336
|
getShadowElementPairsByContextId(contextId, scope) {
|
|
5310
5337
|
let tree = this.#shadowRoots.get(contextId);
|
|
@@ -8,7 +8,7 @@ function customElementWrapper() {
|
|
|
8
8
|
while (parentNode.parentNode) {
|
|
9
9
|
parentNode = parentNode.parentNode;
|
|
10
10
|
}
|
|
11
|
-
console.debug("[WDIO]", "newShadowRoot", this, parentNode, parentNode === document);
|
|
11
|
+
console.debug("[WDIO]", "newShadowRoot", this, parentNode, parentNode === document, document.documentElement);
|
|
12
12
|
return origConnectedCallback?.call(this);
|
|
13
13
|
};
|
|
14
14
|
const origDisconnectedCallback = Constructor.prototype.disconnectedCallback;
|
|
@@ -25,7 +25,7 @@ function customElementWrapper() {
|
|
|
25
25
|
while (parentNode.parentNode) {
|
|
26
26
|
parentNode = parentNode.parentNode;
|
|
27
27
|
}
|
|
28
|
-
console.debug("[WDIO]", "newShadowRoot", this, parentNode, parentNode === document);
|
|
28
|
+
console.debug("[WDIO]", "newShadowRoot", this, parentNode, parentNode === document, document.documentElement);
|
|
29
29
|
return shadowRoot;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadowRoot.d.ts","sourceRoot":"","sources":["../src/shadowRoot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,WAAW,CAAA;AAStC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,qBAShE;AAED;;;;GAIG;AACH,qBAAa,iBAAiB;;
|
|
1
|
+
{"version":3,"file":"shadowRoot.d.ts","sourceRoot":"","sources":["../src/shadowRoot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,WAAW,CAAA;AAStC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,qBAShE;AAED;;;;GAIG;AACH,qBAAa,iBAAiB;;gBAOd,OAAO,EAAE,WAAW,CAAC,OAAO;IAyBlC,UAAU;IA2BhB;;;OAGG;IACH,aAAa;IAIb;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ;IAgGvC,4BAA4B,CAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;IAkC1E,gCAAgC,CAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EAAE;IAgBpG,qBAAqB,CAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IActF,gBAAgB,CAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAOvD;AAED,qBAAa,cAAc;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,cAAc,CAAA;IACrB,QAAQ,sBAA4B;gBAEvB,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,cAAc;IAMxE;;OAEG;IACH,gBAAgB,CAAE,IAAI,EAAE,cAAc,GAAG,IAAI;IAC7C;;;;;OAKG;IACH,gBAAgB,CAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,IAAI;IA6B5D,IAAI,CAAE,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAelD,cAAc,CAAE,UAAU,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAe/D,kBAAkB,IAAK,MAAM,EAAE;IAO/B,IAAI,IAAK,cAAc,EAAE;IAIzB,MAAM,CAAE,OAAO,EAAE,MAAM,GAAG,OAAO;CAepC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webdriverio",
|
|
3
3
|
"description": "Next-gen browser and mobile automation test framework for Node.js",
|
|
4
|
-
"version": "9.2.
|
|
4
|
+
"version": "9.2.12",
|
|
5
5
|
"homepage": "https://webdriver.io",
|
|
6
6
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"optional": true
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "5283e03d12615050ba8e1c54a9903e171068d143"
|
|
114
114
|
}
|