How can I use the path/location of a @FindBy variable as an argument to a method?
I have the following @FindBy value in my class...
@FindBy(xpath=".//*[@id='HasAnotherSubsidisedQual_container']")
@CacheLookup WebElement mSubsidisedQual;
I then have a method for checking whether an element exists...
public boolean isElementPresent(By element){
try {
mDriver.findElement(element);
return true;
}
catch (org.openqa.selenium.NoSuchElementException e){
return false;
}
}
I then use that method in another method which contains an assertion
public void checkSmartAndSkilled () {
Assert.assertTrue(isElementPresent(By.xpath(".//*[@id='HasAnotherSubsidisedQual_container']")));
}
This all works fine, however instead of specifying By.xpath... etc in the assertion, is there anyway to pass in as an argument the path for my @FindBy WebElement mSubsidisedQual?
Many thanks