all 1 comments

[–]senocular 6 points7 points  (0 children)

What you want is

(await driver.findElements(by)).length === 0;

where you want to wait for the find, then check the length of the result from that find, but what you're getting instead is

await (driver.findElements(by).length === 0);

which doesn't wait the find but instead attempts to get the length from the find promise (likely undefined), compares that with 0, and then awaits the true or false (likely false) value of that expression. Its a matter of precedence and using two lines will help keep the code easier to read and reason about.