Simple question, is it possible to resume selenium code the moment the browser lands on a certain URL?
            Asked
            
        
        
            Active
            
        
            Viewed 130 times
        
    2 Answers
1
            import sys
WebDriverWait(driver, sys.maxsize - 1).until(lambda s: s.current_url == "https://www.myurl.com/")
 
    
    
        Mick
        
- 796
- 4
- 8
- 
                    What does `sys.maxsize - 1` does? – undetected Selenium Jan 10 '21 at 20:53
- 
                    It will wait forever – Mick Jan 10 '21 at 20:53
- 
                    or more accurately, for 2^64 - 1 seconds – Mick Jan 10 '21 at 20:53
0
            
            
        When you invoke get() method, Selenium executes the next line only when the browser attains document.readyState equals complete.
So you don't have to take any additional steps for Selenium to resume code execution the moment the browser lands on a certain url.
However, in some rarest of the rare cases you may have to explicitly wait for document.readyState to be equal to complete using:
driver.execute_script("return document.readyState").equals("complete"))
References
You can find a couple of relevant detailed discussions in:
 
    
    
        undetected Selenium
        
- 183,867
- 41
- 278
- 352
