Setting up environment and browser options via registry adjustments is a very powerful tool but in most cases, you do not need to change settings of your OS or additional third-party applications. Usually, it’s sufficient to set up only the browser you launch for testing. The easiest way to do this is by launching a browser with settings different from the default. It may be done using special classes located in OpenQA.Selenium.IE, OpenQA.Selenium.Firefox and OpenQA.Selenium.Chrome namespaces.
Setting up the Internet Explorer
There is the InternetExplorerOptions class in the OpenQA.Selenium.IE namespace which provides the ability to launch IE browser with desired options. The number of options is a bit limited but it is sufficient for most cases. Here is the full list of all options allowed:
Example of usage:
In the code above IEoptions.IgnoreZoomLevel property is True because there is the appropriate node in the App.config file –
<add key=”IgnoreZoomLevel” value=”true” /> – and its value is “true”.
Contrariwise IEoptions.IntroduceInstabilityByIgnoringProtectedModeSettings property is False because no corresponding node is found in the App.config since there is no one.
Setting up Google Chrome
For launching the Chrome browser with desired options special command line arguments are used. It means that if the arguments contain an option, the option is True and will be switched on when the browser starts. I have found the list of Chrome browser options with descriptions here.The usage example is listed below.
Setting up Mozilla Firefox
All the preferences for the Mozilla Firefox browser may be adjusted through FirefoxProfile class located in OpenQA.Selenium.Firefox namespace. This is a very powerful tool which allows you to set up almost everything in the browser – UI, add-ons, behavior, connections, extensions, scripting and many other things. But you should be careful because some of the settings may cause the browser’s crash if incorrect values will be put into.
A very big part of Firefox settings described here. But keep in mind that not all of the features described on the site may be available for your version of the Firefox though the main setting is general for all versions. Personal features of a concrete browser may be seen on its ‘about:config’ page (just type the command in the address bar). The list of settings available for the specific instance of the Firefox browser will be displayed.
To adjust Firefox browser you have to know not only the name and the value of a feature but its type as well. Fortunately, there may be only three kinds of feature types: boolean, integer and string.
I utilized the following approach (maybe not the most elegant) – I wrote all values in App.config file as strings and then parsed the strings inside the code.
Environment adjustments via Registry Table Of Content Running tests on Android