使用PhantomJS的Selenium在尝试启动会话时会发出KeyError:'sessionId'

时间:2015-09-22 15:23:35

标签: python macos selenium phantomjs

我正在尝试在Mac上使用Selenium(2.47.3)和PhantomJS(2.0.0),但在标题中收到错误。 Python是3.5.0。

Traceback (most recent call last):
File "/Users/QuickSilver/Desktop/autocrawlerfinal.py", line 31, in <module>
driver = webdriver.PhantomJS('/Users/QuickSilver/Desktop/crawler/phantomjs-2.0.0-macosx/bin/phantomjs', port=631)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 56, in __init__
desired_capabilities=desired_capabilities)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 87, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 143, in start_session
self.session_id = response['sessionId']
KeyError: 'sessionId'

要重现的最小代码是

from selenium import webdriver
driver = webdriver.PhantomJS('/Users/QuickSilver/Desktop/crawler/phantomjs-2.0.0-macosx/bin/phantomjs', port=631)

在线提到这个错误的唯一提到系统代理,但没有,并且无论如何都将localhost添加到例外。可能导致这种情况的原因是什么?

0 个答案:

没有答案