- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Fetch all href link using selenium in python.
We can fetch href links in a page in Selenium by using the method find_elements(). All the links in the webpage are designed in a html document such that they are enclosed within the anchor tag.
To fetch all the elements having <anchor> tagname, we shall use the method find_elements_by_tag_name(). It will fetch a list of elements of anchor tag name as given in the method argument. If there is no matching tagname in the page, an empty list shall be returned.
from selenium import webdriver driver = webdriver.Chrome (executable_path="C:\chromedriver.exe") driver.maximize_window() driver.get("https://www.google.com/") # identify elements with tagname <a> lnks=driver.find_elements_by_tag_name("a") # traverse list for lnk in lnks: # get_attribute() to get all href print(lnk.get_attribute(href)) driver.quit()
- HTML DOM Link href Property
- How to get an attribute value from a href link in selenium?
- How can I get the href of elements found by partial link text using Selenium?
- How to click a link whose href has a certain substring in Selenium?
- HTML <link> href Attribute
- Click a href button with Selenium and Python?
- How to click on a link using Selenium webdriver in Python.
- How to effectively hide Href From a Link in PHP?
- Add PHP variable inside echo statement as href link address?
- How to click on a link in Selenium with python?
- How to find an element using the “Link Text/Partial Link Text” in Selenium?
- How to open a link in new tab using Selenium WebDriver?
- How to click on a hyper link using linkText in Selenium?
- How to get the content of href within some targeted class using selenium?