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...

2
  • 4
    please add the website information screenshots etc – PDHide May 2 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. – Lee Jensen May 3 at 18:06
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!

1
  • could you add the website information – PDHide May 2 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")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.