Ranorex Spy cannot detect ItemType on WPF list items

Bug reports.
mrollins
Posts: 10
Joined: Wed Aug 28, 2013 6:35 pm

Ranorex Spy cannot detect ItemType on WPF list items

Post by mrollins » Wed Aug 28, 2013 7:50 pm

Ranorex Spy cannot detect the AutomationProperties.ItemType attached property for WPF list items. This applies to both TreeViewItems and ListBoxItems. In both cases ItemType shows as unset when it has been bound to a valid value.

Snoop sees the ItemType property without issue, Ranorex consistently ignores it on list items; though Ranorex can detect the ItemType property on custom controls and elements.

I can work around this by using the non-intuitive ItemStatus in some cases, but there have been instances where I would like to use both ItemStatus and ItemType on the same list item.

--
Michael
Attachments
RanorexSpy ListBoxItem.PNG
RanorexSpy ListBoxItem.PNG (65.23 KiB) Viewed 1714 times
Snoop ListBoxItem.PNG
Snoop ListBoxItem.PNG (47.95 KiB) Viewed 1714 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex Spy cannot detect ItemType on WPF list items

Post by Support Team » Mon Sep 02, 2013 1:03 pm

Hi,

In comparison to Ranorex, Snoop invokes (and influences) the whole process to get the information out of the application under test.
Ranorex uses UIAutomation in order to get the information of the WPF application.
It seems that there is an issue in the UIAutomation implementation of your listitems. Please check if Microsoft Inspect or Microsoft UISpy is able to get the right value of the property.

Which code do you use to change/set the value of the ItemType property?

Regards,
Markus
.
Image

mrollins
Posts: 10
Joined: Wed Aug 28, 2013 6:35 pm

Re: Ranorex Spy cannot detect ItemType on WPF list items

Post by mrollins » Tue Sep 03, 2013 6:01 pm

It seems MS Inspect can't find the value of the ItemType property either. I'm setting the value of the attached property right next to the ItemStatus property which is of the same type and that works fine. I am at a a loss.

Code: Select all

<ListBox>
   <ListBox.ItemContainerStyle>
      <Style TargetType="ListBoxItem">
         <Setter
            Property="AutomationProperties.ItemStatus"
            Value="{Binding MediaType}" />
         <Setter
            Property="AutomationProperties.ItemType"
            Value="{Binding MediaType}" />
      </Style>
   </ListBox.ItemContainerStyle>
<ListBox>
--
Michael
Michael Rollins

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex Spy cannot detect ItemType on WPF list items

Post by Support Team » Fri Sep 06, 2013 3:04 pm

Hi,

Thank you for sharing your code.
I will analyze the issue in detail and will get back to you as soon as possible.

Regards,
Markus
.
Image

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex Spy cannot detect ItemType on WPF list items

Post by Support Team » Mon Sep 09, 2013 9:56 pm

mrollins wrote:It seems MS Inspect can't find the value of the ItemType property either. I'm setting the value of the attached property right next to the ItemStatus property which is of the same type and that works fine. I am at a a loss.
I would have also thought that should work out of the box. Both properties have the same type (string) and have the exactly same code behind.

If MS Inspect cannot see the value either, than maybe this is some problem with the "MediaType" property of your data source?
Have you tried binding just the ItemType and not the ItemStatus?

UPDATE: I used reflector to get the code of the default UIA implementation for ListBoxItems and look what the method returns:
protected override string GetItemTypeCore()
{
    return string.Empty;
}
Well, for me this is a bug in the .NET Framework, but I'm afraid MS won't change the implementation due to backwards compatibility. Please, use one of the other AutomationProperties as a workaround...

Regards,
Alex
Ranorex Team
.
Image

mrollins
Posts: 10
Joined: Wed Aug 28, 2013 6:35 pm

Re: Ranorex Spy cannot detect ItemType on WPF list items

Post by mrollins » Thu Sep 12, 2013 3:44 pm

Thanks for looking into it for me, reflection is a bit beyond me at the moment.

I figured it was an MS issue when Inspect failed to return the value, but I'm at a loss as to why anyone would implement it that way. One would think the idea of a list of different types of items (e.g. Files and Folders) would be obvious to WPF designers.
Michael Rollins