This is a migrated thread and some comments may be shown as answers.

Test Gauge

3 Answers 35 Views
Gauges
This is a migrated thread and some comments may be shown as answers.
p-h
Top achievements
Rank 1
p-h asked on 11 Oct 2018, 10:27 AM

Hello,

I am using Telerik testing framework.

I need to test RadVerticalLinearGauge/RadHorizontalLinearGauge and RadRadialGauge that contains RadialScale/LinearScale, GaugeRanges, BarIndicator and Needles.

How can I get their properties like: ticks, colors, values of needle and bar, max, min etc.?

Thank's!

3 Answers, 1 is accepted

Sort by
0
Nikolai
Telerik team
answered on 16 Oct 2018, 08:36 AM
Hello,

Telerik Testing Framework allows both visual tree search and getting any dependency property of any WPF visual control. For more complex scenarios and/or re-usability you can create your own wrapper classes for any control. The framework comes with intrinsic wrapper for more common controls such as TextBox, TextBlock, Button, all part of the ArtOfTest.WebAii.Controls.Xaml.Wpf namespace. We also have some wrappers for RadGauge and other Telerik WPF controls here.

If you decide to implement your own wrappers your can follow this example: 
var rhlg = this.ActiveApplication.MainWindow.Find.ByType("RadHorizontalLinearGauge");
int maxValue = rhlg.GetProperty<int>("Max");

this is how you can get the "Max" value of a single "RadHorizontalLinearGauge". The approach for other properties or control types is the same.

Regards,
Nikolai
Progress Telerik 
0
p-h
Top achievements
Rank 1
answered on 25 Oct 2018, 10:38 AM

I wrote this line in my code:

int maxValue = rhlg.GetProperty<int>("Max");

but it caused an exception:
"There is no automation property collected with name 'Max'!"

It happened with more properties and also on more types like scales or range.

Thank's!

0
Nikolai
Telerik team
answered on 29 Oct 2018, 12:36 PM
Hi,

The issue here might be caused by the framework cache. GetProperty<T> and GetProperty(AutomationProperty) behave differently for different controls, usually the generic method will do a look up just for the cached values for speed, so you can switch between the two if the first does not return the proper value. 

I've written simple Silverlight test against our demo site but it should be the same for WPF apps.

this.ActiveBrowser.NavigateTo("https://demos.telerik.com/silverlight/#Gauge/Customization/LinearTickMarks");           
             
System.Threading.Thread.Sleep(15000);          
             
var slApp = this.ActiveBrowser.SilverlightApps()[0];
             
Assert.IsNotNull(slApp);
             
var vls = slApp.Find.ByType("VerticalLinearScale");
            
Assert.IsNotNull(vls);
             
var maxValue = vls.GetProperty(new AutomationProperty("Max", typeof(int)), int.MinValue);
             
this.Log.WriteLine("MaxValue: " + maxValue.ToString());

that should work as per your case. 

Regards,
Nikolai
Progress Telerik 
Tags
Gauges
Asked by
p-h
Top achievements
Rank 1
Answers by
Nikolai
Telerik team
p-h
Top achievements
Rank 1
Share this question
or