0

I have a very complex py.test script that uses selenium to test a non-public webpage. In that test script I have the following code:

wait = WebDriverWait(driver, 1)
result = wait.until(EC.element_to_be_clickable(('xpath', "//span[contains(text(), 'Start simulation')]/..")))

According to the documentation (or here), I expect that piece of code to 'wait' for a maximum of 1 second. However, it is stuck there for about 256 seconds!

Why is that? How can that happen?

Versioning information: - pytest==3.6.1 - selenium==3.14.1

Alex
  • 41,580
  • 88
  • 260
  • 469
  • 1
    Just note that this is not the official documentation. It is clearly mentioned on the home page https://selenium-python.readthedocs.io/index.html – Bitto Feb 22 '19 at 10:14
  • So where is the official documentation then. It is not clearly mentioned on the home page https://selenium-python.readthedocs.io/index.html. – Alex Feb 22 '19 at 10:15
  • No. Nothing mentions where to find the official documentation. – Alex Feb 22 '19 at 10:17
  • The official documentation i believe is at https://www.seleniumhq.org/docs/ – Bitto Feb 22 '19 at 10:18
  • 'contribute', 'fork'? what? – Alex Feb 22 '19 at 10:18
  • @Alex did you try to set page load timeout: `driver.set_page_load_timeout(1)`? – Sers Feb 22 '19 at 11:01

3 Answers3

3

Please check if you have an implicit wait somewhere in your code. Its a good idea not to mix implicit and explicit waits. One known issue is that if you have implicit wait somewhere else, that might affect the explicit wait time.

https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/2948

Bitto
  • 7,937
  • 1
  • 16
  • 38
  • The wait is absolutely definitively with 100% certainty in this line of code: `result = wait.until(EC.element_to_be_clickable(('xpath', "//span[contains(text(), 'Start simulation')]/..")))` – Alex Feb 22 '19 at 10:35
  • @Alex You don't know that... just because it *fails* there, doesn't mean that it's not due to a bad interaction with implicit waits. Do you have an implicit wait set? The docs clearly state not to mix the two. – JeffC Feb 22 '19 at 14:27
2

WebDriverWait only starts waiting after the page is loaded (browser returns document.readyState == 'complete'). If the page load takes 256 seconds, the WebDriverWait hasn't even started yet.

JeffC
  • 22,180
  • 5
  • 32
  • 55
0

Just Check If you try instead of this.

wait = WebDriverWait(driver, 1)
result = wait.until(EC.element_to_be_clickable(('xpath', "//span[contains(text(), 'Start simulation')]/..")))

Try this to make any difference.

wait = WebDriverWait(driver, 1)
    result = wait.until(EC.element_to_be_clickable((By.XPATH, "//span[contains(text(), 'Start simulation')]/..")))
KunduK
  • 32,888
  • 5
  • 17
  • 41
  • same behavior as before. Waits only 60 seconds now. – Alex Feb 22 '19 at 10:32
  • well could you please share html part of the script you are trying? – KunduK Feb 22 '19 at 10:34
  • good question. I cannot. The whole browser is unresponsive. I am unable to open a developer console. Interesting... – Alex Feb 22 '19 at 10:37
  • As it turns out, it seems to be a problem with the page I am trying to load. It essentially blocks everything, including selenium somehow. So your question regarding the page content brought me in the right direction. – Alex Feb 22 '19 at 10:48