input_box.send_keys使用后提示selenium.common.exceptions.ElementNotInteractableException: Message: element

使用python脚本进行自动操作时遇到报错

selenium.common.exceptions.ElementNotInteractableException: Message: element

 

脚本代码:

# 输入验证码
input_box = wait.until(presence_of_element_located((By.ID, "qrcodeLoginId")))
input_box.send_keys(verification_code)

网页前端代码:

<div id="form_tip_id" class="phone_input_style" style="height: 40px;">
                                    <input class="input_tip" id="qrcodeLoginId_tip" readonly="readonly" value="请输入邀请码" style="color: rgba(0, 0, 0, 0.26); border: none; font-family: 微软雅黑; display: none;">
                                    <input class="input" id="qrcodeLoginId" style="border: none; font-weight: 1; color: rgba(0, 0, 0, 0.87); width: 400px; font-family: 微软雅黑; display: inline-block;" type="text" value="">
                                </div>

修改代码:

先定位到上层元素,click后再键入keys验证码

# 选中在表单框
input_box = wait.until(presence_of_element_located((By.ID, "qrcodeLoginId_tip")))
input_box.click()
# 输入验证码
input_box = wait.until(presence_of_element_located((By.ID, "qrcodeLoginId")))
input_box.send_keys(verification_code)

 

posted @ 2023-04-12 11:28  (ToT)  阅读(92)  评论(0)    收藏  举报