FindControl

Find a control within a parent control (window) matching the selection criteria.

Control FindControl(string wantedText);

Control FindControl(string wantedText, int maxWait);

Control FindControl(string wantedText, TextMatch textMatch);

Control FindControl(string wantedText, TextMatch textMatch, int maxWait);

Control FindControl(string wantedText, string wantedClass);

Control FindControl(string wantedText, string wantedClass, int maxWait);

Control FindControl(string wantedText, string wantedClass, TextMatch textMatch);

Control FindControl(string wantedText, string wantedClass, TextMatch textMatch, int maxWait);

Control FindControl(Predicate<Control> selectionFunction);

Control FindControl(Predicate<Control> selectionFunction, int maxWait);

Parameters

wantedText: The text 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.

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

A Control object that can be used to access the found window.

Remarks

After finding a top-level window control, you would use this method to find a child control within the window control.  The control can be matched on a text value, and/or a class name or a custom selection function.

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

Example

Control notepadWindow = FindTopWindow("Untitled - Notepad");

Control editArea = notepadWindow.FindControl(null, "Edit");

// find the Edit class control in the notepad window

 

Control okButton = window.FindControl("OK");

 

Control orientButton = setupDialog.FindControl("Landscape", "Button");

// class "Button" with text "Landscape"

orientButton.ClickButton();

 

Control explorer_w = FindTopWindow(none, "ExploreWClass", 10000);

// explorer window, wait for 10 seconds

Control explorer_w = FindTopWindow(myFunction, 10000); // call a user supplied method bool myFunction

 

Control window;

try

{

listBox = window.FindControl("", "ListBox", 5000); // wait for 5 seconds

}

catch (Facilita.Exception.TimeoutException e)

{

Error(@"Failed to find ListBox");

}

 

This topic was last updated on June 21, 2019, at 02:49:50 PM.

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