亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Python selenium -send_keys 或通過 JS 設置值不起作用

Python selenium -send_keys 或通過 JS 設置值不起作用

撒科打諢 2023-12-20 16:06:58
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">您需要單擊第一個單元格


查看完整回答
反對 回復 2023-12-20
  • 1 回答
  • 0 關注
  • 236 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號