Handling multiple window/applications with same name

Ask general questions here.
hsarmah2021
Posts: 10
Joined: Tue Oct 27, 2020 1:43 pm

Handling multiple window/applications with same name

Post by hsarmah2021 » Thu Nov 19, 2020 3:29 pm

Hi everyone,
In some tests, I need to launch multiple instances of the same application in parallel and perform different actions on them. But in Ranorex how to handle such situation , since for Ranorex xpaths, the window header is same and it can't differentiate between different instances so it ends up clicking on any of them in Random. Is there a way to do this may be in code module? I did not find anything related to this in the guide.

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

Re: Handling multiple window/applications with same name

Post by odklizec » Thu Nov 19, 2020 7:32 pm

Hi,

It would be much easier to answer your question, if we can see a Ranorex snapshot (not screenshot) of your app, ideally, post multiple snapshots taken at a time when there are opened multiple windows. If there are no differences in these App windows (their titles), you may need to use element indexes. But as mentioned, to provide a reasonable suggestion, we need to see snapshot(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

hsarmah2021
Posts: 10
Joined: Tue Oct 27, 2020 1:43 pm

Re: Handling multiple window/applications with same name

Post by hsarmah2021 » Fri Nov 20, 2020 12:15 pm

I have attached the snapshot here of both the applications when they were open at the same time. The password I have sent you in private message. Thank you!
Attachments
Snapshots.zip
(369.24 KiB) Downloaded 8 times

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

Re: Handling multiple window/applications with same name

Post by odklizec » Fri Nov 20, 2020 12:52 pm

Hi,

I'm afraid, I'm not able to find any difference in these snapshots (except ProcessId and some GUIDs). The problem is, that both snapshots were taken with active instance of the app/window. So all app attributes are the same. I think that if you examine both instances with spy, without activating the background app/window, you may find some differences in Windows Style, Topmost, Window Style, and so on?

Anyway, is there any reason why don't you simply keep just one instance of the app? This would make your life much easier.

Another possibility might be to add "ProcessId" attribute to root repo element and make it variabilized. Then at start of the app, get the app ProcessID and fill it to variable connected with root repo variable (processID). Then once there is opened second instance of the app, get its processID and replace the root repo processId variable.
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

hsarmah2021
Posts: 10
Joined: Tue Oct 27, 2020 1:43 pm

Re: Handling multiple window/applications with same name

Post by hsarmah2021 » Fri Nov 20, 2020 1:27 pm

Thanks for your reply.

I need two instances in parallel because I need to perform some actions in both of them and see some changes.

Identifying the process id and using it as a variable seems fine, but how to use this process id in the xpath? Are there any example?

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

Re: Handling multiple window/applications with same name

Post by odklizec » Fri Nov 20, 2020 1:45 pm

Hi,

The xpath could look like this:

Code: Select all

/form[@title>'OpenProtocol Controller S' and @processid=$processIDVar]
Of course, you need to connect that variable with Global or TestCase/SmartFolder parametr, which needs to by filled with appropriate process id. You can get the process ID via Run App command (its return value).
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