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'])
我尝试登录网站,我可以成功输入帐户名称 - 即" acc"在代码中,但是当它来到pwd时,它将显示错误消息。我测试了pwd元素可以正常,只有send_keys行出错了。
selenium.common.exceptions.ElementNotInteractableException: Message: Element <input id="passwordInput1" class="inputField1" name="passwordInput1" type="text"> is not reachable by keyboard
它发生在geckodriver和chromedrive中,但是对于phantomjs没问题。谁知道发生了什么?
答案 0 :(得分:1)
键盘当时不可用。这意味着使用键盘无效。我遇到的情况是页面已经改变,弹出窗口,例如,改变。你应该使用:
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')
查看当时的页面状态。