Page 1 of 1

System.Windows.Automation.TogglePattern via Ranorex.Adapter

Posted: Tue Oct 30, 2012 2:14 pm
by josephberriosgmt
I am converting pre-written UI Automation scripts written in C# using AutomationElements to get the items I want to handle. I am trying to get a Telerik RadIndicator ProgressBar TogglePattern state. I have created a custom WaitForMaxTime() method that will wait until the element is no longer busy. When I try to get the TogglePattern this is the error message I get:

The type 'System.Windows.Automation.TogglePattern' must be convertible to 'Ranorex.Adapter' in order to use it as a parameter 'T' in the generic method 'T Ranorex.Core.Element.As<T>()' .

When I try to include VisualStudio Automation DLLs, Ranorex will "purge" them at some point and I can no longer use them. Is there a way to bridge the gap between Windows Automation TogglePattern and Ranorex Adapters?

Re: System.Windows.Automation.TogglePattern via Ranorex.Adapter

Posted: Fri Nov 02, 2012 2:57 pm
by Support Team
Hello,

You could access UI Automation components of your object as shown below:

Unknown unk = "/form[@controlname='MainForm']/unknown";
var uia = unk.As<UIAutomation>()
uia.AutomationElement;

If you wanna access UI Automation Toggle components of your object you could use:

Ranorex.Button b;
var uiaToogle = b.As<UIAutomationToggle>();
uiaToogle.Toggle();

Please take a look at UIAutomation and UIAutomationToggle classes in our documentation.

Regards,
Markus (T)