This is a migrated thread and some comments may be shown as answers.

Coded UI and RadTreeView: How to navigate through nodes that have not yet been displayed?

3 Answers 133 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Claudio
Top achievements
Rank 1
Claudio asked on 25 Jun 2014, 02:46 PM
I have an application using a WPF RadTreeView control. I try to control the RadTreeView using a Coded UI Test.

Now I found out that the Playback is only able to find nodes of an RadTreeView which have already been displayed in the application. Given
a tree that looks like this:

Node1
   Node11
   Node12
Node2
   Node21
   Node22

After application start the RadTreeView only displays the top level nodes:

Node1
Node2

When I now try to find the 'Node11' control:

    WpfRadTreeViewItem node = _AppWindow.Navigation.GetNode("Node11");
    Click(node);

I get the error: 'The playback failed to find the control with the given search properties'. However, after expanding the Node1 and Node2 manually (and closing them again), the playback is able to locate the control (even if it is not currently displayed in the navigation tree).
I assumed that this is related to the "LoadOnDemand" feature of the RadTreeView, so I tried to set the 'IsLoadOnDemandEnabled'
and the 'IsVirtualizing' properties of the RadTreeView to 'False', but that did not change the behavior.

Is there a way that playback find's the control even if it has been not yet displayed in the navigation tree?
Is there a way to force the RadTreeView to load all subitems even if they are not yet displayed?

While searching for a workaround I tried to expand the root nodes by setting the 'IsExpanded' property to 'True':

    WpfRadTreeViewItem node = _AppWindow.Navigation.GetNode(target);
    node.IsExpanded = true;

However, if I do this, I get another error 'SetProperty of "IsExpanded" is not supported on control type: TreeItem'.

Why do I get this error?
What can I do to expand the Node by the Playback?
(Klicking on is no good idea since the node may already be expanded.)

Thanks and best regards,
Claudio

3 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 26 Jun 2014, 07:30 AM
Hello Claudio,

Please let me first explain when RadTreeView generates its RadTreeViewItems.

-- RadTreeView is populated entirely in XAML or in code behind with creating RadTreeViewItems - this means that no virtualization is performed - all containers (RadTreeViewItems are generated)

-- RadTreeView is databound and IsVirtualizing = False. The containers which are root level items are generated. If you expand a TreeViewItem - all of its children are also generated. 

-- RadTreeView is databound and IsVirtualizing = True. The containers which are root level items and are in the ViewPort are generated. When expanding an item, the children which appear in the Viewport are also generated.

Generally , if you need to generate a particular item, you need to ensure that all of its predecessors are expanded. You can do so manually or with GetItemByPath method.

WpfRadTreeViewItem does not have IsExpanded property - this is  Coded UI LEvel 4 Support which we do not support currently.


Regards,
Petar Mladenov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Claudio
Top achievements
Rank 1
answered on 30 Jun 2014, 06:33 PM
Dear Petar,

thank you very much for your response!
[quote]...
Generally , if you need to generate a particular item, you need to ensure that all of its predecessors are expanded. You can do so manually or with GetItemByPath method.
[/quote]
So, in other words, there is no way to ensure all node items are loaded at startup? But, then, what is the LoadOnDemand Property for?
And GetItemByPath() is not controllable by the UI test, is it?

[quote]
WpfRadTreeViewItem does not have IsExpanded property - this is  Coded UI LEvel 4 Support which we do not support currently.
[/quote]

Well, in my version of Telerik for Wpf (2013.3.1316.40) I'm using the Telerik.VisualStudio.TestTools.UITesting.WpfControls.WpfRadTreeViewItem class and this class offers an IsExpanded() and an IsSelected() property, the code compiles and when setting the property I get the error described above. If you currently do not support this feature, I highly recommend to remove those properties in order not to confuse your users with unimplemented interfaces.

Sorry, but I see no stable and correct way on how to control the RadTreeView by an coded UI test anyway. To be honest I'm a bit disappointed because I think especially the RadTreeView is a important component for the navigation within the application. So it is very hard to coded-ui-test applications that are using the RadTreeView in any way.

All what's missing is either allow the application to load all nodes at once at startup or implement the IsExpanded and IsSelected properties of the WpfRadTreeViewItem class. Or both :-)

Thanks again and best regards,
Claudio

0
Petar Mladenov
Telerik team
answered on 02 Jul 2014, 06:59 AM
Hi Claudio,

There are several ways to generate all RadTreeViewItems on load but this might be an extremely slow operation in large trees (one of the ways is for instance the ExpandeAll() public method). Generally you should avoid this in order to prevent slow performance.

The LoadOnDemand feature in the RadTreeView enables you to see a loading indicator when you expand an item and you load a data from a DB (or other large source with large dataset) in the LoadOnDemand event Handler. This feature refers more to the loading data in the moment you need to load it rather than a UI operation. You can load big set of data , but display only part of it in the ViewPort, the rest of the RadTreeViewItems won't be generated in a virtualized scenario.

We understand IsExpanded and IsSelected do not work when you try to set them- we currently do not support such operations. However, we need these properties public with public setters and getters due to the specific implementation of the CodedUI support level 1,2 and 3.

Have you considered using Telerik Test Studio for your scenario. Test Studio provides translators for RadTreeViewItem and you will be able to set IsExpanded and IsSelected programmatically.

Regards,
Petar Mladenov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
TreeView
Asked by
Claudio
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Claudio
Top achievements
Rank 1
Share this question
or