How to click on a hyperlink using Selenium WebDriver?
On This Page Steps to Click a Hyperlink in Selenium WebDriverJune 10, 2026 · 3 min read · Tool Comparison
In Selenium WebDriver, hyperlinks (HTML & lt; a & gt; tags) can be interacted with by place the element using its textbook or attribute and performing a click action. Selenium provides built-in methods like By.linkText () and By.partialLinkText () to easily name and click links. Steps to Click a Hyperlink in Selenium WebDriver This guide explains how to click hyperlinks in Selenium WebDriver, with example and best practices for testing across real device. Below are the steps on how to chatter on a hyperlink using Selenium WebDriver: Also Read: Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script. This code example will click on a link that take towww.test.com: Explanation: Output: Navigated to: https: //www.test.com/services To ensure consistent user experience across different device and browser, it is important to test it in. BrowserStack Automate offer a program, where you can entree over 3500+ different devices, browsers, and OS combination. # Ask-and-Contributeabout this topic with our Discord community. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.How to click on a hyperlink using Selenium WebDriver?
Overview
Steps to Click a Hyperlink in Selenium WebDriver
Example of How to Click a Hyperlink in Selenium WebDriver
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class ClickHyperlinkExample {public static nothingness main (String [] args) {// Set the itinerary for the ChromeDriver executable System.setProperty (`` webdriver.chrome.driver '', `` path_to_chromedriver ''); // Initialize WebDriver WebDriver driver = new ChromeDriver (); try {// Navigate to the webpage that contains the hyperlink driver.get (`` https: //www.test.com ''); // Locate the hyperlink utilise its visible text WebElement link = driver.findElement (By.linkText (`` Learn more about our services '')); // Perform the click action on the hyperlink link.click (); // Verify the navigation by printing the current URL String currentUrl = driver.getCurrentUrl (); System.out.println (`` Navigated to: `` + currentUrl);} finally {// Close the browser after the test driver.quit ();}}}Extra Notes
Related Guides
Automate This With SUSA
Test Your App Autonomously