How to add XPath parameter dynamically in Selenium?

Ask a question+

I want to add an XPath parameter dynamically in Selenium? Is it possible.
FindBy(how = How.XPATH, using = “//div[@class=’boxes’]”)
public List<WebElement> boxes;

String randomString = "something";
String startLocator = "//div[@class='cardLabel'][contains(text(), '";
String endLocator = "')]";
Jack 580
add comment

1 Answer


@FindBy is an annotation in Java, and as such happens before the code is run. So well before you this the webpage, @FindBy has finalized.

Muhamed Aziz 660
add comment

Your Answer