Storing dynamically generated page tab as value

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
mos
Posts: 6
Joined: Wed Aug 27, 2014 12:11 pm
Location: Schweiz
Contact:

Storing dynamically generated page tab as value

Post by mos » Wed Aug 27, 2014 1:12 pm

Hello everyone

Our application, which is an ERP system, is opening tabs with dynamically generated names. For example when I open the stock lists in our software to add new articles it will generate a name for that tab page according to the new given article number which is automatically generated. Please have a look at File 1 as an example. So in this example I created an article which is now dispayed in the page tab called 'Artikelstamm-872120.g' 'Artikelstamm-' is static but the rest is the article number my new article was given. I would like to know a way so I am able to store the value within a variable to be able to identify the correct page tab later on, for example to close just that one tab but leave other tabs open. Or in other words, to be able to identify the correct page tab to do further actions on it. The problem is, whenever I add new articles to the software, I do not know the article number given beforehand so I need a way to get the value, store it so i can assign it to be able to identify the correct page tab later on. I hope this is possible somehow.

Unfortunately I am not familiar with coding and checking guides and FAQ did not provide me with the answer I was looking for. I am sorry if I have missed that page or did not understand how I could implement this in my test environment.

If you need more information or whatever, feel free to ask.

Thanks in advance for you help.
Attachments
prt_art_stm.png
File 1
prt_art_stm.png (7.33 KiB) Viewed 1073 times

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

Re: Storing dynamically generated page tab as value

Post by krstcs » Wed Aug 27, 2014 2:56 pm

Mos,

Welcome to the Ranorex community!

There are a couple of things that you could do, depending on how your software under test is designed:

1. Does the software use an algorithm to determine the name, or is it a random generator? If there is an algorithm, you could implement a mirror in your test's user-code.

2. Does the newest tab always open in the last position (i.e., always in the right-most position)? If so, you could search for the tab after it is created by assuming that the right most tab is the correct one (this is, however only a valid assumption if the software actually works that way).
Shortcuts usually aren't...

User avatar
testautomator
Posts: 67
Joined: Fri Oct 25, 2013 6:37 am
Location: Bangalore, India

Re: Storing dynamically generated page tab as value

Post by testautomator » Thu Aug 28, 2014 5:59 am

Also, you could compare the new one against the stored names of the all the previous tabs. If it dosent match then its a new one and it goes into the list. But this depends on the functionality.

Yes, the best one is checking it in the last position for any new tab, if that is true.

mos
Posts: 6
Joined: Wed Aug 27, 2014 12:11 pm
Location: Schweiz
Contact:

Re: Storing dynamically generated page tab as value

Post by mos » Thu Aug 28, 2014 8:09 am

Hello krstcs and testautomator

Thanks for your replies. Much appreciated.
krstcs wrote:1. Does the software use an algorithm to determine the name, or is it a random generator? If there is an algorithm, you could implement a mirror in your test's user-code.
The software has a way of generating new id's and therefore new article numbers but it is as simple as that. It just checks for the next free available number and takes it. You can also use a specific number if you want so it could be that you do not know in advance which number is free and therefore not used yet.
krstcs wrote:2. Does the newest tab always open in the last position (i.e., always in the right-most position)? If so, you could search for the tab after it is created by assuming that the right most tab is the correct one (this is, however only a valid assumption if the software actually works that way).
The newest tab will always open in the right-most position.

How could I search for that? Unfortunately, I do not know how I could do this.
testautomator wrote:Also, you could compare the new one against the stored names of the all the previous tabs. If it dosent match then its a new one and it goes into the list. But this depends on the functionality.
Same here. I do not know how I could compare new tabs against the already stored ones and determine which one is the new tab. I just starting using Ranorex and test automation tools all together even though I have learned quite a bit already.

Thanks again for your replies and your time. Hopefully you can shed some light in the dark :)

User avatar
testautomator
Posts: 67
Joined: Fri Oct 25, 2013 6:37 am
Location: Bangalore, India

Re: Storing dynamically generated page tab as value

Post by testautomator » Thu Aug 28, 2014 9:57 am

You are welcome,
Now how to find where the tab is, use spy. Maybe you should see some videos on how to modify the objects xpath and other introductory videos from Ranorex.

Also, you can use some kind of array to store the tab name and then compare new one against it. But I suggest go with the tab opened is the right most or left most. Look at the structure where the tab appears.

mos
Posts: 6
Joined: Wed Aug 27, 2014 12:11 pm
Location: Schweiz
Contact:

Re: Storing dynamically generated page tab as value

Post by mos » Thu Aug 28, 2014 11:37 am

I have watched the tutorial videos but unfortunately it did not help me in solving this specific problem or maybe I could not adapt it to my problem. If you have a look at the attachment included in this post, the new tabs will always be listed under TabPageList'PageTabList' as a new element but since I do not know the given name before hand, I cannot find it anymore as soon as I get a new article number. Hence my idea was to store 'Artikelstamm-872120.g' in a variable once the new article got assigned a new number and thus I could make a repository variable and look for that afterwards (something like @accessiblename='$ArtVar') but I do not know how I could get the value 'Artikelstamm-872120.g' and save it into @accessiblename='$ArtVar', if this is possible at all.
Attachments
spy_art_stm.png
File 2
spy_art_stm.png (45.38 KiB) Viewed 1046 times

User avatar
testautomator
Posts: 67
Joined: Fri Oct 25, 2013 6:37 am
Location: Bangalore, India

Re: Storing dynamically generated page tab as value

Post by testautomator » Thu Aug 28, 2014 11:49 am

You could use regular expression to find the article name if it always started with 'Artikels' or "Artikelstamm-":
I am using code here but you can modify the xpath in the repository too.
Tabpage tabTemp = "your xpath till the tabpagelist";
Tabpage newTab = tabTemp.FindSingle("Artikels.*");
// If you want the name for the tab
string strTabName = newTab.getattribute("accessiblename"); or newtab.text;

mos
Posts: 6
Joined: Wed Aug 27, 2014 12:11 pm
Location: Schweiz
Contact:

Re: Storing dynamically generated page tab as value

Post by mos » Thu Aug 28, 2014 3:30 pm

Hi testautomator

I have found another way to get around this, at least for now. Since I am no developer at all, it is not that easy for me to implement code but I can forward this to our developers and I am sure they can help me here :)

Thanks for your time and help, once again.

User avatar
testautomator
Posts: 67
Joined: Fri Oct 25, 2013 6:37 am
Location: Bangalore, India

Re: Storing dynamically generated page tab as value

Post by testautomator » Thu Aug 28, 2014 5:33 pm

Your welcome. Try changing the xpath of the object in repository itself. Try it :D