随机'连接被重置'与Selenium的网页

时间:2015-04-17 09:51:13

标签: python selenium

我们使用selenium来测试我们是否能够浏览。但有时间歇性地,selenium会在地址栏中键入实际的URL,但页面不会加载,而是“连接已重置”页面加载。

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("http://www.google.com")

#Timeout setting block
self.selenium.set_timeout(90)
While True:
   if time.time() - start_time < 90:
     try:
       # Waiting 1 second for page load
       self.selenium.wait_for_page_to_load('1000')
       self.log.info('Page loaded')
     except Exception as e:

       msg = ('Ignore Selenium error till page loads:'
                       ' {0}'.format(e))
       self.log.info(msg)
   else:
     break

0 个答案:

没有答案