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 A allwink45 Follow Improve Article Tags : Software Testing Technical Scripter 2022 selenium Similar Reads AVL Tree Data Structure An AVL tree defined as a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees for any node cannot be more than one. Balance Factor = left subtree height - right subtree heightFor a Balanced Tree(for every node): -1 ⤠Balance Factor ⤠1Example of an 4 min read What is Software Testing? Software testing is an important process in the Software Development Lifecycle(SDLC). It involves verifying and validating that a Software Application is free of bugs, meets the technical requirements set by its Design and Development, and satisfies user requirements efficiently and effectively.Here 11 min read Types of Software Testing Software testing is a important of software development life-cycle that ensures a product works correctly, meets user expectations, and is free of bugs. There are different types of software testing, each designed to validate specific aspects of an application, such as functionality, performance, se 15+ min read What is an API (Application Programming Interface) In the tech world, APIs (Application Programming Interfaces) are crucial. If you're interested in becoming a web developer or want to understand how websites work, you'll need to familiarize yourself with APIs. Let's break down the concept of an API in simple terms.What is an API?An API is a set of 10 min read Software Testing Life Cycle (STLC) The Software Testing Life Cycle (STLC) is a process that verifies whether the Software Quality meets the expectations or not. STLC is an important process that provides a simple approach to testing through the step-by-step process, which we are discussing here. Software Testing Life Cycle (STLC) is 7 min read Differences between Black Box Testing and White Box Testing In the Software Testing field, various methods are used to find defects, which used to increasing the software's quality. Black-Box Testing and White-Box Testing play important roles in these process.Let's Learn about them in detail.Table of ContentWhat is Black Box Testing?What is White Box Testing 6 min read Python Match Case Statement Introduced in Python 3.10, the match case statement offers a powerful mechanism for pattern matching in Python. It allows us to perform more expressive and readable conditional checks. Unlike traditional if-elif-else chains, which can become unwieldy with complex conditions, the match-case statement 7 min read Black Box Testing - Software Engineering Black Box Testing is a Software testing method in which the internal working of the application is not known to the tester. The Black Box Testing mainly focuses on testing the functionality of software without any knowledge of the internal logic of an application. Here we are learning the topics rel 12 min read What is Agile Methodology? The Agile methodology is a proper way of managing the project with breaking them into smaller phases which is iteration. It basically focus on flexibility of the project which we can change and improve the team work regularly as per requirements.Table of ContentWhat is Agile?What is the Agile Method 14 min read Software Testing Interview Questions and Answers Software testing is the process of checking if a software application meets requirements and works as expected. Its main goal is to find defects or bugs and ensure the software is reliable and performs well in different situations. This skill is essential for maintaining high-quality products at com 15+ min read Like