Any hyperlinks on a web page can be identified using PartiallinkText as well. Here elements can be found by a portion of the text in a Link Text element from the link it contains. And if there is no DOM element available with the given Name, then NoSuchElementException is raised in that case.
Syntax: WebElement element = driver.findElement(By.partialLinkText(<PARTIALLINKTEXT>));
Let’s take an example by locating “UI Elements” in “https://demoapp1.tequality.tech/” page.
Step1: Open “https://demoapp1.tequality.tech/“ in browser
Step2: Hover your mouse to Forms present in side-menu
Step3: Right click on the mouse and do inspect element
WebElement element = driver.findElement(By.partialLinkText("Form"));