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:
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
Its opening the chrome but blocking popup.