Table is not recognized after a refresh/update of page

Ranorex Spy, Recorder, and Studio.
fimo420
Posts: 55
Joined: Wed Jun 20, 2012 9:49 am

Table is not recognized after a refresh/update of page

Post by fimo420 » Mon Oct 21, 2013 8:47 am

Hi,

I have this big table with lots of columns and rows. When i mapp the table in repository from the ranorex spy it works. I mean i can highlight it in the spy and from the repository.
However, when i update that page, the whole table is regenerating which makes my repository item to stop working. I cannot highlight the item from repository or from spy, until i refresh the spy.

For ex:
.//td[#'P13adff7a8d43469e89844599c4233b02_6_oReportCell']/table//td/table/tbody/tr[5]/td[1] (first)
.//td[#'P13adff7a8d43469e89844599c4233b02_7_oReportCell']/table//td/table/tbody/tr[5]/td[1] (2nd)

As you see there is a tiny change.
/td[#'P13adff7a8d43469e89844599c4233b02_7_oReportCell']?
I can make that part to be not unique, but that will find many other tables/fields which i dont want to.

So anyone that have similar problems or know the solution please let me know.
Thanks guys.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Table is not recognized after a refresh/update of page

Post by Support Team » Wed Oct 23, 2013 6:14 am

Hi Fimo,

When the id of a web element is not unique you could use another attribute instead.
Are there any other unique attributes which can be used?
It may also be possible to use regex in this case (td[~'P13adff7a8d43469e89844599c4233b02'']).
In order to analyze this in detail may I ask you to post a Ranorex snapshot file of your webpage?

Regards,
Markus
.
Image

fimo420
Posts: 55
Joined: Wed Jun 20, 2012 9:49 am

Re: Table is not recognized after a refresh/update of page

Post by fimo420 » Wed Oct 23, 2013 9:19 am

Hi Marcus,

Thanks for reply.
I've tried to find another unique attribute, but cannot find any that i can use.
I've tried to make a snapshot file for the last 30mins, but it doesnt work.
The spy tool hangs and i thought it just takes long time, but even after 30m no luck.
Maybe its to heavy for ranorex spy?
I'm not sure exactly why it stops, it works fine with other webpages to create a snapshot.

Anything else i can try?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Table is not recognized after a refresh/update of page

Post by Support Team » Thu Oct 24, 2013 2:08 pm

Hello fimo420,

It should not take that long to make a snapshot even if the application has a lot of elements.
Which Ranorex version do you use?
Did you install all prerequisites of Ranorex?
Which technology do you use within in your application?
Do you get any warning or error message?

Did you try to use the regex expression suggested by my colleague?
Is it possible to uniquely identify your elements with it?

Thanks in advance.

Regards,
Markus (T)
.
Image

fimo420
Posts: 55
Joined: Wed Jun 20, 2012 9:49 am

Re: Table is not recognized after a refresh/update of page

Post by fimo420 » Thu Oct 24, 2013 2:23 pm

Hi Markus,

My ranorex version is latest, 4.1.1
Everything required to ranorex is installed, and works fine
There are no warnings or messages that i can see.
I mean i can take snapshots of my other applications/webpages.

And the page/tool that we are trying to mapp/work with is:
Microsoft SQL Server Report Manager, inside it we have a xml reporting page that have lots of tables.


I've tried the regexp, but ranorex doesnt accept it.
ex:
.//td[#'P13adff7a8d43469e89844599c4233b02_6_oReportCell']/table//td/table/tbody/tr[5]/td[1]
tried to put it like:
.//td[~'P13adff7a8d43469e89844599c4233b02']/table//td/table/tbody/tr[5]/td[1]
But ranorex doesnt let me save it.

Let me know if theres anything else you want from me.

I'm attaching a screenshot of the spy if that helps, since snapshot is not possible
Attachments
spy screenshot.png
spy screenshot.png (183.71 KiB) Viewed 1464 times

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

Re: Table is not recognized after a refresh/update of page

Post by krstcs » Fri Oct 25, 2013 2:00 pm

You must tell Ranorex what to compare the regex too.

td[@id~'P13adff7a8d43469e89844599c4233b02']/table//td/table/tbody/tr[5]/td[1]

Notice the "@id" - this tells the RanoreXPath to check the ID attribute of the element for the given pattern. You left that out in your example, which is an error, and why it won't save.

The "#" is shorthand for "id=" and is used when the ID is absolutely unique and can be hashed for quicker searches. It is almost always FASTER (for Ranorex at runtime) to find an element using "#", but sometimes you may not be able to do that because the "#" requires a perfect, exact match for the given ID.
Shortcuts usually aren't...

fimo420
Posts: 55
Joined: Wed Jun 20, 2012 9:49 am

Re: Table is not recognized after a refresh/update of page

Post by fimo420 » Tue Oct 29, 2013 10:46 am

Hi krstcs,

Thanks, i forgot that:
I did try the way you suggested :.//div[@id~'.*']/table/tbody/tr[5]/td[1]/table/tbody
Since the div id is unique everytime it regenerates :(
But it takes long time, over 1m...

I tried to regenerate the path without the "enable search by unique" setting, so that i get full path.
The path become very long but i added a regexp for all unique id's and it goes much faster and works for the moment :)
"
?/?/form[@id='ui_form']/span[1]/table/tbody/tr[2]/td/table//span/table//span[@id='ctl32_ReportViewer']/div[@id='ctl32']/table[@id='ctl32_fixedTable']//div[@id='ctl32_ctl09']/div[@id='VisibleReportContentctl32_ctl09']/div[@id~'.*']/table//td[@id~'.*']/div[@id~'.*']/table/tbody/tr[5]/?/?/table/tbody"

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

Re: Table is not recognized after a refresh/update of page

Post by krstcs » Wed Oct 30, 2013 1:40 pm

I would suggest that using ".*" as your regex comparison is not a good idea as it will find EVERYTHING.

From what you had posted earlier, your ids only change by a little bit each time. You could still use the first segment of characters and it would go faster.

td[@id~'P13adff7a8d43469e89844599c4233b02'] (only finds the td elements at this level that have the given match string in them)

instead of

td[@id~'.*'] (finds every td element at that level)

If your div id is Dynamic (it changes every time you run the app) then you may need to find a different attribute to key off of. Or, you should talk to your developers about what they might be able to do to make each element unique.
Shortcuts usually aren't...

fimo420
Posts: 55
Joined: Wed Jun 20, 2012 9:49 am

Re: Table is not recognized after a refresh/update of page

Post by fimo420 » Thu Oct 31, 2013 9:31 am

Yeh you're right about the ".*", but thats the only way i can use it now. The whole id is dynamic after you refresh the page by closing and restarting browser.
This specific page is generated from "Microsoft SQL Server Report Manager", so i cannot talk to Microsoft guys about this :)
So, its out of my hand, but hey it still works as of now with .* even if its a bit heavy and takes 30s more.

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

Re: Table is not recognized after a refresh/update of page

Post by krstcs » Thu Oct 31, 2013 1:36 pm

That's unfortunate, but I understand.

Microsoft is one of the worst offenders when it comes to correctly implementing their own automation framework.

Glad it is working for you.


One thing you might do is looking for a pattern in the id. Do they always start with a letter? Do that always have hexadecimal characters after that? Etc. You can then create a more precise, but still generic pattern match that should still be better than ".*". But you probably thought of that. :D
Shortcuts usually aren't...