Selenium Element not intractable

Issue

Weird case happening here. I am trying to insert some keys in a username and password input field. It was working just fine and suddenly it did stop.

Just to make thing clear for everyone. Once I click on login button, I get redirected to the login page where I have my username and password input fields. and their divs are as follow.

enter image description here

in my selenium code I target the username and password element by their name.

user = driver.find_element_by_name('username')
user.send_keys('Myusername')
user.send_keys(Keys.RETURN)

But when I run my code I get the error:

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
  (Session info: chrome=91.0.4472.106)

Any idea why is error occurring? Please if you need more info just let me know

EDIT:

The Wait it did work but only at the first try, if I run it a second time it throws this error:

Traceback (most recent call last):
  File "test.py", line 25, in <module>
    usern = wait.until(EC.element_to_be_clickable((By.NAME, "username"))).send_keys('myusername')
  File "/Users/<user>/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/support/wait.py", line 80, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 

This is the full code I tried:

wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.NAME, "username"))).send_keys('myusername')
wait.until(EC.element_to_be_clickable((By.NAME, "password"))).send_keys('mypassword')

and it throws the above error.

and this is the screenshotenter image description here

Solution

I think you need ExplicitWait :

try this :

wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.NAME, "username"))).send_keys('your user name')

If this does not work then two things :

  1. Launch your browser in full screen : driver.maximize_window()

  2. Use of ActionsChain :

wait = WebDriverWait(driver, 10) ActionChains(driver).move_to_element(wait.until(EC.element_to_be_clickable((By.NAME, "username")))).send_keys('your user name').perform()

Update 1 :

driver.get("<link>")
wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.XPATH, "//*[local-name()='svg' and contains(@class, 'Card__OTSigninButton-sc')]"))).click()
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div[class$='visible-lg'] input#signInFormUsername"))).send_keys('user name')
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div[class$='visible-lg'] input#signInFormPassword"))).send_keys('password')
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div[class$='visible-lg'] input[name='signInSubmitButton']"))).click()

imports :

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

Answered By – cruisepandey

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published