1

I'm struggling with a phone number field that I fill using send_keys function in selenium. Actually, the submit button is supposed to be enabled after filling out the phone number, but it doesn't except if I enter the phone number manually.

I tried to click on the phone number field before filling it out, but it still doesn't work. Here is the code I'm using:

phone=webdriver.find_element_by_id("phonenumber")
phone.click()
phone.clear()
phone.send_keys(number)

Any help will be appreciated...

Lee Jensen
2,3281 gold badge13 silver badges24 bronze badges
asked May 1, 2021 at 22:46
2
  • 4
    please add the website information screenshots etc Commented May 2, 2021 at 6:47
  • What does "number" equal to in your above example? Seem like you're using a variable here but don't show it declared. That's probably why it's not working. Commented May 3, 2021 at 18:06

2 Answers 2

1

I finally found a solution by using actions and Keys.NUMPAD. Here is a sample of code:

phone=webdriver.find_element_by_id("phonenumber")
actions=ActionChains(webdriver)
actions.click(phone)
actions.send_keys(Keys.NUMPAD0)
actions.send_keys(Keys.NUMPAD2)
actions.perform()

This way i can submit the phone number like if i entered it manually!

answered May 2, 2021 at 0:16
1
  • could you add the website information Commented May 2, 2021 at 6:47
1

You can enter mobile number as following:

phone=webdriver.find_element_by_id("phonenumber")
phone.click()
phone.clear()
phone.send_keys("0123456")
answered May 2, 2021 at 4:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.