How to access WPF properties

Best practices, code snippets for common functionality, examples, and guidelines.
Posts: 1
Joined: Thu Apr 19, 2018 9:09 am

How to access WPF properties

Post by brahim » Thu Apr 19, 2018 9:52 am


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"
        Title="MainWindow" Height="350" Width="525" AutomationProperties.AutomationId="MainWindow">
        <TextBox Foreground="Aqua" FontStyle="Italic" Width="200" Height="25" AutomationProperties.AutomationId="TextBox">Value</TextBox>        
Ranorex User Code :

Code: Select all

        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


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

Re: How to access WPF properties

Post by Support Team » Fri Apr 20, 2018 2:40 pm

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,