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
提交
取消