Page 1 of 1

Repository: Find smallest

Posted: Wed Aug 19, 2020 10:27 am
by HansSchl
I'd like to create a RanorexPath expression that describes the element if a collection of items which has the smallest value in a specific attribute. For example, like this:

Code: Select all

.../table/row/cell[@name='id' and @value=min(.../table/row/cell[@name='id']/@value)]
Currently, I cannot even imagine how to do that with user code (is it possible that user code returns a RepoItemInfo?).

Re: Repository: Find smallest

Posted: Tue Aug 25, 2020 7:50 am
by odklizec
Hi,

I'm afraid, Ranorex xpath implementation does not support syntax like this. It would be easier to suggest something reliable, if you post a Ranorex snapshot (not screenshot) featuring the elements you want to compare. I personally would create a list of elements and then compare their values in a loop. And of course, you may need to convert strings to numbers, because all properties returned from repo elements are by default strings ;) But as mentioned, snapshot would tell us more.

Re: Repository: Find smallest

Posted: Tue Aug 25, 2020 8:29 am
by HansSchl
Hi,

sorry I cannot offer a screenshot because I haven't even started to create the test case. This is a sketch:
- AUT is a database client. It displays entries in a table which (for this test case) is not in a specific order.
- Database entries have a unique ID. The ID is displayed in a table column.
- The ID of a new entry is higher than any previously existing ID.
- The test run should create a new entry and then verify that the new entry has an ID that is greater than all previously existing IDs. It should also click the new entry because that opens a "properties" dialog for verification of further details.

Idea to implement the test run:
- Find highest existing ID, store value in a variable
- Create new entry
- Find highest existing ID, verify that it is greater than value in the variable
- Click the entry with the new highest ID

To find the row with a specific ID, I use a RanorexPath like" .../table/row/cell[@accessiblename<'ID' and @accessiblevalue='123']/.." But how to find the row with the highest ID? My first thought was to write user code that returns RepoItemInfo which I can store in a variable, but I read that we can only store strings in variables. So the second thought is user code that returns the row index of the "maximum" row as function value which I can store in a variable $maxIndex so that I can refer to the "maximum" row as ".../table/row[$maxIndex]".

As you can see from the various posts I created over the past few days, I am trying to find the "best way to do things", often with no specific use case in mind. I am a developer and my tester colleagues frequently ask me how to solve this and that with Ranorex, so I'm trying to create a grab bag of snippets which they can easily use. I am always open to alternative approaches if you think I see things too much from a programmer's perspective.

Hans