I'm trying to use Selenium with Javascript (NodeJS) and I need to count some elements by CSS selector.
I tried several approaches:
client.findElements(By.css(".some-class")).size();
It gives me: Uncaught TypeError: client.findElements(...).size is not a function
client.findElements(By.css(".some-class")).Count();
It gives me: Uncaught TypeError: client.findElements(...).size is not a function
client.findElements(By.css(".some-class")).length;
Here length
is always undefined.
What am I missing?
Thanks in advance.
findElements
返回一个将解析为WebElements数组的promise。
client.findElements(By.css(".some-class")).then(elements => console.log(elements.length));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.