Hi,
I am trying to add an extension to the chrome using serenity.properties file. But I am not able to achieve it. Is there any way to do it?
How would you code this in plain Selenium?
Just did a quick check, this works:
public class ChromeDriverWithExtension implements DriverSource {
@Override
public WebDriver newDriver() {
try {
ChromeOptions options = new ChromeOptions();
options.addExtensions(new File("extension.crx"));
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
return new ChromeDriver(options);
}
catch (Exception e) {
throw new Error(e);
}
}
@Override
public boolean takesScreenshots() {
return true;
}
webdriver.driver = provided
webdriver.provided.type = mydriver
webdriver.provided.mydriver = au.com.acme.ChromeDriverWithExtension
thucydides.driver.capabilities = mydriver
Using a custom driver is probably the best option at this atage
For anyone that comes across this, use chrome.extension = path/to/extension.crx
Most helpful comment
For anyone that comes across this, use
chrome.extension = path/to/extension.crx