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

How to retrieve rows inside tbody tag

6 Answers 110 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
sherjo
Top achievements
Rank 1
sherjo asked on 11 Feb 2015, 10:11 AM
I have the following DOM:

<table id="abcde">
<thead>
<tr></tr>
<tr></tr>
</thead>
<tbody>
<tr>
<td>
<div>
<ul>
<li class ="view"></li>
<li class ="delete"><a href="???">delete</a></li>
</ul>
</div>
</td>
<td>
<a href="???">known search string</a>
</td>
</tr>
</tbody>
</table>

I need to do the following:
1. find the row of the "known search string"
2. click the delete hyperlink for that row

I have tried using this to know the number of rows that exists:
HtmlTable tTbl = Find.ById<HtmlTable>("abcde");
Log.Writeline(tTbl.Rows.Count.ToString());

but it always returns an exception error, so I was not able to proceed.

Any kind of help will be appreciated.

Thanks!

Sherjo







6 Answers, 1 is accepted

Sort by
0
Ivaylo
Telerik team
answered on 16 Feb 2015, 07:06 AM
Hello Sherjo,

Here is an article on how you can search for a string in an html table. Once found you can proceed the same way to click on it.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
sherjo
Top achievements
Rank 1
answered on 17 Feb 2015, 02:58 AM
Will check the article.
I'll post an update of my progress.

thanks!
0
Ivaylo
Telerik team
answered on 17 Feb 2015, 08:52 AM
Hello Sherjo,

You are most welcome.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
sherjo
Top achievements
Rank 1
answered on 02 Mar 2015, 02:52 AM
Hi, 

I used the code below, but it only returned values from the rows inside the <thead></thead> tags.
How do I access the rows inside the <tbody></tbody> tags?

HtmlDiv tDiv = Find.ByAttributes<HtmlDiv>("class=inner");
HtmlTable tTbl = tDiv.Find.ById<HtmlTable>("alerttemplate-list");
IList<HtmlTableRow> list = tTbl.Find.AllByTagName<HtmlTableRow>("tr");
foreach (HtmlTableRow item in list)
{
    Log.WriteLine(item.InnerText.ToString());    
}

thanks!
0
sherjo
Top achievements
Rank 1
answered on 03 Mar 2015, 06:37 AM
Hi,

Just an update. I was able to make my code work!
I just added, ActiveBrowser.RefreshDomTree(); at the top of my code and the row inside the tbody tags were recognized.

thanks!
0
Ivaylo
Telerik team
answered on 03 Mar 2015, 01:36 PM
Hеllo Sherjo,

Thank you for the update.

I am glad to hear you've worked it out.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
sherjo
Top achievements
Rank 1
Answers by
Ivaylo
Telerik team
sherjo
Top achievements
Rank 1
Share this question
or