Environment:
- WebdriverIO version:
7.0.5
- Mode: WDIO Testrunner
- If WDIO Testrunner, running sync/async: async
- Node.js version:
15.6.0
- NPM version:
7.4.0
- Browser name and version: not applicable
- Platform name and version: not applicable
- Additional wdio packages used (if applicable): not applicable
Config of WebdriverIO
not applicable
Describe the bug
In version 7 of WDIO, the type definitions for browser.execute() seem to have changed but have become incorrect when using WebdriverIO.Elements as arguments. The type definitions do not model the conversion of WebdriverIO.Elements into W3C DOM Elements. Instead, inner arguments types are expected to also be the outer ones.
To Reproduce
- Setup WebdriverIO project with TypeScript as described here:
- Put this code into any file:
function foo(wdioElement: WebdriverIO.Element) {
await browser.execute((domElement: Element) => {
domElement.addEventListener("click", () => console.log("whatever"));
}, wdioElement);
}
- Run TypeScript to check for errors
Expected behavior
TS should not show errors since at runtime WebdriverIO.Element is landing in the browser-side as a DOM Element. Note, that stripping the Element type from domElement: Element will move the error to the domElement.addEventListener(...) line.
Log
system-tests/src/safariClickHack.ts:35:8 - error TS2345: Argument of type 'WebdriverIO.Element' is not assignable to parameter of type 'Element'.
Type 'Element' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 120 more.
35 }, element);
~~~~~~~
Additional context
Used TypeScript version 4.1.5.
Environment:
7.0.515.6.07.4.0Config of WebdriverIO
not applicable
Describe the bug
In version 7 of WDIO, the type definitions for
browser.execute()seem to have changed but have become incorrect when usingWebdriverIO.Elements as arguments. The type definitions do not model the conversion ofWebdriverIO.Elements into W3C DOMElements. Instead, inner arguments types are expected to also be the outer ones.To Reproduce
Expected behavior
TS should not show errors since at runtime
WebdriverIO.Elementis landing in the browser-side as a DOMElement. Note, that stripping theElementtype fromdomElement: Elementwill move the error to thedomElement.addEventListener(...)line.Log
Additional context
Used TypeScript version
4.1.5.