我试图使用我使用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();
1条答案
按热度按时间qcbq4gxm1#
此错误消息...
...表示您使用的Selenium版本不支持google-chrome浏览器版本。
详情
您使用的是 Chrome版本86和 Senenium v4.0.0。但是Selenium v4.0.0的CHANGELOG提到:
由于 Selenium v4.0.0 不支持 Chrome Version 86,因此您会看到错误。
解决方案
一种可能的做法是确保: