@wdio/utils 8.33.1 → 8.36.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/index.d.ts CHANGED
@@ -2,13 +2,13 @@ import webdriverMonad from './monad.js';
2
2
  import initializePlugin from './initializePlugin.js';
3
3
  import { startWebDriver } from './startWebDriver.js';
4
4
  import { initializeWorkerService, initializeLauncherService } from './initializeServices.js';
5
- import { commandCallStructure, isValidParameter, getArgumentType, safeImport, isFunctionAsync, transformCommandLogResult, sleep, isAppiumCapability } from './utils.js';
5
+ import { commandCallStructure, isValidParameter, getArgumentType, safeImport, isFunctionAsync, transformCommandLogResult, sleep, isAppiumCapability, getBrowserObject } from './utils.js';
6
6
  import { wrapCommand, executeHooksWithArgs, executeAsync } from './shim.js';
7
7
  import * as asyncIterators from './pIteration.js';
8
8
  import { testFnWrapper, wrapGlobalTestMethod } from './test-framework/index.js';
9
9
  import { isW3C, capabilitiesEnvironmentDetector, sessionEnvironmentDetector, devtoolsEnvironmentDetector } from './envDetector.js';
10
10
  import { UNICODE_CHARACTERS, HOOK_DEFINITION } from './constants.js';
