Duplication of similar repository items
Duplication of similar repository items
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
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
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?
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 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
Re: Duplication of similar repository items
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 (26.6 KiB) Viewed 1847 times
Re: Duplication of similar repository items
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:
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:
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.
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']
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
Shortcuts usually aren't...
Re: Duplication of similar repository items
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
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.
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
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.
Please see my post above about what to include when raising issues on the forums here.
Shortcuts usually aren't...
Re: Duplication of similar repository items
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
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
-
- This is the snapshot of code where how individual element is called in repository.
- repoCode.png (18.92 KiB) Viewed 1814 times
Re: Duplication of similar repository items
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".
More information about repository variables can be found under the following link: https://www.ranorex.com/help/latest/les ... Repository
Code: Select all
TestRepository repo = TestRepository.Instance;
repo.MyIndex=2;