Reputation: 103
I'm using python 3.7 and have got an error in selenium
I have a website looking something like that:
<html>
<body>
<div class="foo">
<div class="bar1">something clickable</div>
<div class="bar2">something clickable</div>
<div class="bar3">something clickable</div>
<div class="bar4">something clickable</div>
</div>
<body>
<html>
and I want to use selenium to click each of the bars, so I wrote:
from selenium import webdriver
browser=webdriver.Chrome()
browser.get('https://www.some-website.com')
for i in browser.find_elements_by_class_name('foo'):
i.click()
but, when executing I get nothing, so I run:
print(len(browser.find_elements_by_class_name('foo')))
which outputs zero
even when I put WebDriverWait
before I still get zero...
why?
Upvotes: 2
Views: 173
Reputation: 1166
try this xpath this will return 4 webelements
driver.find_elements_by_xpath("//div[@class='foo']//*")
Upvotes: 2