Serenity-core: Serenity 2.0.48 - It is not possible to pass list in serenity.properties for chrome_experimental_options

Created on 14 Aug 2019  路  12Comments  路  Source: serenity-bdd/serenity-core

Inform a value of a list in serenity.properties, the property is not beign identified by serenity.

Example of property:
chrome_experimental_options.excludeSwitches=enable-automation

Error returned:

Caused by: net.thucydides.core.webdriver.DriverConfigurationError: Could not instantiate new WebDriver instance of type class org.openqa.selenium.chrome.ChromeDriver (invalid argument: cannot parse capability: goog:chromeOptions
from invalid argument: cannot parse excludeSwitches
from invalid argument: must be a list

At ChromeDriverCapabilites.java the code which treats the "chrome_experimental_options" calls for ChromePreferences.from(), but apparently this method doesn't recognizes list values.

public Map<String, Object> from(EnvironmentVariables environmentVariables) {
        List<String> propertiesWithPrefix =
            environmentVariables.getKeys()
                    .stream()
                    .filter( key -> key.startsWith(prefix))
                    .collect(Collectors.toList());

        Map<String, Object> preferences = new HashMap();

        for(String propertyKey : propertiesWithPrefix) {
            String preparedPropertyKey = getPreparedPropertyKey(propertyKey);
            String propertyValue = environmentVariables.getProperty(propertyKey);
            if (isNotEmpty(propertyValue)) {
                preferences.put(preparedPropertyKey, asObject(propertyValue));
            }
        }

        return preferences;
    }

Is there any way of inform "excludeSwitches=enable-automation" in serenity.properties?

My versions:
2.0.481.9.15

All 12 comments

Do you know what the code would look like in plain Selenium to use this option?

@wakaleo

I've in touch with some examples, like: Example.

I don't know if it is what exactly you've asked.

As a workaround I've created a custom driver:

ChromeOptions options = new ChromeOptions();
        options.setExperimentalOption("prefs", chromePrefs);
        options.setExperimentalOption("excludeSwitches", Arrays.asList("enable-automation"));

I found this because in ChromeDriver version 76 they removed the "--disable-inforbars" and because of that some of my tests are breaking.

--disable-infobars is no longer supported
Chrome will no longer support the --disable-infobars flag, which was used to hide pop-up warnings from Chrome Browser. To support automated testing, kiosks, and automation, the CommandLineFlagSecurityWarningsEnabled policy was added to allow you to disable some security warnings.

And some people suggested to add those properties

options.setExperimentalOption("excludeSwitches", Arrays.asList("enable-automation"));
options.setExperimentalOption("useAutomationExtension", false);

Adding the CustomDriver with those information, the message of "chrome is being controlled by automated software" was gone, but, if serenity.properties support those properties that will be good.

This could be a bug, possibly fixed in 2.0.70. You would use:

chrome_experimental_options.excludeSwitches = "[enable-automation]"
chrome_experimental_options. useAutomationExtension = false

Using
chrome_experimental_options.excludeSwitches = "[enable-automation]

Still returning

Caused by: net.thucydides.core.webdriver.DriverConfigurationError: Could not instantiate new WebDriver instance of type class org.openqa.selenium.chrome.ChromeDriver (invalid argument: entry 0 of 'firstMatch' is invalid
from invalid argument: cannot parse capability: goog:chromeOptions
from invalid argument: cannot parse excludeSwitches
from invalid argument: must be a list

This will only work in version 2.0.70

Fixed in 2.0.70

@wakaleo

In version 2.0.71 the configuration haven't worked, in serenity.properties I put the information:

chrome_experimental_options.excludeSwitches="[enable-automation]"
chrome_experimental_options.useAutomationExtension=false

But when tests starts the message of "chrome is being controlled by automated software" still appear. Using custom driver that works.

In serenity.properties, try:

chrome_experimental_options.excludeSwitches=[enable-automation]
chrome_experimental_options.useAutomationExtension=false

With

chrome_experimental_options.excludeSwitches=[enable-automation]
chrome_experimental_options.useAutomationExtension=false

The result is:

Caused by: net.thucydides.core.webdriver.DriverConfigurationError: Could not instantiate new WebDriver instance of type class org.openqa.selenium.chrome.ChromeDriver (invalid argument: entry 0 of 'firstMatch' is invalid from invalid argument: cannot parse capability: goog:chromeOptions from invalid argument: cannot parse excludeSwitches from invalid argument: must be a list

Can you raise a support ticket so we can look at this more closely?

@wakaleo to disable popup blocker I tried below threebut none worked for me. On Serenity version 2.2.13

  1. chrome_experimental_options.excludeSwitches=disable-popup-blocking
  2. chrome_preferences.excludeSwitches="[disable-popup-blocking]"
  3. chrome.switches="--ignore-certificate-errors;--disable-default-apps;--test-type;--enable-automation;--test-type=browser;--disable-plugins;--disable-extensions;--window-size=1920;1080;--no-sandbox;--disable-gpu;--privileged;disable-popup-blocking"

Its opening the chrome but blocking popup.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

knludi picture knludi  路  4Comments

PrasadNutalapati picture PrasadNutalapati  路  7Comments

gkushang picture gkushang  路  4Comments

Prasannajnaeyulu picture Prasannajnaeyulu  路  6Comments

thePantz picture thePantz  路  4Comments