Page 1 of 1

Identifying elements in a context menu

Posted: Thu Jan 31, 2019 6:06 pm
by cpalex
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
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?

Re: Identifying elements in a context menu

Posted: Thu Jan 31, 2019 9:02 pm
by mayo
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.

Re: Identifying elements in a context menu

Posted: Thu Jan 31, 2019 9:11 pm
by odklizec
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.

Re: Identifying elements in a context menu

Posted: Fri Feb 01, 2019 5:34 am
by cpalex
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