gpt4 book ai didi

java - 无法使用最新的 selenium 驱动程序 + Chrome 驱动程序启动带有扩展名的 URL

转载 作者:行者123 更新时间:2023-12-02 06:02:37 25 4
gpt4 key购买 nike

添加扩展程序时 Chrome 驱动程序卡住/无法启动网址

Chrome浏览器74.0.3729.131(官方版本)(64位)
ChromeDriver 74.0.3729.6
SeleniumDriver selenium-server-standalone-3.141.59

public class ChromeBrowser {

public static void main(String args[]){

try{
//Code working with out extensions
System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");

//Code failed with extensions
ChromeOptions options = new ChromeOptions();
options.addExtensions(new File("./drivers/modheader_2_1_2.crx"));
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
ChromeDriver drivers = new ChromeDriver(capabilities);
drivers.get("http://www.google.com");
}
catch(Exception e){
System.out.println("Exception caught :: "+e.getMessage());
}

}
}

最佳答案

添加扩展是 Chrome 的一项功能,因此您可以忽略这两行

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);

并通过

ChromeDriver drivers = new ChromeDriver(options);

到 ChromeDriver

关于java - 无法使用最新的 selenium 驱动程序 + Chrome 驱动程序启动带有扩展名的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55965436/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com