Reputation: 69
i tried to send phone numbers to input element below
<div id="mainframe.childframe.form.div_main.form.div_work.form.edt_mbtlTelNoCentral" class="Edit" tabindex="-1" style="left:309px;top:305px;width:85px;height:28px;" aria-label="휴대전화 가운데자리(필수입력) " aria-description="" userstatus="" status="enabled"><input id="mainframe.childframe.form.div_main.form.div_work.form.edt_mbtlTelNoCentral:input" class="nexainput" style="left:0px;top:0px;width:83px;height:26px;ime-mode:disabled;" value="" maxlength="4" type="text"><input id="mainframe.childframe.form.div_main.form.div_work.form.edt_mbtlTelNoCentral:input" class="nexainput" style="left:0px;top:0px;width:83px;height:26px;ime-mode:disabled;" value="" maxlength="4" type="text"></div>
with this code
actions = ActionChains(driver)
ele = driver.find_element_by_xpath('//*[@maxlength="4"]')
actions.click(ele).key_down(Keys.CONTROL).send_keys("a").key_up(Keys.CONTROL).send_keys("Keys.Delete").send_keys('9049').perform()
but it keep send key like this enter image description here
how can i fix this?
Upvotes: 2
Views: 123
Reputation: 3503
Assuming I am looking in the right place (my Korean is not up to scratch even with Google Translate), I believe you have two boxes matching xpath "//*[@maxlength="4"]".
I have created this example to fill both of them:
#get elements matching your xpath; this will return 2 items
elems = driver.find_elements_by_xpath('//*[@maxlength="4"]')
#to fill both boxes
numbers=[1234,5678]
for i, num in enumerate(numbers):
elems[i].clear()
elems[i].send_keys(num)
Upvotes: 1