UITestControl.SearchProperties Property

Gets the property-value pair collection that is used to identify a control.

Namespace:  Microsoft.VisualStudio.TestTools.UITesting
Assembly:  Microsoft.VisualStudio.TestTools.UITesting (in Microsoft.VisualStudio.TestTools.UITesting.dll)

Syntax

'Declaration
Public ReadOnly Property SearchProperties As PropertyExpressionCollection
public PropertyExpressionCollection SearchProperties { get; }
public:
property PropertyExpressionCollection^ SearchProperties {
    PropertyExpressionCollection^ get ();
}
member SearchProperties : PropertyExpressionCollection with get
function get SearchProperties () : PropertyExpressionCollection

Property Value

Type: Microsoft.VisualStudio.TestTools.UITesting.PropertyExpressionCollection
The property-value pair collection that is used to identify a control.

Examples

WinButton saveButton = new WinButton(window);
saveButton.SearchProperties.Add(WinProperties.Button.Name, “btnSave”);

If you want to use Contains operator

WinButton saveButton = new WinButton(window);
//If the name of the button contains “Save”, then it will be found.
saveButton.SearchProperties.Add(WinProperties.Button.Name, “Save”, PropertyExpressionOperator. Contains);

The generated code will resemble the following:

Public WinButton BtnSaveButton
{
   get
   {
      if ((this.mBtnSaveButton == null))
         {
            this.mBtnSaveButton = new WinButton(this);
#region Search Criteria
            this.mBtnSaveButton.SearchProperties[WinProperties.Button.Name] = "btnSave";
#endregion
         }
return this.mBtnSaveButton;
   }
}

.NET Framework Security

See Also

Reference

UITestControl Class

Microsoft.VisualStudio.TestTools.UITesting Namespace