Ocaramba DriverContext Browser Options: Complete Guide to Supported Browsers and Configuration
Ocaramba's DriverContext supports 12+ browser types including Chrome, Firefox, Safari, Edge (legacy and Chromium), Internet Explorer, RemoteWebDriver, BrowserStack, and mobile platforms via Appium.
The DriverContext class in the accenture/ocaramba repository serves as the core engine for browser instantiation in automated testing. Understanding which browser options are supported by Ocaramba's DriverContext is essential for configuring cross-browser test suites, remote grid execution, and mobile device testing through a unified API.
Supported Browser Types in Ocaramba's DriverContext
The framework defines all supported drivers in the BrowserType enum located in OcarambaLite/BrowserType.cs. The DriverContext.Start() method uses this enum to determine which browser instance to create.
The complete list of supported browser options includes:
- Chrome – Full support with
ChromeOptionsconfiguration - Firefox – Full support with
FirefoxOptionsconfiguration - InternetExplorer/IE – Legacy IE support using
InternetExplorerOptions - Safari – macOS Safari automation via
SafariOptions - Edge – Legacy Microsoft Edge (EdgeHTML)
- EdgeChromium – Modern Chromium-based Edge
- RemoteWebDriver – Selenium Grid execution
- BrowserStack – Cloud testing via BrowserStack
- Appium – Mobile testing for Android and iOS
- CloudProvider – Generic cloud provider support
- Android/Iphone – Direct mobile device references
How DriverContext Configures Browser Options
The architecture follows a factory pattern where DriverContext.Start() acts as the entry point. Located in OcarambaLite/DriverContext.cs, this method contains a switch statement that maps each BrowserType to a specific initialization method.
The configuration flow works as follows:
- Configuration Reading –
BaseConfiguration.TestBrowserreads the browser type fromappsettings.jsonor environment variables - Method Selection – The
Start()switch invokes browser-specific methods likeStartChrome(),StartFirefox(), orSetupRemoteWebDriver() - Options Building – Each method calls a private property getter (e.g.,
ChromeOptions,FirefoxOptions) that constructs the Selenium options object - Capability Injection – The options objects incorporate settings from configuration sections like
ChromePreferences,FirefoxExtensions, and proxy settings
Configuring Chrome Browser Options
Chrome support utilizes the ChromeOptions class. The DriverContext.ChromeOptions property (lines 40-44 in DriverContext.cs) builds the options instance by reading ChromePreferences from configuration.
// appsettings.json configuration
{
"ChromePreferences": {
"download.default_directory": "C:\\Downloads",
"profile.default_content_settings.popups": 0
},
"ChromeExtensions": [
"path\\to\\extension.crx"
]
}
using Ocaramba;
public class ChromeTest
{
private readonly DriverContext driverContext = new DriverContext();
public void RunChromeTest()
{
BaseConfiguration.TestBrowser = BrowserType.Chrome;
driverContext.Start();
driverContext.WindowMaximize();
driverContext.Driver.Navigate().GoToUrl("https://example.com");
// Test execution logic here
driverContext.Stop();
}
}
Configuring Firefox and Internet Explorer Options
Firefox configuration follows a similar pattern using FirefoxOptions. The DriverContext.FirefoxOptions property (lines 18-22) handles extensions and preferences.
Internet Explorer support uses InternetExplorerOptions via the InternetExplorerOptions property (lines 46-50), which configures IE-specific capabilities like ignoring protected mode settings.
// Firefox configuration example
BaseConfiguration.TestBrowser = BrowserType.Firefox;
BaseConfiguration.FirefoxExtensions = new[] { "path\\to\\extension.xpi" };
driverContext.Start(); // Creates FirefoxDriver with custom options
Remote WebDriver and Cloud Provider Configuration
For Selenium Grid execution, DriverContext supports RemoteWebDriver through the SetupRemoteWebDriver() method (lines 215-218). This method constructs the appropriate options object based on the target browser, then creates a RemoteWebDriver instance pointing to the grid hub.
// Remote WebDriver configuration
BaseConfiguration.TestBrowser = BrowserType.RemoteWebDriver;
BaseConfiguration.RemoteWebDriverHub = "http://selenium-grid-hub:4444/wd/hub";
BaseConfiguration.CrossBrowserEnvironment = "linux-chrome"; // Maps to specific capabilities
driverContext.Start(); // Creates RemoteWebDriver with ChromeOptions
BrowserStack cloud testing uses the BrowserStack enum value, which invokes SetupBrowserStack() (lines 266-270). This creates a Chrome-based remote driver configured for BrowserStack's infrastructure.
Mobile Testing with Appium in DriverContext
Mobile automation is supported through the Appium browser type. The StartAppium() method (lines 244-260) builds an AppiumOptions object and instantiates either AndroidDriver or IOSDriver based on the platform configuration.
// Appium mobile configuration
BaseConfiguration.TestBrowser = BrowserType.Appium;
BaseConfiguration.AppiumPlatformName = "Android";
BaseConfiguration.AppiumDeviceName = "Pixel_3a_API_30_x86";
BaseConfiguration.AppiumAppPath = "/path/to/app.apk";
driverContext.Start(); // Creates AndroidDriver with AppiumOptions
Summary
- Ocaramba's DriverContext supports 12+ browser types defined in the
BrowserTypeenum, including Chrome, Firefox, Safari, Edge (both legacy and Chromium), Internet Explorer, and mobile platforms. - Configuration-driven architecture allows browser selection via
BaseConfiguration.TestBrowser(set inappsettings.jsonor code), with specialized options classes (ChromeOptions,FirefoxOptions, etc.) built by private property getters inDriverContext.cs. - Remote and cloud execution is supported through
RemoteWebDriver,BrowserStack, andCloudProvidertypes, withSetupRemoteWebDriver()handling grid capabilities andSetupBrowserStack()configuring cloud-specific Chrome instances. - Mobile automation uses the
Appiumbrowser type, whereStartAppium()constructsAppiumOptionsand creates platform-specific drivers (AndroidDriverorIOSDriver) based on configuration settings.
Frequently Asked Questions
How do I configure Chrome-specific preferences in Ocaramba?
Chrome preferences are configured through the ChromePreferences section in appsettings.json or via the ChromePreferences configuration property. The DriverContext.ChromeOptions property reads these settings and applies them to the ChromeOptions instance before creating the ChromeDriver. For example, you can set download directories or disable popups by adding key-value pairs to the ChromePreferences configuration object.
What is the difference between Edge and EdgeChromium in Ocaramba?
The Edge enum value targets the legacy Microsoft Edge browser (EdgeHTML engine), while EdgeChromium targets the modern Chromium-based Edge browser. Both use EdgeOptions classes, but the EdgeChromium configuration in DriverContext.EdgeOptions (lines 81-85) allows setting the BinaryLocation property specifically for the Chromium driver, whereas the legacy implementation uses the older Edge driver protocol.
How does Ocaramba handle mobile testing with Appium?
Ocaramba handles mobile testing through the Appium browser type and the StartAppium() method in DriverContext.cs (lines 244-260). When BaseConfiguration.TestBrowser is set to BrowserType.Appium, the method builds an AppiumOptions object using platform-specific settings like AppiumPlatformName, AppiumDeviceName, and AppiumAppPath. It then instantiates either an AndroidDriver or IOSDriver based on whether the platform name is "Android" or "iOS", enabling native mobile automation through the same DriverContext API used for desktop browsers.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →