Perform automated and live-interactive testing on 3000+ real desktop and mobile devices online.
You can click on a hyperlink using Selenium WebDriver in Java by calling the click() method of the WebElement interface. Here is an example:
// create a new instance of WebDriver
WebDriver driver = new ChromeDriver();
// navigate to a web page
driver.get("https://www.lambdatest.com");
// find the hyperlink using its link text
WebElement link = driver.findElement(By.linkText("Click here"));
// click on the hyperlink
link.click();
// wait for the new page to load
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.urlContains("new-page"));
// close the browser
driver.quit();
To click on a hyperlink using the WebDriver API, first, create an instance of WebDriver and navigate to a web page. Then find the hyperlink using its link text, "Click here," in this case, and store it in a WebElement variable called a `link`. Finally, use the `click()` method to click on the hyperlink and wait for it to load by using a `WebDriverWait` object. Once this is done, close the browser using `quit()`.
Test your websites, web-apps, or mobile apps seamlessly with LambdaTest.
Start Free TestingEarn resume-worthy Selenium certifications that help you land a top job.
Learn MoreTest orchestration and execution cloud of 3000+ browsers and OS
24/7 support
Enterprise grade security
Fastest test execution cloud