Skip to content

Description of appsettings.json file

Jakub Raczek edited this page Jun 26, 2025 · 2 revisions

Appsettings.json (appsettings.Linux.json if environment variable ASPNETCORE_ENVIRONMENT is set to "Linux") file should be added as a content to your project during when using Ocaramba templates. Each of setting from that file is also available in your test project by using properties from BaseConfiguration class.

 this.Driver.IsElementPresent(this.downloadPageHeader, BaseConfiguration.ShortTimeout);

Change settings stored in App.config to target your application under tests.

Set proper "appSettings": {"protocol": "http" or "appSettings": {"protocol": "https", and name of server "host": "the-internet.herokuapp.com",, optionally "url": "\home",. Choose the browser for test execution "browser": "Chrome".

{
  "appSettings": {
    "protocol": "http",
    "host": "the-internet.herokuapp.com",
    "browser": "Chrome",
    "url": ""
  }
}

Option FirefoxUseLegacyImplementation set as false in all App.config files, for Firefox 47 and lower set it to true, more details here

"FirefoxUseLegacyImplementation": "false"

If you want to pass path to Firefox browser e.g. FirefoxPortable set Firefox as a browser and set proper FireFoxBrowserExecutableLocation full path e.g. C:\FirefoxPortable\FirefoxPortable.exe.

     "browser": "Firefox",
     "FireFoxBrowserExecutableLocation":"C:\\FirefoxPortable\\FirefoxPortable.exe"

If you want to pass full path to the directory containing geckodriver.exe set proper PathToFirefoxDriverDirectory full directory path e.g. C:\GeckoDriver.

    "PathToFirefoxDriverDirectory": "C:\\GeckoDriver"

If you selected RemoteWebDriver for Selenium Grid support as a browser set also DriverCapabilities and RemoteWebDriverHub.

    "browser":"RemoteWebDriver",
    "DriverCapabilities" :"Firefox",
    "RemoteWebDriverHub" :"http://localhost:4444/wd/hub"

more details here

Uncomment proxy setting if you are going to use your tests with other tools like e.g. ZAP

    "proxy" :"127.0.0.1:9999"

As of version 3.1.17, there are new options for proxy: If you want to use one adress for all proxy types you can still use above line other wise using setting bellow is recommended.

    "httpProxy" :"127.0.0.1:9999" ,
    "ftpProxy" :"127.0.0.1:9999" ,
    "sslProxy" :"127.0.0.1:9999" ,
    "socksproxy" :"127.0.0.1:9999"

Note if both proxy and one of the specific proxies are uncommented value from specific proxy takes priority.

Note that Safari Webdriver doesn't support proxy.

Set timeouts to better fit performance of your web application under tests.

    "longTimeout" :"30" ,
    "mediumTimeout" :"10" ,
    "shortTimeout" :"3"

In case of using remote webdriver there is an opiton to control it's time out:

    "remoteTimeout" :"300"

All timeout values are provided in seconds.

Click on links to find more details about settings for taking screen shots: full desktop, selenium, page source saving and downloading files.

    "UseCurrentDirectory" :true,
    "DownloadFolder" :"TestOutput",
    "ScreenShotFolder" :"TestOutput",
    "PageSourceFolder" :"TestOutput",
    "SeleniumScreenShotEnabled" :true,
    "GetPageSourceEnabled" :true

Set PathToFirefoxProfile if you want to use default FireFox profile instead of creating new one.

    "PathToFirefoxProfile" :"C:\\Users\\username\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles"

Set SynchronizationWithAngularEnabled to true if you want to enable synchronization with AngularJS.

"SynchronizationWithAngularEnabled" :"true"

Description about nlog section can be found here.

Description about FirefoxPreferences, FirefoxExtensions and ChromePreferences, ChromeExtensions sections can be found here.

The DataDrivenFile setting in needed only in Ocaramba.NUnit, more details here.

You can add new settings to App.config file and make them available in your test project by implementing similar methods in e.g. ProjectBaseConfiguration class.

    using System;
    using System.Configuration;
    using System.Globalization;

    public static class ProjectBaseConfiguration
    {
        public static bool MyNewBoolSetting
        {
            get
            {
                if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["MyNewBoolSetting"]))
                {
                    return false;
                }

                if (ConfigurationManager.AppSettings["MyNewBoolSetting"].ToLower(CultureInfo.CurrentCulture).Equals("true"))
                {
                    return true;
                }

                return false;
            }
        }

        public static string MyNewStringSetting
        {
            get { return ConfigurationManager.AppSettings["MyNewStringSetting"]; }
        }

        public static double MyNewDoubleSetting
        {
            get { return Convert.ToDouble(ConfigurationManager.AppSettings["MyNewDoubleSetting"], CultureInfo.CurrentCulture); }
        }

You can update App.config file by powershell script before test execution, more details here

Full content of appSettings file.

{
  "appSettings": {
    "protocol": "http",
    "host": "the-internet.herokuapp.com",
    "browser": "RemoteWebDriver",
    "url": "",
    "PathToChromeDriverDirectory": "",
    "PathToFirefoxDriverDirectory": "",
    "PathToInternetExplorerDriverDirectory": "",
    "ChromeBrowserExecutableLocation": "",
    "FireFoxBrowserExecutableLocation": "",
    "FirefoxUseLegacyImplementation": "false",
    "PathToFirefoxProfile": "",
    "RemoteWebDriverHub": "http://localhost:4444/wd/hub",
    "DriverCapabilities": "CloudProvider",
    "longTimeout": "30",
    "mediumTimeout": "10",
    "shortTimeout": "3",
    "ImplicitlyWaitMilliseconds": "200",
    "username": "admin",
    "password": "admin",
    "UseCurrentDirectory": "true",
    "DownloadFolder": "TestOutput",
    "ScreenShotFolder": "TestOutput",
    "PageSourceFolder": "TestOutput",
    "SeleniumScreenShotEnabled": "true",
    "GetPageSourceEnabled": "true",
    "JavaScriptErrorLogging": "false",
    "JavaScriptErrorTypes": "SyntaxError,EvalError,ReferenceError,RangeError,TypeError,URIError,Refused to display,Internal Server Error,Cannot read property",
    "EnableEventFiringWebDriver": "false",
    "DataDrivenFile": "DataDriven\\DataDriven.xml",
    "DataDrivenFileXlsx": "DataDriven\\DataDriven.xlsx"
  },
  "DriverCapabilities": {
    "projectName": "Ocaramba",
    "debug": "true",
    "buildName": "Ocaramba.Tests.CloudProviderCrossBrowser",
    "networkLogs": "true",
    "local": "false"
  },
  "environments": {
    "ChromeWindows": {
      "browser": "Chrome",
      "os": "Windows",
      "osVersion": "10",
      "sessionName": "parallel_test"
    },

    "EdgeChromiumWindows": {
      "browser": "Edge",
      "os": "Windows",
      "osVersion": "10",
      "sessionName": "parallel_test"
    },
    "FirefoxWindows": {
      "browser": "firefox",
      "os": "Windows",
      "osVersion": "10",
      "sessionName": "parallel_test"
    }
  },
  "FirefoxPreferences": {},
  "FirefoxExtensions": {},
  "FirefoxArguments": {},
  "ChromePreferences": {},
  "ChromeExtensions": {},
  "ChromeArguments": {},
  "InternetExplorerPreferences": {}
}
Clone this wiki locally