Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 键错误';sessionId';启动phantomJS时_Macos_Python 3.x_Selenium_Phantomjs - Fatal编程技术网

Macos 键错误';sessionId';启动phantomJS时

Macos 键错误';sessionId';启动phantomJS时,macos,python-3.x,selenium,phantomjs,Macos,Python 3.x,Selenium,Phantomjs,当我尝试自己运行phamtonjs时,收到了一个很好的回溯: Traceback (most recent call last): File "test_selenium.py", line 4, in <module> phantom_brow = webdriver.PhantomJS('phantomjs-2.1.1-macosx/bin/phantomjs') File "/Users/me/.virtualenvs/test_bed/lib/python3.

当我尝试自己运行phamtonjs时,收到了一个很好的回溯:

Traceback (most recent call last):
  File "test_selenium.py", line 4, in <module>
    phantom_brow = webdriver.PhantomJS('phantomjs-2.1.1-macosx/bin/phantomjs')
  File "/Users/me/.virtualenvs/test_bed/lib/python3.5/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 58, in __init__
desired_capabilities=desired_capabilities)
  File "/Users/me/.virtualenvs/test_bed/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
self.start_session(desired_capabilities, browser_profile)
  File "/Users/me/.virtualenvs/test_bed/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 180, in start_session
self.session_id = response['sessionId']
KeyError: 'sessionId'

目前在ElCap的代理后面。不过,在我的Windows并行系统上运行时没有问题。

这可能与您使用代理有关:@ele在启动phantomjs之前,是否可以加载任何设置以允许它通过代理?将代理作为服务添加到args中到目前为止没有任何效果。我还应该注意,Chrome和Firefox将被加载。也许这个解决方案会有所帮助?:这可能与您使用代理有关:@elethan在启动phantomjs允许它通过代理之前,我可以加载任何设置吗?将代理作为服务添加到args中到目前为止没有任何效果。我还应该注意,Chrome和Firefox将加载。也许这个解决方案会有所帮助
from selenium import webdriver

if __name__ == '__main__':
    phantom_brow = webdriver.PhantomJS('phantomjs-2.1.1-macosx/bin/phantomjs')