首页 > 解决方案 > Selenium - 键盘python无法访问

问题描述

birthday = driver.find_element_by_name("date_of_birth_day")
birthday.send_keys("11092000")
birthday.send_keys(Keys.RETURN)

当我运行此代码时,我得到

"input class=" web-date-input__form-input" name="date_of_birth_day" type="number"> is not 
 reachable by keyboard"

但元素是“Keyboard-Focusable”

input class="web-date-input__form-input" type="number" placeholder="DD" autocomplete="off" maxlength="2" max="31" min="1" name="date_of_birth_day" tabindex="3" data-testid="input-birthday-day" value="11".

我不明白这个问题

标签: pythonselenium

解决方案


我找到了一种方法来解决它,只需发送没有元素的密钥,我不确定它是否会在任何情况下工作,但它对我有用。

import actions = ActionChains(driver)
  actions.send_keys("11092000")
  actions.send_keys(Keys.RETURN)
  actions.perform()

推荐阅读