0

Does anybody have idea how they would automate opening and closing links on Github page of your project? So basically I wanted to automate opening and closing all the links on my Github page just to make sure none of the links are broken. Idea is it would open a link one by one (there are hundreds of links) and if the link is opened successfully it would close it and go to the next one if the link is broken it would print that link is broken and would continue to the next one.

I tried to do this in Selenium but for some reason Selenium was giving me a error that element is not interactable. I tried to find solution online but I did not have any luck. So I decided to try here maybe someone has any solution or something I would be thankful

    driver.get("https://github.com/project")
    
    links = driver.find_elements_by_xpath('//*[@href]')
    
    for link in links:
        link.click()

Here is the error:

File "d:\Python\test.py", line 15, in <module>
    link.click()
  File "C:\Python39\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
    self._execute(Command.CLICK_ELEMENT)
  File "C:\Python39\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "C:\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

I didn't even get to the part where I would close the tab and print error since I am failing on first step

Prophet
  • 32,350
  • 22
  • 54
  • 79
Comi
  • 1
  • What exactly are you trying to click? `//*[@href]` has 102 different elements on that page, not all of them clickable – JD2775 May 06 '21 at 15:49
  • Does this answer your question? [Open web in new tab Selenium + Python](https://stackoverflow.com/questions/28431765/open-web-in-new-tab-selenium-python) – vitaliis May 06 '21 at 15:55
  • @JD2775 Actually did not think of that some elements might not be clickable, thanks I will try to figure out some way around this issue – Comi May 06 '21 at 16:02
  • @vitaliis It does look helpful I will try some of the ideas from the answers thank you – Comi May 06 '21 at 16:02

0 Answers0