Reputation: 864
I'm building an automated test suite using White. One of the things I need to do is click on an icon in the System Promoted Notification Area (bottom right bit of the Start bar). I'm having trouble identifying it to White though. Using Spy++, I've discovered that it's nested three layers deep in windows that have no caption to search, which is the normal way White identifies windows. I'm therefore trying to find the correct window by class.
According to Spy++, I first need to get window 10042, which has the class "Shell_TrayWnd". Then its child window 10048, with class TrayNotifyWnd, then finally the System Promoted Notification Area, window 1005E, with class ToolbarWindow32. Taking some hints from this answer, I've tried the following code:
win=Desktop.Instance.Get<Window>(SearchCriteria.ByNativeProperty(AutomationElement.ClassNameProperty, "Shell_TrayWnd"));
but when I try to run it, I get this error logged (sic):
Exception: Error occured while geting (),AutomationElementIdentifiers.ClassNameProperty=Shell_TrayWnd
Any ideas?
EDIT: I changed the error logging so I was getting the full traceback rather than just the exception message, and found System.ArgumentException: Must specify at least two conditions.
So I've modified the code to
win = Desktop.Instance.Get<Window>(SearchCriteria.ByClassName("Shell_TrayWnd").AndIndex(0));
but it's still giving the exact same error message despite my having specified two conditions.
Exception: TestStack.White.WhiteException: Error occured while geting (),ClassName=Shell_TrayWnd,Index=0 ---> System.ArgumentException: Must specify at least two conditions.
Upvotes: 3
Views: 1313
Reputation: 547
Within White UI Automation, there is a distinction between SearchCriteria
and SearchConditions
. SearchConditions
is used internally by the framework, whereas criteria are externally added as parameters and then internally converted to conditions (and then even further converted to the Microsoft UIAutomation framework).
If you change the search criteria to
SearchCriteria.ByClassName("Shell_TrayWn").NotIdentifiedByText(String.Empty)
it will stop throwing errors.
This is because it defaults to everything being searched for by names/text as a search condition, and is throwing an irrelevant error message (it ought to be an ArgumentException
with the message of "Must Specify a name/text condition")
Upvotes: 1