Skip to main content

ToAutomationControl

Return a WinDriver AutomationControl object from a WinDriver Control.

AutomationControl ToControl();

Parameters

None

Remarks

This method returns a WinDriver AutomationControl Class object. This can be useful if you wish to use Automation Control class methods that do not have an equivalent in the Control class.

Example

// Launch a desktop item by name. Find the item and double click it
public void LaunchDesktopItem(string name)
{
Control desktop = FindTopWindow("Program Manager");
Control listview = desktop.FindControl("FolderView", 1000);

AutomationControl acListView = listview.ToAutomationControl(); // convert to an automation control
try
{
AutomationControl item = acListView.FindControl(name, ControlType.ListItem);
item.DoubleLeftClick();
}
catch (Exception)
{
ExitVU("Failed to find desktop item: " + name, false);
}
}

Related: