Page 1 of 1

Recorder picks wrong item from Repositery.

Posted: Thu Oct 01, 2015 5:14 pm
by stapes
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?

Re: Recorder picks wrong item from Repositery.

Posted: Fri Oct 02, 2015 8:07 am
by odklizec
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]

Re: Recorder picks wrong item from Repositery.

Posted: Fri Oct 02, 2015 10:09 am
by stapes
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!!

Re: Recorder picks wrong item from Repositery.

Posted: Fri Oct 02, 2015 11:33 am
by odklizec
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.