【问题标题】:WebDriverManager take incorrect version of driver in seleniumWebDriverManager 在 selenium 中采用不正确的驱动程序版本
【发布时间】:2020-07-24 13:13:24
【问题描述】:

我正在尝试通过正在使用以下命令安装 chrome 浏览器的 docker 运行 selenium 脚本:

RUN dpkg-divert --add --rename --divert /opt/google/chrome/google-chrome.real /opt/google/chrome/google-chrome \
    && echo "#!/bin/bash\nexec /opt/google/chrome/google-chrome.real --no-sandbox --disable-setuid-sandbox \"\$@\"" > /opt/google/chrome/google-chrome \
    && chmod 755 /opt/google/chrome/google-chrome

以上命令是安装chrome浏览器84版:

Setting up google-chrome-stable (84.0.4147.89-1) ...
update-alternatives: using /usr/bin/google-chrome-stable to provide /usr/bin/x-www-browser (x-www-browser) in auto mode
update-alternatives: using /usr/bin/google-chrome-stable to provide /usr/bin/gnome-www-browser (gnome-www-browser) in auto mode
update-alternatives: using /usr/bin/google-chrome-stable to provide /usr/bin/google-chrome (google-chrome) in auto mode

但 WebDriverManager 正在安装驱动程序版本 85:

 10 [TestNG-test=StructurePhoto-1] INFO io.github.bonigarcia.wdm.WebDriverManager - Please answer the following questionnaire based on your experience with WebDriverManager. Thanks a lot!
10 [TestNG-test=StructurePhoto-1] INFO io.github.bonigarcia.wdm.WebDriverManager - ====> XXXXXXX.cc/wdm-survey <====
876 [TestNG-test=StructurePhoto-1] INFO io.github.bonigarcia.wdm.WebDriverManager - Reading https://chromedriver.storage.googleapis.com/ to seek chromedriver
1825 [TestNG-test=StructurePhoto-1] INFO io.github.bonigarcia.wdm.online.Downloader - Downloading https://chromedriver.storage.googleapis.com/85.0.4183.38/chromedriver_linux64.zip
4148 [TestNG-test=StructurePhoto-1] INFO io.github.bonigarcia.wdm.online.Downloader - Extracting binary from compressed file chromedriver_linux64.zip
6296 [TestNG-test=StructurePhoto-1] INFO io.github.bonigarcia.wdm.WebDriverManager - Exporting webdriver.chrome.driver as /root/.m2/repository/webdriver/chromedriver/linux64/85.0.4183.38/chromedriver
Starting ChromeDriver 85.0.4183.38 (9047dbc2c693f044042bbec5c91401c708c7c26a-refs/branch-heads/4183@{#779}) on port 24023
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

由于上述版本不匹配,脚本失败。 我正在使用依赖项:

<dependency>
             <groupId>io.github.bonigarcia</groupId>
             <artifactId>webdrivermanager</artifactId>
             <version>4.0.0</version>
        </dependency>

我不确定出了什么问题,有人可以帮我解决这个问题。

谢谢。

【问题讨论】:

    标签: java selenium selenium-webdriver webdriver


    【解决方案1】:

    请使用下面的行,您可以在其中指定版本号。

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

    【讨论】:

    • 如果我使用修复版本,它会在版本更新时产生问题....我也在 chrome 版本为 83 的 Windows 机器上运行相同的 selenium 脚本......所以我没有想要使用 WebDriverManager 的修复版本。
    • 是的,这是一个已知的限制。但是,你试过 4.1.0 版本吗?
    • 我已经尝试过使用 WebDriverManager version-4.1.0 但仍然遇到同样的问题。
    猜你喜欢
    • 1970-01-01
    • 2017-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-01
    • 2015-08-29
    相关资源
    最近更新 更多