selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable error while trying to login with Selenium and Python selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable error while trying to login with Selenium and Python selenium selenium

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable error while trying to login with Selenium and Python


You need to do a lot of things to get this work.

  • Need to set windows-size since you are dealing with headless mode.By passing the arguments.options.add_argument("window-size=1920x1080")

    -Need to click ACEPTO button and then click on login link.

    -Induce WebDriverWait And element_to_be_clickable()

Here is the code.

from selenium.webdriver.chrome.options import Optionsfrom selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.webdriver.common.action_chains import ActionChainsoptions = Options()options.add_argument('--headless')options.add_argument('--disable-gpu')options.add_argument("start-maximized")options.add_argument("disable-infobars")options.add_argument("--disable-extensions")options.add_argument("window-size=1920x1080")email = 'fake@gmail.com'password = 'fakepass3'driver = webdriver.Chrome('chromedriver', options=options)driver.get('https://www.ecobolsa.com/index.html')WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//button[normalize-space()='ACEPTO']"))).click()loginlink=WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//li[@class='login']/a")))ActionChains(driver).move_to_element(loginlink).click(loginlink).perform()WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.ID,"userNameTextBox"))).send_keys(email)WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.ID,"password_login"))).send_keys(password)print('pass')


To login in within the website https://www.ecobolsa.com/index.html using Selenium you need to:

  • Induce WebDriverWait for:

    • Button with text as ACEPTO to be clickable.
    • Element containing the link to login to be clickable.
    • Username field to be clickable.
  • Code Block:

    options = webdriver.ChromeOptions()options.add_argument("window-size=1920x1080")options.add_argument("--headless")options.add_experimental_option("excludeSwitches", ["enable-automation"])options.add_experimental_option('useAutomationExtension', False)driver = webdriver.Chrome(options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')driver.get("https://www.ecobolsa.com/index.html")WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.qc-cmp-button[onclick]"))).click()WebDriverWait(driver, 20).until(EC.invisibility_of_element((By.CSS_SELECTOR, "div.qc-cmp-ui-container.qc-cmp-showing")))ActionChains(driver).move_to_element(WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "li.login>a")))).click().perform()WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#userNameTextBox"))).send_keys("jatorna")driver.find_element_by_css_selector("input#password_login").send_keys("jatorna")driver.save_screenshot('./Screenshots/login.png')print("Program completed")driver.quit()
  • Browser Snapshot:

login