C# webdriver html元素的缩写定义
在webdriver中,使用c#,可以使用以下命令定义html元素:C# webdriver html元素的缩写定义,c#,webdriver,pageobjects,C#,Webdriver,Pageobjects,在webdriver中,使用c#,可以使用以下命令定义html元素: //Textfields public static IWebElement userFieldElement { get {return Configuration.driver.FindElement(By.XPath(".//input[@name='USER']"));} } 是否有一种简略的方式来定义相同的内容?我试过: public static IWebElement passwo
//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会尝试查找以这种方式定义的所有元素。无论如何,第一种方法是有效的。另一种可能的方法可能是使用该类
我要去PageFactory。
[FindsBy(How = How.XPath, Using = ".//input[@name='USER']")]
public IWebElement userFieldElement { get; set; }