Selenium:Runtime.executionContextCreated具有无效的“context”:

2024-05-29 07:31:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我在这里和这里看了类似的问题,但是我找不到答案,所以我决定在这里给出答案。 我安装了最新的chrome_驱动程序v2.9,但仍然出现Runtime.executionContextCreated错误。 这是我的密码

from selenium import webdriver

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

并在python shell上引发异常:

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)

Tags: inenvvenvlibseleniumlinevirtualfold
3条回答

我也遇到过类似的问题,我在mac上使用了chrome驱动程序2.25版,而且很管用。

我也有类似的问题。 在我将chrome驱动程序版本从2.9降到2.27之后,它就工作了。 也许你可以试着把它降级。

必须将chromedriver路径传递给Chrome()构造函数

path = '/path/to/chromedriver'

driver = webdriver.Chrome(path)

如果修好了请告诉我。此外,建议尝试使用最新的chromedriver,并提出问题,如果有。

相关问题 更多 >

    热门问题