System.Windows.Automation.TogglePattern via Ranorex.Adapter

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Posts: 1
Joined: Tue Oct 30, 2012 2:04 pm

System.Windows.Automation.TogglePattern via Ranorex.Adapter

Post by josephberriosgmt » Tue Oct 30, 2012 2:14 pm

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?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA

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

Post by Support Team » Fri Nov 02, 2012 2:57 pm


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

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

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

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

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

Markus (T)