Page 1 of 1

Duplicate tree nodes

Posted: Thu Jan 16, 2020 1:00 pm
by rajm
Hi,

Im trying to find a container under a main form, which inturn contains other child forms to work on.
But since the main form appears as duplicates and only one of them displays the proper hierarchy, the code fails to find elements using the ranorex repository definition. Ranorex chooses the first of duplicate and says that the container doesnot exists.

As i have many such scenarios , didnt want to use index to choose the elements and wanted to choose the right hierarchy form and/or using the windows properties. This was working fine until sometime ago, but only recently the main form appears twice when looking through ranorex spy and the code fails.

i have checked through windows sdk tool 'inspect' just to make sure there are no duplicates in the AUT. Please let me know how to chose the right element without using index.

Attached snapshot.

From Flight handler is the duplicate form with similar properties but doesn't contain the correct hierarchy of elements.
Frmmain is the correct form which contains the MDIClient container, and the child forms will be under this container.

Re: Duplicate tree nodes

Posted: Thu Jan 16, 2020 10:42 pm
by odklizec
Hi,

It seems you forgot to attach the snapshot. Also, please post the full xpath to the problematic element(s). Thanks.

Re: Duplicate tree nodes

Posted: Fri Jan 17, 2020 12:11 pm
by rajm
Sorry added attachments.

its the main form and the xpath is :- /form[@title~'Flight Handler' and @controlname='frmMain']. Xpath and most other attributes appears to be same for both tree nodes.

I need to chose frmmain which has MDIClient container and forms as child to it. Not the flight handler form which has workspace instead of mdiclient, and the child forms appears outside workspace.
Since the xpath is same , Ranorex chooses the first form 'flight handler' and when i look for 'frmfindflight' under mdiclient , it fails.

please let me know if there is a way to limit spy to find only one copy of the form. I tried modifying WPF plugins to UIA only , but still the duplicates appears.

Re: Duplicate tree nodes

Posted: Fri Jan 17, 2020 12:33 pm
by odklizec
Hi,

This is an interesting problem.

At first, your problem could be solved by using this xpath...

Code: Select all

/form[@controlname='frmMain']
It seems that the controlname attribute is only available in the instance of form you are looking for. At least it works in the snapshots you posted.

As for the reason why the form is duplicated in the Spy tree, I think it has something to do with Delphi implementation of the app? And most interesting fact is, that the the form without MDI client shows much more attributes in root form element? Additionally, the content of MDI form is available also in the second instance of form, just under different UI node...
DelphiForm.png
Have you tried to disable Delphi plugin in Ranorex Settings? I guess one of the forms will disappear after disabling this option? ;)

Re: Duplicate tree nodes

Posted: Fri Jan 17, 2020 3:31 pm
by rajm
Hi,

Thanks for your response. Yes after disabling the delphi plugin- the duplicate disappeared, and only the form with MDIClient appears.

But for some reason , the mdiclient container is not found during runtime under frmmain using below code.
//if(formInfo.FindAdapter<Form>().TryFindSingle<Ranorex.Container>("container[@class='MDIClient']" ,10000, out mdi_element))
forminfo = /form[@controlname='frmMain' and @title~'Flight Handler'].

Since there are 10 different types of frmmain and all have mdiclient inside them, i used generic code to find the mdi container to close all the child forms as part of routine. For now im using the direct repo item (if(repo.FrmMain_FH.FH_MDIClient.SelfInfo.Exists()) , which works fine.

When checked the forminfo under runntime (debug local variable) , still the child forms appears outside mdi client and there is workspace pane (just like the duplicate).

checked with the developer regarding the delphi plugin - they have no idea about the duplicate forms, and their code isnt changed.

Also the xpath name / controlname both points to the first flight handler when run from code.

Re: Duplicate tree nodes

Posted: Tue Jan 21, 2020 1:58 pm
by foals11
Hi,

It is expected that there are two trees in Spy, when the delphi plugin is enabled.
One is the tree of the delphi plugin and the other is the tree of the UIA plugin.
As odklizec correctly mentioned, you have to modify the path of the form element, to differ between the trees.

regards,