Q:

Dynamically changing linktext in Selenium

I have a scenario where Lintext will change dynamically.I tried with a string variable like below and it is not working. It is giving the error message - The value for annotation attribute FindBy.linkText must be a constant expression.
@FindBy(linkText = strLinkText) 
private WebElement DName;
public WebElement lnkDName() {
return DName;   
}

How to handle dynamic link text? I already tried xpath which is also not working.

A:

If at least part of the link text is always the same, you can fint it by partialLinkText
driver.findElement(By.partialLinkText(String));

