Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.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
如何在selenium中禁用chrome扩展_Selenium_Google Chrome Extension_Chromium - Fatal编程技术网

如何在selenium中禁用chrome扩展

如何在selenium中禁用chrome扩展,selenium,google-chrome-extension,chromium,Selenium,Google Chrome Extension,Chromium,我试图在启动selenium chrome时禁用所有chrome扩展。 但每次我运行代码时,所有扩展都会不断启动。 是否有办法禁用扩展 示例代码 找到了解决办法 capabilities.setCapability("chrome.switches", Arrays.asList("--disable-extensions")); 设置功能chrome.Switchs不适用于我(chrome版本53.0.2785.143 m,ChromeDriver 2.18.343845) 相反,使用选

我试图在启动selenium chrome时禁用所有chrome扩展。 但每次我运行代码时,所有扩展都会不断启动。 是否有办法禁用扩展

示例代码 找到了解决办法

  capabilities.setCapability("chrome.switches", Arrays.asList("--disable-extensions"));
设置功能chrome.Switchs不适用于我(chrome版本53.0.2785.143 m,ChromeDriver 2.18.343845)

相反,使用选项可以:

ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-extensions");
driver = new ChromeDriver(options);
或根据将选项设置为功能

ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-extensions");
caps.setCapability(ChromeOptions.CAPABILITY, options);
driver = new ChromeDriver(caps);

ChromeDriver(功能)已弃用

请使用以下设置chrome选项:

ChromeOptions options = new ChromeOptions();
options.addArguments("chrome.switches","--disable-extensions");
ChromeOptions options = new ChromeOptions();
options.addArguments("chrome.switches","--disable-extensions");