selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable when clicking on an element using Selenium Python

Nandan picture Nandan · Mar 19, 2019 · Viewed 12.2k times · Source

I understand this question has been asked but I need some solution for this error:

 Traceback (most recent call last):
 File "goeventz_automation.py", line 405, in <module>
if login(driver) is not None:
File "goeventz_automation.py", line 149, in login
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[@track-element='header-login']"))).click()
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/support/wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:

This is the code where its getting error:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import TimeoutException
import urllib.request as request
import urllib.error as error
from PIL import Image
from selenium.webdriver.chrome.options import Options
import datetime as dt
import time
from common_file import *
from login_credentials import *

def login(driver):
global _email, _password
if waiter(driver, "//a[@track-element='header-login']") is not None:
    #login = driver.find_element_by_xpath("//a[@track-element='header-login']")
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[@track-element='header-login']"))).click()
    #login.click()
    if waiter(driver,"//input[@id='user_email']") is not None:
        email = driver.find_element_by_xpath("//input[@id='user_email']")
        password = driver.find_element_by_xpath("//input[@id='password']")
        email.send_keys(_email)
        password.send_keys(_password)
        driver.find_element_by_xpath("//button[@track-element='click-for-login']").click()
        return driver
    else:
        print("There was an error in selecting the email input field. It may be the page has not loaded properly.")
        return None
else:
    print("There was an error in selecting the header-login attribute on the page.")
    return None

if __name__ == '__main__':
    chrome_options = Options()
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--no-sandbox')
    chrome_options.add_argument('--disable-dev-shm-usage')

    driver = webdriver.Chrome('/usr/bin/chromium/chromedriver',chrome_options=chrome_options)
    #d.get('https://www.google.nl/')
    #driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get('https://www.goeventz.com/')
    if login(driver) is not None:
        print(create_event(driver))

I think there is some problem with Keys.ENTER, but I don't know how to solve this. I have tried every possible solution.............

Answer

DebanjanB picture DebanjanB · Mar 19, 2019

This error message...

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

...implies that the desired element was not interactable when you tried to invoke click() on it.

A couple of facts:

  • When you initialize the Chrome browser always in maximized mode.
  • You can disable-extensions.
  • You need to disable-infobars as well.

I have used the same xpath which you have constructed and you can use the following solution:

  • Code Block:

    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
    
    options = webdriver.ChromeOptions()
    options.add_argument("start-maximized");
    options.add_argument("disable-infobars")
    options.add_argument("--disable-extensions")
    driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
    driver.get("https://www.goeventz.com/")
    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//a[@track-element='header-login']"))).click()
    
  • Browser Snapshot:

login_page