Diffrent Captions of Objects in multiple runs

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
tingelcore
Posts: 10
Joined: Thu Jul 27, 2017 11:04 am

Diffrent Captions of Objects in multiple runs

Post by tingelcore » Tue Oct 10, 2017 3:32 pm

Hi,

I have a problem recognising Objects in my SUT. After I proceed with my test at a point a new window pops up with a caption I don't know. These windows always are the same but with different captions. Normally I would handle it with variables in objects via a CSV-File but since I don't know how these windows are gonna be called I can't do that this time.

Is there a chance to recognise objects without the use of the caption?

edit for clarification: So basically either the name of the window become "Unknown" + name I typed in OR it becomes a complete new name I don't know.


Update: So actually there is a way for me to know it before, so I can set up a second column in my CSV-File. Only Problem now is the "Unknown" Issue. Is there an Option to give Ranorex 2 possible path's ? Like search 20 seconds for the first, if you can't find it use the second?

Greetings,
Björn

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

Re: Diffrent Captions of Objects in multiple runs

Post by krstcs » Tue Oct 10, 2017 4:36 pm

First, if you could post a Ranorex Snapshot (NOT a screenshot!) of the element in question it would help. It's hard to give you a good solution without knowing the structure of the UI.

Second, you can do a great many things with XPath and Regular Expressions (regex) that will allow you to get around issues like this. In RanoreXPath (Ranorex's version of XPath) you can make the path use regex to find multiple matching elements (just note that it will always return the FIRST one it finds!).

//div[@innertext='My Button'

could be:

//div[@innertext~'(My|Your) Button'

Now the element would find the button with the innertext value of either 'My Button' or 'Your Button'. You can even make it case insensitive by surrounding it with "(?i:<value>)".
Shortcuts usually aren't...

tingelcore
Posts: 10
Joined: Thu Jul 27, 2017 11:04 am

Re: Diffrent Captions of Objects in multiple runs

Post by tingelcore » Wed Oct 11, 2017 9:19 am

Hi,

thanks for your reply.

so your suggetion work with empty sides like

//div[@innertext~'(|xyz)Button'

would this work for "Button" as well as "xyzButton"?

The Snapshot-File is bigger than 1MB so I can't attach it. But your solution should work fine for me. Thank you for that.

e: Since I will have the list of names that it will "transform" into, I stay with the problem, that the name may stays the same but get an prefix of "Unknown". So it would be either "Unknown+$varName1" OR "$varName2". Im not sure if this would work.
//div[@innertext~'(Unknown $varName1|$varName2)' seems not right (can't test it right now without the names unfortunately).

Otherwise it will throw an error when the Unknown+name comes, this would be ok since most of the time when it throws unknown the test case failed anyway.



UPDATE: I feel kind of stupid right now, since the object is stored as a tab and is always the only tab I could modify the XPath to index=0 and it works.
Thanks for your help :D

Greetings

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

Re: Diffrent Captions of Objects in multiple runs

Post by krstcs » Wed Oct 11, 2017 1:46 pm

You're welcome! Glad you found a solution that works for you!
Shortcuts usually aren't...