![]() |
VOOZH | about |
The Ocaramba framework provides a suite of helper classes located in OcarambaLite/Helpers to simplify common test automation tasks such as synchronizing with asynchronous UI states, managing file system operations, measuring application performance, and capturing diagnostic artifacts like screenshots. These utilities are designed to be used both internally by the framework and externally within Page Objects and test suites.
WaitHelper provides a robust mechanism for polling a condition until it returns true or a timeout is reached. Unlike standard Selenium waits which are often tied to IWebElement states, WaitHelper can evaluate any Func<bool> delegate, making it suitable for checking database states, file existence, or complex UI logic OcarambaLite/Helpers/WaitHelper.cs35-47
The core logic uses Task.Run to execute the condition check and the timeout check in parallel OcarambaLite/Helpers/WaitHelper.cs87-98 It uses an asynchronous loop with Task.Delay to avoid blocking threads unnecessarily while polling OcarambaLite/Helpers/WaitHelper.cs89-93
| Method | Description |
|---|---|
Wait(Func<bool> condition, TimeSpan timeout, string message) | Waits for a condition with a default 1-second sleep interval. Throws WaitTimeoutException on failure OcarambaLite/Helpers/WaitHelper.cs47-50 |
Wait(Func<bool> condition, TimeSpan timeout, TimeSpan sleepInterval, string message) | Allows specifying a custom polling interval. Throws WaitTimeoutException on failure OcarambaLite/Helpers/WaitHelper.cs63-71 |
Wait(Func<bool> condition, TimeSpan timeout, TimeSpan sleepInterval) | Returns a bool indicating success or failure without throwing an exception OcarambaLite/Helpers/WaitHelper.cs85-120 |
Sources: OcarambaLite/Helpers/WaitHelper.cs35-121
FilesHelper manages file system interactions, specifically focusing on validating downloaded files and filtering files by type using the FileType enum OcarambaLite/Helpers/FilesHelper.cs37-38
The helper maps FileType enum values to string extensions via ReturnFileExtension OcarambaLite/Helpers/FilesHelper.cs55-92 Supported types include .pdf, .xls, .csv, .txt, .docx, .png, .xml, and .html.
GetFilesOfGivenType and GetFilesOfGivenTypeFromAllSubFolders allow searching for files with specific extensions and optional name postfixes OcarambaLite/Helpers/FilesHelper.cs105-160WaitForFileOfGivenName polls the file system until a specific file appears in the target directory, which is essential for verifying downloads OcarambaLite/Helpers/FilesHelper.cs190-200RenameFile and CopyFile which utilize BaseConfiguration timeouts to ensure operations complete Ocaramba.UnitTests/Tests/FilesHelperTests.cs52-71Sources: OcarambaLite/Helpers/FilesHelper.cs37-200 Ocaramba.UnitTests/Tests/FilesHelperTests.cs18-80
Ocaramba includes a performance monitoring subsystem based on System.Diagnostics.Stopwatch. This is primarily used to measure "Load Times" for specific user scenarios OcarambaLite/Helpers/PerformanceHelper.cs36-37
This class maintains a loadTimeList of SavedTimes objects OcarambaLite/Helpers/PerformanceHelper.cs48-55
StartMeasure() resets and starts the internal stopwatch OcarambaLite/Helpers/PerformanceHelper.cs99-103 StopMeasure(string title) stops the timer, records the duration in milliseconds, and logs the result OcarambaLite/Helpers/PerformanceHelper.cs109-120AllGroupedDurationsMilliseconds calculates the average duration and the 90th percentile for measurements grouped by Scenario and Browser OcarambaLite/Helpers/PerformanceHelper.cs68-88This helper formats performance data into service messages for CI/CD platforms OcarambaLite/Helpers/PrintPerformanceResultsHelper.cs36-37
##teamcity[testStarted ...] and ##teamcity[testFinished ... duration='...'] syntax to report average and 90th percentile results OcarambaLite/Helpers/PrintPerformanceResultsHelper.cs44-72appveyor CLI or PowerShell Add-AppveyorTest to report results as formal test outcomes OcarambaLite/Helpers/PrintPerformanceResultsHelper.cs78-148The following diagram illustrates how performance data moves from the measurement phase to CI reporting.
Performance Data Flow: Measurement to CI
Sources: OcarambaLite/Helpers/PerformanceHelper.cs36-121 OcarambaLite/Helpers/PrintPerformanceResultsHelper.cs36-148
While the standard framework captures full-page screenshots on failure, the TakeScreenShot helper provides specialized support for capturing specific IWebElement instances.
The class TakeScreenShot provides the TakeScreenShotOfElement method OcarambaLite/Helpers/TakeScreenShot.cs33-50
IWebElement to ITakesScreenshot, calls GetScreenshot(), and saves the resulting image to a specified folder and name OcarambaLite/Helpers/TakeScreenShot.cs54-58Sources: OcarambaLite/Helpers/TakeScreenShot.cs33-60 Ocaramba.Tests.PageObjects/PageObjects/TheInternet/IFramePage.cs49-71
NameHelper provides string manipulation specifically for test data and file management:
[^a-zA-Z0-9] to sanitize strings for use in file paths OcarambaLite/Helpers/NameHelper.cs100-108DateHelper provides formatted date strings commonly used in test data generation OcarambaLite/Helpers/DateHelper.cs25-30:
dd-MM-yyyy format OcarambaLite/Helpers/DateHelper.cs37-40ddMMyyyy format OcarambaLite/Helpers/DateHelper.cs25-28ddMMyyyyHHmmss format OcarambaLite/Helpers/DateHelper.cs49-52Sources: OcarambaLite/Helpers/NameHelper.cs34-109 OcarambaLite/Helpers/DateHelper.cs25-55 Ocaramba.UnitTests/Tests/NameHelperTests.cs22-38
Helpers are often consumed by high-level WebElement wrappers to provide stable interactions. For example, the Select element uses BaseConfiguration timeouts and internal polling to ensure a dropdown is populated before attempting a selection OcarambaLite/WebElements/Select.cs84
Code Entity Mapping: Helper Usage in WebElements
Sources: OcarambaLite/WebElements/Select.cs74-84 OcarambaLite/WebElements/Table.cs34-87 Ocaramba.Tests.PageObjects/PageObjects/TheInternet/IFramePage.cs63-70 OcarambaLite/Helpers/DateHelper.cs25-30
Refresh this wiki