Issue
Hei there So I recently finished a small script that uses selenium to visit a website and download a specific part of it as image. I didn't find any other way than using selenium. I am really new with using this api. Now the script works, on my windows and on my linux machine. But I have a weird error that I don't really get. I know why the error happens according to other posts I saw, but I tripple checked that all my versions match. Below I will post all the versions I use and the script itself. Important is that the script works and does the screenshot as it should, but the warning is still probably not a good thing right? I am out of ideas to fix it
Things I was able to find out
I am pretty sure it has to have something to do with my Jar file. The error only happens if I use a jar file on windows or linux. With my intelliJ idea it doesn't produce any error. Now I generate the jar file with intelliJ and I dont really know what could cause this. I tried to readd my dependencies and nothing helped. Any help is greatly appreciated
Error output from my Java jar
Starting ChromeDriver 101.0.4951.41 (93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951@{#904}) on port 42307 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. Apr 29, 2022 8:40:21 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C Apr 29, 2022 8:40:21 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch WARNING: Unable to find an exact match for CDP version 101, so returning the closest version found: 100 Apr 29, 2022 8:40:21 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch INFO: Found CDP implementation for version 101 of 100
Part of my pom.xml. I generated the jar with intelliJ tho and not maven directly
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.1.4</version>
</dependency>
</dependencies>
Code snippet from script
System.setProperty("webdriver.chrome.driver", chromedriverPath);
ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized", "--headless", "--window-size=2560,1440","--ignore-certificate-errors","--disable-extensions","--disable-dev-shm-usage");
options.addArguments("--log-level=3");
WebDriver driver = new ChromeDriver(options);
driver.get("somewebsiteurl (placeholder)" + code);
Chrome version on my ubuntu machine (same on windows)
➜ MRimagedownloader google-chrome --version
Google Chrome 101.0.4951.41
And this is the version of chromedriver I used. Of course the windows one for windows and the linux for my ubuntu machine
https://chromedriver.storage.googleapis.com/index.html?path=101.0.4951.41/
Solution
This error message...
Apr 29, 2022 8:40:21 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch WARNING: Unable to find an exact match for CDP version 101, so returning the closest version found: 100
Apr 29, 2022 8:40:21 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch INFO: Found CDP implementation for version 101 of 100
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. google-chrome
Deep Dive
Your main issue is the incompatibility between the version of the binaries you are using as follows:
- Presumably you are using the updated Google Chrome Version 101.0.
- Your are using ChromeDriver 101.0
- You are also using Selenium v4.1.4 where the release notes mentions:
- Supported CDP versions: 85, 99, 100, 101
Everything seems in perfect sync and ideally should have worked out of the box.
However, I strongly believe the instance of Google Chrome pointed by MRimagedownloader
is of version 101.0 where as the instance of Google Chrome used by Selenium is of version 100.0.
You need to upgrade the version of Google Chrome used by Selenium to v101.0.
Answered By - undetected Selenium
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.