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...
-
4please add the website information screenshots etcPDHide– PDHide2021年05月02日 06:47:34 +00:00Commented 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.Lee Jensen– Lee Jensen2021年05月03日 18:06:21 +00:00Commented May 3, 2021 at 18:06
2 Answers 2
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!
-
could you add the website informationPDHide– PDHide2021年05月02日 06:47:12 +00:00Commented May 2, 2021 at 6:47
You can enter mobile number as following:
phone=webdriver.find_element_by_id("phonenumber")
phone.click()
phone.clear()
phone.send_keys("0123456")