2

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?

6
  • have you tried just sending the keys directly to the element? ele.send_keys("9049") Commented Apr 30, 2020 at 6:07
  • @BendikKnapstad Yes but it didn't worked Commented Apr 30, 2020 at 6:17
  • what page are you trying to use? Commented Apr 30, 2020 at 6:18
  • @BendikKnapstadhttps://www.ehaneul.go.kr:5443/esky_p/esky_index.jsp#MENU:M211002000 here but it's korean website Commented Apr 30, 2020 at 6:19
  • sorry but the page wants me to download something. that wont happen Commented Apr 30, 2020 at 8:39

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much bro!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.