Identifying elements in a context menu

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
cpalex
Posts: 20
Joined: Sat Feb 17, 2018 12:37 am

Identifying elements in a context menu

Post by cpalex » Thu Jan 31, 2019 6:06 pm

I am struggling to uniquely identify items in a context menu.

I have the technique down to delay tracking, and can effectively look at all of the elements in my context menu. However, every item in the menu is simply 'MenuItem', and I cannot seem to find any uniquely identifiable attribute. Currently, Ranorex just uses 'contextmenu/menuitem[1]'

Here is a picture of the context menu:
ContextMenu.png
ContextMenu.png (5.67 KiB) Viewed 130 times
As you can see, each item in the context menu has a different text.

However, if you look at the elements in Spy, there are no references to the text in the context menu. See attached snapshot.

Is there something I am missing, or is there no way to uniquely identify the elements in this custom context menu, other than image-based?
Attachments
ContextMenu.rxsnp
(9.79 KiB) Downloaded 4 times

User avatar
mayo
Posts: 6
Joined: Fri Dec 28, 2018 7:42 pm

Re: Identifying elements in a context menu

Post by mayo » Thu Jan 31, 2019 9:02 pm

Greeting,

Looking at the provided snapshot it appears you are not getting very much to work with (likely due to poor/missing accessibility on the element). Due to this, you have three options:

Use the RXPath index -

/contextmenu[@processname='CMW']/contextmenu/menuitem[1]

/menuitem[2]

/menuitem[3]

Use the ChildIndex attribute -

/contextmenu[@processname='CMW']/contextmenu/menuitem[@ChildIndex='1']

[@ChildIndex='2']

[@ChildIndex='3']

Alternatively, you can always use image-based.

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

Re: Identifying elements in a context menu

Post by odklizec » Thu Jan 31, 2019 9:11 pm

Hi,

I would also suggest to try GDI capture approach (described in user guide), which often helps with extracting RAW texts from apps, with poorly or not implemented accessibility. It’s not perfect, but definitely better than unrealiable (from long-term perspective) image-based automation.
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

cpalex
Posts: 20
Joined: Sat Feb 17, 2018 12:37 am

Re: Identifying elements in a context menu

Post by cpalex » Fri Feb 01, 2019 5:34 am

I did look at GDI, but for some reason, it is not an option on this particular context menu.

After looking again, I was able to manually add the process name to the GDI capture list, and it does capture. GDI is not my favorite, but it's better than nothing