How to locate a link using its text in Selenium?
Hello Rhian-lewis,
Using linkText()
and partialLinkText()
methods, we can locate a link. The difference between the two is – linkText()
matches the complete string passed as a parameter to the link texts. Whereas partialLinkText()
only matches the string parameter partially.
WebElement link1 = driver.findElement(By.linkText("artOfTesting"));
WebElement link2 = driver.findElement(By.partialLinkText("artOf"));