4

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/

tctfox
  • 95
  • 1
  • 1
  • 4
  • That's normal. It will fallback to latest available. Devtools CDP version (bindings?) come from the Selenium package. They just added CDP version 101 (to match with chromedriver v101) 2 days ago in github, and I don't think that version has been released yet: https://github.com/SeleniumHQ/selenium/tree/trunk/java/src/org/openqa/selenium/devtools – pcalkins Apr 29 '22 at 19:52

2 Answers2

3

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.


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.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    Hei there. Thanks for the answer! How would I change that tho? On my Linux system there is only one Chrome version. Has this something to do with some dependencies? – tctfox Apr 30 '22 at 06:31
0

I had the same problem, using maven with vscode, but solved it after being hinted by what you wrote: "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. "

When exporting the jar file, the GUI presents me with a list of elements, of which 88 were preselected, including these:

  • selenium-devtools-v104-4.5.0.jar
  • selenium-devtools-v105-4.5.0.jar
  • selenium-devtools-v106-4.5.0.jar

This fixed it: I unchecked v104 and v105

Now I get this response:

okt. 08, 2022 6:22:38 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch INFO: Found exact CDP implementation for version 106

Nakilon
  • 34,866
  • 14
  • 107
  • 142