How to validate something has been added to a tree

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Djones92
Posts: 9
Joined: Tue Aug 16, 2016 3:54 pm

How to validate something has been added to a tree

Post by Djones92 » Fri Sep 02, 2016 8:55 am

Using Silverlight 5, Ranorex 6
In our application, there is a form to fill in name of object, etc... once this form has been filled in and the "Ok" button clicked, this item gets added to a tree, where the location depends on the type of object you're creating, child, grandchild etc (see image for better idea - concept shown with arrows). This means the position within the tree could also be different.
Our scope here to be able to create a large(ish) data set quickly using data connectors within the application and prove entry of data works correctly, but my problem is obviously these things aren't added to the tree until runtime. As such I'm having problems validating the data (Name field) that is being added to the tree as it doesn't exist until I run the test. It should be noted if I try image based testing around the text, it works, but obviously this is not robust.


Please note for security purposes I am unable to provide snapshots.
Thank you.
Attachments
treeexample.png
treeexample.png (35.55 KiB) Viewed 793 times

asdf
Posts: 174
Joined: Mon Mar 21, 2016 3:16 pm

Re: How to validate something has been added to a tree

Post by asdf » Wed Sep 07, 2016 7:40 am

Hi Djones,

Unfortunately, I'm not exactly sure if I understand your question correctly.
Could you please explain your approach a little bit more detailed?

Kind regards,
asdf

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

Re: How to validate something has been added to a tree

Post by odklizec » Wed Sep 07, 2016 7:44 am

Hi,

Additionally, please post a Ranorex snapshot (not screenshot!) of the tree in question. Ideally, post the snapshot created before and after adding new item to the tree.
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

Djones92
Posts: 9
Joined: Tue Aug 16, 2016 3:54 pm

Re: How to validate something has been added to a tree

Post by Djones92 » Wed Sep 07, 2016 2:10 pm

Hi odklizec

Unfortunately I am not able to produce snapshots due to the nature of my work.
I will try to explain better:
There is a form to input some data, this includes the name of an object. The name of the object is what will be added to the tree and how we access that piece of data from then on. Where the object is placed in the tree will depend on what kind of object you are creating - in this case a parent, child or grandchild, for instance.

Example - in my form I have written "ExampleName" (this could come from a data connector) and some other stuff and clicked OK. This object happens to be a child, so it will be placed (when the tree is open) under a Parent "ParentName" (created already).

I would like to be able to validate what is being added under "Parent", i.e "ExampleName" when technically I do not have an xpath to latch on to as the "ExampleName" object does not exist in the tree until I run my test. The validation part is simple - but what I am struggling to work out is how to dynamically and robustly search "under" the Parent object to find this newly added data. There may be multiple existing children under parent placed on the same "level" as "ExampleName"
  • ParentName
    • AlreadyExistingChild
      • Grandchild1
    • ExampleName
    • AlreadyExistingChild2

Djones92
Posts: 9
Joined: Tue Aug 16, 2016 3:54 pm

Re: How to validate something has been added to a tree

Post by Djones92 » Mon Sep 12, 2016 10:17 am

I now have a solution with the assistance of our developers.

This will probably vary depending on your AUT and technology.
What we have done is use a StringBuilder in the usercode.

Code: Select all

//first parent node
StringBuilder sb = new StringBuilder(string.Format("?/?/treeitem[@name~'^.*{0}.*']/text[@name=$varParentName]", varParentName));

repo. ..Tree.ParentNodeInfo.Path = new RxPath(sb.ToString());

//then do the same for each expandable level under the parent. The {0} will increase the lower down you go.
//a Grandchild will need the xpath using {3} args, for example.
Recorder actions now work, such as Click repo item ParentNode.


NOTE So far this is only in the init method but could be written so each layer in the tree has its own method, ClickParent() for example, for keyword driven testing and more importantly - simplicity.