我面临一些有关 Selenium 脚本的问题。到目前为止,我使用的是 Chrome v73,它会自动更新到 v74。现在的问题是,当我尝试执行时代码没有执行。抛出以下错误。 有人可以建议如何执行吗?
Starting ChromeDriver 73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72) on port 36996
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created: Chrome version must be between 70 and 73
(Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.06 seconds
最佳答案
ChromeDriver - WebDriver for Chrome 的当前版本部分明确提到以下内容:
- 如果您使用的是 Chrome 版本 75,请下载 ChromeDriver 75.0.3770.8
- 如果您使用的是 Chrome 版本 74,请下载 ChromeDriver 74.0.3729.6
- 如果您使用的是 Chrome 版本 73,请下载 ChromeDriver 73.0.3683.68
- 对于旧版本的 Chrome,请参阅 this discussion了解支持它的 ChromeDriver 版本。
解决方案
如果您使用的是 Chrome v74.x,则必须使用 ChromeDriver v74.0.3729.6 作为强制措施。
<小时/>ChromeDriver 放弃向后兼容性
John Chen(所有者 - chromedriver)最近确认:
<小时/>Backward compatibility was dropped from ChromeDriver for a couple of reasons:
- It adds complexity to the code, and is expensive to maintain.
- It requires an infrastructure to test each build of ChromeDriver against multiple versions of Chrome. There is no such requirement anywhere else inside Chrome, and it became increasingly difficult to convince our build team to maintain such an infrastructure just for ChromeDriver.
I understand this creates difficulty for some of our users, but unfortunately it has become impossible for us to keep supporting the backward compatibility.
John Chen 的电子邮件快照
<小时/>引用
您可以在以下位置找到相关的详细讨论:
关于selenium - 由于向后兼容性已被删除,如何使用 ChromeDriver 73 和 Chrome 版本 74 执行现有的 selenium 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55956014/