How to find all broken invalid links from a webpage using python selenium

0 votes
How to find all broken/invalid links from a webpage using python selenium?
Jul 31, 2019 in Selenium by Ruchi
3,548 views

1 answer to this question.

0 votes

Hi Ruchi, following lines of code can help you in finding qall broken/invalid links on a webpage using python selenium webdriver:

webdriver.get(PAGEURL)

links = webdriver.find_elements_by_css_selector("a")

for link in links:

  if (requests.head(link.get_attribute('href')).status_code == 200):
  print("Valid link")
  else:
  print("Broken link")
answered Jul 31, 2019 by Anvi
• 14,150 points

Related Questions In Selenium

0 votes
2 answers
0 votes
1 answer

How to check all checkboxes on a webpage using Selenium?

Hey Jenny, to check all the checkboxes ...READ MORE

answered Jun 26, 2019 in Selenium by Suraj
5,138 views
0 votes
1 answer
0 votes
1 answer

How to get all options of a dropdown on a webpage using Selenium Webdriver?

Hey Joel, you can use following lines ...READ MORE

answered Jul 15, 2019 in Selenium by Abha
• 28,140 points
2,440 views
0 votes
1 answer

How to Hover using Mouse in python using Webdriver

from selenium.webdriver.common.action_chains import ActionChains def hover(self): ...READ MORE

answered Aug 8, 2018 in Selenium by Meci Matt
• 9,460 points
2,404 views
0 votes
1 answer

How to launch browsers using Python-Selenium?

Hey Nikita, to launch browser in Python-Selenium, ...READ MORE

answered May 24, 2019 in Selenium by Anvi
• 14,150 points
1,063 views
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP