Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable chrome extension in selenium

I am trying to disable all chrome extensions when starting up my selenium chrome. But all extensions keep starting up each time I run the code. Is there a way of disabling the extensions.

Sample Code

public static void main(String[] args) throws IOException {
    System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver.exe");
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability("chrome.binary", "C:\\Users\\ngzhongqin\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");
    WebDriver driver = new ChromeDriver(capabilities);
    driver.get("http://www.cnn.com");
    WebElement searchBox = driver.findElement(By.name("q"));
}

 
like image 310
Ng Zhong Qin Avatar asked Dec 27 '12 03:12

Ng Zhong Qin


People also ask

Which of the following selenium code is used to disable plugins?

addArguments("--disable-extensions"); // Start the chrome session WebDriver driver = new ChromeDriver(options);

Should I disable extensions in Chrome?

They can slow down your browser and even present security risks. It's worth taking a few minutes to look through your Chrome extensions to see which ones you have installed and whether you're actually using them. If you're not using them regularly, you should disable them.


1 Answers

Found a fix.

  capabilities.setCapability("chrome.switches", Arrays.asList("--disable-extensions"));
like image 86
Ng Zhong Qin Avatar answered Nov 15 '22 10:11

Ng Zhong Qin