【问题标题】:C# Selenium: GetXpathCount shows 0C# Selenium:GetXpathCount 显示 0
【发布时间】:2011-06-28 17:40:00
【问题描述】:

以下是我正在测试的网站的代码 sn-p:

<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>

我的代码:

 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); 
            }

【问题讨论】:

    标签: c# arrays loops selenium


    【解决方案1】:

    最简单的方法是使用selenium.getTable("table_name".colnumber.rownumber)

    【讨论】:

      猜你喜欢
      • 2019-11-28
      • 2011-02-15
      • 2018-04-27
      • 1970-01-01
      • 1970-01-01
      • 2020-01-19
      • 1970-01-01
      • 2023-03-18
      • 2014-06-10
      相关资源
      最近更新 更多