What is the best way to check URL change with Selenium in Python?

前端 未结 5 2008
我在风中等你
我在风中等你 2020-12-10 15:42

So, what\'s I want to do is to run a function on a specific webpage (which is a match with my regex).

Right now I\'m checking it every second and it works, but I\'m

5条回答
  •  死守一世寂寞
    2020-12-10 15:57

    This is how I implemented it eventually. Works well for me:

    driver = webdriver.Chrome()
    wait = WebDriverWait(driver, 5)
    desired_url = "https://yourpageaddress"
    
    def wait_for_correct_current_url(desired_url):
        wait.until(
            lambda driver: driver.current_url == desired_url)
    

提交回复
热议问题