Get Cell data from table

Ask general questions here.
swainpabitra
Posts: 13
Joined: Thu Dec 04, 2014 5:21 pm

Get Cell data from table

Post by swainpabitra » Fri Apr 22, 2016 11:08 am

Hello Team,

I am working on Remote Desktop for a website application.
The website is made up with asp pages.

There is a table from which i have to fetch values from cells.
There are large number of Rows in that table.

The path is:
"table[4]/tbody/tr[2]//font[@innertext~'^w\.1527064\.500000506\.XXXA']"
"table[4]/tbody/tr[3]//font[@innertext~'^w\.1527066\.500000507\.XXXA']"
"table[4]/tbody/tr[4]//font[@innertext~'^w\.1527067\.500000508\.XXXA']"
...etc

I want the values of "innertext" which in residing inside "//font" tag.
I have worked with "Tr" then "Td" then collected data.
But in this case they have used "font[@....]".

So, how can i get those data those are available inside "font tag"?

I have tried following:

// Get the DownloadTable
Ranorex.TBodyTag downloadTable = repo.MedicaidKS.TopMenuArea.DownloadTable;
IList<Ranorex.TrTag> rows = downloadTable.FindChildren<Ranorex.TrTag>();

for (int i=1; i < rows.Count; i++)
{
//IList<Ranorex.FontTag> fnt = rows.FindChildren<Ranorex.FontTag>();

//IList<Ranorex.TdTag> cells = rows.FindChildren<Ranorex.TdTag>();
}

But in Both cases i got "NULL"..

So please guide me how to achieve this.

NOTE:: I am using Ranorex 5.4


Thank you,
Pabitra.
Last edited by swainpabitra on Fri Apr 22, 2016 12:18 pm, edited 1 time in total.

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

Re: Get Cell data from table

Post by odklizec » Fri Apr 22, 2016 11:41 am

Hi Pabitra,

Please specify, which subversion of Ranorex 5.4 you exactly using (5.4.1...5.4.6).
Additionally, please post a Ranorex Snapshot (not screenshot!) of the table in question. It would be much easier for us to help you with available snapshot.

If you cannot post a snapshot, create a sample table (e.g. using this online tool http://www.w3schools.com/tags/tag_table.asp) where we can see and test your table.
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

swainpabitra
Posts: 13
Joined: Thu Dec 04, 2014 5:21 pm

Re: Get Cell data from table

Post by swainpabitra » Mon Apr 25, 2016 9:05 am

I am using currently subversion: Ranorex 5.4.6
Browser: IE8

I am unable to create snapshot due large table, having 800 rows approx.
But i am attaching screenshot of repository taken from "Ranorex Spy".

Also I am working on Remote Desktop and then inside other Remote Desktop.(2nd level).


Thank you,
Pabitra.
Attachments
RanorexTable.png
Table screenshot
RanorexTable.png (16.96 KiB) Viewed 941 times

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

Re: Get Cell data from table

Post by odklizec » Mon Apr 25, 2016 9:29 am

Hi,

I'm sorry, but screenshot is not very useful. You see, I (and I believe anyone here) don't have a time to recreate HTML table and debug your code without snapshot/sample HTML ;)

You can reduce the size of snapshot by unchecking "complete ancestor tree" option in global configuration. Check this post:
http://www.ranorex.com/forum/how-to-cli ... tml#p31535

If the size of snapshot is still too big to be uploaded directly to the forum, you can use a public cloud service (like google drive, one drive, etc...) and simply share a download link. Eventually, create a sample HTML table, as suggested in my previous post.

BTW, are you sure there is installed Ranorex on the target (remote) machine? Because Ranorex cannot identify elements via remote desktop! Please check this user guide post about automating via Remote Desktop:
http://www.ranorex.com/support/user-gui ... norex.html
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

swainpabitra
Posts: 13
Joined: Thu Dec 04, 2014 5:21 pm

Re: Get Cell data from table

Post by swainpabitra » Mon Apr 25, 2016 2:16 pm

Yes, In remote machine Ranorex is installed and i am working over there.

<table>
<tbody>
<tr>TH'File Name' </tr>
<tr>TH'Type'</tr>
<tr>TH'Date Available'</tr>
<tr>TH'Date Downloaded'</tr>
<tr>TH'Original(ID)'</tr>
<tr>
<td> A 'http://www.google.com/common_id=12345'
<td>FONT'Claim Acknowledgement'
<td>FONT' 01-04-2016'
<td>FONT'01-01-1990'
<td>FONT'MyFile1234'
</tr>
<tr>
<td> A 'http://www.google.com/common_id=123451212'
<td> FONT'Claim Acknowledgement'
<td>FONT' 01-04-2016'
<td>FONT'01-01-1990'
<td>FONT'MyFile1234'
</tr>
<tr>
<td> A 'http://www.google.com/common_id=1234512'
<td> FONT'Claim Acknowledgement'
<td>FONT' 01-04-2016'
<td>FONT'01-01-1990'
<td>FONT'MyFile1234'
</tr>
</tbody>
</table>

hope this will help.

otherwise i will try reduce size as you mentioned in link.

Thank You,
Pabitra

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

Re: Get Cell data from table

Post by krstcs » Mon Apr 25, 2016 2:58 pm

