webdriverio
webdriverio copied to clipboard
[📖 Docs]: Limitations for nth selector using TypeScript does not work
Pre-check
- [X] I know I can edit the docs but prefer to file this issue
Describe the improvement
Unclear documentation
Description of the improvement / report
It appears that the documentation for limitations to select the nth element of an array using waitUnitl does not work when using TypeScript, or at least fails TypeScript validation because the success case returns an object of type WebdriverIO.Element where waitUntil only accepts a function that returns boolean | Promise<boolean>. The error with the example verbatim is in the attached screenshot.

Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Thanks for reporting!
I believe waitUntil returns the truthy value returned by the callback. The typings and docs should reflect that.
Any contributions that resolves the bug are highly appreciated. Please take a look into our contribution guidelines and let us know if you have any questions. Cheers!
HI @christian-bromann ,
Looks like the typing's are fine, as waitUntil should return a Boolean value.
waitUntil(this: WebdriverIO.Browser | WebdriverIO.Element, condition: () => boolean|Promise< boolean >, { timeout, interval, timeoutMsg }?: Partial<WaitUntilOptions>): Promise<true | void>;
Looks like code sample in docs should be updated , like below
await browser.waitUntil(
async () => {
const elems = await $$('div');
return elems.length === 2;
}, {
timeoutMsg: 'Never found enough div elements'
})
Please suggest, will give the PR for this in docs!
@harsha509 thanks for investigating. I think the types might be wrong here. I believe waitUntil is implemented so it returns the truthy value, e.g.:
const value = await browser.waitUntil(() => 'foobar');
console.log(value); // outputs: "foobar"
Can you confirm? If so I suggest to not expect a boolean as return value but a generic.
@christian-bromann @harsha509 Was any other progress made on this?
@nextlevelbeard I don't think so, would you like to pick it up?
fixed by https://github.com/webdriverio/webdriverio/pull/9767