Its general knowledge that in Java, the easiest way to accomplish this is by
List <WebElement> listItems=findElement(by.selector(selector)).findElements(by.selector(selector));
The question is how do you accomplish this in Javascript. I have searched online to no avail.
I use Selenium-Mocha-chai.
Javascript is asynchronous, and doing it via promises, it would something like:
var listItems;
driver.findElement(By.selector(selector))
.then(function(element){
return element.findElements(By.selector(selector2));
}).then(function(elements){
listItems=elements;
// do some stuff...
}).catch(function(e){ // error handler
console.error(e);
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With