C#硒:GetXpathCount显示0 [英] C# Selenium: GetXpathCount shows 0
本文介绍了C#硒:GetXpathCount显示0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是从网站上code段我的测试:
<表格的宽度=100%CELLSPACING =3的cellpadding =0BORDER =0>
<&TBODY GT;
&所述; TR>
< TD WIDTH =2%VALIGN =顶ALIGN =中心>
< TD WIDTH =48%VALIGN =顶align =left>
< FONT类=wlCategoryLinkBold大小=2>
&LT;目标=SearchFrame href=\"http://wlAtlas.aspx?cmd=display=Administrative&wlTarget=wlReturnURL=PDocs.aspx\">Administrative</a>
在code我有:
公开名单&LT;串GT;搜索(ISelenium SEL)
{
Sel.Click(// * [@ id中=Search_Tab_Search]);
清单&LT;串GT;主题=新的List&LT;串GT;();
INT SE =(INT)Sel.GetXpathCount(//字体[@类='wlCategoryLinkBold'] / A);
的for(int i = 1; I&LT; =本身,我++)
{
如果(Sel.IsElement present(//字体[@类='wlcategoryLinkBold'] /一[+ I +]))
{
字符串值= Sel.GetText(//字体[@类='wlcategoryLinkBold'] /一个[+ I +]);
topics.Add(值);
}
解决方案
最简单的将是使用 selenium.getTable(表格名.colnumber.rownumber)
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&wlTarget=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)
这篇关于C#硒:GetXpathCount显示0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文