This is a migrated thread and some comments may be shown as answers.

Object identification suggestion

2 Answers 104 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
algot
Top achievements
Rank 1
algot asked on 30 Mar 2012, 09:26 AM
I have following data grid with many rows in it which are like following
<tr class="ms-crm-List-Row" otype="9005" oid="{EF80BD25-B979-E111-8FE2-00155D282904}" statecode="Completed" operationtype="10">
<TD class=ms-crm-List-DataCell align=center><INPUT id=checkBox_{EF80BD25-B979-E111-8FE2-00155D282904} class=ms-crm-RowCheckBox title="Cell_1" tabIndex=0 value="" type=checkbox></TD>
<TD class=ms-crm-List-DataCell align=center><IMG alt="" src="/_imgs/ico_16_9005.gif?ver=1339846006"></TD>
<TD class=ms-crm-List-DataCell><NOBR title="Cell_2"><A id=gridBodyTable_primaryField_{EF80BD25-B979-E111-8FE2-00155D282904}_0 class=ms-crm-List-Link title="Cell_2" tabIndex=0 href="#" target=_self>Cell_2</A></NOBR></TD>
<TD class=ms-crm-List-DataCell><NOBR>
<LI style="DISPLAY: inline"><SPAN class=gridLui title=Cell_3 ondblclick=clearTimer() contentEditable=false onclick=handleGridClick() otype="2" oid="{0EF8471E-B979-E111-8FE2-00155D282904}"><IMG id=ico_16_2 class="ms-crm-ImageStrip-ico_16_2 ms-crm-Lookup-Item" alt="" src="/_imgs/imagestrips/transparent_spacer.gif">Cell_3</SPAN></NOBR></LI></TD>
<TD class=ms-crm-List-DataCell><NOBR>Cell_4</NOBR></TD>
<TD class=ms-crm-List-DataCell><NOBR><A style="CURSOR: hand" id=gridBodyTable_lookup_{EF80BD25-B979-E111-8FE2-00155D282904}_0 class=ms-crm-List-Link title="Cell_5" tabIndex=0 onclick=handleLookupAnchorClick() href="#" target=_self>
<LI style="DISPLAY: inline"><SPAN class=gridLui title="Cell_6" ondblclick=clearTimer() contentEditable=false onclick=handleGridClick() otype="8" oid="{36D460BF-1940-E111-A0D7-00155D282904}">Cell_6</SPAN></A></NOBR></LI></TD>
<TD class="ms-crm-List-DataCell ms-crm-NumbersAndDates"><NOBR>Cell_7</NOBR></TD>
<TD class="ms-crm-List-DataCell ms-crm-NumbersAndDates">Cell_8</NOBR></TD>
<TD class=ms-crm-List-DataCell> </TD>
To handle it I should click on cell with title "Cell2"(but this ID have all rows in table).
Rows differ each other by value in Cell_3.

Please suggest how I could define row with proper 'Cell_3' value and click call with Cell_2 value?

2 Answers, 1 is accepted

Sort by
0
Stoich
Telerik team
answered on 04 Apr 2012, 08:25 PM
Hi Alexander,

you will need to go through all the rows in order to find the one that you want. From there you will need to back track and go into the second cell. The code is going to be roughly something like this:

HtmlTable tbl = Find.ById<HtmlTable>("myTable"); //Get the entire table
 
foreach (HtmlTableRow r in tbl.Rows) { //Go through all cells
     
HtmlTableCell c = (HtmlTableCell) r.Cells[3]; //Get cell that contains the title Cell3 (zero indexing)
      
Element temp = c.Find.ByAttributes("title=Cell_3"); //Look for element with attribute Cell_3 - that would be an HTML span
  
    if (temp != null) { //If desired attribute is found in an element contained within this cell
         
      HtmlTableCell c1 = (HtmlTableCell)  r.Cells[2]; //Get previous cell that we want to click
        c1.Click(); //Click cell
     break; //End loop
    }
     
}

 

Greetings,
Stoich
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
algot
Top achievements
Rank 1
answered on 05 Apr 2012, 09:10 AM
Thank you very much, It'll very helpful.
Tags
General Discussions
Asked by
algot
Top achievements
Rank 1
Answers by
Stoich
Telerik team
algot
Top achievements
Rank 1
Share this question
or