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
<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
0
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
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
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!
I'll post an update of my progress.
thanks!
0
Hello Sherjo,
You are most welcome.
Regards,
Ivaylo
Telerik
You are most welcome.
Regards,
Ivaylo
Telerik
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!
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!
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
Hеllo Sherjo,
Thank you for the update.
I am glad to hear you've worked it out.
Regards,
Ivaylo
Telerik
Thank you for the update.
I am glad to hear you've worked it out.
Regards,
Ivaylo
Telerik