Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

The Selenium documentation mentions that the Chrome web driver can take an instance of  ChromeOptions., but I can't figure out how to create  ChromeOptions.

I'm hoping to pass the   --disable-extensions  flag to Chrome.

1 Answer

0 votes
by (62.9k points)

You can create an instance of ChromeOptions, which has convenient methods for setting ChromeDriver-specific capabilities. You can then pass the ChromeOptions object into the ChromeDriver constructor:

Below is the code:

DesiredCapabilities capabilities = DesiredCapabilities.chrome();

ChromeOptions options = new ChromeOptions();

options.addArguments("test-type");

capabilities.setCapability("chrome.binary", "<Path to binary>");

capabilities.setCapability(ChromeOptions.CAPABILITY, options);

webDriver = new ChromeDriver(capabilities);  

Hope this helps!

Browse Categories

...