Accessing all inner text or cells for large HTML table

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
regex
Posts: 48
Joined: Tue Aug 14, 2012 5:47 pm

Accessing all inner text or cells for large HTML table

Post by regex » Mon Sep 10, 2012 4:37 pm

Code: Select all

var grid = Path.ToElement.Grid;  
			IList<Ranorex.DivTag> myList = grid.FindDescendants<Ranorex.DivTag>();  
			foreach(Ranorex.DivTag tag in myList )  
			{  
   			  Report.Info(tag.GetInnerHtml());  
			}
I want to assess this table. I want to identify the individual cells, convert to int, and manipulate them via the GUI. I can do this with individual cells but how do I pull them out from this list? The attached image has the debugging image of indexes. Thanks.
You do not have the required permissions to view the files attached to this post.

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Accessing all inner text or cells for large HTML table

Post by Ciege » Mon Sep 10, 2012 5:04 pm

Just do what you need to do within the foreach... If you already know how to do it with a single cell (as you have mentioned) this should be quite simple for you to add to the foreach...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

regex
Posts: 48
Joined: Tue Aug 14, 2012 5:47 pm

Re: Accessing all inner text or cells for large HTML table

Post by regex » Mon Sep 10, 2012 5:32 pm

Thanks for the reply. I'm a little brain blocked right now. Equivalent to writer's block? What's a method for pulling out those indexes from within that list?

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Accessing all inner text or cells for large HTML table

Post by Ciege » Mon Sep 10, 2012 5:45 pm

Well, you have the tag in your foreach already... Now you want to get the innertext of the tag. Use RanorexSpy to look at a tag and see the properties of the element. Then get the property you want and assign it to a variable so that you can convert it to an int.

Or am I totally missing your question?
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

regex
Posts: 48
Joined: Tue Aug 14, 2012 5:47 pm

Re: Accessing all inner text or cells for large HTML table

Post by regex » Mon Sep 10, 2012 5:59 pm

Yes, I could do that. That's how my current code base is setup.

I want to find the method to get the exact index of the element instead of calling the path. This reduces the cost by reducing calls to the repository by just taking the List element. I don't know the method for getting the list elements from within that for each.

Ideally, I'm going to have the GUI setup, so the manual user can just enter the index number, and the numbers are counted.

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Accessing all inner text or cells for large HTML table

Post by Ciege » Mon Sep 10, 2012 6:10 pm

By index do you mean the position of the tag in your iList?

Since you already have the iList of you your tags you do not need to make any call to your repository... You already have the element. In your code snippet, myList is a list of DivTag elements. tag is DivTag element. So you already have the element.

You report.info code proves this by displaying the tag innerHTML to the log. Rather than displaying it to the log you can handle each tag element as you would want to.

So, if I understand you correctly, that you consider the index as the position of the tag element in the iList, you can either take the index number that is provided by the user and count that many in your foreach, or you can just get a specific item from your list (do a google search on getting an item from an iList in c#).
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

regex
Posts: 48
Joined: Tue Aug 14, 2012 5:47 pm

Re: Accessing all inner text or cells for large HTML table

Post by regex » Tue Sep 11, 2012 10:40 pm

Ciege,

Thanks again. Yes - just need to grab from the iList in C#. I'll do a search on that but thought you might have a quick piece of code you could show me.

Thanks.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Accessing all inner text or cells for large HTML table

Post by Support Team » Thu Sep 13, 2012 2:09 pm

Hi,

Did you already solve the issue?
Here is a link to the API of such a DivTag, there you can see which attributes/methods are supported: DivTag.

Regards,
Markus
Ranorex Support Team