webdriver html 元素的缩写定义
Abbreviated definition of a webdriver html element
在 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 试图找到所有以这种方式定义的元素,如果包含它们的 class 出于任何原因被调用。无论如何,第一种方法有效。
另一种可能的方法可能是使用 FindsBy class
[FindsBy(How = How.XPath, Using = ".//input[@name='USER']")]
public IWebElement userFieldElement { get; set; }
在 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 试图找到所有以这种方式定义的元素,如果包含它们的 class 出于任何原因被调用。无论如何,第一种方法有效。
另一种可能的方法可能是使用 FindsBy class
[FindsBy(How = How.XPath, Using = ".//input[@name='USER']")]
public IWebElement userFieldElement { get; set; }