get the nth attribute

Ask general questions here.
Posts: 32
Joined: Fri Jan 04, 2019 1:38 pm

get the nth attribute

Post by rsudhak » Tue Feb 12, 2019 12:15 am

hi ,

I have a list of menu, say L1,L2,L3...Ln , similarly I have a list of sub -menu say K2,L2,M2... . sub menu is a context menu pop up box. I have 3 questions here
1. how do I get the element xpath easily, please note that I am new to Ranorex, I want something similar to Actions class in selenium, where I can click on the menu and then move to the sub menu. (spy doesnt help here :( and cntrl plus windows crashes spy)
2.In the scenario you see that L2 is in the menu as well as submenu, When I run the test on its own it passes, but when run as a suite it fails and always click the L2 from the the menu instead of the sub menu. whats the best way to differentiate the two elements.
3. Also , is there a way to select the nth attribute eg . I can select the menu item with //menuitem[@name='L2'], I want to select the submenu by giving the nth attribute eg something like //menuitem[@name='L2][2], so that it clicks on 2nd element with the attribute i.e the submenu


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

Re: get the nth attribute

Post by odklizec » Tue Feb 12, 2019 8:34 am


Could you please answer below questions?
Ranorex version?
OS version?
Have you tried Ctrl+Win shortcut with both 32 and 64bit spy?
Have you tried to track the problematic menu on another PC?

Ctrl+Win shortcut is the only way how to track popup menus/elements. So if Spy crashes during instant tracking, it's really not good and I would suggest to investigate the source of this crash. Could you please examine, if there is a Spy/Ranorex-related crash log saved in Windows event viewer? Also, please examine Ranorex trace logs (as discussed here).

Unfortunately, without seeing Ranorex snapshot (NOT screenshot) of the problematic menu, it's hard to answer your questions. But generally speaking, yes, it's possible to use indexes to determine which of the found menu items should be selected. What you have used is basically correct. And of course, these indexes could be variabilized. But again, without snapshot, it's hard to provide more detailed answer. And as long as the Spy is crashing during instant tracking, the only other way how to create Snapshot might be from recording/code. In recording, there is a Create Snapshot action.
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