Reputation: 37
acc = self.wait.until(EC.visibility_of_element_located((By.XPATH,"//tr[@valign='top']/td[2]/input[@id='account']")))
acc.send_keys(user['userid'])
time.sleep(1)
pwd = self.wait.until(EC.visibility_of_element_located((By.XPATH, "//tr[@valign='bottom']/td/input[@id='passwordInput1']")))
pwd.send_keys(user['pwd'])
I tried to login to a website and i can successfully input the account name--that is "acc" in the codes, but when it came the pwd, it will display an error message. And i tested that the pwd element can be fine, only the send_keys line went wrong.
selenium.common.exceptions.ElementNotInteractableException: Message: Element <input id="passwordInput1" class="inputField1" name="passwordInput1" type="text"> is not reachable by keyboard
It occurred in geckodriver and chromedrive, but was okay with phantomjs. Anyone knows what's happening?
Upvotes: 3
Views: 5794
Reputation: 125
You could try sending text by action chains:
import selenium.webdriver.common.actions
ActionChains(driver).send_keys_to_element(element, password).perform()
Where:
driver
is the driver you are using,
element
is your located element,
password
is the text you want to send.
This solved my similar issue.
Docs: https://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.common.action_chains
Upvotes: 0
Reputation: 435
The keyboard is not available at that time.It mean that using a keyboard is not effective.The situation I've encountered is that the page has changed, and the popup window, for example, alter.You should use :
driver.save_screenshot('screen.png')
try:
pwd = self.wait.until(
EC.visibility_of_element_located((By.XPATH, "//tr[@valign='bottom']/td/input[@id='passwordInput1']")))
pwd.send_keys(user['pwd'])
except Exception as e:
print(e)
driver.save_screenshot('screen.png')
to see the page status at that time.
Upvotes: 1