This article helps you make validations stable and maintainable, especially across different machines (dev PC vs CI agent), where UI timing, resolution, or dynamic values can cause “works on my machine” failures.
Choose the right validation type
Ranorex supports:
- Text-based validation: Validate visible text (labels, messages, values).
- Attribute-based validation: Validate stable UI properties (Exists/Visible/Enabled, state, attribute values).
- Image-based validation: Validate visual output when text/attributes aren’t reliable (icons, charts, rendered content).
Rule of thumb
- Prefer attribute-based or text-based validations for stability across machines.
- Use image-based validation only when you truly need to validate the visual state, and keep the validated region as small and intentional as possible.
Most common causes of flaky validations (and fixes)
Dynamic values (IDs, timestamps, counters, changing text)
Fix options:
- Use validation variables instead of constants when values change per run.
- Use regex-based validation when only part of a changing string matters.
Timing and synchronization
Symptoms: Validations fail intermittently or only on slower machines.
Fix options:
- Validate after the UI is actually updated (add appropriate waits/actions before validating).
- Use the validation action’s Grace period to allow time for the expected state/value to appear.
- Use whitelisting when possible to improve performance during recording/execution and reduce noise.
Image-based validation pitfalls (most “agent machine” failures)
Image validations are sensitive to UI differences (scaling/DPI, theme, font rendering). If you can validate a stable attribute (Exists/Visible/state), prefer that.
Best practices:
- Select a sub-region instead of validating the whole screenshot whenever possible.
- Pick the right mode:
- Contains: check that a smaller image is contained within a reference image
- Compare: compare against a complete reference image
- If you use ignore regions, avoid overlapping find/ignore regions (Ranorex warns this can cause failures).
- Use reporting aids when available (expected/actual images, difference image, ignore regions).
“I don’t see the validation in the report”
A validation may run, but its message might not appear due to the report level threshold.
Fix options:
- Ensure the container’s report level threshold includes validation messages you want to see (for example, Info vs Success).
Special case: tooltip validations
Tooltip timing can be tricky; Ranorex supports a dedicated workflow (including the tooltip hotkey).