How to Configure Timeouts in Ocaramba: A Complete Guide to BaseConfiguration

Ocaramba centralizes all timeout configuration in the static BaseConfiguration class, reading values from appsettings.json to control Selenium wait behaviors across your entire test suite.

When working with the Accenture Ocaramba test automation framework, managing wait times efficiently is critical for stable Selenium tests. Rather than scattering hard-coded delays throughout your code, Ocaramba provides a declarative, centralized approach to timeout management through environment-specific JSON configuration files.

Understanding the BaseConfiguration Architecture

The BaseConfiguration class in OcarambaLite/BaseConfiguration.cs serves as the single source of truth for all timeout values. According to the Ocaramba source code, this static class initializes an IConfigurationRoot builder that loads settings hierarchically from appsettings.json and environment-specific overrides:

public static readonly IConfigurationRoot Builder = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json", true, true)
    .AddJsonFile($"appsettings.{Env}.json", true, true)
    .Build();

Each timeout property reads its corresponding configuration key, converts the value to the appropriate type (typically double for seconds or TimeSpan for remote connections), and exposes it as a strongly-typed static property. This implementation appears in lines 302–340 of BaseConfiguration.cs.

Available Timeout Properties

Ocaramba defines five distinct timeout categories to handle different synchronization scenarios:

  • ShortTimeout – Maps to appSettings:shortTimeout; used for quick assertion-level waits such as element visibility checks in WebDriverExtensions.IsElementPresent (see OcarambaLite/Extensions/WebDriverExtensions.cs lines 107–115).
  • MediumTimeout – Maps to appSettings:mediumTimeout; the default for general-purpose operations including JavaScript/AJAX synchronization and Select element interactions (referenced in OcarambaLite/WebElements/Select.cs lines 74–115).
  • LongTimeout – Maps to appSettings:longTimeout; reserved for page-load operations and heavy asynchronous operations, frequently passed to WaitHelper.Wait methods (see OcarambaLite/Helpers/WaitHelper.cs lines 69–73).
  • ImplicitlyWaitMilliseconds – Maps to appSettings:ImplicitlyWaitMilliseconds; configures the Selenium WebDriver implicit wait in milliseconds.
  • RemoteWebDriverTimeout – Maps to appSettings:remoteTimeout; specifies the connection timeout in seconds when using Selenium Grid or remote WebDriver instances.

Configuring Timeouts in appsettings.json

To configure timeouts in Ocaramba, modify the appSettings section of your appsettings.json file (or create environment-specific variants like appsettings.Development.json):

{
  "appSettings": {
    "shortTimeout": "5",
    "mediumTimeout": "15",
    "longTimeout": "30",
    "ImplicitlyWaitMilliseconds": "500",
    "remoteTimeout": "120"
  }
}

Changes take effect immediately at runtime without requiring code recompilation, as the configuration reloads when the test session initializes.

Using Timeouts in Test Code

Default Timeout Usage

All Ocaramba helper methods automatically reference BaseConfiguration properties. When you call extension methods like IsElementPresent, the framework implicitly uses BaseConfiguration.ShortTimeout:

// Uses ShortTimeout (5s default) from appsettings.json
bool exists = driver.IsElementPresent(By.Id("submit-button"));

Overriding Timeouts for Specific Operations

For scenarios requiring custom durations, bypass the configuration and pass explicit TimeSpan values directly to wait methods:

// Wait up to 45 seconds for a specific slow-loading element
var customTimeout = TimeSpan.FromSeconds(45);
driver.IsElementPresent(myLocator, customTimeout.TotalSeconds);

// Or use WaitHelper with LongTimeout for complex conditions
WaitHelper.Wait(driver, () => driver.Title.Contains("Dashboard"), 
    TimeSpan.FromSeconds(BaseConfiguration.LongTimeout));

Accessing Configuration Values Programmatically

You can reference timeout values directly in your test logic for logging or conditional waits:

Console.WriteLine($"Current short timeout: {BaseConfiguration.ShortTimeout}s");
Console.WriteLine($"Current medium timeout: {BaseConfiguration.MediumTimeout}s");
Console.WriteLine($"Current long timeout: {BaseConfiguration.LongTimeout}s");

Remote WebDriver Timeout Configuration

When executing tests against Selenium Grid or remote instances, increase the remoteTimeout value to accommodate network latency. This configuration in appsettings.json sets the connection timeout to 120 seconds:

{
  "appSettings": {
    "remoteTimeout": "120"
  }
}

This value is particularly important when running tests over VPN connections or across geographically distributed grid nodes.

Summary

  • Centralized Configuration: All timeout values live in BaseConfiguration class (OcarambaLite/BaseConfiguration.cs), loaded from appsettings.json.
  • Five Timeout Levels: Short, Medium, Long, Implicit Wait (ms), and Remote Driver timeouts cover all synchronization scenarios.
  • Declarative Updates: Modify appsettings.json to adjust wait times without changing test code.
  • Framework Integration: Extension methods in WebDriverExtensions.cs and Select.cs automatically consume these values.
  • Override Capability: Pass explicit TimeSpan parameters to any wait method when you need exceptions to the global configuration.

Frequently Asked Questions

Where does Ocaramba store timeout configuration values?

Ocaramba stores timeout configuration in the static BaseConfiguration class, which reads values from appsettings.json using the Microsoft Extensions Configuration API. The framework looks for keys under the appSettings section, including shortTimeout, mediumTimeout, longTimeout, ImplicitlyWaitMilliseconds, and remoteTimeout.

How do I change timeout values without modifying code?

Edit the appsettings.json file in your test project root (or create environment-specific files like appsettings.Staging.json). Update the numeric values in the appSettings section, save the file, and rerun your tests. The ConfigurationBuilder in BaseConfiguration.cs automatically reloads these values at runtime.

Can I use different timeouts for specific test scenarios?

Yes. While BaseConfiguration provides global defaults, you can override any timeout for individual operations by passing explicit TimeSpan or double parameters to wait methods. For example, use WaitHelper.Wait with a custom TimeSpan.FromSeconds(45) instead of relying on BaseConfiguration.LongTimeout for unusually slow operations.

What is the difference between ShortTimeout and ImplicitlyWaitMilliseconds?

ShortTimeout (configured in seconds) is used by Ocaramba's custom wait helpers and extension methods for explicit waits on specific conditions. ImplicitlyWaitMilliseconds configures the Selenium WebDriver's native implicit wait mechanism, which affects how long the driver waits when searching for elements that aren't immediately present.

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:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →