Skip to main content

ToControl

Return a WinDriver Control object from an AutomationControl.

Control ToControl();

Parameters

None

Remarks

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

Not all AutomationControl objects can be converted to a Control object. This will always apply if the AutomationControl does not have a Windows handle (the Element.Current.NativeWindowHandle). You can check the presence of a Windows handle using a Windows spy tool for Automation Elements.

Example

AutomationControl notepad = FindTopAutomationWindow("notepad");
notepad.ToControl().ShowWindow(ShowWindowCodes.SW_MAXIMIZE);

Related: