WebDriverManager take incorrect version of driver in selenium

柔情痞子 提交于 2020-08-08 05:32:32

问题


I am trying to run the selenium script through the docker which is installing the chrome browser using following command:

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

the above command is installing the chrome browser version 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

but the WebDriverManager is installing the driver version 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.

Because of above version miss-match the scripts are failing. i am using the dependency:

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

I am not sure what is going wrong can someone please help me on this.

Thanks.


回答1:


Please use the below line, where you can specify the version number.

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


来源:https://stackoverflow.com/questions/63074312/webdrivermanager-take-incorrect-version-of-driver-in-selenium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!