I looked at the documentation located here, but couldn't find an answer.
I want to get an element by class name
or xpath
and return the number of instances. There seems to be no available function in Python, such as get_xpath_count()
.
Any ideas on how to achieve this?
Try driver.find_elements_by_xpath
and count the number of returned elements.
You Can simply use len()
function:
len(driver.find_elements_by_xpath('//a'))
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