No way to get number of elements returned by `findElements`
See original GitHub issueThis issue may not be Protractor related but I’m not sure where else to look. My setup is using Protractor with jasmine-node to test an Angular front-end to a Rails app. When I try to get how many elements are found by protractor.findElements
it always errors out.
My spec file follows the onJasmineNode example. So far I’ve tried the following:
ptor.findElements(protractor.By.css('.selector-string')).size();
: [object object] has no method sizeptor.findElements(protractor.By.css('.selector-string')).count();
: [object object] has no method countptor.findElements(protractor.By.css('.selector-string')).length;
: undefined is not a function
For fun I wrapped the findElements in a console.log and it returns this:
{ then: [Function: then],
cancel: [Function: cancel],
isPending: [Function: isPending] }
Issue Analytics
- State:
- Created 10 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
How to get the number of elements found using Selenium ...
Try driver.find_elements_by_xpath and count the number of returned elements.
Read more >FindElements in Selenium – FindElement by XPath - Guru99
It returns an empty list if there are no elements found using the given locator strategy and locator value. Below is the syntax...
Read more >How to return the number of elements present in the website?
Example: In a page, some elements have text = 'coach 1'. I want to count all elements have this text but I don't...
Read more >findElement vs findElements in Selenium - BrowserStack
The findElements command returns an empty list if no elements are found using the given locator strategy and locator value. Below is the...
Read more >Selenium findElement and findElements Examples
Selenium findElements command takes in By object as the parameter and returns a list of web elements. It returns an empty list if...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
like all webdriver functions, findElements returns a promise. So, to get the length, you’ll need to do
The .length bit is incorrect, not sure where that came from.
element.all(...).count()
should do the trick.