Search code examples
c#ui-automationmicrosoft-ui-automationwhite-framework

Refresh White Automation Element Tree


I am using TestStack.White to do automation UI testing. A problem I am running into is that the elements tree is not updated after I click a button that brings up a new screen.

White works using UI Automation Verify(Microsoft tool), so if you cannot find an element using that tool, White will not be able to find it either.

If I open the app, click the button to render the view, and then open up UI Automation Verify, then all the fields in that new view show up in the tool. However, if I have UI Automation Verify open before I click the button, the new view does not show up in the tool. Hence, it seems I need to simply refresh the elements tree somehow.

Is there some way I can do this in C# so that my White testing will be able to see those new rendered elements?


Solution

  • I had the same problem (when switching from creating control to simply changing the visibility of existing controls). Before that code worked:

    checkButton.Toggle();
    

    After that it didn't. The solution was to use

    Mouse.Instance.Click(checkButton.ClickablePoint);
    

    instead.

    Somehow the TestStack/White does respond and refreshes UI better when you use Mouse object directly.