Duplicate tree nodes

Ask general questions here.
rajm
Posts: 3
Joined: Thu Jan 16, 2020 12:24 pm

Duplicate tree nodes

Post by rajm » Thu Jan 16, 2020 1:00 pm

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.

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

Re: Duplicate tree nodes

Post by odklizec » Thu Jan 16, 2020 10:42 pm

Hi,

It seems you forgot to attach the snapshot. Also, please post the full xpath to the problematic element(s). Thanks.
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

rajm
Posts: 3
Joined: Thu Jan 16, 2020 12:24 pm

Re: Duplicate tree nodes

Post by rajm » Fri Jan 17, 2020 12:11 pm

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.
Attachments
Duplicates.PNG
mainview
Duplicates.PNG (24.81 KiB) Viewed 222 times
Duplicate forms-frmmmain.rxsnp
Proper hierarchy form with MDI-Client and child forms
(102.08 KiB) Downloaded 9 times
Duplicate forms-flight handler.rxsnp
Duplicate form without MDI-client hierarchy
(1.01 MiB) Downloaded 10 times

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

Re: Duplicate tree nodes

Post by odklizec » Fri Jan 17, 2020 12:33 pm

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
DelphiForm.png (202.13 KiB) Viewed 220 times
Have you tried to disable Delphi plugin in Ranorex Settings? I guess one of the forms will disappear after disabling this option? ;)
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

rajm
Posts: 3
Joined: Thu Jan 16, 2020 12:24 pm

Re: Duplicate tree nodes

Post by rajm » Fri Jan 17, 2020 3:31 pm

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.

foals11
Posts: 20
Joined: Wed Sep 18, 2019 9:19 am

Re: Duplicate tree nodes

Post by foals11 » Tue Jan 21, 2020 1:58 pm

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,