I am scraping a website, where i need to select a value from dropdown. Then i need to click on search button. Which then populates a table with multiple pages of search results. For each result i want to click on it, which redirects to another page, extract data from that. Then come back and do the same for other search results.
select = Select(browser.find_element_by_id("dropdown id here"))
options = select.options
for index in range(0,len(options)):
select.select_by_index(index)
browser.find_element_by_id("checkbox").click()
time.sleep(5)
browser.find_element_by_id("click on search").click()
elems = browser.find_elements_by_xpath("need to enter all href for search results")
time.sleep(5)
for elem in elems:
#Need to enter each search result's href scrape within data and get back to search results again##
elem.get_attribute("href")
elem.click()
browser.find_element_by_id("for going back to search page again").click()
I get this error when i'm trying to iterate
StaleElementReferenceException: Message: stale element reference: element is not attached to the page document (Session info: chrome=87.0.4280.88)