How to add XPath parameter dynamically in Selenium?

Ask a question+
2

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 = "')]";
wait.until(ExpectedConditions.elementToBeClickable(By.xpath(startLocator+randomString+endLocator)));
Jack 580
add comment

1 Answer

1

@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