Skip to content
Advertisement

How to click on the login button using selenium?

I am trying to log in to “investors.com,” but to do that, I need to click on the “Sign In” button. Currently, I am using selenium to achieve this task. Sadly, I have tried everything, but nothing seems to work. I am not sure why that is the case. Maybe, the website composition is different. I am not sure. I will post the following code I am using at the moment. Any help will be appreciated. Thanks in advance!

My code:

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time

driver = webdriver.Chrome(executable_path="C:/SeliniumWebDrivers/chromedriver.exe")
driver.get('https://investors.com')
driver.implicitly_wait(10)
elements= driver.find_element_by_xpath('//*[@id="__next"]/div[2]/div[2]/div/div[2]/div[2]').click()
driver.quit()

The error I receive:

Traceback (most recent call last):
  File "D:stockProgramIBD stocksMarket_condition.py", line 17, in <module>
    elements= driver.find_element_by_xpath('//*[@id="__next"]/div[2]/div[2]/div/div[2]/div[2]').click()
  File "C:UsersarsalAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdriverremotewebelement.py", line 80, in click
    self._execute(Command.CLICK_ELEMENT)
  File "C:UsersarsalAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdriverremotewebelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "C:UsersarsalAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdriverremotewebdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:UsersarsalAppDataLocalProgramsPythonPython39libsite-packagesseleniumwebdriverremoteerrorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
  (Session info: chrome=104.0.5112.101)

Advertisement

Answer

div node is not clickable by default. You need to select and click its child link:

driver.find_element_by_link_text('Sign In').click()
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement