Skip to main content

Adding Browser Extentions with Selenium WebDriver

When Selenium WebDriver launch a browser , it creates a new profile or options set with browser's default features.This launched browser does not contain addons or extentions.In everytime we need to add on , which addon or extention we want to use.

Chrome

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addExtensions( new File( "/path/to/extension.crx" )) ;
driver = new ChromeDriver(chromeOptions);

Firefox

FirefoxProfile profile = new FirefoxProfile() ; 
profile.addExtension( new File( "/path/to/addon.xpi" )) ; 
FirefoxOptions firefoxOptions = new FirefoxOptions() ; 
firefoxOptions.setProfile(profile) ; 
FirefoxDriver driver = new FirefoxDriver(firefoxOptions) ;