I am trying to go into every city one by one here but after the program comes back from the first page, it does not go into the next page and displays StaleElementReferenceException
error.
This is my code:
url = "https://www.agoda.com/region/punjab-province-pk.html"
s=Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=s)
driver.implicitly_wait(5)
driver.get(url)
a = ActionChains(driver)
cities = driver.find_elements(By.CSS_SELECTOR, value='dt[data-selenium="neighbor-name"]')
for city in cities:
print(city.text)
a.double_click(city).perform()
print(driver.current_url)
driver.back()
Even though when I just print elements in list it displays all of them but does not print or click when I write these lines of code used to navigate forward and back.
What am I doing wrong here?
Any help would be appreciated.