Trying and failing to input text into the username and password text fields on this page:
I'm able to select the element but it throws the not interactable message.
I've tried:
#1
login_form = driver.find_element(By.CSS_SELECTOR, "input[id='signInFormUsername']")
login_form.send_keys('User')
#2
login_form = WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[id='signInFormUsername']")))
login_form.send_keys('User')
Any other means of sending text to this element?
Root cause: There are 2 elements with @id=signInFormUsername
, you need to identify and locate the second element. Your code is trying to locate the first element, and the first element is not visible on browser, hence you are getting Element not interactable
exception.
Solution: Using XPath locator strategy, use the below XPath expression to locate second element in the DOM:
(//input[@id='signInFormUsername'])[2]
Code:
login_form = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "(//input[@id='signInFormUsername'])[2]")))
login_form.send_keys('User')
UPDATE: How to find if XPath expression locates one or more elements:
Press key F12 --> Press Ctrl + F on console and paste the XPath expression //input[@id='signInFormUsername']
. You will notice 2 results as shown in below screenshot. First one won't highlight on the desired text box, but second one will. Try it.