Reputation: 9
I'm trying to come up with a script that clicks multiple elements on a page. I've created a for loop to try and loop through the elements clicking them all. However when the loop tries to click the following element i got the error (The element is stale)
I've tried using an explicit wait for element, but have yet to figure how to put it to work
for i in driver.find_elements_by_class_name('marginright5.link.linkWithHash.detailsLink'):
i.click().WebDriverWait(driver, 30).until(EC.element_to_be_clickable((i))
driver.back()
Hopefully you can help me figure out what went wrong with my code. Using it like this i get a syntax error, not sure why.
Upvotes: 0
Views: 432
Reputation: 7563
It seem like you need combination between element_to_be_clickable
with invisibility_of_element_located
.
So after you click each element you need make sure the element invisible then you can call driver.back
.
for i in driver.find_elements_by_class_name('marginright5.link.linkWithHash.detailsLink'):
WebDriverWait(driver, 30).until(EC.element_to_be_clickable(i))
i.click()
WebDriverWait(driver, 30).until(EC.invisibility_of_element_located(i))
driver.back()
Upvotes: 1