anhle_ptit
Newbie
- Jun 30, 2020
- 21
- 1
I have trouble in send_keys one input one when fill the OTP code by selenium in python. Somebody can help me ?
html-code
'''
<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>
'''
---------------------------------------------------------------------------------------------------
my solution
'''
while True:
if index > 7:
break
input_cell = WebDriverWait(self.driver, 10).until(lambda driver: self.driver.find_element_by_xpath("//div[@class='UEclfJ _27cR_W']/input[{}]".format(index)))
self.action.move_to_element(input_cell)
print("success cell")
input_cell.send_keys(code[index] - 1)
index+=1
sleep(2)
'''
It not work !
html-code
'''
<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>
'''
---------------------------------------------------------------------------------------------------
my solution
'''
while True:
if index > 7:
break
input_cell = WebDriverWait(self.driver, 10).until(lambda driver: self.driver.find_element_by_xpath("//div[@class='UEclfJ _27cR_W']/input[{}]".format(index)))
self.action.move_to_element(input_cell)
print("success cell")
input_cell.send_keys(code[index] - 1)
index+=1
sleep(2)
'''
It not work !