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".

我不明白这个问题

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

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

最新更新