This is My String in non 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?



Source link https://sqa.stackexchange.com/questions/20073/-string-format-with-pagefactory

LEAVE A REPLY

Please enter your comment!
Please enter your name here