...

/

Clicking a Link By Text, ID, and XPath

Clicking a Link By Text, ID, and XPath

Build on the fundamentals of Selenium by learning how to locate hyperlinks.

Click a link by text

Probably the most direct way to click on a link in Selenium is by using text in the web page. For that, we use linkText as follows:

driver.findElement(By.linkText("Recommend Selenium")).click();

Click a link by partial text

We can achieve the similar goal even if we just work with the partial text ...