I would like to loop a set of links with selenium in python. I have tried to follow this explanation with no success. I keep getting the "stale element reference error(I am trying to use WebDriverWait). my code is as follows:
list_of_links = mydriver.find_elements_by_xpath('//ul[@class="directory dir-col"]/li/a')
for link in list_of_links:
UI.WebDriverWait(mydriver, 30).until(lambda mydriver:mydriver.find_element_by_xpath('//ul[@class="directory dir-col"]/li/a'))
link.click()
mydriver.back()
I did try placing the webdriver wait command before and after the click and back commands with no success. any help will be highly appreciated.