FindControl

Find an automation control within a parent automation control matching the selection criteria.

AutomationControl FindControl(string wantedText);

AutomationControl FindControl(string wantedText, int maxWait);

AutomationControl FindControl(string wantedText, TextMatch textMatch);

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

AutomationControl FindControl(string wantedText, string wantedClass);

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

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

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

AutomationControl FindControl(Predicate<Control> selectionFunction);

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

Parameters

wantedText The text or Name value of the AutomationControl.  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

An AutomationControl object.

Remarks

Use this method to find a child automation control within a parent automation control.

The window can be matched on the AutomationElement Name value and or a class name or a custom selection function.

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

Example

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

AutomationControl editArea = notepadWindow.FindControl(null, "Edit"); // find the Edit class control in the notepad window

 

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

 

AutomationControl orientButton = setupDialog.FindControl("Landscape", "Button"); // class "Button" with text "Landscape"

orientButton.LeftClick();

 

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

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

 

AutomationControl window;

try

{

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

}

catch (Facilita.Exception.TimeoutException e)

{

Error(@"Failed to find ListBox");

}

See also: FindControls

 

This topic was last updated on January 13, 2022, at 02:42:23 PM.

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