Trying to get details of Tyres on this page. https://eurawheels.com/fr/catalogue/INFINY-INDIVIDUAL . Each tyre has different FINITIONS. The price and other details are different for each FINITIONS. I would like to click on each FINITION type. The problem is that on clicking the FINITION type the links go stale, and You cannot refresh the page, if you do it will take you back to the starting page. So, How can I avoid stale element error without refreshing the page?
count_added = False
buttons_div = driver.find_elements_by_xpath('//div[@class="btn-group"]')
fin_buttons = buttons_div[2].find_elements_by_xpath('.//button')
fin_count = len(fin_buttons)
if fin_count > 2:
for z in range(fin_count):
if not count_added:
z = z + 2 #Avoid clicking the Title
count_added = True
fin_buttons[z].click()
finition = fin_buttons[z].text
time.sleep(2)
driver.refresh() #Cannot do this. Will take to a different page
See Question&Answers more detail:os