Ranorex must not use to-be-validated property in RxPath

Bug reports.
bkruse
Posts: 38
Joined: Tue Jul 20, 2010 12:19 pm

Ranorex must not use to-be-validated property in RxPath

Post by bkruse » Tue Aug 24, 2010 8:53 am

Hi all,

imho, Ranorex must not use the to-be-validated Property as any part of the RxPath.

If the to-be-validated property is part of the RxPath (that is part of the recognition properties) and we encounter the case where this to-be-validated property is wrong, then Ranorex will fail finding the element instead of reporting a validation issue.

To clearify using an example, I have a standard use case:
Open the about dialog and verify some data in it, especially in a table.

Lets assume two columns in the table and the example row contains:
|Operating System|Windows 7 Business|

While recording I choose Validate Mode and click on the desired table cell (the right one which contains "Windows 7 Business") and in Ranorex Validation Dialog I selected the text property.

Back in Ranorex, I see that the recorded validation row uses the Repository Item "CellWindows_7_Business_" which has RxPath "row[@index='2']/cell[@text='Windows 7 Business ']".
So my question is - if the text value is wrong, for example contains "Ubuntu>Windows :)" - how can Ranorex report a Validation Error? Playback will fail because it cannot find the cell, which is identified by the text value (which is not met, because it is wrong).

regards,
Björn Kruse
Attachments
aboutDialog.zip
Snapshot of the About dialog.
(271.84 KiB) Downloaded 193 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex must not use to-be-validated property in RxPath

Post by Support Team » Tue Aug 24, 2010 2:08 pm

bkruse wrote:So my question is - if the text value is wrong, for example contains "Ubuntu>Windows " - how can Ranorex report a Validation Error?
If the Validate.Attribute(RepoItemInfo) cannot find the element, the validation fails similarly to when the attribute value does not match: a ValidationException is thrown (or false is returned if the validation is configured not to throw exceptions, respectively). The only difference is that the validation message is different.
Please, make sure that you pass the "*Info" repository property or an RxPath to the Validate.Attribute method. Don't pass the actual item (e.g. for the repository item "Button" use "repo.App.ButtonInfo" instead of "repo.App.Button"; the generated recording code should do that automatically), because then an ElementNotFoundException will be thrown, since the item is actually searched before it is passed to the validation method.
bkruse wrote:Playback will fail because it cannot find the cell, which is identified by the text value (which is not met, because it is wrong).
If you use the Validate.Attribute or Exists methods passing a RepoItemInfo or RxPath (see explanation above), playback will fail with a ValidationException and IMHO this is exactly what should happen. I don't see much difference in "the element cannot be found because the attribute value is not correct" and "the element can be found but the attribute value is not correct" as long as the same type of exception is raised :)

Regards,
Alex
Ranorex Team
.
Image

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Ranorex must not use to-be-validated property in RxPath

Post by Ciege » Tue Aug 24, 2010 3:16 pm

If I may be so bold to add to Alex's response...
While recording I choose Validate Mode and click on the desired table cell (the right one which contains "Windows 7 Business") and in Ranorex Validation Dialog I selected the text property.
Record and playback is just one method of using Ranorex or any most automation tool. As Alex said there are ways to catch the validation error if it exists and continue testing as needed. However, when using record and playback you are not using the true power of an automation tool. You can change most anything in code to fit your needs. Expanding your own abilities beyond record and playback will pay huge dividends down the road since you will be able to tailor your tests most any way you want to.
The true power of test automation lies beyond the record and playback so called "silver bullet".
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

bkruse
Posts: 38
Joined: Tue Jul 20, 2010 12:19 pm

Re: Ranorex must not use to-be-validated property in RxPath

Post by bkruse » Tue Aug 24, 2010 3:33 pm

Actually I tried only with Record/Playback, not with programming; but that will come so thanks for the detailed answer in advance :)

For my table cell, it reports
"2010/08/24 16:22:42.464 ERROR Replay Item 'FormProgrammerStandard.Cell5__2__222__1535' was not found within the specified timeout of 10s."
which is kind of different from
"2010/08/24 16:09:45.872 FAILURE Validation Attribute 'Text' of element for item 'FormAbout.Table20000.CellSoftwareVersionValue' does not match the specified value (actual='5. 2. 222. 1535', expected='5.2.222.1535')."
(In the second case, I manually use columnindex and rowindex to detect the correct cell.)

