Home > OS >  Error: element not interactable while using Selenium when sending keys to a textbox
Error: element not interactable while using Selenium when sending keys to a textbox

Time:09-28

I am using Selenium to try to login to a website but when I try to send the keys, I am getting the following error: selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable. The website is: website. I hope anyone can help me.

My code is:

buttom = browser.find_element_by_class_name("loginInputs").find_element_by_class_name("passwordInput")
buttom.send_keys("password")

CodePudding user response:

It doesn't work because the element with the class name passwordInput is a <div>. What you want is the <input> element, so use:

password = browser.find_element_by_class_name("loginInputs").find_element_by_class_name("passwordInput").find_element_by_css_selector("input")
password.send_keys("password")

CodePudding user response:

There is literally no need to use nested parent-child relationship to get the login - username and password fields, filled using Selenium

username = browser.find_element_by_css_selector("input[placeholder='Username']")
username.send_keys("username")

password = browser.find_element_by_css_selector("input[placeholder='Password']")
password.send_keys("password")

login_btn = browser.find_element_by_css_selector(".loginButton.button.submitButton")
login_btn.click()

perfectly does the job of entering and submitting the button for login - tested using Selenium 4 on a Mac machine.

CodePudding user response:

The website is in two languages and the attribute values of input tag changes. Better try with this xpath and apply Explicit waits.

# Import Required:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait

driver.get("https://betway.es/es/sports/cpn/tennis/231")
wait = WebDriverWait(driver,30)

username = wait.until(EC.element_to_be_clickable((By.XPATH,"//div[contains(@class,'usernameInput')]/input")))
username.send_keys("Sample Text")
password = wait.until(EC.element_to_be_clickable((By.XPATH,"//div[contains(@class,'passwordInput')]/input")))
password.send_keys("Sample Text")
  • Related