(
selector: ElementFunction,
scope: WebdriverIO.Browser | WebdriverIO.Element,
referenceId?: string
)
| 204 | } |
| 205 | |
| 206 | function fetchElementByJSFunction( |
| 207 | selector: ElementFunction, |
| 208 | scope: WebdriverIO.Browser | WebdriverIO.Element, |
| 209 | referenceId?: string |
| 210 | ): Promise<ElementReference | ElementReference[]> { |
| 211 | if (!('elementId' in scope)) { |
| 212 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 213 | return scope.execute(selector as any, referenceId) |
| 214 | } |
| 215 | /** |
| 216 | * use a regular function because IE does not understand arrow functions |
| 217 | */ |
| 218 | const script = (function (elem: HTMLElement, id: string) { |
| 219 | return (selector as unknown as Function).call(elem, id) |
| 220 | }).toString().replace('selector', `(${selector.toString()})`) |
| 221 | const args: (WebdriverIO.Element | string)[] = [scope as WebdriverIO.Element] |
| 222 | if (referenceId) { |
| 223 | args.push(referenceId) |
| 224 | } |
| 225 | return getBrowserObject(scope).executeScript(`return (${script}).apply(null, arguments)`, args) |
| 226 | } |
| 227 | |
| 228 | export function isElement(o: Selector) { |
| 229 | return ( |
no test coverage detected
searching dependent graphs…