Problem while accessing the second row in datagrid.

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
sagargurao
Posts: 10
Joined: Mon May 16, 2016 7:49 am

Problem while accessing the second row in datagrid.

Post by sagargurao » Thu May 19, 2016 11:10 am

I am trying to access a DataGridRow in a web application that is built in Silverlight using for loop.
The problem is, Ranorex identifies the cells while interacting with the first row. However, it is not able to identify the second row (or further rows).
These rows are identifiable using Spy, however, they seem to be invisible while accessing through ranorex code.

Following is the code I am using to access the rows.

for(int count=0;count<ArrVarPreproColLayoutDetails.Length;count++)
{
ColLayourDetailSpecs=ArrVarPreproColLayoutDetails[count].Split(new char[]{','});
string strRow=".//object[#'AppSilverlightControl']/form[@name='Silverlight Control']/form[@classname='Popup']//tabpage[@name='Default Configuration']/table[@automationid='dgColumnsConfig']/element/element["+count+1+"]";
Element Row=strRow;
Row.Focus();

string strCaption=".//object[#'AppSilverlightControl']/form[@name='Silverlight Control']/form[@classname='Popup']//tabpage[@name='Default Configuration']/table[@automationid='dgColumnsConfig']/element/element["+count+1+"]/element[1]";
Element Caption=strCaption;
Mouse.MoveTo(Caption);
Mouse.DoubleClick();
Thread.Sleep(1000);
Mouse.DoubleClick();
Keyboard.Press(ColLayourDetailSpecs[0].ToString());

string strType=".//object[#'AppSilverlightControl']/form[@name='Silverlight Control']/form[@classname='Popup']//tabpage[@name='Default Configuration']/table[@automationid='dgColumnsConfig']/element/element["+count+1+"]/element[2]";
Element Type=strType;
Mouse.MoveTo(Type);
Mouse.Click();
Keyboard.Press(ColLayourDetailSpecs[1].ToString());
Keyboard.Press("{Return}");

string strPosition=".//object[#'AppSilverlightControl']/form[@name='Silverlight Control']/form[@classname='Popup']//tabpage[@name='Default Configuration']/table[@automationid='dgColumnsConfig']/element/element["+count+1+"]/element[3]";
Element Position=strPosition;
Mouse.MoveTo(Position);
Mouse.Click();
Keyboard.Press(ColLayourDetailSpecs[2].ToString());
Keyboard.Press("{Return}");

string strDataSource=".//object[#'AppSilverlightControl']/form[@name='Silverlight Control']/form[@classname='Popup']//tabpage[@name='Default Configuration']/table[@automationid='dgColumnsConfig']/element/element["+count+1+"]/element[4]";
Element DataSource=strDataSource;
Mouse.MoveTo(DataSource);
Mouse.Click();
Keyboard.Press(ColLayourDetailSpecs[3].ToString());
Keyboard.Press("{Return}");

string strExcelColRef=".//object[#'AppSilverlightControl']/form[@name='Silverlight Control']/form[@classname='Popup']//tabpage[@name='Default Configuration']/table[@automationid='dgColumnsConfig']/element/element["+count+1+"]/element[5]";
Element ExcelColRef=strExcelColRef;
Mouse.MoveTo(ExcelColRef);
Mouse.DoubleClick();
Thread.Sleep(1000);
Mouse.DoubleClick();
Keyboard.Press(ColLayourDetailSpecs[4].ToString());

if(count<=ArrVarPreproColLayoutDetails.Length-1)
{
repo.ReportingProcessManager.Popup.BtnAddNewRow.Click();
Thread.Sleep(10000);
}
ColLayourDetailSpecs=null;
}

We are using Ranorex version 4.1.1.15872.
Attachments
PreProcessorDataGridRow.rxsnp
DataGridRow snapshot.
(164.28 KiB) Downloaded 41 times

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

Re: Problem while accessing the second row in datagrid.

Post by odklizec » Thu May 19, 2016 11:34 am

Hi,

In my opinion the problem you are facing lies in this line (bold part of code)
string strRow=".//object[#'AppSilverlightControl']/form[@name='Silverlight Control']/form[@classname='Popup']//tabpage[@name='Default Configuration']/table[@automationid='dgColumnsConfig']/element/element["+count+1+"]";
If you are hoping to increment element index, then you need to do this before the 'string' line and not in the way you did it. The result of your code will be [01], [11], [21]

So should use this code instead:

Code: Select all

count = count +1;
string strRow=".//object[#'AppSilverlightControl']/form[@name='Silverlight Control']/form[@classname='Popup']//tabpage[@name='Default Configuration']/table[@automationid='dgColumnsConfig']/element/element["+count+"]";
Last edited by odklizec on Thu May 19, 2016 12:37 pm, edited 2 times 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

sagargurao
Posts: 10
Joined: Mon May 16, 2016 7:49 am

Re: Problem while accessing the second row in datagrid.

Post by sagargurao » Thu May 19, 2016 12:29 pm

Ahh....now I know what will be causing the problem.

I tried to implement the logic as described by you and it worked.

Thanks again...appreciate your time and efforts. :)

nkarora
Posts: 12
Joined: Mon Dec 05, 2016 12:54 am

Re: Problem while accessing the second row in datagrid.

Post by nkarora » Fri Dec 16, 2016 5:51 am

Hi,
I have similar problem but able to see record if underlying tag is not used.

Here is the part of Code having problem.

IList<TableTag> actdir1Tables=Repo.Sitetrak.P2P_SelectSitesForm.P2pPreview.Direction1TR.NetworkTableDirection1.TableRow.FindDescendants<TableTag>();
Int32 tblCntAct = actdir1Tables.Count;

for (Int32 itbl = 0; itbl <= actdir1Tables.Count - 1; itbl++)
{
IList<TrTag> actdir1rows = actdir1Tables[itbl].FindDescendants<TrTag>();

SelectSite("H18N",actdir1rows); // Selecting the site using common function.

----
During debug actdir1rows display the value when SelectSite is not used while UnCommenting on SelectSite no value display after first row.

Can you please suggest issue with code.

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

Re: Problem while accessing the second row in datagrid.

Post by odklizec » Fri Dec 16, 2016 8:23 am

Hi,

Unfortunately, without seeing (at least) a Ranorex snapshot of your table (small sample app would be even better) is very hard to suggest something reliable. Please upload the snapshot (not screenshot!) of the table in question so we can examine it together with the code you provided.

Also, next time please post your problem in a new topic. It's better to discuss separate problems in separate topics. Thanks ;)
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