Is it possible to add varaiables to FindBy Using annotation or any work around on that??

I have menu item with xpth as follows

  • .//*[@id=’ATTENDANCE_href’]
  • .//*[@id=’EMPLOYEES_href’]

I used page object model and use this function to click them using menu title in variable sMEnu something like this

public class MainMenu{

public WebElement Dashboard_MainMenu(String sMenu,WebDriver driver){
element = driver.findElement(By.xpath(".//*[@id='"+"sMenu"+"_href']"));
return element;

now I want to implement pagefactory and want to use variable. Lost in how to add variable to xpath.

@FindBy(how = How.XPATH, using = ".//*[@id='+[sMenu here]*+_href']")

Someone has a work around?? appreciate your help.

samchughtai Default Asked on December 8, 2015 in Selenium WebDriver.
Add Comment
0 Answer(s)

Your Answer

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