Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# webdriver html元素的缩写定义_C#_Webdriver_Pageobjects - Fatal编程技术网

C# webdriver 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

在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会尝试查找以这种方式定义的所有元素。无论如何,第一种方法是有效的。

另一种可能的方法可能是使用该类


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