更多细节可以帮助。你有错误信息吗?你的代码如何?
在任何情况下,一些想法,可能有助于弄清楚发生了什么事是:
设置窗口的大小,以适合你的测试的东西。
driver.set_window_size(900, 800)
保存屏幕截图。
driver.save_screenshot('screen.png')
检查页面源是否符合您的期望。
with open('temp.html', 'w') as f:
f.write(driver.page_source)
您可能会尝试查看升级Selenium是否有帮助。
pip install selenium --upgrade
您可以通过下载并指定路径来测试other versions of PhantomJS。 1.9.8版帮助我绕过了过去的一些安全限制。
driver = webdriver.PhantomJS(
executable_path='/path/to/the/downloaded/phantomjs19',
# you can specify args, such as:
service_args=[
'--ignore-ssl-errors=true',
'--ssl-protocol=any',
'--web-security=false',
],
# and also other capabilities:
desired_capabilities={
'phantomjs.page.settings.resourceTimeout': '5000',
'phantomjs.page.settings.userAgent': (
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53 "
"(KHTML, like Gecko) Chrome/15.0.87"
),
},
)
请让我知道这是否有帮助!
此问题应提供重现问题的步骤,包括代码。为什么?因为用于调试的策略取决于您尝试执行的具体操作。而“挂在启动”是一个非常模糊的描述。 – Louis
我对windows不太了解,但是在Unix系统上,selenium和phantomjs对stderr和stdout IO模式做了一些更改,所以它可能会以某种方式使IO流死锁。我遇到的这个问题可能与相关阅读:http://stackoverflow.com/questions/22669734/ioerror-errno-35-resource-temporarily-unavailable-with-phantomjs-python-s – RecursivelyIronic