Tuesday, 20 January 2015

Searching a UI Test Control with an invalid property


What if we give an invalid property as the Search/Filter 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 google.com using a InvalidSearchProperty,
this.mUISearchEdit.SearchProperties["InvalidSearchProperty"] = "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 google.com using a InvalidFilterProperty,
this.mUISearchEdit.FilterProperties["InvalidFilterProperty"] = "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 InvalidSearchProperty
this.mUIItem6Button.SearchProperties["InvalidSearchProperty"] = "foo-bar";
you would get the following exception.
System.ArgumentException: The property InvalidSearchProperty 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.