Accessing Webelement in wait Method without specifying locator type

I have a query regarding element declaration in page factory pattern & access of that element in wait Method. I am mentioning my query in detail as below.
I have implemented Page factory pattern in my dummy test project where i declared webelement & wait method as like below.
In wait method implementation, i had to specify locator type for element like in this case it is  “By.XPath(statementMenu)”.
So, my query is, can’t we just type element without specifying locator type like this “By(statementMenu)”. i have tried this but it didn’t work.
Why i am asking this means, i wanted it to be more generic so that tomorrow if element identification changes  then i will have less maintenance work i will only update ‘using’ values in ‘FindBy’ section
of that page & rest code will work accordingly.
So, any solution/idea on how to achieve this.
for eg.
//WebElement details
[FindsBy(How = How.XPath, Using = “.//*[@id=’menu-item-statements’]/span”)]
 private IWebElement statementMenu { get; set; }
 //Wait Method
 WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0, 0, 5));
 return wait.Until(drv => drv.FindElement(By.XPath(statementMenu)));
 Thanks in adv.
Train Asked on August 10, 2016 in Selenium WebDriver.
Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.