![]() |
VOOZH | about |
The BaseConfiguration class serves as the central configuration engine for Ocaramba. It leverages Microsoft.Extensions.Configuration to provide a unified, hierarchical access point for test settings defined in JSON files and environment variables OcarambaLite/BaseConfiguration.cs31-52 It abstracts the complexity of reading different configuration sections (like browser options, timeouts, and paths) and provides strongly-typed properties for the rest of the framework.
Ocaramba uses a layered configuration approach. The BaseConfiguration class initializes a static IConfigurationRoot named Builder OcarambaLite/BaseConfiguration.cs49-52
The configuration is built by loading files in the following order of precedence (later files override earlier ones):
ASPNETCORE_ENVIRONMENT variable OcarambaLite/BaseConfiguration.cs44-51This diagram shows how BaseConfiguration maps JSON keys to internal framework logic.
Configuration Mapping
Sources: OcarambaLite/BaseConfiguration.cs38-52 OcarambaLite/DriverContext.cs187
The settings are primarily divided into the appSettings section for general framework behavior and browser-specific sections for driver-level customization.
appSettings)These keys reside under the "appSettings" node in the JSON files Ocaramba.Tests.NUnit/appsettings.json2-39
| Key | Description | Property in BaseConfiguration |
|---|---|---|
browser | Target browser (e.g., Chrome, Firefox, RemoteWebDriver) | TestBrowser OcarambaLite/BaseConfiguration.cs65-83 |
protocol | Application protocol (http/https) | Protocol OcarambaLite/BaseConfiguration.cs132-143 |
host | Base domain for the application under test | Host OcarambaLite/BaseConfiguration.cs148-159 |
url | Full URL if host/protocol are not used | Url OcarambaLite/BaseConfiguration.cs164-175 |
longTimeout | Max wait time for long-running operations (seconds) | LongTimeout |
mediumTimeout | Standard wait time (seconds) | MediumTimeout |
shortTimeout | Quick check wait time (seconds) | ShortTimeout |
ImplicitlyWaitMilliseconds | Selenium implicit wait setting | ImplicitlyWaitMilliseconds |
SeleniumScreenShotEnabled | Global toggle for capturing screenshots on failure | SeleniumScreenShotEnabled |
GetPageSourceEnabled | Global toggle for saving HTML source on failure | GetPageSourceEnabled |
JavaScriptErrorLogging | Enables console error capture in Chrome | JavaScriptErrorLogging |
JavaScriptErrorTypes | Comma-separated list of JS errors to monitor | JavaScriptErrorTypes Ocaramba.Tests.NUnit/appsettings.json34 |
Sources: OcarambaLite/BaseConfiguration.cs65-175 Ocaramba.Tests.NUnit/appsettings.json2-39
These settings allow the framework to locate web drivers and browser binaries Ocaramba.Tests.NUnit/appsettings.json7-13
PathToChromeDriverDirectory: Directory containing chromedriver.exe Ocaramba.Tests.NUnit/appsettings.json7ChromeBrowserExecutableLocation: Path to a specific Chrome binary Ocaramba.Tests.NUnit/appsettings.json11PathToFirefoxProfile: Path to a custom Firefox profile directory OcarambaLite/BaseConfiguration.cs111-127PathToEdgeChromiumDriverDirectory: Path for Edge driver binaries Ocaramba.Tests.NUnit/appsettings.json10Ocaramba supports cross-platform execution by utilizing the appsettings.Linux.json file. When the environment variable ASPNETCORE_ENVIRONMENT is set to Linux, the framework loads this file to override Windows-specific paths and settings OcarambaLite/BaseConfiguration.cs44-52
Typical overrides in appsettings.Linux.json include:
-headless for Firefox or headless for Chrome/Edge Ocaramba.Tests.NUnit/appsettings.Linux.json41-62no-sandbox and disable-dev-shm-usage for stable execution in containers Ocaramba.Tests.NUnit/appsettings.Linux.json49-50/ instead of \) Ocaramba.Tests.NUnit/appsettings.Linux.json34-36Environment Selection Logic
Sources: OcarambaLite/BaseConfiguration.cs44-52 Ocaramba.Tests.NUnit/appsettings.Linux.json1-63
Beyond simple key-value pairs, BaseConfiguration handles complex objects for browser customization.
The framework reads sections for specific browsers to inject arguments into DriverOptions Ocaramba.Tests.NUnit/appsettings.json41-56
headless, no-sandbox) Ocaramba.Tests.NUnit/appsettings.Linux.json47-52profile.password_manager_enabled: false) Ocaramba.Tests.NUnit/appsettings.json50-54When browser is set to RemoteWebDriver, the framework uses the following keys:
RemoteWebDriverHub: The URL of the Selenium Grid or Cloud provider (e.g., http://localhost:4444/wd/hub) Ocaramba.Tests.NUnit/appsettings.json18DriverCapabilities: Defines the set of capabilities or the browser name to request from the remote hub Ocaramba.Tests.NUnit/appsettings.json20environments: In cloud provider scenarios (like SauceLabs or BrowserStack), this section defines parallel execution targets such as ChromeWindows or FirefoxWindows Ocaramba.Tests.CloudProviderCrossBrowser/appsettings.Linux.json41-61To add custom settings for a specific project:
appSettings section of appsettings.json.Builder property in BaseConfiguration OcarambaLite/BaseConfiguration.cs49-52Example of framework internal access:
Internal Data Flow
Sources: OcarambaLite/DriverContext.cs101-102 OcarambaLite/BaseConfiguration.cs38-52 Ocaramba.Tests.NUnit/appsettings.json29
Refresh this wiki