C# Selenium: GetXpathCount shows 0
The following is a code snippet from the website I'm testing:
<table width="100%" cellspacing="3" cellpadding="0" border="0">
<tbody>
<tr>
<td width="2%" valign="top" align="center">
<td width="48%" valign="top" align="left">
<font class="wlCategoryLinkBold" size="2">
<a target="SearchFrame" href="http://wlAtlas.aspx?cmd=display=Administrative&w开发者_Go百科lTarget=wlReturnURL=PDocs.aspx">Administrative</a>
The code I have:
public List<string> Search(ISelenium Sel)
{
Sel.Click(//*[@id="Search_Tab_Search"]);
List<string> topics = new List<string>();
int se = (int) Sel.GetXpathCount("//font[@class='wlCategoryLinkBold']/a");
for (int i = 1; i <= se; i++)
{
if (Sel.IsElementPresent("//font[@class='wlcategoryLinkBold']/a[" + i + "]"))
{
string value = Sel.GetText("//font[@class='wlcategoryLinkBold']/a[" + i + "]");
topics.Add(value);
}
The easiest will be to use selenium.getTable("table_name".colnumber.rownumber)
精彩评论