Selenium Chrome驱动程序“SessionNotCreatedError”

时间:2016-10-19 20:12:51

标签: vba selenium-webdriver selenium-chromedriver

我过去几个月每天都运行这个脚本,出于某种原因,今天它尝试启动时会抛出此错误:

There was an error while the code was executing.
SessionNotCreatedError session not created exception from unknown error:
Runtime.executioncontextCreated has invalid 'context':{"auxData":{frameId":"4120.1","isDefault":true, "id":1,"name":"","origin":"://"}
(Session info: chrome=54.0.2840.59)
(Driver info: chromedriver=2.21371459
(36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4, platform=Windows NT 6.1 SP1 x86_64)

这是我的代码:

Dim drvSelenium As New Selenium.ChromeDriver

drvSelenium.SetPreference "download.default_directory", MyFilePathHere
drvSelenium.SetPreference "download.directory_upgrade", True
drvSelenium.SetPreference "download.extensions_to_open", ""
drvSelenium.SetPreference "download.prompt_for_download", False

drvSelenium.Start "chrome", "http://www.google.com"

当它到达最后一行时它会抛出错误,而我不确定是什么改变了。我可能已经有一些Windows更新运行了一夜,但我无法指出导致它不能突然工作的原因:(

1 个答案:

答案 0 :(得分:1)

当我从:

下载2.24版本时

http://chromedriver.storage.googleapis.com/index.html?path=2.24/

解压缩并运行后,它会打开命令提示符并显示“仅允许本地连接”。但是,我的代码仍然抛出错误。事实证明它正在按预期运作。

我最终做了解决问题的方法是“C:\ Program Files \ SeleniumBasic”并将当前的“chromedriver.exe”重命名为“chromedriver21.exe”,然后复制并粘贴“chromedriver.exe”我从上面的链接下载到该文件夹​​。

现在当我的代码执行时,它正在使用2.24可执行文件并且工作正常。

我确信这对大多数人来说都是一个简单易用的解决方案,如果不是其他所有人的话。但似乎更新这个驱动程序应该更直接,也许它是,我只是错过了它。

在我找到解决方案之前,我没有仔细阅读过,但对于像我这样的人来说,这可能是更好的资源:

https://sites.google.com/a/chromium.org/chromedriver/getting-started

此外,这是我开始的地方,没有指出我正确的方向,我正在添加它来总结我的旅程:

http://www.seleniumhq.org/download/