Locate And Wait Elements

Learn how to locate and wait desktop elements with BELLATRIX desktop module.


public void MessageChanged_When_ButtonHovered_Wpf()
    var button = App.Components.CreateByName<Button>("E Button").ToBeVisible();


    var label = App.Components.CreateByName<Button>("ebuttonHovered").ToHasContent(40, 1);
    Assert.AreEqual("ebuttonHovered", label.InnerText);


var button = App.Components.CreateByName<Button>("E Button").ToBeVisible();

Sometimes you need to perform an action against an element only when a specific condition is true. As mentioned in previous part of the guide, BELLATRIX by default always waits for elements to exist. However, sometimes this may not be enough. For example, you may want to click on a button once it is clickable. It may be disabled at the beginning of the tests because some validation is not met. Your test fulfil the initial condition and if you use vanilla WebDriver the test most probably fails because WebDriver clicks too fast before your button is enabled by your code. So we created additional syntax sugar methods to help you deal with this. You can use element “ToBe” methods after the Create and CreateAll methods. As you can see in the example below you can chain multiple of this methods.

Note: Since BELLATRIX, elements creation logic is lazy loading as mentioned before, BELLATRIX waits for the conditions to be True on the first action you perform with the component.

Note: Keep in mind that with this syntax these conditions are checked everytime you perform an action with the component. Which can lead tо small execution delays.

var label = App.Components.CreateByName<Button>("ebuttonHovered").ToHasContent(40, 1);

You can always override the timeout settings for each method. The first value is the timeout in seconds and the second one controls how often the engine checks the condition.

All Available ToBe Methods



Waits for the element to exist on the page. BELLATRIX always does it by default. But if use another ToBe methods you need to add it again since you have to override the default behaviour.



Waits for the element to disappear. Usually, we use in assertion methods.



Waits for the element to be visible.



Waits for the element to be invisible.



Waits for the element to be clickable (may be disabled at first).



Waits for the element to has some content in it. For example, some validation DIV or label.



Waits for the element to be disabled.


The default timeouts that BELLATRIX use are placed inside the testFrameworkSettings.json file. Inside it, is the timeoutSettings section. All values are in seconds.

"timeoutSettings": {
  "implicitWaitTimeout": "0",
  "elementWaitTimeout": "30",
  "sleepInterval": "1",
  "validationsTimeout": "30",
  "createSessionTimeout": "10",
  "waitForAppLaunchTimeout": "10",
  "elementToBeVisibleTimeout": "30",
  "elementToExistTimeout": "30",
  "elementToNotExistTimeout": "30",
  "elementToBeClickableTimeout": "30",
  "elementNotToBeVisibleTimeout": "30",
  "elementToHaveContentTimeout": "15"
},elementToHaveContentTimeout": "15"