0

I am creating some tests and once in a while Firefox gets stuck on loading a page forever (until I manually refresh or press the ESC key) I'm using Python 2.7.11 and Selenium 2.53.6 and Firefox 46 (tested 39 as well)

I set the following preferences for the Driver:

driver.set_page_load_timeout(30)
profile.set_preference("network.http.response.timeout", 0.5)
profile.set_preference('webdriver.load.strategy', 'unstable')

Sometimes the timeoutExeption is caught and selenium restarts the loop, however sometimes this does not happen.

How can I stop this behavior?

Ferri.ema
  • 13
  • 5
  • What is your firefox version? – Sirsendu Aug 10 '16 at 14:58
  • 46. Sorry! I added to the question :) – Ferri.ema Aug 10 '16 at 15:30
  • Oops! Missed.,, can you please try with 39 or anything below 40 – Sirsendu Aug 10 '16 at 15:47
  • I am trying now with Firefox 39. Since I am not sure how to exactly replicate the issue, I need to let it run for a while and will get back to you! – Ferri.ema Aug 10 '16 at 17:58
  • The test just ran into the same issue. :( Loading forever on the last page of the test (where the test is supposed to driver.close and start over again) – Ferri.ema Aug 10 '16 at 18:13
  • I think `profile.set_preference("network.http.response.timeout", 5)` is the right name and syntax (it's integer, so minimum is 1 sec, but 5 sec is more realistic expectation). Also try `profile.set_preference("dom.max_script_run_time", 30)` which could be helpful if your page is stuck running script – timbre timbre Aug 10 '16 at 19:31
  • @KirilS. I changed the network.http.response.timeout to 25 and added the max_script. However I get nosuchelement error after 2 seconds of page load. I also have profile.set_preference('webdriver.load.strategy', 'unstable') which is what causes the issue. However without this preference selenium gets stuck much more often – Ferri.ema Aug 10 '16 at 20:56
  • if you are getting "nosuchelement" on `driver.get_element_by_...` function, use `WebDriverWait` after `get`, similar to explanation in the first answer to this question: http://stackoverflow.com/questions/26566799/selenium-python-how-to-wait-until-the-page-is-loaded. The reason it happens is because `get` does not really guarantee that page is really loaded. So you have to create your own conditions with Wait – timbre timbre Aug 10 '16 at 21:54

0 Answers0