1

Simple question, is it possible to resume selenium code the moment the browser lands on a certain URL?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
MadeInUtrecht
  • 69
  • 1
  • 9

2 Answers2

1
import sys

WebDriverWait(driver, sys.maxsize - 1).until(lambda s: s.current_url == "https://www.myurl.com/")
Mick
  • 796
  • 4
  • 8
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