Fetch row/column count and iterate through each cell values

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
niranjantest
Posts: 10
Joined: Fri May 12, 2017 11:21 am

Fetch row/column count and iterate through each cell values

Post by niranjantest » Mon May 15, 2017 2:48 pm

hi,

I am trying to access a grid build on Infragistics2.Win.UltraWinGrid control type. My intention is to get the below action donw :

1- get the row count
2- get the column count
3- iterate each cell value one by one

Attached is the app snapshot and spy shot.

Ranorex version-5.4.5

Any help will really get appreciate.

regards,
nir
You do not have the required permissions to view the files attached to this post.

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

Re: Fetch row/column count and iterate through each cell values

Post by odklizec » Mon May 15, 2017 3:02 pm

Hi,

What you have posted is screenshot, not snapshot. Ranorex snapshot is an xml file, containing the GUI structure. Unfortunately, screenshot is useless here. Please learn how to create a snapshot from the link in my signature. Thanks.
Last edited by odklizec on Tue May 16, 2017 6:28 am, edited 1 time in total.
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

niranjantest
Posts: 10
Joined: Fri May 12, 2017 11:21 am

Re: Fetch row/column count and iterate through each cell values

Post by niranjantest » Tue May 16, 2017 6:23 am

Believe it or not I have tried to take the ranorex snapshot but Ranorex iteslf gets stuck and not able to save the same.

Let me try to take it today again..if success will able to share..

regards,
Nir

niranjantest
Posts: 10
Joined: Fri May 12, 2017 11:21 am

Re: Fetch row/column count and iterate through each cell values

Post by niranjantest » Fri May 19, 2017 12:37 pm

Unfortunately i cannot post the screenshot view due to company policy with the attachment restriction. I am able to fetch the row count successfully using the below code snippet but wondering how can i get the cells values of each rows.

var allegesTableRows = repo.FormWindow.AllegesTableRows;
int rowcnt=allegesTableRows.Rows.Count;

Any help will greatly be appreciable.

Thanks,
Nir
You do not have the required permissions to view the files attached to this post.

asdf
Posts: 174
Joined: Mon Mar 21, 2016 3:16 pm

Re: Fetch row/column count and iterate through each cell values

Post by asdf » Mon May 22, 2017 10:04 am

Hi Nir,

I would try to get the values with the following code snippet.

Code: Select all

string accName = repo.FormWindow.AllegesTableRows.Element.GetAttributeValueText("AccessibleName");
string accValue = repo.FormWindow.AllegesTableRows.Element.GetAttributeValueText("AccessibleValue");
I hope this helps.

Best regards,
asdf

niranjantest
Posts: 10
Joined: Fri May 12, 2017 11:21 am

Re: Fetch row/column count and iterate through each cell values

Post by niranjantest » Wed May 24, 2017 2:06 pm

Thanks for the reply,

I tried the provided solution but again its returning NULL value in both cases. Also, i am bit wondering how without cell/row iteration it will fetch the value as suggested by you.

But i tried some other way as per below code snippets:

var allegesTableRows = repo.FormWindow.AllegesTableRows;
//var allegesTableCols = repo.FormWindow.AllegesTableCols;

int rowcnt=allegesTableRows.Rows.Count;

int cellCount=allegesTableRows.Rows[0].Cells.Count;

for (int i = 0; i<=rowcnt; i++)
{
for (int j = 0; j<=cellCount; j++)
{
String strvalue = allegesTableRows.Rows.Cells[j].Text.ToString();
Console.WriteLine("Value:="+strvalue);
}
}


But, now issue here is that console is printing the each cell values in a very slow manner. Its took around min 3-5(max) sec for each cell value to get fetched and displayed. Not sure why this performance issue or what is the root cause for this delay to fetch cells value from the grid.

Regards,
Nir

Regards,
Nir

niranjantest
Posts: 10
Joined: Fri May 12, 2017 11:21 am

Re: Fetch row/column count and iterate through each cell values

Post by niranjantest » Wed May 24, 2017 2:47 pm

Atlast after much R&D i could able to found a solution which works great way without any delay issue for the previously USED FOR loop. Below is the code snippet:

foreach(Row row in repo.FormWindow.AllegesTableRows.Rows )
{
//row.Focus();

foreach (Cell cell in row.Cells)
{
//cell.Focus();
String ColValue=cell.Element.GetAttributeValueText("AccessibleName").Trim();
String CellValue=cell.Element.GetAttributeValueText("AccessibleValue").Trim();
Console.WriteLine("ColName:="+ColValue);
Console.WriteLine("CellValue:="+CellValue);
}

}

Hope this solution helps other for their infragistric grid to get automated using Ranorex7

regards,
Nir

niranjantest
Posts: 10
Joined: Fri May 12, 2017 11:21 am

Re: Fetch row/column count and iterate through each cell values

Post by niranjantest » Wed May 24, 2017 2:49 pm

Thanks to asfd buddy for helping to give me the idea to resolve this issue. Thank you very much!!