Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JAVA硒。镀铬器。如何启用和禁用扩展?_Java_Selenium Chromedriver - Fatal编程技术网

JAVA硒。镀铬器。如何启用和禁用扩展?

JAVA硒。镀铬器。如何启用和禁用扩展?,java,selenium-chromedriver,Java,Selenium Chromedriver,我使用这段代码来添加自己的扩展,但在加载页面之前,它会自动取消标签。我如何启用它 ChromeOptions options = new ChromeOptions(); options.addArguments("load-extension=..."); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(ChromeOptions.CAPABILITY, optio

我使用这段代码来添加自己的扩展,但在加载页面之前,它会自动取消标签。我如何启用它

ChromeOptions options = new ChromeOptions();
options.addArguments("load-extension=...");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
ChromeDriver driver = new ChromeDriver(capabilities);

要使用Chrome添加扩展并禁用插件,请执行以下操作:

ChromeOptions options = new ChromeOptions();
Map<String, Object> preferences = new Hashtable<String, Object>();
options.setExperimentalOption("prefs", preferences);

// add an extension
options.addExtensions(new File("C:\\extension.crx"));

// disable flash and the PDF viewer
preferences.put("plugins.plugins_disabled", new String[]{
    "Adobe Flash Player", "Chrome PDF Viewer"});


ChromeDriver driver = new ChromeDriver(options);
driver.get("https://www.google.co.uk");
ChromeOptions选项=新的ChromeOptions();
映射首选项=新哈希表();
选项。设置实验选项(“首选项”,首选项);
//添加扩展名
options.addExtensions(新文件(“C:\\extension.crx”);
//禁用flash和PDF查看器
preferences.put(“plugins.plugins_disabled”),新字符串[]{
“Adobe Flash Player”、“Chrome PDF查看器”});
ChromeDriver驱动程序=新的ChromeDriver(选项);
驱动程序。获取(“https://www.google.co.uk");

要添加扩展并禁用Chrome插件,请执行以下操作:

ChromeOptions options = new ChromeOptions();
Map<String, Object> preferences = new Hashtable<String, Object>();
options.setExperimentalOption("prefs", preferences);

// add an extension
options.addExtensions(new File("C:\\extension.crx"));

// disable flash and the PDF viewer
preferences.put("plugins.plugins_disabled", new String[]{
    "Adobe Flash Player", "Chrome PDF Viewer"});


ChromeDriver driver = new ChromeDriver(options);
driver.get("https://www.google.co.uk");
ChromeOptions选项=新的ChromeOptions();
映射首选项=新哈希表();
选项。设置实验选项(“首选项”,首选项);
//添加扩展名
options.addExtensions(新文件(“C:\\extension.crx”);
//禁用flash和PDF查看器
preferences.put(“plugins.plugins_disabled”),新字符串[]{
“Adobe Flash Player”、“Chrome PDF查看器”});
ChromeDriver驱动程序=新的ChromeDriver(选项);
驱动程序。获取(“https://www.google.co.uk");

问题在于,浏览器启动时扩展处于活动状态,但在driver.get()之前关闭;问题是,浏览器启动时扩展处于活动状态,但在driver.get()之前关闭;现在我正试图向chrome发送热键以访问我的分机并激活它,但它们不起作用…现在我正试图向chrome发送热键以访问我的分机并激活它,但它们不起作用。。。