The following snapshot is what I see when I do a view of class and Ids in using IE Developer tool. It consists of a table and inside the table there are links. I need to read all the link names, and store the link names in a string array.
When I use Firebug to get the Xpath of each of the links, I get:
/html/body/table/tbody/tr/td[2]/table/tbody/tr/td[2]/font/a
/html/body/table/tbody/tr/td[2]/table/tbody/tr/td[4]/font/a
/html/body/table/tbody/tr/td[2]/table/tbody/tr[3]/td[2]/font/a
/html/body/table/tbody/tr/td[2]/table/tbody/tr[3]/td[4]/font/a
/html/body/table/tbody/tr/td[2]/table/tbody/tr[5]/td[2]/font/a
/html/body/table/tbody/tr/td[2]/table/tbody/tr[5]/td[4]/font/a
I had the following method initially, but QuickWatch showed arrTopics as null. It should have given me at least 10 labels. The value of arrTopics should have been something like {"Administration", "Banking", "Marketing", ...} I think this has to do with my xpath (("//a[@class='wlcategoryLinkBold']/@href").
public List<string> Search(ISelenium Sel)
{
Sel.Click(//*[@id="Search_Tab_Search"]);
List<string> topics = new List<string>();
int se = (int) Sel.GetXpathCount("//a[@class='wlcategoryLinkBold']/@href");
for (int i = 1; i <= se; i++)
{
if (Sel.IsElementPresent("//a[@class='wlcategoryLinkBold']/@href[" + i + "]"))
{
string value = Sel.GetSelectedLabel("//a[@class='wlcategoryLinkBold']/@href[" + i + "]");
topics.Add(value);
}
}
string[] arrTopics = topics.ToArray();
return arrTopics;
}
How do I use
/html/body/table/tbody/tr/td[2]/table/tbody/tr/td[2]/font/a
/html/body/table/tbody/tr/td[2]/table/tbody/tr/td[4]/font/a
/html/body/table/tbody/tr/td[2]/table/tbody/tr[3]/td[2]/font/a
/html/body/table/tbody/tr/td[2]/table/tbody/tr[3]/td[4]/font/a
/html/body/table/tbody/tr/td[2]/table/tbody/tr[5]/td[2]/font/a
/html/body/table/tbody/tr/td[2]/table/tbody/tr[5]/td[4]/font/a
.
.
.
instead of ("//a[@class='wlcategoryLinkBold']/@href) in the Sel.GetXpath()? I see that I need to have another loop that takes care of tr[3], tr[5], td[2], td[4].