Does anyone know if support for Regular Expressions be added to the PropertyCondition class in a future update to the UI Automation Framework?
Say, for example, I am trying to write automated tests for an application where the title bar of the window changes depending on what screen is currently being displayed. So the title bar text might look something like this:
MyUniquelyNamedApplication - Navigation View
MyUniquelyNamedApplication - Configuration View
MyUniquelyNamedApplication - Report View
etc.
If I wanted to write a function that could reliably obtain an AutomationElement for the main window of this application regardless of which screen is currently displayed, using a regular expression would seem the most logical approach, and would look something like this:
Unfortunately, this code currently throws a System.ArgumentException.
Of course, if the application's main window had its Name property properly assigned I could search by AutomationIdProperty instead of NameProperty, but that's not always an option.
-Jesse Kindwall
edit: Wow, the code editor on this forum really does not like Firefox. Formatting fixed.
Say, for example, I am trying to write automated tests for an application where the title bar of the window changes depending on what screen is currently being displayed. So the title bar text might look something like this:
MyUniquelyNamedApplication - Navigation View
MyUniquelyNamedApplication - Configuration View
MyUniquelyNamedApplication - Report View
etc.
If I wanted to write a function that could reliably obtain an AutomationElement for the main window of this application regardless of which screen is currently displayed, using a regular expression would seem the most logical approach, and would look something like this:
public AutomationElement GetAppWindow()
{
System.Text.RegularExpressions.Regex TitleBar = new Regex("MyUniquelyNamedApplication.*");
return AutomationElement.RootElement.FindFirst(TreeScope.Children,
new PropertyCondition(AutomationElement.NameProperty, TitleBar));
}
Unfortunately, this code currently throws a System.ArgumentException.
Of course, if the application's main window had its Name property properly assigned I could search by AutomationIdProperty instead of NameProperty, but that's not always an option.
-Jesse Kindwall
edit: Wow, the code editor on this forum really does not like Firefox. Formatting fixed.