Reputation: 558
Hi Ive used the following code and it works perfectly well. How can I make it click all the li items in a ul with an empty ie class="" >With an Xpath of
Xpath is ('//*[@id="Main_data"]/div[1]ul/li[1]/a/span')
html_list = driver.find_element_by_id("myId")
items = html_list.find_elements_by_tag_name("li")
for item in items:
text = item.text
print text
Ive tried item.click in the loop but obtained no results.
Upvotes: 0
Views: 9031
Reputation: 473873
To locate elements having an empty class, use the "by XPath" locator:
items = driver.find_elements_by_xpath("//ul[@id = 'myId']//li[not(@class)]")
for item in items:
item.click()
Upvotes: 2