我正在尝试运行Selenium的Firefox webdriver,并得到下面的错误。我可以看到response
没有sessionId
-有问题的行是self.session_id = response['sessionId']
-但是我不知道为什么。我用以下方法运行此程序,得到相同的错误:
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\dev\tools\cygwin\home\207013288\dev\projects\scorpion\test\unit\test_
approve_workflows.py", line 27, in test_login
'password', userid='207013288', test=True)
File "C:\dev\tools\cygwin\home\207013288\dev\projects\scorpion\src\workflows.p
y", line 20, in login
browser = webdriver.Firefox()
File "C:\dev\sdks\Python33\lib\site-packages\selenium-2.32.0-py3.3.egg\seleniu
m\webdriver\firefox\webdriver.py", line 62, in __init__
desired_capabilities=capabilities)
File "C:\dev\sdks\Python33\lib\site-packages\selenium-2.32.0-py3.3.egg\seleniu
m\webdriver\remote\webdriver.py", line 72, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\dev\sdks\Python33\lib\site-packages\selenium-2.32.0-py3.3.egg\seleniu
m\webdriver\remote\webdriver.py", line 116, in start_session
self.session_id = response['sessionId']
nose.proxy.KeyError: 'sessionId'
-------------------- >> begin captured logging << --------------------
selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:63801/
hub/session {"sessionId": null, "desiredCapabilities": {"version": "", "browserN
ame": "firefox", "platform": "ANY", "javascriptEnabled": true}}
--------------------- >> end captured logging << ---------------------
我以前没用过硒,我不知道从这里到哪里去。
好吧,首先我想说的是,我差点把头发都拔了,想把它修好。 我的设置: Python2.7 火狐22.0 Selenium网络驱动程序2.33 Windows XP(通过代理服务器进行internet连接)
发现我的问题了吗?
解决方案:
对我不起作用的事情:
在找到这个解决方案之前(在更有经验的工程师的帮助下),我仔细阅读了这里的说明:http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp#advanceduserinteractions .. 用于设置/更改/绕过代理。但我没有得到我想要的结果。
我也看到了这个: Implementing WebdriverBackedSelenium in Python .. 但它提到了一个旧版本的webdriver,并建议删除系统范围内的所有代理设置,这绝对是一个不可启动的(就我而言)。
MAC OSX解决方案
我使用的是Python2.7、Firefox48.0.2和Chrome57.0.2987.98(64位)。
我的错误
*self.session_id = response['sessionId']*
已通过转到“Wifi”选项卡中的“系统首选项”->;“网络”->;“高级”解决。->;代理->;打开“自动代理检测”。更改后,错误不再发生。
相关问题 更多 >
编程相关推荐