Please include the snapshot.

Same as what Pavel said about screenshots, just posting a blob of HTML does not show the full context of the issue so we may not see everything correctly.
Shortcuts usually aren't...

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

Re: Get Cell data from table

Post by odklizec » Mon Apr 25, 2016 3:15 pm

OK, in the end, there is no need to upload the snapshot. The HTML code you posted is wrong, I guess you wanted to post something like this:

Code: Select all

<table>
<tbody>
<tr>
<TH>File Name
<TH>Type
<TH>Date Available
<TH>Date Downloaded
<TH>Original(ID)
</tr>
<tr>
<td><A>http://www.google.com/common_id=12345</A>
<td><FONT>Claim Acknowledgement</FONT>
<td><FONT>01-04-2016</FONT>
<td><FONT>01-01-1990</FONT>
<td><FONT>MyFile1234</FONT>
</tr>
<tr>
<td><A>http://www.google.com/common_id=123451212</A>
<td><FONT>Claim Acknowledgement</FONT>
<td><FONT>01-04-2016</FONT>
<td><FONT>01-01-1990</FONT>
<td><FONT>MyFile1234</FONT>
</tr>
<tr>
<td><A>http://www.google.com/common_id=1234512</A>
<td><FONT>Claim Acknowledgement</FONT>
<td><FONT>01-04-2016</FONT>
<td><FONT>01-01-1990</FONT>
<td><FONT>MyFile1234</FONT>
</tr>
</tbody>
</table>
Now the reason why your code returns null is that the "font" tag is not a child of TD tag, but TR tag! So instead of FindChildren, I would suggest to use FindDescendants or Find method...

Code: Select all

			// Get the DownloadTable
			Ranorex.TBodyTag downloadTable = repo.MedicaidKS.TopMenuArea.DownloadTable;
			IList<Ranorex.TrTag> rows = downloadTable.FindChildren<Ranorex.TrTag>();

			for (int i=1; i < rows.Count; i++)
			{
				IList<Ranorex.FontTag> fnt = rows[i].FindDescendants<Ranorex.FontTag>();
				// or this... IList<Ranorex.FontTag> fnt = rows[i].Find<Ranorex.FontTag>(".//font");
				for (int j=1; j < fnt.Count; j++)
				{
					string cellText = fnt[j].InnerText; //this returns InnerText of each found font tag element for given row
				}
			}
Hope this helps?
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

swainpabitra
Posts: 13
Joined: Thu Dec 04, 2014 5:21 pm

Re: Get Cell data from table

Post by swainpabitra » Tue Apr 26, 2016 6:27 am

Hello Pavel,

You are awesome!!

Finally got solution and its working good.

But apart from Solution I want to know one thing that,
As I am working for file upload/download task from some websites by using Ranorex Studio.
So, what would be success ratio by using automation system?

Because in sometimes i got issues regarding clicking links for download, clicking Button for upload (sometimes it reaches button location but not get clicked)etc..

It sometimes works and sometimes get fail.

Any suggestions are most welcome.

And Thanks again Pavel.


Thank you,
Pabitra

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

Re: Get Cell data from table

Post by odklizec » Tue Apr 26, 2016 9:31 am

Hi Pabitra,

You are welcome. I'm glad I could help ;)

As for your other problem, this is unfortunately a hard one. If you search this forum, you will find a lot of posts about missed/not performed clicks in case of HTML pages.

Some of them are caused by the fact that the elements are clicked at a time when they are already available (Ranorex found them), but the page/element is not completely loaded and therefore, not ready for the click action. Typically, the easiest solution is to add a short delay action (e.g. 100ms) before Click action. This is unfortunately least elegant solution, because it's not very convenient to manually add delay before each click action ;) You will just have to find the most problematic places in your tests and add delays here or there.

Another possibility is, that the element in question is out of the visible area of display. To solve this problem, try to add Invoke Action >> EnsureVisible() method for given element. Ranorex by default tries to make the element visible during the click operation. However, sometimes is better to add an additional EnsureVisible before click action.

Yet another reason of your problem could be caused by the fact the automation is run on virtual machine or via remote desktop. If you are experiencing problems with clicks on VM/RD, try to disable "Use Asynchronous dispatching of mouse and keyboard events" in Global Settings >> Advanced tab. Also, it may be helpful to increase mouse/keyboard event timings (Recording Defaults tab).

Also, if you are using Turbo Mode in some (or all) recordings, try to disable it in problematic recordings. However, I just experienced a problem with "missed" clicks with test running via RD on VM and what actually helped was "enabling" Turbo Mode in some particular recordings! :shock: Something I would definitely not expect. The truth is, that the tests I've designed on my physical machine runs blazingly fast on the VM. Something that I would not expect either ;)

As you can see, there are many possible reasons and solution. I probably missed some of them, so please search the forum for other reasons and possible solutions. Good luck! ;)
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

swainpabitra
Posts: 13
Joined: Thu Dec 04, 2014 5:21 pm

Re: Get Cell data from table

Post by swainpabitra » Wed Apr 27, 2016 8:32 am

Hello Pavel,

Thank you for your valuable solutions.

I will definitely try all solutions one by one. :wink:

Thank You,
Pabitra.