2017-01-24 38 views
8

我在这里看到类似的问题Protractor/Selenium Webdriver : Runtime.executionContextCreated has invalid 'context'和这里BUG-1473,但我无法得到答案,因此我决定在这里给它。 我安装了最新的chrome_driver v2.9,但仍然收到Runtime.executionContextCreated错误。 这里是我的代码Selenium:Runtime.executionContextCreated具有无效的“上下文”:

from selenium import webdriver 

driver = webdriver.Chrome() 
driver.get('http://www.google.com/xhtml') 

而抛出的异常蟒外壳:

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/Users/humoyun/Documents/virtual_env_fold/flasky/fl_venv/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 248, in get 
    self.execute(Command.GET, {'url': url}) 
    File "/Users/humoyun/Documents/virtual_env_fold/flasky/fl_venv/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute 
    self.error_handler.check_response(response) 
    File "/Users/humoyun/Documents/virtual_env_fold/flasky/fl_venv/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response 
    raise exception_class(message, screen, stacktrace) 
selenium.common.exceptions.WebDriverException: Message: unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"2061.1","isDefault":true},"id":1,"name":"","origin":"://"} 
    (Session info: chrome=55.0.2883.95) 
    (Driver info: chromedriver=2.9.248307,platform=Mac OS X 10.11.3 x86_64) 
+0

你有没有找到解决方案?我发现有几十个线程运行基本的示例,但都没有解决方案。 – Seth

回答

1

你有你的chromedriver路径传递到Chrome()构造

path = '/path/to/chromedriver' 

driver = webdriver.Chrome(path) 

请让我知道它是否修复。如果有的话,建议尝试使用最新的镀铬汽油,并提出问题。

+0

实际上,我添加了chromeriver的路径到系统路径,如果我没有包含它,我会得到不同的错误,但正如你可以看到异常抛出__driver.get('http://www.google.com/xhtml' )__没有__driver = webdriver.Chrome()__并显示它被找到(会话信息:chrome = 55.0.2883.95)(驱动程序信息:__chromedriver = 2.9.248307__,platform = Mac OS X 10.11.3 x86_64)和版本是最新的。 – Humoyun

+1

你是否尝试过使用最新版本的chromedriver? –

+0

是的,当然,你可以从输出中看到**驱动程序信息:chromedriver = 2.9.248307 ** – Humoyun

5

我有类似的问题,我使用铬驱动程序版本2.25的Mac和它的工作。

1

更新chromedriver版本,然后成功启动浏览器。

3

我有类似的问题。 将我的chrome驱动程序版本从2.9降级到2.27后,它可以正常工作。 也许你可以尝试降级它。