2017-01-24 34 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後,它可以正常工作。 也許你可以嘗試降級它。