Strip characters on a match

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Posts: 47
Joined: Wed Mar 18, 2015 10:06 pm

Strip characters on a match

Post by jackrabbit » Fri May 15, 2015 1:20 am

I need to find an object using a text value from a menu. The problem I have is that the menu labels sometimes contains the AMPERSAND character. My problem is that the menu system no longer underlines the letter from the menu item.

In other words, if the menu item shows the option "Print", the text attribute that I need to look for may me "Print", "&Print", "P&rint", "Pr&int", "Pri&nt" ou "Prin&t", there is no way for me to guess which because the UNDERLINE is no longer visible with my screen interface.

Of course, I could go into the program source code, and examine the actual text, but this is not possible for me.

Right now, the only way that I can match my menu item is with the following RxPath:
menuitem[@text='Print' or @text='&Print' or @text='P&rint' or @text='Pr&int' or @text='Pri&nt' or @text='Prin&t']

Of course I could also use:

I wish I could trim the AMPERSAND from the text string before doing a match:

Is there another way to match a string containing a specific character in any location?

Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Strip characters on a match

Post by krstcs » Fri May 15, 2015 2:35 pm

Unfortunately, the first two ways you discussed are really the best ways to do it if you don't know exactly what version you are looking for.

The other thing you might do is see if there is another attribute of the menu item that could be used instead of @text, preferably one that doesn't have any special/dynamic characters.
Shortcuts usually aren't...