@wdio/utils
Advanced tools
Comparing version 8.33.1 to 8.35.0
@@ -5,3 +5,3 @@ import webdriverMonad from './monad.js'; | ||
import { initializeWorkerService, initializeLauncherService } from './initializeServices.js'; | ||
import { commandCallStructure, isValidParameter, getArgumentType, safeImport, isFunctionAsync, transformCommandLogResult, sleep, isAppiumCapability } from './utils.js'; | ||
import { commandCallStructure, isValidParameter, getArgumentType, safeImport, isFunctionAsync, transformCommandLogResult, sleep, isAppiumCapability, getBrowserObject } from './utils.js'; | ||
import { wrapCommand, executeHooksWithArgs, executeAsync } from './shim.js'; | ||
@@ -12,3 +12,3 @@ import * as asyncIterators from './pIteration.js'; | ||
import { UNICODE_CHARACTERS, HOOK_DEFINITION } from './constants.js'; | ||
export { startWebDriver, initializePlugin, initializeLauncherService, initializeWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeImport, sleep, isAppiumCapability, asyncIterators, | ||
export { startWebDriver, initializePlugin, initializeLauncherService, initializeWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeImport, sleep, isAppiumCapability, getBrowserObject, asyncIterators, | ||
/** | ||
@@ -15,0 +15,0 @@ * runner shim |
@@ -6,3 +6,3 @@ /* istanbul ignore file */ | ||
import { initializeWorkerService, initializeLauncherService } from './initializeServices.js'; | ||
import { commandCallStructure, isValidParameter, getArgumentType, safeImport, isFunctionAsync, transformCommandLogResult, sleep, isAppiumCapability } from './utils.js'; | ||
import { commandCallStructure, isValidParameter, getArgumentType, safeImport, isFunctionAsync, transformCommandLogResult, sleep, isAppiumCapability, getBrowserObject } from './utils.js'; | ||
import { wrapCommand, executeHooksWithArgs, executeAsync } from './shim.js'; | ||
@@ -13,3 +13,3 @@ import * as asyncIterators from './pIteration.js'; | ||
import { UNICODE_CHARACTERS, HOOK_DEFINITION } from './constants.js'; | ||
export { startWebDriver, initializePlugin, initializeLauncherService, initializeWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeImport, sleep, isAppiumCapability, asyncIterators, | ||
export { startWebDriver, initializePlugin, initializeLauncherService, initializeWorkerService, isFunctionAsync, transformCommandLogResult, webdriverMonad, commandCallStructure, isValidParameter, getArgumentType, safeImport, sleep, isAppiumCapability, getBrowserObject, asyncIterators, | ||
/** | ||
@@ -16,0 +16,0 @@ * runner shim |
@@ -0,3 +1,5 @@ | ||
/// <reference types="@wdio/globals/types" /> | ||
import logger from '@wdio/logger'; | ||
import * as iterators from './pIteration.js'; | ||
import { getBrowserObject } from './utils.js'; | ||
const log = logger('@wdio/utils:shim'); | ||
@@ -139,5 +141,22 @@ let inCommandHook = false; | ||
* Note(Christian): types for elements are defined in the | ||
* webdriverio package and not accessible here | ||
* webdriverio package and not accessible here (fixed in v9) | ||
*/ | ||
function (index) { | ||
/** | ||
* if we access an index that is out of bounds we wait for the | ||
* array to get that long, and timeout eventually if it doesn't | ||
*/ | ||
if (index >= this.length) { | ||
const browser = getBrowserObject(this); | ||
return browser.waitUntil(async () => { | ||
const elems = await this.parent[this.foundWith](this.selector); | ||
if (elems.length > index) { | ||
return elems[index]; | ||
} | ||
return false; | ||
}, { | ||
timeout: browser.options.waitforTimeout, | ||
timeoutMsg: `Index out of bounds! $$(${this.selector}) returned only ${this.length} elements.` | ||
}); | ||
} | ||
return this[index]; | ||
@@ -144,0 +163,0 @@ }, [prop], { prop, args }); |
@@ -91,2 +91,6 @@ import type { Options, Services } from '@wdio/types'; | ||
export declare function isEdge(browserName?: string): boolean; | ||
/** | ||
* traverse up the scope chain until browser element was reached | ||
*/ | ||
export declare function getBrowserObject(elem: WebdriverIO.Element | WebdriverIO.Browser): WebdriverIO.Browser; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -303,1 +303,11 @@ import { SUPPORTED_BROWSERNAMES, DEFAULT_PROTOCOL, DEFAULT_HOSTNAME, DEFAULT_PATH } from './constants.js'; | ||
} | ||
/** | ||
* traverse up the scope chain until browser element was reached | ||
*/ | ||
// @ts-ignore types are not loaded in time (fixed in v9) | ||
export function getBrowserObject(elem) { | ||
// @ts-ignore types are not loaded in time (fixed in v9) | ||
const elemObject = elem; | ||
// @ts-ignore types are not loaded in time (fixed in v9) | ||
return elemObject.parent ? getBrowserObject(elemObject.parent) : elem; | ||
} |
{ | ||
"name": "@wdio/utils", | ||
"version": "8.33.1", | ||
"version": "8.35.0", | ||
"description": "A WDIO helper utility to provide several utility functions used across the project.", | ||
@@ -57,3 +57,3 @@ "author": "Christian Bromann <mail@bromann.dev>", | ||
}, | ||
"gitHead": "6ee4cdd36e9f10541ede896d18b785ac9c56dacf" | ||
"gitHead": "d6eab1a26ca9feebcde789adacd872067b6c7b83" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
163755
3380