Home > OS >  ElementNotInteractableException when sending keys (email field) Python Selenium
ElementNotInteractableException when sending keys (email field) Python Selenium

Time:08-31

I am trying to login to this website using Selenium: https://openwho.org/sessions/new . However, none of my attempts of sending keys to the email and password fields work.

I have tried to find the field using various methods (i.e. XPATH, ID, CSS Selector, etc.)

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait, Select
from selenium.webdriver.support import expected_conditions as EC    
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("https://openwho.org/sessions/new")

#Different attempts of finding the field
login_element ='/html/body/div[1]/div[2]/div/div/div[1]/div/form/div/div[2]/div/div/input' #previously worked
login_element ='/html/body/nav/div/div[2]/ul[2]/li[10]/ul/li/div/div[1]/div/form/div/div[2]/div/div'
login_element = '/html/body/div[1]/div[2]/div/div/div/div/div[1]/div/form/div/div[2]/div/div' #master xpath
login_element = 'login_email' #id
login_element = '//*[@id="login_email"]' #xpath
login_element = 'login[email]'

#Option 1 [not working]    
login_element = '//*[@id="login_email"]' #xpath
login_button = driver.find_element_by_xpath(login_element)
login_button.click()

#Option 2 [not working]
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH , login_element))).click()

#Option 3 [not working]
element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, login_element)))
element.location_once_scrolled_into_view
element.click()

CodePudding user response:

There are 2 blocks of login elements on this page, the visible is the second one. This means you need to define the locator more precisely.
This should work:

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait, Select
from selenium.webdriver.support import expected_conditions as EC    
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("https://openwho.org/sessions/new")

login_element = "//div[@class='login-box']//input[@name='login[email]']"
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, login_element))).click()
  • Related