My code:
count = 1
next_page_string = "javascript:__doPostBack('ctl00$MainContent$grdResults','Page$" + str(count) + "')"
td_page_number_list = driver.find_elements_by_xpath("//*[@id='MainContent_grdResults']/tbody/tr[22]/td/table/tbody/tr/td/a")
for x in td_page_number_list:
if x.get_attribute("href") == next_page_string:
driver.execute_script("__doPostBack('ctl00$MainContent$grdResults','Page$" + str(count) + "')")
The code is breaking when driver object
goes to execute_script
after the condition is met, giving me error:
stale element reference: element is not attached to the page document
It seems like this has something to do with the for loop in use. I have tried the implicit wait with no luck.
Thank you in advance.