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 How to Select Multiple Elements using Actions Class in Selenium using Java? 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 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 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 How to get current_url using Selenium in Python? While doing work with selenium many URL get opened and redirected in order to keeping track of URL current_url method is used. The current_url method is used to retrieve the URL of the webpage the user is currently accessing. It gives the URL of the current webpage loaded by the driver in selenium. 2 min read How to scrape multiple pages using Selenium in Python? As we know, selenium is a web-based automation tool that helps us to automate browsers. Selenium is an Open-Source testing tool which means we can easily download it from the internet and use it. With the help of Selenium, we can also scrap the data from the webpages. Here, In this article, we are g 4 min read How to find the src of an image in Selenium java? Selenium WebDriver is a popular automation tool used for testing web applications across different browsers. One common task in web automation is extracting information from web elements, such as retrieving the src attribute of an image. The src attribute holds the URL of the image, and Selenium pro 4 min read Like