Page 1 of 1

How to access WPF properties

Posted: Thu Apr 19, 2018 9:52 am
by brahim
Hi

I'm currently testing a Desktop application ( WPF applications ) using Ranorex.The application under test has some textbox that has some properties like bol , fontstyle , foreground.
I'm wondering if there is a way to access and identify WPF properties like FontStyle because UI Automation only exposes a subset of control properties. Well what I'm trying to do is write a method that get RepoItemInfo , use a Ranorex.Text adapter then get newAdapter.element.GetAttributeValue("FontStyle") but the result is always null
My Code :

Code: Select all

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" AutomationProperties.AutomationId="MainWindow">
    <Grid>
        <TextBox Foreground="Aqua" FontStyle="Italic" Width="200" Height="25" AutomationProperties.AutomationId="TextBox">Value</TextBox>        
    </Grid>
</Window>
Ranorex User Code :

Code: Select all

 [UserCodeMethod]
        public static void checkit(RepoItemInfo field)
        {
        
        	Ranorex.Text yourTextBox = field.FindAdapter<Ranorex.Text>(); 	
        	var yourTextBoxElement = yourTextBox.Element;
        	var ValueofText = yourTextBox.TextValue;
        	var TextForeground = yourTextBoxElement.GetAttributeValue("Foreground");
        	var TextFontStyle = yourTextBoxElement.GetAttributeValue("FontStyle");
      
        }

PS: I'm using Ranorex 8.1 version
Thanks in advance

Regards,
Brahim

Re: How to access WPF properties

Posted: Fri Apr 20, 2018 2:40 pm
by Support Team
Hello brahim,

Thank you for your post.

Unfortunately, the wpf properties you mentioned can't be accessed yet.
However, we have collected several improvements in technology-plugins and they will get prioritized by our product management.
As soon as recognizing these properties is possible, you may retrieve the information from our release notes.

Furthermore, you could add a feature request on our user voice platform so that other customer can vote for an implementation.

Kind regards,

Stephan