Recorder picks wrong item from Repositery.

Ask general questions here.
stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Recorder picks wrong item from Repositery.

Post by stapes » Thu Oct 01, 2015 5:14 pm

I recorded a Validation command to validate an error message from our Windows program. This is the message I am looking for: A profile with the specified name already exists. Please specify a unique profile name.

Ranorex has come back & put this into the same field as the one below, so it does not match.
Attribute 'Text' of element for item 'WindowsStaffAppTestingRepository.DocumotiveMobile.AddLoginProfilePopup.TextUsername' does not match the specified value (actual='https://testbed.365agile.com/documotive ... rvice.june', expected='A profile with the specified name already exists. Please specify a unique profile name.').
I have taken a snapshot.

How do I get it to look in the correct place?
Attachments
ValidateAlreadyExists20151001_170747_0_rxlog.rxsnp
Snapshot file
(35.44 KiB) Downloaded 48 times

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

Re: Recorder picks wrong item from Repositery.

Post by odklizec » Fri Oct 02, 2015 8:07 am

Hi,

Could you please post the xpath of the validated element?

My guess is that the xpath is not unique and the same xpath is applicable to multiple elements? Hence the validation picks first found element. Or due to the lack of unique attributes, there are used element indexes in the path, which are not persistent and so the found element (for given index) could be different with each run?

What you need to do is to add some additional attributes to the path, which would make the path unique. Unfortunately, your tested app seems not be automation friendly. There are many text elements, without unique attributes. This is something you should ask your developers to add. Ideally, each element should have it's unique name. But this is something we can only dream of ;)

I would suggest you to check also this article, which should provide you with some general ideas what to do in case of dynamically generated ids, which is applicable also in cases of too few or not unique ids.
http://www.ranorex.com/blog/automated-t ... ynamic-ids

You can use something like this:
/winapp[@packagename='DocumotiveLtd.DocumotiveMobile']//form[@AutomationID='AddLoginProfilePopup']/text[@text~'A profile with the']
Eventually, if you don't want to use the actual text you are going to validate, as an identification attribute, you can use something like this:
/winapp[@packagename='DocumotiveLtd.DocumotiveMobile']//form[@AutomationID='AddLoginProfilePopup']/text[@classname='TextBlock' and @controltype='Text'][2]
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

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: Recorder picks wrong item from Repositery.

Post by stapes » Fri Oct 02, 2015 10:09 am

It looks like you are right, odklizec.

It would appear that the form in question just has a table of Text elements.
When the error message appears, the whole lot moves down one.

I guess I will have to make a handler that loops through them looking for the expected text.

I will ask about getting the developers to make changes at the next opportunity.

This arrangement seems common to all the screens, and also to the buttons.

The buttons go from the rightmost bottom corner of the screen, which as far as I can see, is always the 3rd element.

So instead of using the Repository names for fields, I want to be able to refer to them directly as these kind of entries:
/winapp[@packagename='DocumotiveLtd.DocumotiveMobile']/form/text[2]
So I renamed the fields Text2, Text3, Text4 etc and suddenly it all made sense!!

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

Re: Recorder picks wrong item from Repositery.

Post by odklizec » Fri Oct 02, 2015 11:33 am

Hi,

Unfortunately, using indexes is the least stable option in a long run. You may soon find that the indexes tend to change rather frequently ;) I'm using indexes only when I run out of other options. And even then I'm trying to use some attributes, which would reduce the risk of failure due to not found or non-unique xpath.
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