serenity-bdd / serenity-core

Serenity BDD is a test automation library designed to make writing automated acceptance tests easier, and more fun.
http://serenity-bdd.info
Other
722 stars 518 forks source link

unable to set settings from serenity.properties #1358

Closed sumit24jun closed 2 years ago

sumit24jun commented 6 years ago

Hi,

I wanted to set InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS:true" property in serenity.properties , but its not working for me ( in my CI setup, i cannot guarantee protected settings as it is controlled by IT, hence looking to set it in automaiton)

Please advise how i can set it in serenity,properties.

Additional details if i set it like below in my page that extends pageObject. it works fine but i am unable to refer other properties that are set in serenity.property file

========================================== InternetExplorerOptions opt = new InternetExplorerOptions(); opt.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING,true); opt.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); WebDriver driver = new InternetExplorerDriver(opt);

    super.setDriver(driver);

==========================================================

wakaleo commented 6 years ago

Have you tried something like:

driver_capabilities.iexplorer.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS = true
driver_capabilities.iexplorer.IGNORE_ZOOM_SETTING = true

in your serenity.properties file?

sumit24jun commented 6 years ago

Hi,

tried that as well, but getting driver could not be instantiated exception

sumit24jun commented 6 years ago

Hi,

I wanted to set InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS:true" property in serenity.properties , but its not working for me ( in my CI setup, i cannot guarantee protected settings as it is controlled by IT, hence looking to set it in automaiton)

Please advise how i can set it in serenity,properties.

Additional details if i set it like below in my page that extends pageObject. it works fine but i am unable to refer other properties that are set in serenity.property file

========================================== InternetExplorerOptions opt = new InternetExplorerOptions(); opt.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING,true); opt.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); WebDriver driver = new InternetExplorerDriver(opt);

  super.setDriver(driver);

==========================================================

Hi,

tried that as well, but getting driver could not be instantiated exception

wakaleo commented 6 years ago

You cannot override the driver in that way. There are many reasons for IE not working, a lot of which are nothing to do with code. The properties mentioned about should create the correct capability object. Put a breakpoint in InternetExplorerDriverProvider and see if you can see what is actually causing the exception.

dejj commented 6 years ago

I have the same problem. I tried the following entries in serenity.properties to no avail:

driver_capabilities.iexplorer.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS = true
driver_capabilities.iexplorer.ignoreProtectedModeSettings = true
driver_capabilities.iexplorer.ie.ignoreProtectedModeSettings = true

At this point I am considering forking Serenity just to modify InternetExplorerDriverProvider::recommendedDefaultInternetExplorerCapabilites.

Can you suggest other options?

wakaleo commented 6 years ago

Rather than forking, if you know the code you want in the InternetExplorerDriverProvider, why not add an option in a PR?

dejj commented 6 years ago

I wouldn't want to force anybody to actually use INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, because it introduces flakiness across security domains. I would rather not set it myself, but it's just my company's security policy to reset the IE settings to inconsistent protected mode settings for the different IE-security zones.

I also tried to subclass PageObject and initialize super(with_my_own_driver), but that got bypassed when I called driver.navigate() in my testcases.

Are there some injections mechanisms that I could use to set the option before driver creation?

wakaleo commented 6 years ago

INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS is indeed something that the IE driver author recommends never using. But it would be acceptance to add a property to the ThucydidesSystemProperties class for this. We don't have any options to invervene in driver creation at this stage.

nbarrett commented 6 years ago

I came across the requirement to set these properties on my project and set them slightly differently e.g.

driver_capabilities.iexplorer.ignoreProtectedModeSettings=true
driver_capabilities.iexplorer.ignoreZoomSetting=true

This is because as I understand it, the String values of the InternetExplorerDriver constants need to be used rather than the field names e.g.

public class InternetExplorerDriver extends RemoteWebDriver {
    public static final String IGNORE_ZOOM_SETTING = "ignoreZoomSetting";
    public static final String NATIVE_EVENTS = "nativeEvents";
    public static final String INITIAL_BROWSER_URL = "initialBrowserUrl";
    public static final String ELEMENT_SCROLL_BEHAVIOR = "elementScrollBehavior";
    public static final String UNEXPECTED_ALERT_BEHAVIOR = "unexpectedAlertBehaviour";
    public static final String ENABLE_ELEMENT_CACHE_CLEANUP = "enableElementCacheCleanup";
    public static final String BROWSER_ATTACH_TIMEOUT = "browserAttachTimeout";
    public static final String INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS = "ignoreProtectedModeSettings";
    public static final String ENABLE_PERSISTENT_HOVERING = "enablePersistentHover";
    public static final String REQUIRE_WINDOW_FOCUS = "requireWindowFocus";

When I put the breakpoint into InternetExplorerDriverProvider as John suggests, the values definitely get loaded so there should be no need to create a custom driver, or create a PR:

image