In this blog, Bala has described how Coded UI Test searches for controls. A frequently asked follow-up question is

“What if i give an invalid search property?”

 

For Web technology,

  • If an invalid SearchProperty is used to Find a UITestControl, it will throw UITestControlNotFoundException. 

e.g:- If you searched for the search edit box in bing.com using a BadSearchProperty,

this.mUIEnteryoursearchtermEdit.SearchProperties["BadSearchProperty"] = "foo-bar";

you would get the UITestControlNotFoundException

 

  • If an invalid FilterProperty is used to Find a UITestControl, it will be ignored.

e.g:- If you searched for the search edit box in bing.com using a BadFilterProperty,

this.mUIEnteryoursearchtermEdit.FilterProperties["BadFilterProperty"] = "foo-bar";

you would succeed in locating the edit box and performing operations performed on it.

 

For MSAA & UIA technologies,

  • If an invalid SearchProperty is used to Find a UITestControl, it will throw an ArgumentException

e.g:- If you searched for the button ‘6’ in the calculator using a BadSearchProperty

this.mUIItem6Button.SearchProperties["BadSearchProperty"] = "foo-bar";

you would get the following exception.

System.ArgumentException: The property BadSearchProperty is not a valid search property.

  • FilterProperties are not supported. If you specify FilterProperties for a WinForms or WPF control,  you will get the following message.

System.ArgumentException: Filter properties are not supported by the following technology: MSAA. To search for a control, you must remove the filter properties.

 

NOTE also for all technologies,

  • If an invalid Property is used in GetProperty/SetProperty, it will throw a NotSupportedException.