🖋️
QualityMate
  • QualityMate
  • Getting Started
    • Introduction
    • Why QualityMate
    • Architecture
    • Supported Web Browsers
    • Glossary
  • Components
    • UI Player
      • Basic Concepts
      • UiPlayer
      • MSTest Integration
      • Samples
        • QualityMate Sample Desktop
        • QualityMate Sample Web
        • QualityMate MSTest Integration Sample Desktop
        • QualityMate MSTest Integration Sample Web
        • QualityMate Integration with Test Frameworks
        • Web Authentication Sample
      • QualityMate Project Template
    • UI Recorder
      • Basic Concepts
      • Setting Up the Recorder
      • Validating an Element
      • Generating QualityMate Solution
  • Tools
    • File Comparators
    • Image Processor
    • Project Merger
    • Test Case Generator
      • Filters
      • Rename Recorded Controls
  • Basic Concepts
    • Page Object
      • Work Guide
    • Controls
      • Control Types
        • Generic Types
        • Desktop types
        • Web Types
        • WebMap types
          • Kendo PowerBuilder
          • Kendo WinForms
          • Kendo Silverlight
      • Interactions
        • SendKeys
        • Validate
    • Selectors
      • Selectors in Code
      • Default Selector
      • Shared Selector
      • Selectors Category
        • CSS Selector
        • XPath Selector
        • Image Selector
        • Frame Selector
      • Identifying Selector
        • Identify for Windows Desktop
        • Identify for Web
  • How to Guides
    • Setting Up the Configuration
      • Parameters
      • Context
      • Loading External Data
    • Awaiting for the Application
      • Busy Loaders
      • Retries
    • Defining Controls
      • Extending Controls
      • Control Slice
      • Control Collection
    • Logging on Tests
      • QualityMate Reports
      • Logging
  • Help
    • Best Practices
      • Environment
      • Tests
      • Page Objects
      • Validations
      • Interactions
      • Image Comparisons
    • Known Issues
    • Continuous Integration
      • Agents Session
    • Upgrading QualityMate
      • From version 7 to version 8
      • Previous Versions
      • How to switch from TestFeature to UiTest
    • VS Test
      • Command Line
      • Generate Reports
  • API
    • Control Interfaces
      • IButton
      • ICheckBox
      • IComboBox
      • IControl
      • IControlSlice
      • IDateTimePicker
      • IElement
      • IGrid
      • IGroupBox
      • ILabel
      • IListBox
      • IMenu
      • INumericUpDown
      • IPageObject
      • IProgressBar
      • IRadioButton
      • IRadioButtonGroup
      • ISplitButton
      • IStatusStrip
      • ITab
      • ITextBox
      • IToggleButton
      • IToolBar
      • ITreeView
    • Behavior
      • ICheckableControl
      • IList
      • ITextControl
    • Enums
      • ClickType
      • KeyModifiers
      • MouseButton
  • Changelog
    • Changelog
      • Version 8
      • Version 7
      • Version 6
      • Version 5
      • Version 4
      • Version 3
Powered by GitBook
On this page
  • Retry Methods
  • Examples

Was this helpful?

  1. How to Guides
  2. Awaiting for the Application

Retries

Retry Methods

The Retry class has several methods to handle retrying operations. Below you can find information describing those methods:

Method

Exception On Timeout

Returns

Retries Until

void Do(Action target)

Yes

-

No Exception is raised

bool TryDo(Func<T> target)

No

True if successful; False otherwise

No Exception is raised

T Do(Func<T> target)

Yes

Passed target result

No Exception is raised

void DoUntil(Func<bool> target)

Yes

-

No Exception is raised & Passed target returns True

bool TryDoUntil(Func<bool> target)

No

True if successful; False otherwise

No Exception is raised & Passed target returns True

T DoUntil(Func<T> target, Func<T, bool> validation)

Yes

Passed target result

No Exception is raised & Passed validation returns True

Examples

  • Ensuring a control is clicked.

// Some errors can be raised when clicking a control if, 
// for example, it is not visible at the time.
Retry.Do(() => this.MyPageObject.MyControl.Click());
  • Ensuring a control contained by a ControlCollection is found and clicked.

// This action would normally throw an exception on certain scenarios.
// For example, if the collection does not contain the searched control
// or the control is found but not immediately clickable.
Retry.Do(() => this.MyPageObject.MyControlCollection.Controls
    .First(control => control.Text == "Item 1").Click());
  • Ensuring a control is clicked and then validating that the action is affected.

// Creating a local function that clicks "MyControl" and then validates the result of
// the operation.
bool ClickMyControlAndValidate()
{
    this.MyPageObject.MyControl.Click();
    return this.MyPageObject.MyLabel.Text == "MyControl has been clicked");
}
Retry.DoUntil(ClickMyControlAndValidate);
  • Looking for a control that might or not be present depending on the application state.

if (Retry.TryDoUntil(() => this.MyPageObject.MyControl.Displayed))
{
    // Additional actions to be executed if "MyControl" is found AND is displayed.
}

// Continue normal execution.
PreviousBusy LoadersNextDefining Controls

Last updated 3 years ago

Was this helpful?