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
Diffrent Captions of Objects in multiple runs
-
- Posts: 10
- Joined: Thu Jul 27, 2017 11:04 am
Re: Diffrent Captions of Objects in multiple runs
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>)".
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...
-
- Posts: 10
- Joined: Thu Jul 27, 2017 11:04 am
Re: Diffrent Captions of Objects in multiple runs
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
Greetings
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
Greetings
Re: Diffrent Captions of Objects in multiple runs
You're welcome! Glad you found a solution that works for you!
Shortcuts usually aren't...