How to Get All Available Links on the Page using Selenium in Java? Last Updated : 23 Apr, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report Selenium is an open-source Web-Automation tool that is used to automate web Browser Testing. The major advantage of using selenium is, that it supports all major web browsers and works on all major Operating Systems, and it supports writing scripts on various languages such as Java, JavaScript, C# and Python, etc. While automating a webpage, we are required to fetch and check all the available links present on the webpage, In this article, we will learn to get all the available links present on a page using "TagName". As we know all the links are of type anchor tag "a" in HTML. For Example, <a href="geeksforgeeks.org">geeksforgeeks</a> Table of Content How to fetch all the links on a webpage?Sample Code Example to Scrape LinksHow to fetch all the links on a webpage?Navigate to the webpage.Get the list of WebElements with the TagName "a".List<WebElement> links=driver.findElements(By.tagName("a"));Iterate through the List of WebElements.Print the link text.Sample Code Example to Scrape LinksIn this example, we are navigating to the URL "https://www.geeksforgeeks.org/" and print the link text of all available links on the page. Java public class Geeks { WebDriverManager.chromedriver().setup(); WebDriver driver = new ChromeDriver(); driver.manage().window().maximize(); driver.get("https://www.geeksforgeeks.org/"); // Get all the available Links List<WebElement> links = driver.findElements(By.tagName("a")); // Iterating through all the Links and printing link // text for (WebElement link : links) { System.out.println(link.getText()); } driver.close(); } Output:This program will get all the Links in the List of WebElements and print all the link texts. Comment More infoAdvertise with us Next Article Get all text of the page using Selenium in Python A allwink45 Follow Improve Article Tags : Software Testing Technical Scripter 2022 selenium Similar Reads How to Run Opera Driver in Selenium Using Java? Selenium is a well-known software used for software testing purposes. Selenium consists of three parts. One is Selenium IDE, one is Selenium Webdriver & the last one is Selenium Grid. Among these Selenium Webdriver is the most important one. Using Webdriver online website testing can be done. Th 3 min read Get all text of the page using Selenium in Python As we know Selenium is an automation tool through which we can automate browsers by writing some lines of code. It is compatible with all browsers, Operating systems, and also its program can be written in any programming language such as Python, Java, and many more. Selenium provides a convenient A 3 min read How to Select Multiple Elements using Actions Class in Selenium using Java? Selenium is an open-source web automation tool that supports many user actions to perform in the web browser. Automating a web page that has file upload or other functionality which requires selecting multiple elements, to perform the multiple select actions the selenium provides a class called Acti 2 min read How to Move Mouse Cursor to a Specific Location using Selenium in Java? Selenium is an open-source Web Automation tool that supports many user actions in the web browser. For automating a web page the mouse movement is the most important action taken by the users, so to perform the mouse actions the selenium provides a class called Actions. The Action class provides the 7 min read How to navigate back to current page from Frame in selenium webdriver using Java? When automating tests in Selenium WebDriver using Java, working with frames can be tricky. Frames are separate sections within a webpage that operate independently of the main content. Navigating between frames and the main page is a common task in web automation testing. Understanding how to switch 2 min read How to click a link whose href has a certain substring in Selenium java? A webpage can contain one or more hypertexts referencing other websites with the help of hyperlinks. This is enabled using the HTML anchor tag which has an attribute named href which takes the string value of the hyperlink. In this article, we will be demonstrating how to find specific anchor tags a 4 min read Like