【问题标题】:Selenium Webdriver FindsBy annotation equivalent to driver.FindElements(...)Selenium Webdriver FindsBy 注解等价于 driver.FindElements(...)
【发布时间】:2014-08-07 02:58:03
【问题描述】:

我正在使用 FindsBy 属性使用 PageFactory 和对象识别。到目前为止我很喜欢它,但我找不到与以下内容等效的 FindsBy 注释,它从表中检索元素列表。

driver.FindElements(By.CssSelector("#searchtable tr td a"));

如果我试试这个:

[FindsBy(How = How.CssSelector, Using = "#searchtable tr td a")]
public List<IWebElement> searchGridContents;

我收到错误“字段类型 searchGridContents 不是 IWebElement 或 IList。”

PageFactory.initelements() 查找typeof(IList&lt;IWebElement&gt;) 或typeof(IWebElement))。看来上面的 FindElements 返回的是

System.Collections.ObjectModel.ReadOnlyCollection<OpenQA.Selenium.IWebElement>

PageFactory 是否有与此等效的注释?如果可以的话,我不想混合和匹配元素识别方法。

【问题讨论】:

    标签: c# selenium-webdriver pageobjects


    【解决方案1】:

    通常情况下,答案包含在问题中。解决方案是将其从 List&lt;&gt; 更改为 IList&lt;&gt;

     public IList<IWebElement> searchGridContents;
    

    【讨论】:

      猜你喜欢
      • 2013-02-07
      • 1970-01-01
      • 1970-01-01
      • 2012-01-14
      • 2011-07-12
      • 1970-01-01
      • 1970-01-01
      • 2013-08-30
      • 2014-04-04
      相关资源
      最近更新 更多