What type should I use for browser elements in typescript in wdio tests?

128 Views Asked by At

I'm trying to figure out how to type browser elements. Code example (??? marks the place where you need to add the type):

login_input = await $('div.login_input')
await set_login('login', login_input)

set_login = async (
  login: string, login_input: ???
): Promise<void> => {
  await login_input.setValue(login);
}

This source https://github.com/webdriverio/webdriverio/issues/7767 says that for browser elements you need to use the type ChainablePromiseElement<Promise< Element>>, but if i do it, i have this error: Type 'ChainablePromiseElement' is not generic

I would be grateful for your help!

1

There are 1 best solutions below

0
On BEST ANSWER

I found the answer in the wdio support chat. Need to use type WebdriverIO.Element

set_login = async (
  login: string, login_input: WebdriverIO.Element
): Promise<void> => {
  await login_input.setValue(login);
}