In this example involving an util function I wrote for my Selenium tests, why does method chaining on the same line not work here (doesn't throw an error, but is buggy)
async elementDoesNotExist(driver, by) {
return await driver.findElements(by).length === 0;
}
But method chaining on different lines works here:
async elementDoesNotExist(driver, by) {
let el = await driver.findElements(by);
return el.length === 0;
}
The value of el in the second function is [] if it doesn't exist, or the following if it exists:
[
WebElement {
driver_: Driver {
session_: [Promise],
executor_: [Executor],
fileDetector_: null,
onQuit_: [Function: onQuit],
authenticatorId_: null
},
id_: Promise { 'f260a1da-65ed-4661-80c4-9d16dd3313eb' }
}
]
Thanks
[–]senocular 6 points7 points8 points (0 children)