This is My String in non PageFactory
framework, declared at the class level.
private final String fruits= "//a/h4[text()='%s']";
Which is used in same class in some method like this:
public void clickFruitHeading(String string) {
driver.click(By.xpath(String.format(fruits, string)));
driver.click(By.xpath(String.format(fruits, "Apple")));
}
But when using PageFactory
it is written like this:
@FindBy(xpath = "//a/h4[text()='%s']")
private static WebElement fruits;
How to use String.format
here?