Page 1 of 1

Duplication of similar repository items

Posted: Thu Nov 02, 2017 4:40 pm
by Pallak
Hello,

I have observed may times that similar kind of objects with same automation id needs to be added and used multiple times in repository and code.
For Eg: If I have to use multiple ellipse, I have to create two folders with Ellipse 1 and Ellipse 2 each containing similar items of area , circumference and units with same automation id. Just the index value differs. is it a better way to utilize such elements both in code and repository more effectively without adding 1,2,3 versions of similar type of elements.
Hope, I am able to explain my problem. Kindly let me know if there is a good/alternative solution to this issue.
Thanks
Pallak

Re: Duplication of similar repository items

Posted: Fri Nov 03, 2017 12:27 pm
by odklizec
Hi,

I'm afraid, I don't understand why do you need to create duplicates of existing repo items? Could you please show us your repository and better explain, why you cannot use just one repo item for all modules? Myabe some pictures would help?

Re: Duplication of similar repository items

Posted: Fri Nov 03, 2017 3:02 pm
by Pallak
If you check the screenshot, the automation id is same for values inside Distance 1 and Distance 2. So, if I need 10 such elements to be used, is there any other alternative to use them in both code and repository without creating 10 folders for Distance with 10 items representing Number, Values and Units inside distance.Here, the difference in just in Index, rest other items are similar.

Re: Duplication of similar repository items

Posted: Fri Nov 03, 2017 3:44 pm
by krstcs
First, please ALWAYS include the following information when raising an issue as without it it is very difficult to help in a meaningful way:
1. FULL Ranorex version (currently 7.1.3 and 7.2.0 are supported).
2. Windows version
3. Technology of system under test (html, WPF, Java, etc.)
4. Ranorex SNAPSHOT (NOT SCREENSHOT) of element(s) in question

You only need one Rooted Folder with a variablized index. It would look like this:

Code: Select all

Distance -> //list[@automationid='MeasureBox']/listitem[@name='Mobisante.New.ImabeMarkupAndCalculations.ConnectingLine' and @index=$MyIndex]
-- txtDistanceNumber -> text[@automationid='lenText']
-- txtDistanceValue -> text[@automationid='lenValue']
-- txtDistanceUnits -> text[@automationid='lenUnits']
This allows you to just pass in the index of the row you need at runtime.

Also, if you have a particular column in the list/table/row that uniquely identifies the row/listitem (such as the txtDistanceNumber text element), you could use something like the following for the Distance rooted folder's path:

Code: Select all

Distance -> //list[@automationid='MeasureBox']/listitem[@name='Mobisante.New.ImabeMarkupAndCalculations.ConnectingLine']/text[@automationid='lenText' and @value=$MyValue]/parent::listitem
This will find the text element with the 'lenText' automation id and a value attribute equal to the variable MyValue. It will return the parent listitem of that text element. You can use this in interesting ways to make sure you don't use indexes which are prone to problems when elements change position.

Re: Duplication of similar repository items

Posted: Fri Nov 03, 2017 3:49 pm
by Pallak
Thank you so much for providing a solution. I will try to implement it this way. It will really help :)

Re: Duplication of similar repository items

Posted: Fri Nov 03, 2017 10:10 pm
by Pallak
Could you provide some examples of how this is can be used at run-time.
As per my current implementation, I am using repository instance and identifying elements using their absolute path and directly accessing elements.
For eg:
var repo = Repository.Instance;
RxPath Distance1= repo.DistanceNumberInfo.AbsolutePath;

Kindly help me understand, how to fit the below concept explained by you here to get the 2nd distance no or access this using Index.
This would really help to structure my entire repository.

Thank you.

Re: Duplication of similar repository items

Posted: Mon Nov 06, 2017 2:56 pm
by krstcs
I'm afraid that I wouldn't be able to give you anything meaningful without seeing a Ranorex SNAPSHOT of the elements in question. A screenshot is pretty much worthless in this situation. Without a snapshot I have no real idea what the structure of your app is and can't really help.

Please see my post above about what to include when raising issues on the forums here.

Re: Duplication of similar repository items

Posted: Tue Nov 07, 2017 4:42 pm
by Pallak
1. FULL Ranorex version -7.1.1
2. Windows version - Windows 10
3. Technology of system under test - WPF, C#
4. Ranorex SNAPSHOT (NOT SCREENSHOT) of element(s) in question

Need to identify a way of using index to call elements of below type in code.

Thank you.
Pallak

Re: Duplication of similar repository items

Posted: Wed Nov 08, 2017 11:18 am
by jma
If you use the above-mentioned solution of one Rooted Folder with a variablized index, you can easily change the repository variable during runtime. In the sample below, the variable is called "MyIndex".

Code: Select all

        TestRepository repo = TestRepository.Instance;
        repo.MyIndex=2;
More information about repository variables can be found under the following link: https://www.ranorex.com/help/latest/les ... Repository