Duplication of similar repository items

Ranorex Spy, Recorder, and Studio.
Pallak
Posts: 5
Joined: Thu Nov 02, 2017 4:34 pm

Duplication of similar repository items

Post by Pallak » Thu Nov 02, 2017 4:40 pm

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

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

Re: Duplication of similar repository items

Post by odklizec » Fri Nov 03, 2017 12:27 pm

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?
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

Pallak
Posts: 5
Joined: Thu Nov 02, 2017 4:34 pm

Re: Duplication of similar repository items

Post by Pallak » Fri Nov 03, 2017 3:02 pm

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.
Attachments
Repository.png
Repository.png (26.6 KiB) Viewed 608 times

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Duplication of similar repository items

Post by krstcs » Fri Nov 03, 2017 3:44 pm

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.
Shortcuts usually aren't...

Pallak
Posts: 5
Joined: Thu Nov 02, 2017 4:34 pm

Re: Duplication of similar repository items

Post by Pallak » Fri Nov 03, 2017 3:49 pm

Thank you so much for providing a solution. I will try to implement it this way. It will really help :)

Pallak
Posts: 5
Joined: Thu Nov 02, 2017 4:34 pm

Re: Duplication of similar repository items

Post by Pallak » Fri Nov 03, 2017 10:10 pm

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.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Duplication of similar repository items

Post by krstcs » Mon Nov 06, 2017 2:56 pm

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.
Shortcuts usually aren't...

Pallak
Posts: 5
Joined: Thu Nov 02, 2017 4:34 pm

Re: Duplication of similar repository items

Post by Pallak » Tue Nov 07, 2017 4:42 pm

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
Attachments
repoCode.png
This is the snapshot of code where how individual element is called in repository.
repoCode.png (18.92 KiB) Viewed 575 times

jma
Posts: 111
Joined: Fri Jul 03, 2015 9:18 am

Re: Duplication of similar repository items

Post by jma » Wed Nov 08, 2017 11:18 am

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