Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CustomChromeOptions is not being called with remote provider #2719

Open
xescuder opened this issue Feb 21, 2022 · 8 comments
Open

CustomChromeOptions is not being called with remote provider #2719

xescuder opened this issue Feb 21, 2022 · 8 comments

Comments

@xescuder
Copy link

xescuder commented Feb 21, 2022

I've added an extension from a class that implements CustomChromeOptions (it can't be used from CustomDriverEnhancer as this does not allow to change capabilities):

public class BrowserChromeOptions implements CustomChromeOptions {

    private static final String CHROME_EXTENSION_PROPERTY = "chrome.plugin";

    @Override
    public void apply(EnvironmentVariables environmentVariables, ChromeOptions options) {
        String extensionProperty = EnvironmentSpecificConfiguration.from(environmentVariables).getProperty(CHROME_EXTENSION_PROPERTY);

        if (extensionProperty==null) return;

        PathProcessor pathProcessor = new PathProcessor();
        String extensionPath = pathProcessor.normalize(extensionProperty);
        options.addExtensions(new File(extensionPath));
    }
}

This is working correctly from a local provider, but not in remote. In remote provider the CustomDriverEnhancer is being called, but not the CustomChromeOptions.

Can you add CustomChromeOptions in the code of remote provider?

@wakaleo
Copy link
Member

wakaleo commented Feb 21, 2022

I'm not sure, since the ChromeOptions is a Chrome-specific class. Have a look at the RemoteDriverProvider class and see if you can find a way to do it without breaking support for all of the other remote drivers.

@xescuder
Copy link
Author

Currently, the only way to add extensions with RemoteDriverProvider is to implement a BeforeAWebDriverScenario, but with this option it doesn't work with Chrome.

I've tried also a second option, using the extension property at serenity.json, but it only works with chrome driver, not with remote driver. It seems not using the property.

@wakaleo
Copy link
Member

wakaleo commented Feb 22, 2022

This is a complex problem; I'm not sure when I will be able to look into it, but if feel free to look at the RemoteDriverProvider and see if you can find a more general solution to the problem.

@xescuder
Copy link
Author

OK, I'll see then. It's a must for us in order to execute the tests in our pipeline, I will inform you...

@wakaleo
Copy link
Member

wakaleo commented Feb 22, 2022

If it's a must for your company maybe you could consider sponsoring the implementation of this features then?

@xescuder
Copy link
Author

What do you mean about sponsoring?

@wakaleo
Copy link
Member

wakaleo commented Feb 22, 2022

Serenity BDD is an open source project, which means you have several options to prioritise work on features that your company finds valuable. These include:

  • You can wait for one of the volunteers who maintains the project to pick up the issue and work on it (being open source, there is no guarantee as to if and when this will happen)
  • You can make the change yourself and proposing a pull request
  • You can hire someone to make the change for you
  • You can opt of one of the Serenity BDD corporate support packages, which gives you a convenient way to fund the implementation of specific features that you find valuable.

@xescuder
Copy link
Author

xescuder commented Feb 22, 2022

I've found a way that works using FixtureService:

public class BrowserFixtureService  implements FixtureService {

    private static final String CHROME_EXTENSION = "classpath:plugins/browser-extension-chrome.crx";

    @Override
    public void setup() throws FixtureException {
    }

    @Override
    public void shutdown() throws FixtureException {
    }

    @Override
    public void addCapabilitiesTo(MutableCapabilities capabilities) {
        ChromeOptions options = new ChromeOptions();

        PathProcessor pathProcessor = new PathProcessor();
        String extensionPath = pathProcessor.normalize(CHROME_EXTENSION);
        options.addExtensions(new File(extensionPath));
        capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants