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

I need take the content of <td> from a table

3 Answers 60 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ignacio
Top achievements
Rank 1
Ignacio asked on 07 Nov 2011, 09:14 PM
hi, my problem is I need take the content of cell <td> for the Price1 and Price2, and this doesn't work

(Pages.HTMLTables.Table.Find.AllByExpression<HtmlTableCell>("tagname=td")[0].TextContent);

<TABLE class=Table ><THEAD>
<TR>
<TD class=first-child width=150> Name</TD>
<TD width=100>Cruise Rate</TD>
<TD width=135>
<DIV class=table-align>Government <BR>Fees &amp; Taxes <SPAN class="tooltip 3></A> </SPAN></DIV></TD>
<TD width=136>Vacation <BR>Protection <A class="thickbox learn-more" >Learn More</A> </TD>
<TD class=last-child width=116>Total</TD></TR></THEAD>
<TBODY>
<TR class=first-child>
<TD class=first-child><STRONG>Price1</STRONG></TD>
<TD>$289.00</TD>
<TD>$62.59</TD>
<TD class=td-vpp><A class="remove addRemoveVPLink" href="#" rate="$49.00">Remove $49.00</A>
 <INPUT type=hidden name=addVPSeqNumbers TeaLeaf="true"> </TD>
<TD class=last-child align=right><STRONG>$400.59</STRONG></TD></TR>
<TR>
<TD class=first-child><STRONG> Price2</STRONG></TD>
<TD>$289.00</TD>
<TD>$62.59</TD>
<TD class=td-vpp><A class="remove addRemoveVPLink" href="#" rate="$49.00" >Remove $49.00</A> <INPUT type=hidden name=addVPSeqNumbers TeaLeaf="true"> </TD>
<TD class=last-child align=right><STRONG>$400.59</STRONG></TD></TR>

3 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 10 Nov 2011, 05:52 PM
Hi Ignacio,

Try locating the row by tagname (tr) and InnerText (contains "Price1"), then based on that row, get the second cell:

HtmlTable table = Pages.CHTMLTableHtml.Table;
 
HtmlTableRow rowOne = table.Find.ByExpression<HtmlTableRow>("tagname=tr", "InnerText=~Price1");
 
HtmlTableCell priceOne = rowOne.Cells[1];
Log.WriteLine(priceOne.TextContent.ToString());
  Regards,
Anthony
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Saket
Top achievements
Rank 1
answered on 14 Nov 2011, 05:37 AM
Just adding up to the question
What if the Price1 is selected over at runtime and i am using MS test is there anything avaliable in that case, just like partial url connect provided by the framework.

Thanks
0
Anthony
Telerik team
answered on 15 Nov 2011, 05:02 PM
Hi Saket,

I don't understand what you mean by "What if the Price1 is selected over at runtime". 

Please provide additional detail about the scenario you'd like to accomplish.

Kind regards,

Anthony
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Ignacio
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Saket
Top achievements
Rank 1
Share this question
or