Test Gauge

4 posts, 0 answers
  1. p-h
    p-h avatar
    8 posts
    Member since:
    Jul 2018

    Posted 11 Oct Link to this post

    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!

  2. Nikolai
    Admin
    Nikolai avatar
    106 posts

    Posted 16 Oct Link to this post

    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 
  3. p-h
    p-h avatar
    8 posts
    Member since:
    Jul 2018

    Posted 25 Oct in reply to Nikolai Link to this post

    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!

  4. Nikolai
    Admin
    Nikolai avatar
    106 posts

    Posted 29 Oct Link to this post

    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 
Back to Top