Chrome 需要使用类似于selenium-devtools-v86:4.0.0 error using Selenium and jsoup的内容包含对特定版本CDP的依赖

nimxete2  于 2023-06-19  发布在  Go
关注(0)|答案(1)|浏览(189)

我试图使用我使用Selenium导航到的网页的URL,使用Jsoup访问该网页。
但是,当我尝试这样做时,我在控制台中收到以下消息:“警告:找不到要用于的CDP版本。您可能需要使用类似于org.seleniumhq.selenium:selenium-devtools-v86:4.0.0的东西来包含对CDP特定版本的依赖性,其中版本(“v86”)与您使用的基于chrome的浏览器的版本相匹配,并且工件的版本号与Selenium的版本号相同。
我不知道我做错了什么,或者还有其他方法可以达到这一点。

System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir").concat("\\chromedriver" + ".exe"));
WebDriver driver = new ChromeDriver();
driver.get("https://www.chapters.indigo.ca/en-ca/");
WebElement webElement = driver.findElement(By.id("header__quick-search"));
webElement.sendKeys("9780385697378");
webElement.submit();
driver.findElement(By.className("product-list__product-title")).click();
String url = driver.getCurrentUrl();
final Document document = Jsoup.connect(url).get();
qcbq4gxm

qcbq4gxm1#

此错误消息...

WARNING: Unable to find version of CDP to use for . You may need to include a dependency on a specific version of the CDP using something similar to `org.seleniumhq.selenium:selenium-devtools-v86:4.0.0` where the version ("v86") matches the version of the chromium-based browser you're using and the version number of the artifact is the same as Selenium's.

...表示您使用的Selenium版本不支持google-chrome浏览器版本。

详情

您使用的是 Chrome版本86Senenium v4.0.0。但是Selenium v4.0.0的CHANGELOG提到:

  • 支持的CDP版本:八十五、九十三、九十四、九十五

由于 Selenium v4.0.0 不支持 Chrome Version 86,因此您会看到错误。

解决方案

一种可能的做法是确保:

  • Selenium 更新为***v4.1.3***
  • Chrome 更新为***Chrome v100.0***
  • ChromeDriver 更新为ChromeDriver v100.0.4896.60级别,与 chrome=100.0 匹配。

相关问题