- 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
How can I get the href of elements found by partial link text using Selenium?
We can get the href of elements found by partial link text with Selenium webdriver. First of all we need to identify the links with help of the find_elements_by_partial_link_text() method.
Next to get hold of href of the links we have to use the get_attribute() method and then pass href as a parameter to the method.
Let us identify the href attribute of links identified with partial link text Policy in the below page.
from selenium import webdriver driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") driver.implicitly_wait(0.5) driver.get("https://www.tutorialspoint.com/about/about_careers.htm") #identify links with partial link text l= driver.find_elements_by_partial_link_text("Policy") #iterate links for i in l: #get href from get_attribute() print("Href value of link: " + i.get_attribute("href")) driver.close()
- How to find an element using the “Link Text/Partial Link Text” in Selenium?
- Fetch all href link using selenium in python.
- How to get text found between span – Selenium
- How to get an attribute value from a href link in selenium?
- How to get the content of href within some targeted class using selenium?
- How can I clear text of a textbox using Python Selenium WebDriver?
- How to get typed text from a textbox by using Selenium Webdriver?
- How to get the text from a website using selenium?
- HTML DOM Link href Property
- How to click a link whose href has a certain substring in Selenium?
- How can I check if some text exist or not in the page using Selenium?
- How to locate element by partial id match in Selenium?
- How can I get Webdriver Session ID in Selenium?
- HTML <link> href Attribute