Code : Automating Extension automation with Selenium

Below code is for Chrome. This will work for Firefox  with little change in code.

// Load extension file
File file = new File(“chrome.crx”);
ChromeOptions options = new ChromeOptions();
options.addExtensions(file);

// Launch browser instance with the extension
WebDriver driver = new ChromeDriver(options);

// Access Extension in browser window .. This further allows you to automate all the actions through Selenium
driver.get(“extension://palgcoflnoaklkflllnmheiollkgkipm/popup.html”);

Advertisements