5

我正在远程 Jenkins Linux 机器上运行我的 Selenium CI 测试。我还使用 WebDriverManager 来管理 Chromedriver。

远程 Chrome 版本是 79.0.3945.88。这是我无权更改的内容。当 Chrome 版本从 78 更新时,我开始收到警告

07:26:19 [1579242379.444][WARNING]: This version of ChromeDriver has not been tested with Chrome version 79.

所以我更新了 Chromedriver

WebDriverManager.chromedriver().version("79.0.3945.88").setup();

但后来我会得到

09:02:35 09:02:35.908 [main] DEBUG i.g.bonigarcia.wdm.WebDriverManager - The proper chromedriver version for your Google Chrome is unknown ... trying with the latest
09:02:37 09:02:36.999 [main] DEBUG i.g.bonigarcia.wdm.WebDriverManager - Latest version of chromedriver according to https://chromedriver.storage.googleapis.com/LATEST_RELEASE is 79.0.3945.36
09:02:37 09:02:37.030 [main] INFO  i.g.bonigarcia.wdm.WebDriverManager - Exporting webdriver.chrome.driver as /var/lib/jenkins/.m2/repository/webdriver/chromedriver/linux64/79.0.3945.36/chromedriver

并且测试仍然会失败,因为页面的 HTML 不会加载。我尝试延长等待时间,但这没有帮助。

正如这里所建议的,接下来我尝试了在https://chromedriver.chromium.org/downloads上找到的所有 Chromedriver 78 和 79 版本,但没有一个起作用。

之后,我试图找到一个精确的.88版本并使用它

WebDriverManager.chromedriver().targetPath(" https://centos.pkgs.org/7/epel-x86_64/chromedriver-79.0.3945.88-1.el7.x86_64.rpm.html ").version("79.0.3904.88" )。设置();

但结果是:

13:33:47 13:33:47.404 [main] INFO  i.g.bonigarcia.wdm.WebDriverManager - Reading https://chromedriver.storage.googleapis.com/ to seek chromedriver
13:33:48 13:33:48.566 [main] ERROR i.g.bonigarcia.wdm.WebDriverManager - chromedriver 79.0.3904.88 for LINUX64 not found in https://chromedriver.storage.googleapis.com/
13:33:48 13:33:48.568 [main] WARN  i.g.bonigarcia.wdm.WebDriverManager - There was an error managing chromedriver 79.0.3904.88 (chromedriver 79.0.3904.88 for LINUX64 not found in https://chromedriver.storage.googleapis.com/) ... trying again using mirror
13:34:59 13:34:59.973 [main] ERROR i.g.bonigarcia.wdm.WebDriverManager - chromedriver 79.0.3904.88 for LINUX64 not found in http://npm.taobao.org/mirrors/chromedriver/
13:34:59 13:34:59.973 [main] WARN  i.g.bonigarcia.wdm.WebDriverManager - There was an error managing chromedriver 79.0.3904.88 (chromedriver 79.0.3904.88 for LINUX64 not found in http://npm.taobao.org/mirrors/chromedriver/) ... trying again using latest from cache
13:35:03 13:35:03.454 [main] DEBUG i.g.bonigarcia.wdm.WebDriverManager - Latest version of chromedriver according to http://npm.taobao.org/mirrors/chromedriver/LATEST_RELEASE is 79.0.3945.36
13:35:53 13:35:53.530 [main] INFO  io.github.bonigarcia.wdm.Downloader - Downloading http://npm.taobao.org/mirrors/chromedriver/79.0.3945.36/chromedriver_linux64.zip
13:35:54 13:35:54.771 [main] INFO  io.github.bonigarcia.wdm.Downloader - Extracting binary from compressed file chromedriver_linux64.zip

我还将 WebDriverManager 从 3.2.0 更新到 3.7.0,最后更新到 3.8.1,但没有任何帮助。

有没有办法让我加载79.0.3945.88.Chromedriver 的精确版本?

还是有其他解决方法?

4

2 回答 2

2

可以找到所有 chromedriver 版本: https ://chromedriver.storage.googleapis.com 所以目前 79 的最新版本是 79.0.3945.36 。您可能可以使用它甚至更新,例如 80.0.3987.16 。

我个人使用工具 selenium-standalone 来完成这项任务。当然,您也可以手动下载驱动程序并使用它。但只需从最简单的驱动程序示例开始即可。

于 2020-01-30T10:33:43.290 回答
0

解决!脚步:

1.)下载chrome webdriver(检查您安装的chrome版本并下载相关驱动程序)表单:https ://sites.google.com/a/chromium.org/chromedriver/downloads

2.) 添加这些行:

System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");

ChromeDriver 驱动程序 = 新的 ChromeDriver();

3.)删除或评论以下内容:(如果存在于您的代码中)

WebDriverManager.chromedriver().setup();

WebDriver driver = new ChromeDriver();

于 2021-07-10T20:14:19.720 回答