【问题标题】:Abbreviated definition of a webdriver html elementwebdriver html 元素的缩写定义
【发布时间】:2015-05-18 15:35:42
【问题描述】:

在 webdriver 中,使用 c#,您可以使用以下方法定义一个 html 元素:

//Textfields        
public static IWebElement userFieldElement 
{
   get {return Configuration.driver.FindElement(By.XPath(".//input[@name='USER']"));}
}   

是否有定义相同的缩写方式?我试过了:

public static IWebElement passwordFiedfElement = Configuration.driver.FindElement(By.XPath(".//input[@name='USER']"));

但它是无效的,因为如果包含它们的类因任何原因被调用,webdriver 试图找到所有以这种方式定义的元素。无论如何,第一种方法有效。

【问题讨论】:

    标签: c# webdriver pageobjects


    【解决方案1】:

    另一种可能的方法可能是使用FindsBy

    [FindsBy(How = How.XPath, Using = ".//input[@name='USER']")]
    public IWebElement userFieldElement { get; set; }
    

    【讨论】:

    • 我要去PageFactory。
    猜你喜欢
    • 2012-11-22
    • 2015-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-20
    • 1970-01-01
    • 1970-01-01
    • 2017-06-02
    相关资源
    最近更新 更多