Monday, March 20, 2017

Search Configurations for the control in CodedUI

Search configuration of the control


We have some predefined search configuration which helps to narrow down the search space (search only in visible controls) or to do perform some prerequisite before actually starting the search (expand parent tree node before searching for the child node). Following are the different search configs:

var app = ApplicationUnderTest.Launch(@"yourapplication.exe");
 var mainWindow = new WinWindow(app);
 mainWindow.WindowTitles.Add("Form1");

 WinText textLabel = new WinText(mainWindow);
 textLabel.SearchProperties.Add(WinControl.PropertyNames.Name, "Some Text Label");

 WinEdit siblingEditControl = new WinEdit(textLabel);
 siblingEditControl.SearchConfigurations.Add(SearchConfiguration.NextSibling);
 siblingEditControl.Text = "setting the text";

SearchConfig ParameterDescription
AlwaysSearchUITest uses a cache while doing actions on an Application by adding Always Search in the search config user can force UITest to not to use the cached value for the control.
DisambiguateSearchIf the parent and the controls properties are same there are chances that UITest would start doing action on the parent itself. This config can be used to ask the playback to act on its child rather than the parent itself.
ExpandWhileSearchingExpand the control before looking for the other control inside it. E.g., TreeView
NextSiblingSearch in the siblings inside the container. Sometime if the control is nameless we may iterate from the named control inside the same container to reach the control.
VisibleOnlySearch only in the visible control. It helps to reduce the search space.

No comments:

Post a Comment