webdriverio 8.29.3 → 8.30.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/README.md +5 -1
- package/build/commands/browser/$$.d.ts.map +1 -1
- package/build/commands/browser/$$.js +2 -1
- package/build/commands/browser/reloadSession.d.ts +10 -1
- package/build/commands/browser/reloadSession.d.ts.map +1 -1
- package/build/commands/browser/reloadSession.js +16 -3
- package/build/middlewares.js +2 -2
- package/build/utils/index.d.ts +3 -2
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +19 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -46,6 +46,10 @@ For more information on [options](https://webdriver.io/docs/options#webdriver-op
|
|
|
46
46
|
<center>Package Sponsors:</center>
|
|
47
47
|
<p align="center">
|
|
48
48
|
<a href="https://www.browserstack.com/automation-webdriverio">
|
|
49
|
-
<img src="https://
|
|
49
|
+
<img src="https://webdriver.io/img/sponsors/browserstack_black.svg" alt="BrowserStack" width="300" />
|
|
50
|
+
</a>
|
|
51
|
+
|
|
52
|
+
<a href="https://saucelabs.com">
|
|
53
|
+
<img src="https://webdriver.io/img/sponsors/saucelabs_black.svg" alt="Sauce Labs" width="300" />
|
|
50
54
|
</a>
|
|
51
55
|
</p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"$$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/$$.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAsB,EAAE,CACpB,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,EAC/C,QAAQ,EAAE,QAAQ,GAAG,gBAAgB,EAAE,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"$$.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/$$.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAIvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAsB,EAAE,CACpB,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,EAC/C,QAAQ,EAAE,QAAQ,GAAG,gBAAgB,EAAE,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,WAAW,EAAE,qCAmBlF"}
|
|
@@ -50,7 +50,8 @@ export async function $$(selector) {
|
|
|
50
50
|
if (Array.isArray(selector) && isElement(selector[0])) {
|
|
51
51
|
res = [];
|
|
52
52
|
for (const el of selector) {
|
|
53
|
-
|
|
53
|
+
const $el = await findElement.call(this, el);
|
|
54
|
+
$el && res.push($el);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
const elements = await getElements.call(this, selector, res);
|
|
@@ -13,11 +13,20 @@
|
|
|
13
13
|
await browser.reloadSession()
|
|
14
14
|
console.log(browser.sessionId) // outputs: 9a0d9bf9d4864160aa982c50cf18a573
|
|
15
15
|
})
|
|
16
|
+
|
|
17
|
+
it('should reload my session with new capabilities', async () => {
|
|
18
|
+
console.log(browser.capabilities.browserName) // outputs: chrome
|
|
19
|
+
await browser.reloadSession({
|
|
20
|
+
browserName: 'firefox'
|
|
21
|
+
})
|
|
22
|
+
console.log(browser.capabilities.browserName) // outputs: firefox
|
|
23
|
+
})
|
|
16
24
|
* </example>
|
|
17
25
|
*
|
|
18
26
|
* @alias browser.reloadSession
|
|
27
|
+
* @param newCapabilities new capabilities to create a session with
|
|
19
28
|
* @type utility
|
|
20
29
|
*
|
|
21
30
|
*/
|
|
22
|
-
export declare function reloadSession(this: WebdriverIO.Browser): Promise<string>;
|
|
31
|
+
export declare function reloadSession(this: WebdriverIO.Browser, newCapabilities?: WebdriverIO.Capabilities): Promise<string>;
|
|
23
32
|
//# sourceMappingURL=reloadSession.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reloadSession.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/reloadSession.ts"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"reloadSession.d.ts","sourceRoot":"","sources":["../../../src/commands/browser/reloadSession.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,aAAa,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE,WAAW,CAAC,YAAY,mBAoCzG"}
|
|
@@ -15,19 +15,32 @@ const log = logger('webdriverio');
|
|
|
15
15
|
await browser.reloadSession()
|
|
16
16
|
console.log(browser.sessionId) // outputs: 9a0d9bf9d4864160aa982c50cf18a573
|
|
17
17
|
})
|
|
18
|
+
|
|
19
|
+
it('should reload my session with new capabilities', async () => {
|
|
20
|
+
console.log(browser.capabilities.browserName) // outputs: chrome
|
|
21
|
+
await browser.reloadSession({
|
|
22
|
+
browserName: 'firefox'
|
|
23
|
+
})
|
|
24
|
+
console.log(browser.capabilities.browserName) // outputs: firefox
|
|
25
|
+
})
|
|
18
26
|
* </example>
|
|
19
27
|
*
|
|
20
28
|
* @alias browser.reloadSession
|
|
29
|
+
* @param newCapabilities new capabilities to create a session with
|
|
21
30
|
* @type utility
|
|
22
31
|
*
|
|
23
32
|
*/
|
|
24
|
-
export async function reloadSession() {
|
|
33
|
+
export async function reloadSession(newCapabilities) {
|
|
25
34
|
const oldSessionId = this.sessionId;
|
|
35
|
+
/**
|
|
36
|
+
* if a new browser name is given we can shut down the driver since we start a new one
|
|
37
|
+
*/
|
|
38
|
+
const shutdownDriver = Boolean(newCapabilities?.browserName);
|
|
26
39
|
/**
|
|
27
40
|
* end current running session, if session already gone suppress exceptions
|
|
28
41
|
*/
|
|
29
42
|
try {
|
|
30
|
-
await this.deleteSession({ shutdownDriver
|
|
43
|
+
await this.deleteSession({ shutdownDriver });
|
|
31
44
|
}
|
|
32
45
|
catch (err) {
|
|
33
46
|
/**
|
|
@@ -42,7 +55,7 @@ export async function reloadSession() {
|
|
|
42
55
|
log.debug('Disconnected puppeteer session');
|
|
43
56
|
}
|
|
44
57
|
const ProtocolDriver = (await import(this.options.automationProtocol)).default;
|
|
45
|
-
await ProtocolDriver.reloadSession(this);
|
|
58
|
+
await ProtocolDriver.reloadSession(this, newCapabilities);
|
|
46
59
|
const options = this.options;
|
|
47
60
|
if (Array.isArray(options.onReload) && options.onReload.length) {
|
|
48
61
|
await Promise.all(options.onReload.map((hook) => hook(oldSessionId, this.sessionId)));
|
package/build/middlewares.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ELEMENT_KEY } from 'webdriver';
|
|
2
2
|
import refetchElement from './utils/refetchElement.js';
|
|
3
3
|
import implicitWait from './utils/implicitWait.js';
|
|
4
|
-
import { getBrowserObject } from './utils/index.js';
|
|
4
|
+
import { getBrowserObject, isStaleElementError } from './utils/index.js';
|
|
5
5
|
/**
|
|
6
6
|
* This method is an command wrapper for elements that checks if a command is called
|
|
7
7
|
* that wasn't found on the page and automatically waits for it
|
|
@@ -31,7 +31,7 @@ export const elementErrorHandler = (fn) => (commandName, commandFn) => {
|
|
|
31
31
|
return result;
|
|
32
32
|
}
|
|
33
33
|
catch (err) {
|
|
34
|
-
if (err.name === 'stale element reference') {
|
|
34
|
+
if (err.name === 'stale element reference' || isStaleElementError(err)) {
|
|
35
35
|
const element = await refetchElement(this, commandName);
|
|
36
36
|
this.elementId = element.elementId;
|
|
37
37
|
this.parent = element.parent;
|
package/build/utils/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare const getPrototype: (scope: 'browser' | 'element') => Record<stri
|
|
|
14
14
|
* @param {?Object|undefined} res body object from response or null
|
|
15
15
|
* @return {?string} element id or null if element couldn't be found
|
|
16
16
|
*/
|
|
17
|
-
export declare const getElementFromResponse: (res
|
|
17
|
+
export declare const getElementFromResponse: (res?: ElementReference) => string | null;
|
|
18
18
|
/**
|
|
19
19
|
* traverse up the scope chain until browser element was reached
|
|
20
20
|
*/
|
|
@@ -33,10 +33,11 @@ export declare function parseCSS(cssPropertyValue: string, cssProperty?: string)
|
|
|
33
33
|
*/
|
|
34
34
|
export declare function checkUnicode(value: string, isDevTools?: boolean): string[];
|
|
35
35
|
export declare function isElement(o: Selector): boolean | "";
|
|
36
|
+
export declare function isStaleElementError(err: Error): boolean;
|
|
36
37
|
/**
|
|
37
38
|
* logic to find an element
|
|
38
39
|
*/
|
|
39
|
-
export declare function findElement(this: WebdriverIO.Browser | WebdriverIO.Element, selector: Selector): Promise<Error | ElementReference>;
|
|
40
|
+
export declare function findElement(this: WebdriverIO.Browser | WebdriverIO.Element, selector: Selector): Promise<Error | ElementReference | undefined>;
|
|
40
41
|
/**
|
|
41
42
|
* logic to find a elements
|
|
42
43
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAOvD,OAAO,KAAK,EAAmB,QAAQ,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAOtG,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QAAG,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;KAAE;CACnE;AAiBD;;GAEG;AACH,eAAO,MAAM,YAAY,UAAW,SAAS,GAAG,SAAS,uCAexD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"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AO,iDAuC9D;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,UAInD;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,iBAK3D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAE,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAcnE;AAED,wBAAsB,YAAY,CAAE,OAAO,EAAE,WAAW,CAAC,OAAO,oBAoB/D;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB,UACnF,MAAM,mBAAmB,MAAM,SAAS,WAAW,KAAK,wBAAwB,UAOjG;AAMD;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,aACnB,mBAAmB,EAAE,UACvB,YAAY,OAAO,GAAG,mBAAmB,YACvC,QAAQ,GAAG,gBAAgB,EAAE,GAAG,mBAAmB,EAAE,8BAExD,GAAG,EAAE,6BAuCf,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM,wBAAyB,MAAM,YAAgD,CAAA;AAElG;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,SACvB,OAAO,MAAM,EAAE,MAAM,CAAC,SACrB,OAAO,MAAM,EAAE,MAAM,CAAC,YAShC,CAAA"}
|
package/build/utils/index.js
CHANGED
|
@@ -182,6 +182,15 @@ export function isElement(o) {
|
|
|
182
182
|
? o instanceof HTMLElement
|
|
183
183
|
: o && typeof o === 'object' && o !== null && o.nodeType === 1 && typeof o.nodeName === 'string');
|
|
184
184
|
}
|
|
185
|
+
export function isStaleElementError(err) {
|
|
186
|
+
return (
|
|
187
|
+
// Chrome
|
|
188
|
+
err.message.includes('stale element reference') ||
|
|
189
|
+
// Firefox
|
|
190
|
+
err.message.includes('is no longer attached to the DOM') ||
|
|
191
|
+
// Safari
|
|
192
|
+
err.message.includes('Stale element found'));
|
|
193
|
+
}
|
|
185
194
|
/**
|
|
186
195
|
* logic to find an element
|
|
187
196
|
*/
|
|
@@ -239,7 +248,16 @@ export async function findElement(selector) {
|
|
|
239
248
|
const uid = Math.random().toString().slice(2);
|
|
240
249
|
window.__wdio_element[uid] = selector;
|
|
241
250
|
selector = ((id) => window.__wdio_element[id]);
|
|
242
|
-
let elem = await fetchElementByJSFunction(selector, this, uid)
|
|
251
|
+
let elem = await fetchElementByJSFunction(selector, this, uid).catch((err) => {
|
|
252
|
+
/**
|
|
253
|
+
* WebDriver throws a stale element reference error if the element is not found
|
|
254
|
+
* and therefor can't be serialized
|
|
255
|
+
*/
|
|
256
|
+
if (isStaleElementError(err)) {
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
throw err;
|
|
260
|
+
});
|
|
243
261
|
elem = Array.isArray(elem) ? elem[0] : elem;
|
|
244
262
|
return getElementFromResponse(elem) ? elem : notFoundError;
|
|
245
263
|
}
|
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": "8.
|
|
4
|
+
"version": "8.30.0",
|
|
5
5
|
"homepage": "https://webdriver.io",
|
|
6
6
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -69,17 +69,17 @@
|
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@types/node": "^20.1.0",
|
|
72
|
-
"@wdio/config": "8.
|
|
72
|
+
"@wdio/config": "8.30.0",
|
|
73
73
|
"@wdio/logger": "8.28.0",
|
|
74
|
-
"@wdio/protocols": "8.
|
|
74
|
+
"@wdio/protocols": "8.29.7",
|
|
75
75
|
"@wdio/repl": "8.24.12",
|
|
76
|
-
"@wdio/types": "8.
|
|
77
|
-
"@wdio/utils": "8.
|
|
76
|
+
"@wdio/types": "8.30.0",
|
|
77
|
+
"@wdio/utils": "8.30.0",
|
|
78
78
|
"archiver": "^6.0.0",
|
|
79
79
|
"aria-query": "^5.0.0",
|
|
80
80
|
"css-shorthand-properties": "^1.1.1",
|
|
81
81
|
"css-value": "^0.0.1",
|
|
82
|
-
"devtools-protocol": "^0.0.
|
|
82
|
+
"devtools-protocol": "^0.0.1255431",
|
|
83
83
|
"grapheme-splitter": "^1.0.2",
|
|
84
84
|
"import-meta-resolve": "^4.0.0",
|
|
85
85
|
"is-plain-obj": "^4.1.0",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"resq": "^1.9.1",
|
|
92
92
|
"rgb2hex": "0.2.5",
|
|
93
93
|
"serialize-error": "^11.0.1",
|
|
94
|
-
"webdriver": "8.
|
|
94
|
+
"webdriver": "8.30.0"
|
|
95
95
|
},
|
|
96
96
|
"peerDependencies": {
|
|
97
97
|
"devtools": "^8.14.0"
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"optional": true
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "033e2a91e97c9bd060eb70f2e4e412d382bec3af"
|
|
105
105
|
}
|