How to access WPF properties

Best practices, code snippets for common functionality, examples, and guidelines.
brahim
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

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

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

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,

Stephan