Ranorex Spy cannot select single item within WPF ListBox

Ranorex Spy, Recorder, and Studio.
MillionsterNutzer
Posts: 6
Joined: Mon Mar 14, 2016 1:59 pm

Ranorex Spy cannot select single item within WPF ListBox

Post by MillionsterNutzer » Mon Mar 14, 2016 2:18 pm

Hi!

I'm a GUI developer and the testers of my department are starting to use Ranorex to test my applications (.Net 4.6 / C# / WPF). As it seems this works fine so far but there is one specific problem that they asked me to fix:

In my application I have several ListViews or ListBoxes containing multiple items. Unfortunuately they cannot select a single item in these List-UserControls but only the whole list which is not of any benefit (Please see screenshot).

I've created an example project to dive into the issue but even if I assign nothing more than a ItemsSource my testers can still only access the ListView itself but not its items. When I change the ListView to a DataGrid then they can access the single cells of each row which seems to be fine.

I assmue this is a basic problem which is already known. Is there anything that I can do as a GUI developer to fix this problem with my lists? Or are my testers doing something wrong?

Regards

Ralf
Attachments
ListViewItemNotSelectable.png
ListViewItemNotSelectable.png (33.38 KiB) Viewed 1192 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3921
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex Spy cannot select single item within WPF ListBox

Post by odklizec » Tue Mar 15, 2016 9:57 am

Hi,

Could you please post a Ranorex snapshot (or even better sample project you've created) of the problematic listbox? What version of Ranorex do you use?

At first, I would suggest to enable two WPF-related Ranorex options mentioned here:
http://www.ranorex.com/forum/unable-to- ... tml#p33791

If this does not help, try to switch the WPFLegacy/UIA Interaction from WpfPreferred to UIAOnly option. Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

MillionsterNutzer
Posts: 6
Joined: Mon Mar 14, 2016 1:59 pm

Re: Ranorex Spy cannot select single item within WPF ListBox

Post by MillionsterNutzer » Wed Mar 16, 2016 10:26 am

Hi odklizec,

we are running Ranorex Version 5.4.5

In my main software one of my testers found one ListView that actually allowed selecting a ListViewItem directly instead of the whole list.

I've created an example project in order to find out the difference which enabled the selection for that one specific ListView.
As it seems the following addition in the XAML seems to make a major difference for Ranorex while there is no change in the GUI from an optical or behavior point of view:

Code: Select all

            <ListView.ItemsPanel>
                <ItemsPanelTemplate x:Uid="ItemsPanelTemplate_2">
                    <StackPanel x:Uid="StackPanel_1" Orientation="Vertical" />
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
I have attached you the said Project. It is a Visual Studio 2015 C# WPF project. I hope you can use this. Please don't be confused by the name of the project as I used it initally to make some tests with a custom ComboBox. Just ignore the ComboBox on the window and concentrate on the ListView: By default you cannot let Ranorex select a single item in it, but this becomes possible when ItemsPanel of the ListView is set to a StackPanel.

Could you please have a look at this and verify that you have the same behavior on your side?

Regards

Ralf
Attachments
FilterComboBox.zip
(44.39 KiB) Downloaded 45 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3921
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex Spy cannot select single item within WPF ListBox

Post by odklizec » Wed Mar 16, 2016 10:38 am

Hi Ralf,

I'm able to select individual items (via Ranorex 5.4.5 Spy) in both samples. The trick is to enable Show All Elements WPF option, as mentioned in this post:
unable-to-access-listitem-from-a-wpf-list-t8349.html#p33791
Hope this helps? ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

MillionsterNutzer
Posts: 6
Joined: Mon Mar 14, 2016 1:59 pm

Re: Ranorex Spy cannot select single item within WPF ListBox

Post by MillionsterNutzer » Thu Mar 17, 2016 9:16 am

Hi odklizec,

I've talked this through with one of my testers and he came to the same conclusion as some of the guys in your referenced thread: It is not a good idea to use "Show All Elements" in a regular use case because it slows down the procress tremendously and also messes up things in other places.

We will investigate further into explixitly using an ItemsPanelTemplate as shown in my example. If this does not contain negative any side effects then we should be fine with this.

As a side note: One odd thing that we noticed every now and then was that after using my example with the custom ItemsPanelTemplate Ranox sometimes was able to see the ListViewItems of the regular ListView which it was not able to see before. This somehow smells like a bug in Ranorex, however we were not able to reproduce it in a reliable manner. Not sure if this is of any interest for you or someone else who stumples upon the same issue...

Thanks!

Ralf

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3921
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex Spy cannot select single item within WPF ListBox

Post by odklizec » Thu Mar 17, 2016 10:00 am

Hi Ralf,

I did not experience a temporary ability to select individual items in regular listview (with your sample app and disabled "show all elements" Ranorex WPF option). If this happens again to you, I would suggest to save a snapshot of the list view. Then refresh the spy and save another snapshot, where the list view items are not selectable. Then send both snapshot to Ranorex support. This may help them to identify the source of problem.

As for "show all elements" Ranorex WPF option, I think it may be possible to enable/disable this option from code? So then you don't have to enable via Ranorex settings and keep it enabled all the time. I believe this piece of code enables the Show All Elements from code (and disable it with 'false'):

Code: Select all

Ranorex.Plugin.WpfConfiguration.ShowCompleteVisualTree=true;
Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration