Reputation: 190
I am trying to fill out a registration form using Selenium for practice as I am beginning to familiarize myself with this library.
It is the registration form on this website: https://www.fast2sms.com/
I start with this:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.fast2sms.com/")
Over there, I click on the signup button with the data-target
attribute set to "#signupM"
using a css selector for the same:
driver.find_element_by_css_selector('button[data-target="#signupM"]').click()
I then set up some dummy values for the fields:
from phone_gen import PhoneNumber
name = "John Doe"
dob = "02-01-1990"
phone_number = PhoneNumber("India").get_number().replace("+91", "")
email_address = f"{phone_number}@mailinator.com"
I wait for the name field, and fill it:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
name_field = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'input[name="signup_name"]')))
name_field.send_keys(name)
Then phone number and email address:
phone_number_field = driver.find_element_by_css_selector('input[name="signup_mobile"]')
phone_number_field.send_keys(phone_number)
email_addr_field = driver.find_element_by_css_selector('input[name="signup_email"]')
email_addr_field.send_keys(email_address)
Everything up until here works fine, exactly as expected, but when I try to fill in the Date of Birth field, I face issues:
dob_field = driver.find_element_by_css_selector('input[name="signup_dob"]')
dob_field.send_keys(dob)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
Select Particular Date using Python Selenium (Rollover dates)
Using Selenium on calendar date picker
Interacting with pop-up boxes using selenium in python
Upvotes: 0
Views: 1549
Reputation: 288
I get why it may not be working. The website is using a particular javascript library called datedropper. Thus the input element for the date is in the readonly format.
I think you can resolve it by doing:
js_code = "document.querySelector('input[name=signup_dob]').value ="
driver.execute_script(js_code + your_date)
Not quite sure the js code is gonna work. It might need some editing.
Upvotes: 1