11
- export { startWebDriver, initializePlugin, initializeLauncherService, initializeWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeImport, sleep, isAppiumCapability, asyncIterators,
11
+ export { startWebDriver, initializePlugin, initializeLauncherService, initializeWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeImport, sleep, isAppiumCapability, getBrowserObject, asyncIterators,
12
12
  /**
13
13
  * runner shim
14
14
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,cAAc,MAAM,YAAY,CAAA;AACvC,OAAO,gBAAgB,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,O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AgB,EAAE,eAAe,EAAE,UAAU,EACnE,eAAe,EAAE,yBAAyB,EAAE,KAAK,EAAE,kBAAkB,EACrE,gBAAgB,EACnB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC3E,OAAO,KAAK,cAAc,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAC/E,OAAO,EACH,KAAK,EAAE,+BAA+B,EACtC,0BAA0B,EAAE,2BAA2B,EAC1D,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEpE,OAAO,EACH,cAAc,EACd,gBAAgB,EAChB,yBAAyB,EACzB,uBAAuB,EACvB,eAAe,EACf,yBAAyB,EACzB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,KAAK,EACL,kBAAkB,EAClB,gBAAgB,EAChB,cAAc;AAEd;;GAEG;AACH,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,oBAAoB;AAEpB;;GAEG;AACH,KAAK,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,2BAA2B;AAE3B;;GAEG;AACH,kBAAkB,EAClB,eAAe,EAClB,CAAA"}
package/build/index.js CHANGED
@@ -3,13 +3,13 @@ import webdriverMonad from './monad.js';
3
3
  import initializePlugin from './initializePlugin.js';
4
4
  import { startWebDriver } from './startWebDriver.js';
5
5
  import { initializeWorkerService, initializeLauncherService } from './initializeServices.js';
6
- import { commandCallStructure, isValidParameter, getArgumentType, safeImport, isFunctionAsync, transformCommandLogResult, sleep, isAppiumCapability } from './utils.js';
6
+ import { commandCallStructure, isValidParameter, getArgumentType, safeImport, isFunctionAsync, transformCommandLogResult, sleep, isAppiumCapability, getBrowserObject } from './utils.js';
7
7
  import { wrapCommand, executeHooksWithArgs, executeAsync } from './shim.js';
8
8
  import * as asyncIterators from './pIteration.js';
9
9
  import { testFnWrapper, wrapGlobalTestMethod } from './test-framework/index.js';
10
10
  import { isW3C, capabilitiesEnvironmentDetector, sessionEnvironmentDetector, devtoolsEnvironmentDetector } from './envDetector.js';
11
11
  import { UNICODE_CHARACTERS, HOOK_DEFINITION } from './constants.js';
12
- export { startWebDriver, initializePlugin, initializeLauncherService, initializeWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeImport, sleep, isAppiumCapability, asyncIterators,
12
+ export { startWebDriver, initializePlugin, initializeLauncherService, initializeWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeImport, sleep, isAppiumCapability, getBrowserObject, asyncIterators,
13
13
  /**
14
14
  * runner shim
15
15
  */
@@ -8,7 +8,7 @@
8
8
  * @param {Object} [thisArg] - Value to use as *this* when executing the `callback`.
9
9
  * @return {Promise} - Returns a Promise with undefined value.
10
10
  */
11
- export declare const forEach: <T>(array: T[], callback: Function, thisArg?: T | undefined) => Promise<void>;
11
+ export declare const forEach: <T>(array: T[], callback: Function, thisArg?: T) => Promise<void>;
12
12
  /**
13
13
  * Same functionality as [`forEach()`](global.html#forEach), but runs only one callback at a time.
14
14
  * @param {Array} array - Array to iterate over.
@@ -16,7 +16,7 @@ export declare const forEach: <T>(array: T[], callback: Function, thisArg?: T |
16
16
  * @param {Object} [thisArg] - Value to use as *this* when executing the `callback`.
17
17
  * @return {Promise} - Returns a Promise with undefined value.
18
18
  */
19
- export declare const forEachSeries: <T>(array: T[], callback: Function, thisArg?: T | undefined) => Promise<void>;
19
+ export declare const forEachSeries: <T>(array: T[], callback: Function, thisArg?: T) => Promise<void>;
20
20
  /**
21
21
  * Implements ES5 [`Array#map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) method.<br><br>
22
22
  * Creates a new array with the results of calling the provided callback once for each element.<br>
@@ -28,7 +28,7 @@ export declare const forEachSeries: <T>(array: T[], callback: Function, thisArg?
28
28
  * @param {Object} [thisArg] - Value to use as *this* when executing the `callback`.
29
29
  * @return {Promise} - Returns a Promise with the resultant *Array* as value.
30
30
  */
31
- export declare const map: <T>(array: T[], callback: Function, thisArg?: T | undefined) => Promise<any[]>;
31
+ export declare const map: <T>(array: T[], callback: Function, thisArg?: T) => Promise<any[]>;
32
32
  /**
33
33
  * Same functionality as [`map()`](global.html#map), but runs only one callback at a time.
34
34
  * @param {Array} array - Array to iterate over.
@@ -36,7 +36,7 @@ export declare const map: <T>(array: T[], callback: Function, thisArg?: T | unde
36
36
  * @param {Object} [thisArg] - Value to use as *this* when executing the `callback`.
37
37
  * @return {Promise} - Returns a Promise with the resultant *Array* as value.
38
38
  */
39
- export declare const mapSeries: <T>(array: T[], callback: Function, thisArg?: T | undefined) => Promise<any[]>;
39
+ export declare const mapSeries: <T>(array: T[], callback: Function, thisArg?: T) => Promise<any[]>;
40
40
  /**
41
41
  * Implements ES5 [`Array#find()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) method.<br><br>
42
42
  * Returns the value of the element that satisfies the provided `callback`. The value returned is the one found first.<br>
@@ -47,7 +47,7 @@ export declare const mapSeries: <T>(array: T[], callback: Function, thisArg?: T
47
47
  * @param {Object} [thisArg] - Value to use as *this* when executing the `callback`.
48
48
  * @return {Promise} - Returns a Promise with the element that passed the test as value, otherwise *undefined*.
49
49
  */
50
- export declare const find: <T>(array: T[], callback: Function, thisArg?: T | undefined) => Promise<T | undefined>;
50
+ export declare const find: <T>(array: T[], callback: Function, thisArg?: T) => Promise<T | undefined>;
51
51
  /**
52
52
  * Same functionality as [`find()`](global.html#find), but runs only one callback at a time.
53
53
  * @param {Array} array - Array to iterate over.
@@ -55,7 +55,7 @@ export declare const find: <T>(array: T[], callback: Function, thisArg?: T | und
55
55
  * @param {Object} [thisArg] - Value to use as *this* when executing the `callback`.
56
56
  * @return {Promise} - Returns a Promise with the element that passed the test as value, otherwise *undefined*.
57
57
  */
58
- export declare const findSeries: <T>(array: T[], callback: Function, thisArg?: T | undefined) => Promise<T | undefined>;
58
+ export declare const findSeries: <T>(array: T[], callback: Function, thisArg?: T) => Promise<T | undefined>;
59
59
  /**
60
60
  * Implements ES5 [`Array#findIndex()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex) method.<br><br>
61
61
  * Returns the index of the element that satisfies the provided `callback`. The index returned is the one found first.<br>
@@ -66,7 +66,7 @@ export declare const findSeries: <T>(array: T[], callback: Function, thisArg?: T
66
66
  * @param {Object} [thisArg] - Value to use as *this* when executing the `callback`.
67
67
  * @return {Promise} - Returns a Promise with the index that passed the test as value, otherwise *-1*.
68
68
  */
69
- export declare const findIndex: <T>(array: T[], callback: Function, thisArg?: T | undefined) => Promise<unknown>;
69
+ export declare const findIndex: <T>(array: T[], callback: Function, thisArg?: T) => Promise<unknown>;
70
70
  /**
71
71
  * Same functionality as [`findIndex()`](global.html#findIndex), but runs only one callback at a time.
72
72
  * @param {Array} array - Array to iterate over.
@@ -74,7 +74,7 @@ export declare const findIndex: <T>(array: T[], callback: Function, thisArg?: T
74
74
  * @param {Object} [thisArg] - Value to use as *this* when executing the `callback`.
75
75
  * @return {Promise} - Returns a Promise with the index that passed the test, otherwise *-1*.
76
76
  */
77
- export declare const findIndexSeries: <T>(array: T[], callback: Function, thisArg?: T | undefined) => Promise<number | undefined>;
77
+ export declare const findIndexSeries: <T>(array: T[], callback: Function, thisArg?: T) => Promise<number | undefined>;
78
78
  /**
79
79
  * Implements ES5 [`Array#some()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some) method.<br><br>
80
80
  * Test if some element in `array` passes the test implemented in `callback`.<br>
@@ -85,7 +85,7 @@ export declare const findIndexSeries: <T>(array: T[], callback: Function, thisAr
85
85
  * @param {Object} [thisArg] - Value to use as *this* when executing the `callback`.
86
86
  * @return {Promise} - Returns a Promise with *true* as value if some element passed the test, otherwise *false*.
87
87
  */
88
- export declare const some: <T>(array: T[], callback: Function, thisArg?: T | undefined) => Promise<unknown>;
88
+ export declare const some: <T>(array: T[], callback: Function, thisArg?: T) => Promise<unknown>;
89
89
  /**
90
90
  * Same functionality as [`some()`](global.html#some), but runs only one callback at a time.
91
91
  * @param {Array} array - Array to iterate over.
@@ -93,7 +93,7 @@ export declare const some: <T>(array: T[], callback: Function, thisArg?: T | und
93
93
  * @param {Object} [thisArg] - Value to use as *this* when executing the `callback`.
94
94
  * @return {Promise} - Returns a Promise with *true* as value if some element passed the test, otherwise *false*.
95
95
  */
96
- export declare const someSeries: <T>(array: T[], callback: Function, thisArg?: T | undefined) => Promise<boolean>;
96
+ export declare const someSeries: <T>(array: T[], callback: Function, thisArg?: T) => Promise<boolean>;
97
97
  /**
98
98
  * Implements ES5 [`Array#every()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every) method.<br><br>
99
99
  * Test if all elements in `array` pass the test implemented in `callback`.<br>
@@ -104,7 +104,7 @@ export declare const someSeries: <T>(array: T[], callback: Function, thisArg?: T
104
104
  * @param {Object} [thisArg] - Value to use as *this* when executing the `callback`.
105
105
  * @return {Promise} - Returns a Promise with *true* as value if all elements passed the test, otherwise *false*.
106
106
  */
107
- export declare const every: <T>(array: T[], callback: any, thisArg?: T | undefined) => Promise<boolean>;
107
+ export declare const every: <T>(array: T[], callback: any, thisArg?: T) => Promise<boolean>;
108
108
  /**
109
109
  * Same functionality as [`every()`](global.html#every), but runs only one callback at a time.<br><br>
110
110
  * @param {Array} array - Array to iterate over.
@@ -112,7 +112,7 @@ export declare const every: <T>(array: T[], callback: any, thisArg?: T | undefin
112
112
  * @param {Object} [thisArg] - Value to use as *this* when executing the `callback`.
113
113
  * @return {Promise} - Returns a Promise with *true* as value if all elements passed the test, otherwise *false*.
114
114
  */
115
- export declare const everySeries: <T>(array: T[], callback: Function, thisArg?: T | undefined) => Promise<boolean>;
115
+ export declare const everySeries: <T>(array: T[], callback: Function, thisArg?: T) => Promise<boolean>;
116
116
  /**
117
117
  * Implements ES5 [`Array#filter()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) method.<br><br>
118
118
  * Creates a new array with the elements that passed the test implemented in `callback`.<br>
@@ -122,14 +122,14 @@ export declare const everySeries: <T>(array: T[], callback: Function, thisArg?:
122
122
  * @param {Object} [thisArg] - Value to use as *this* when executing the `callback`.
123
123
  * @return {Promise} - Returns a Promise with the resultant filtered *Array* as value.
124
124
  */
125
- export declare const filter: <T>(array: T[], callback: Function, thisArg?: T | undefined) => Promise<unknown>;
125
+ export declare const filter: <T>(array: T[], callback: Function, thisArg?: T) => Promise<unknown>;
126
126
  /**
127
127
  * Same functionality as [`filter()`](global.html#filter), but runs only one callback at a time.
128
128
  * @param {Array} array - Array to iterate over.
129
129
  * @param {Function} callback - Function to apply each item in `array`. Accepts three arguments: `currentValue`, `index` and `array`.
130
130
  * @return {Promise} - Returns a Promise with the resultant filtered *Array* as value.
131
131
  */
132
- export declare const filterSeries: <T>(array: T[], callback: Function, thisArg?: T | undefined) => Promise<Awaited<T>[]>;
132
+ export declare const filterSeries: <T>(array: T[], callback: Function, thisArg?: T) => Promise<Awaited<T>[]>;
133
133
  /**
134
134
  * Implements ES5 [`Array#reduce()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce) method.<br><br>
135
135
  * Applies a `callback` against an accumulator and each element in `array`.
@@ -138,5 +138,5 @@ export declare const filterSeries: <T>(array: T[], callback: Function, thisArg?:
138
138
  * @param {Object} [initialValue] - Used as first argument to the first call of `callback`.
139
139
  * @return {Promise} - Returns a Promise with the resultant value from the reduction.
140
140
  */
141
- export declare const reduce: <T>(array: T[], callback: Function, initialValue?: T | undefined) => Promise<any>;
141
+ export declare const reduce: <T>(array: T[], callback: Function, initialValue?: T) => Promise<any>;
142
142
  //# sourceMappingURL=pIteration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pIteration.d.ts","sourceRoot":"","sources":["../src/pIteration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO,4BAAmC,QAAQ,2CAW9D,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,4BAAmC,QAAQ,2CAMpE,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,GAAG,4BAAmC,QAAQ,4CAU1D,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,4BAAmC,QAAQ,4CAQhE,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,IAAI,4BAA6B,QAAQ,oDAqBrD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,4BAAmC,QAAQ,oDAMjE,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,4BAA6B,QAAQ,8CAqB1D,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,4BAAmC,QAAQ,yDAMtE,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,IAAI,4BAA6B,QAAQ,8CAyBrD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,4BAAmC,QAAQ,8CAOjE,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,KAAK,4BAA6B,GAAG,8CAyBjD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,4BAAmC,QAAQ,8CAOlE,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,4BAA6B,QAAQ,8CAwBvD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,4BAAmC,QAAQ,mDAQnE,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,4BAAmC,QAAQ,+CAmB7D,CAAA"}
1
+ {"version":3,"file":"pIteration.d.ts","sourceRoot":"","sources":["../src/pIteration.ts"],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AAQ,EAAE,MAAM,EAAE,KAAK,GAAE,QAAQ,GAAG,QAAQ,EAAO,EAAE,IAAI,GAAE,GAAG,EAAO,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CA4DvJ;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,CAqN9F;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAC,WAAW,EAAE,IAAI,GAAE,GAAG,EAAO,EAAE,OAAO,GAAE,MAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CA2CxJ"}
package/build/shim.js CHANGED
@@ -1,5 +1,7 @@
1
+ /// <reference types="@wdio/globals/types" />
1
2
  import logger from '@wdio/logger';
2
3
  import * as iterators from './pIteration.js';
4
+ import { getBrowserObject } from './utils.js';
3
5
  const log = logger('@wdio/utils:shim');
4
6
  let inCommandHook = false;
5
7
  const ELEMENT_QUERY_COMMANDS = [
@@ -136,9 +138,26 @@ export function wrapCommand(commandName, fn) {
136
138
  * `this` is an array of WebdriverIO elements
137
139
  *
138
140
  * Note(Christian): types for elements are defined in the
139
- * webdriverio package and not accessible here
141
+ * webdriverio package and not accessible here (fixed in v9)
140
142
  */
141
143
  function (index) {
144
+ /**
145
+ * if we access an index that is out of bounds we wait for the
146
+ * array to get that long, and timeout eventually if it doesn't
147
+ */
148
+ if (index >= this.length) {
149
+ const browser = getBrowserObject(this);
150
+ return browser.waitUntil(async () => {
151
+ const elems = await this.parent[this.foundWith](this.selector);
152
+ if (elems.length > index) {
153
+ return elems[index];
154
+ }
155
+ return false;
156
+ }, {
157
+ timeout: browser.options.waitforTimeout,
158
+ timeoutMsg: `Index out of bounds! $$(${this.selector}) returned only ${this.length} elements.`
159
+ });
160
+ }
142
161
  return this[index];
143
162
  }, [prop], { prop, args });
144
163
  }
package/build/utils.d.ts CHANGED
@@ -88,4 +88,8 @@ export declare function isChrome(browserName?: string): boolean;
88
88
  export declare function isSafari(browserName?: string): boolean;
89
89
  export declare function isFirefox(browserName?: string): boolean;
90
90
  export declare function isEdge(browserName?: string): boolean;
91
+ /**
92
+ * traverse up the scope chain until browser element was reached
93
+ */
94
+ export declare function getBrowserObject(elem: WebdriverIO.Element | WebdriverIO.Browser): WebdriverIO.Browser;
91
95
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAW,MAAM,aAAa,CAAA;AAe7D,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,WAGnC;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE;IAAE,sBAAsB,CAAC,EAAE;QAAE,KAAK,EAAE,GAAG,CAAA;KAAE,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,QAwCzH;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,UAAQ,UA+BrF;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAE,MAAM,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;;;EAapF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAE,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,WA8B/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAE,GAAG,EAAE,GAAG,wGAExC;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAAE,IAAI,E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AC,EAAE,MAAM,WAE3C;AAED;;GAEG;AAEH,wBAAgB,gBAAgB,CAAE,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAKtG"}
package/build/utils.js CHANGED
@@ -300,3 +300,13 @@ export function isFirefox(browserName) {
300
300
  export function isEdge(browserName) {
301
301
  return Boolean(browserName && SUPPORTED_BROWSERNAMES.edge.includes(browserName.toLowerCase()));
302
302
  }
303
+ /**
304
+ * traverse up the scope chain until browser element was reached
305
+ */
306
+ // @ts-ignore types are not loaded in time (fixed in v9)
307
+ export function getBrowserObject(elem) {
308
+ // @ts-ignore types are not loaded in time (fixed in v9)
309
+ const elemObject = elem;
310
+ // @ts-ignore types are not loaded in time (fixed in v9)
311
+ return elemObject.parent ? getBrowserObject(elemObject.parent) : elem;
312
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/utils",
3
- "version": "8.33.1",
3
+ "version": "8.36.0",
4
4
  "description": "A WDIO helper utility to provide several utility functions used across the project.",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-utils",
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "@puppeteer/browsers": "^1.6.0",
41
41
  "@wdio/logger": "8.28.0",
42
- "@wdio/types": "8.32.4",
42
+ "@wdio/types": "8.36.0",
43
43
  "decamelize": "^6.0.0",
44
44
  "deepmerge-ts": "^5.1.0",
45
45
  "edgedriver": "^5.3.5",
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "6ee4cdd36e9f10541ede896d18b785ac9c56dacf"
57
+ "gitHead": "bc4e87f18f8f3cd8293734264f3ffb1e6a194cd7"
58
58
  }