How to Get All Available Links on the Page using Selenium in Java? Last Updated : 23 Apr, 2024 Comments Improve Suggest changes 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 How to Get All Available Links on the Page using Selenium in Java? A allwink45 Follow Improve Article Tags : Java Technical Scripter Software Testing Selenium Technical Scripter 2022 selenium +2 More Practice Tags : Java Similar Reads How to get the total number of checkboxes in a page using Selenium? In the world of automated testing, Selenium is a powerful tool that helps automate web browsers. One common task during web testing is determining the number of specific elements on a page, such as checkboxes. This can be useful for validating the presence and quantity of checkboxes on a form or any 3 min read How do I pass options to the Selenium Chrome driver using java? Selenium WebDriver is a widely used tool for automating web browsers. When working with Selenium ChromeDriver, passing custom options to the browser allows you to tailor the browsing experience based on your test requirements. Whether you're running tests in headless mode, disabling notifications, o 2 min read How to Open Chrome Browser Using Selenium in Java? Selenium is an open-source popular web-based automation tool. The major advantage of using selenium is, it supports all browsers like Google Chrome, Microsoft Edge, Mozilla Firefox, and Safari, works on all major OS, and its scripts are written in various languages i.e Java, Python, JavaScript, C#, 3 min read How to get an attribute value from a href link in Selenium java? When working with Selenium WebDriver in Java, automating web interactions often involves handling hyperlinks. A common task is to extract the attribute value from a <a> tag, specifically the href attribute, which contains the link's destination URL. Extracting this href value allows you to ver 3 min read How to get the total number of radio buttons on a page using Selenium? When automating web testing with Selenium, one common task is to count the total number of radio buttons on a page. Radio buttons are crucial for selecting one option from a set of choices, and ensuring they are correctly displayed can be important for validating form functionality. In this guide, w 3 min read 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 download File in Selenium Using java Automating the file download process is essential in web automation testing, especially for validating functionalities involving document downloads such as PDFs, images, or CSV files. However, Selenium WebDriver doesnât directly handle file downloads. To overcome this limitation, we can configure th 2 min read How to get innerHTML of whole page in selenium java driver? When automating web applications with Selenium WebDriver in Java, it's often necessary to retrieve the entire HTML content of a webpage. This can be useful for testing purposes, data extraction, or validating the structure of the page. Selenium WebDriver provides a straightforward way to access the 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 Like