FindTopWindow

Find a top level AutomationControl window matching the selection criteria.

AutomationControl FindTopAutomationWindow(string wantedText);

AutomationControl FindTopAutomationWindow(string wantedText, ControlType controlType);

AutomationControl FindTopAutomationWindow(string wantedText, int maxWait);

AutomationControl FindTopAutomationWindow(string wantedText, string wantedClass);

AutomationControl FindTopAutomationWindow(string wantedText, TextMatch textMatch);

AutomationControl FindTopAutomationWindow(string wantedText, string wantedClass, int maxWait);

AutomationControl FindTopAutomationWindow(string wantedText, string wantedClass, TextMatch textMatch);

AutomationControl FindTopAutomationWindow(string wantedText, TextMatch textMatch, ControlType controlType);

AutomationControl FindTopAutomationWindow(string wantedText, TextMatch textMatch, int maxWait);

AutomationControl FindTopAutomationWindow(string wantedText, string wantedClass, TextMatch textMatch, int maxWait);

AutomationControl FindTopAutomationWindow(ControlType controlType);

AutomationControl FindTopAutomationWindow(Predicate<AutomationControl> selectionFunction);

AutomationControl FindTopAutomationWindow(PredicateAutomationControl> selectionFunction, int maxWait);

Parameters

wantedText: The text caption of the Control. The default match criteria is contains, case insensitive. This value can be none or an empty string "" if you are only matching on wantedClass.

controlType:The Windows AutomationElement System.Windows.Automation.ControlType type e.g. ControlType.Button

maxWait: The maximum time in milliseconds to wait for the window to be created. The default value is 120,000 milliseconds (2 minutes).

textMatch: Options are TextMatch.Contains (default), TextMatch.Exact, TextMatch.StartsWith, TextMatch.EndsWith, TextMatch.MatchCase See TextMatch.

wantedClass: The window class name.

selectionFunction: A reference to a user supplied selection function. See SelectionFunction.

Return Value

An AutomationControl object.

Remarks

This method is one of the first called to identify a required top level window or dialog. It waits until a matching window is found (unlike the FindTopAutomationWindows methods that do not wait).

The window can be matched on caption, a caption and a class name, the control type or a custom selection function.

If a matching window is not found a TimeoutException is thrown. You can catch this exception as shown below.

This method can be much slower than the equivalent WinDriver Control method with the same name, especially if there are many windows to search for a match. The depth of the tree searched is limited to MaxSearchDepth, default value is 3.

Example

AutomationControl notepadWindow = FindTopAutomationWindow("Untitled - Notepad");

AutomationControl word_w = FindTopAutomationWindow("Microsoft Word", TextMatch.EndsWith);

AutomationControl explorer_w = FindTopAutomationWindow(none, "ExploreWClass", 10000); // explorer window, wait for 10 seconds

AutomationControl explorer_w = FindTopAutomationWindow(myFunction, 10000); // call a user supplied method bool myFunction

 

AutomationControl window;

try

{

window = FindTopAutomationWindow("myWindow", 20000); // wait for 20 seconds

WriteMessage("myWindow Openl");

}

catch (Facilita.Exception.TimeoutException e)

{

Error(@"Failed to find top windowl");

}

Related:

 

This topic was last updated on October 11, 2019, at 11:19:01 AM.

Eggplant icon Eggplantsoftware.com | Documentation Home | User Forums | Support | Copyright © 2019 Eggplant