硒webdriver无限期悬挂数小时

时间:2018-04-05 11:46:17

标签: python selenium-webdriver phantomjs selenium-chromedriver

python脚本卡住了。如何生成异常? 例如:代码中使用的url,我该如何处理这种情况。我也试过chromedriver。

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities


url="http://collegeofdesign.info/?page_id=9"

caps = webdriver.DesiredCapabilities.PHANTOMJS
caps["phantomjs.page.settings.resourceTimeout"] = 10
caps["pageLoadStrategy"] = "none"


browser = webdriver.PhantomJS(desired_capabilities=caps,executable_path='/home/md/Downloads/phantomjs-2.1.1-linux-x86_64/bin/phantomjs',service_args=['--ignore-ssl-errors=true', '--ssl-protocol=any','--cookies-file=/tmp/tmpfile'])

browser.set_page_load_timeout(10)
browser.set_script_timeout(5)
browser.implicitly_wait(15)

browser.get(url) ## stuck here infinitely
browser.quit()

0 个答案:

没有答案