Override browser profile preferences, install browser extensions

Jakub Raczek edited this page Jun 26, 2018 · 10 revisions

Our framework supports overriding browser profile preferences set in DriverContext class or adding additional not included in our code, passing arguments to browsers and installing browser extensions. It can be done by adding settings in FirefoxPreferences, FirefoxArguments and FirefoxExtensions or ChromePreferences, ChromeArguments and ChromeExtensions sections of App.config file.

<?xml version="1.0" encoding="utf-8"?>
    <section name="FirefoxPreferences" type="System.Configuration.NameValueSectionHandler"/>
    <section name="FirefoxExtensions" type="System.Configuration.NameValueSectionHandler"/>
    <section name="FirefoxArguments" type="System.Configuration.NameValueSectionHandler"/>
    <section name="ChromePreferences" type="System.Configuration.NameValueSectionHandler"/>
    <section name="ChromeExtensions" type="System.Configuration.NameValueSectionHandler"/>
    <section name="DriverCapabilities" type="System.Configuration.NameValueSectionHandler"/>
    <section name="ChromeArguments" type="System.Configuration.NameValueSectionHandler"/>
    <section name="InternetExplorerPreferences" type="System.Configuration.NameValueSectionHandler"/>
    <add key="PreferenceToBeOverride" value="NewValue" />
    <add key="FirefoxPluginName.xpi" value=""/>
    <add key="PreferenceToBeOverride" value="NewValue" />
    <add key="ChromePluginName.crx" value=""/>
    <add key="--headless" value=""/>
+    <add key="EnsureCleanSession" value="false"/>
+  </InternetExplorerPreferences>

To pass arguments to Chrome browser to e.g. start in headless mode add this section to your App.config file

    <add key="--headless" value=""/>

To start e.g. FireFox with FireBug extension copy firebug-x.x.x-fx.xpi file to bin folder of your project and add this section to your App.config file

    <add key="firebug-2.0.19-fx.xpi" value=""/>

To overwrite any e.g. Firefox preferences or add new one add this section to your App.config file

    <add key="network.automatic-ntlm-auth.trusted-uris" value="servername1,servername2" />

With the InternetExplorer you can only override EnsureCleanSession and IgnoreZoomLevel preferences, by default both are set to true in DriverContext class.

In order to start FireFox with default firefox profile edit following section in your App.config file, set proper path to FireFox default profile.

<!--Use default firefox profile?-->
<add key="UseDefaultFirefoxProfile" value="true"/>
<add key="PathToFirefoxProfile" value="C:\Users\username\AppData\Roaming\Mozilla\Firefox\Profiles"/>
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.