How to select each element in the column 2 of the table

Ranorex Spy, Recorder, and Studio.
sjana12
Posts: 2
Joined: Thu Dec 15, 2016 6:44 pm

How to select each element in the column 2 of the table

Post by sjana12 » Tue Dec 27, 2016 10:29 pm

Hi,

I am new to Ranorex . Can you please send me the code for this?

My application has a table which consists of 4 columns. Table has many number of rows, but I need to select 75 cells (elements) in the second column and need to validate that it gets selected.

Div/Table/Tbody/TR
Each Trtag has Td[1], Td[2], Td[3] and Td[4]

Table name = stripList (divtag)
Column 1 = Td/Imgtag
Column 2 = Td/divtag
Column 3 = Tdtag
column 4 = Tdtag


Table = /dom[@domain]//iframe[#'content_iframe']//div[#'strip_list']

Column 2 = /dom[@domain]/iframe[#'content_iframe']//div[#'strip_list']/table/tbody/tr[2]/td[2]//div[#'090a3be56efaa9b2123669759a0eb200']

Thanks
SJan

User avatar
N612
Posts: 62
Joined: Mon Jul 11, 2016 4:01 pm

Re: How to select each element in the column 2 of the table

Post by N612 » Wed Dec 28, 2016 8:15 pm

Hello,

Can you please provide a snapshot of your application's table? It makes it much easier to work with and can allow us to provide you more accurate information.

http://www.ranorex.com/support/user-gui ... files.html

If you have a repository element which returns many elements (ie: one repository element = 75 cells in a column), you can use the below loop in a code module to loop through each element.

Code: Select all

var repoAllCells = repo.dom.table.cellInfo; //Access Info object by appending 'Info'

IList<TdTag> allCells = repoAllCells.CreateAdapters<TdTag>(); //Create a list
foreach (TdTag cell in allCells) //Loop through list
	Report.Info(cell.InnerText.ToString()); //Do stuff with specific element
As always, there are many ways to achieve this. It really depends on your configuration, environment and needs.

I hope this helps!

sjana12
Posts: 2
Joined: Thu Dec 15, 2016 6:44 pm

Re: How to select each element in the column 2 of the table

Post by sjana12 » Fri Dec 30, 2016 9:50 pm

Thank you.
I tried the other way and it worked. Second column elements consists of Div tags and these are the only Divtags in the table. So, I directly found the Divtags and used the For loop to loop through each row element (in the second column)to select specific 75 elements from the list.