One is an error, one is a failure.



Generally said, I just see:
Ranorex takes @text as single identification attribute for the table cell (at least in my case).
Thus it will not be able to find that cell if the text doesn't match/is wrong.
Thus it cannot (by definition) detect and report a validation failure.

Ok, its more a high-level, conceptual issue; I don't know if you all agree with my point of view :)

regards,
Björn

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Ranorex must not use to-be-validated property in RxPath

Post by Ciege » Tue Aug 24, 2010 3:45 pm

I see what you are saying and I agree one gives you more information than the other. But remember, they cant make record and playback do everything. It is a simple means to an end. To get what you want is to do a little coding, which is just what you did to change the recognition string from the text property to the row/column.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex must not use to-be-validated property in RxPath

Post by Support Team » Tue Aug 24, 2010 3:52 pm

Ciege wrote:But remember, they cant make record and playback do everything.
Actually, in this case you can do that using record and replay, the recorder should automatically generate the correct code using the repository item info objects :)
bkruse wrote:For my table cell, it reports
"2010/08/24 16:22:42.464 ERROR Replay Item 'FormProgrammerStandard.Cell5__2__222__1535' was not found within the specified timeout of 10s."
As I wrote in my previous posting, Ranorex will not report that message but a standard validation error if you pass the "Info" object of the corresponding repository item or an RxPath to the validation method.
bkruse wrote:Ranorex takes @text as single identification attribute for the table cell (at least in my case).
Thus it will not be able to find that cell if the text doesn't match/is wrong.
Thus it cannot (by definition) detect and report a validation failure.
You are right if you first search for the element and then pass the element to the Validate.Attribute method. That way Ranorex will throw an ElementNotFoundException if the element is not found. However, as I wrote in my last post, when you pass a RepoItemInfo object or RxPath to the Validate.Attribute method, Ranorex will throw a ValidationException (with an InnerException of type ElementNotFoundException) - similarly to when the attribute values would not match.

Regards,
Alex
Ranorex Team
.
Image

bkruse
Posts: 38
Joined: Tue Jul 20, 2010 12:19 pm

Re: Ranorex must not use to-be-validated property in RxPath

Post by bkruse » Tue Aug 24, 2010 4:43 pm

@Ciege: Don't be afraid, I know the world behing "record & playback" :wink:

Back to topic:
To get what you want is to do a little coding, which is just what you did to change the recognition string from the text property to the row/column.
Exactly, but it's also easy to detect by comparing the validation task with the repository item.
But from re-thinking about it, I agree that it is probably less serious and more complex to solve (if adequate).

I already observed the generated code and it IS using the "Info" object (by default, so that's ok). I overlooked the fact that if running the project, then (as Alex formulated well)
Ranorex will throw a ValidationException (with an InnerException of type ElementNotFoundException) - similarly to when the attribute values would not match.
Only in case I use the playback button (on the default recorded testcase), it is not reporting the ValidationException. This was my initial concern and I probably got ahead of myself :roll:

Thanks for your input, guys!
regards, Björn

mzperix
Posts: 137
Joined: Fri Apr 06, 2012 12:19 pm

Re: Ranorex must not use to-be-validated property in RxPath

Post by mzperix » Thu Jun 06, 2013 1:45 pm

Going back to your initial question: I encountered too with this kind of behaviour. And our usual solution to edit the ranorexpath to be still be able to find the right element, but not by it's text attribute. in your example:
instead of

Code: Select all

row[@index='2']/cell[@text='Windows 7 Business ']
you can use

Code: Select all

row[@index='2']/cell[index_of_cell]
Indexing in rxpath starts with 1.
This way the validation will show the correct result. If the cell is there on the srceen even with different text inside it, ranorex will find by the rxpath. The downside of this is that you can edit only one-by-one these items, which can be a burden if you have to update many element.

Other than coding, you can tell ranorex to use other attribute to indentify when using the record-playback method: http://www.ranorex.com/blog/automated-t ... ynamic-ids