英文:
WebDriverManager take incorrect version of driver in selenium
问题
以下是翻译好的内容:
我正在尝试通过Docker运行Selenium脚本,该脚本使用以下命令安装Chrome浏览器:
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:
正在设置 google-chrome-stable (84.0.4147.89-1) ...
update-alternatives: 正在使用 /usr/bin/google-chrome-stable 以提供 /usr/bin/x-www-browser (x-www-browser) 的自动模式
update-alternatives: 正在使用 /usr/bin/google-chrome-stable 以提供 /usr/bin/gnome-www-browser (gnome-www-browser) 的自动模式
update-alternatives: 正在使用 /usr/bin/google-chrome-stable 以提供 /usr/bin/google-chrome (google-chrome) 的自动模式
但是WebDriverManager正在安装驱动程序版本85:
10 [TestNG-test=StructurePhoto-1] INFO io.github.bonigarcia.wdm.WebDriverManager - 请根据您使用WebDriverManager的经验回答以下问卷。非常感谢!
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 - 读取 https://chromedriver.storage.googleapis.com/ 以查找 chromedriver
1825 [TestNG-test=StructurePhoto-1] INFO io.github.bonigarcia.wdm.online.Downloader - 正在下载 https://chromedriver.storage.googleapis.com/85.0.4183.38/chromedriver_linux64.zip
4148 [TestNG-test=StructurePhoto-1] INFO io.github.bonigarcia.wdm.online.Downloader - 正在从压缩文件 chromedriver_linux64.zip 中提取二进制文件
6296 [TestNG-test=StructurePhoto-1] INFO io.github.bonigarcia.wdm.WebDriverManager - 将 webdriver.chrome.driver 导出为 /root/.m2/repository/webdriver/chromedriver/linux64/85.0.4183.38/chromedriver
正在启动 ChromeDriver 85.0.4183.38 (9047dbc2c693f044042bbec5c91401c708c7c26a-refs/branch-heads/4183@{#779}),端口为 24023
仅允许本地连接。
有关保护 ChromeDriver 的建议,请参阅 https://chromedriver.chromium.org/security-considerations。
ChromeDriver 已成功启动。
由于上述版本不匹配,脚本执行失败。我正在使用以下依赖项:
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>4.0.0</version>
</dependency>
我不确定出了什么问题,可以有人帮忙吗?
谢谢。
英文:
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
得分: 0
请使用以下行,您可以在其中指定版本号。
WebDriverManager.chromedriver().version("84").setup();
英文:
Please use the below line, where you can specify the version number.
WebDriverManager.chromedriver().version("84").setup();
专注分享java语言的经验与见解,让所有开发者获益!
评论