HTML 代码:<div class='UEclfJ _27cR_W'><input type ='tel' autocomplete='one-time-code' maxlength = '6'><input class='_1y306T _2ynKud' maxlength = '1'reandonly value><input class='_1y306T' maxlength = '1'reandonly value><input class='_1y306T' maxlength = '1'reandonly value><input class='_1y306T' maxlength = '1'reandonly value><input class='_1y306T' maxlength = '1'reandonly value><input class='_1y306T' maxlength = '1'reandonly value></div>我尝试在 send_keys 之前删除“readonly”,但它不起作用。我也设置了值,但它无法单击下一步按钮。输入是验证码形式,六个单元格。我看到单击元素时类名是可以更改的。我的代码: cell_change = WebDriverWait(self.driver,10).until(lambda driver:self.driver.find_element_by_xpath('//input[contains(@class, "_1y306T") and contains(@class, "_2ynKud")]')) self.driver.execute_script("arguments[0].removeAttribute('readonly','readonly')", cell_change) print("remove success") sleep(3) cell_change.send_keys("1") sleep(1)有人可以帮我解决这个问题或给我一些想法吗?我对此非常感激:(感谢您关心我的问题。
1 回答
江户川乱折腾
TA贡献1851条经验 获得超5个赞
这段代码似乎可以解决问题:
number_input = driver.find_element_by_xpath('//input[@type="tel"]')
number_input.find_element_by_xpath('./following-sibling::input').click()
number_input.send_keys('123456')
说明:为了能够输入数字,<input type="tel">您需要单击第一个单元格
添加回答
举报
0/150
提交
取消