Selenium - Python: send_keys does not send data

Viewed 43

I have a problem. I am trying to fill out the Facebook registration form using selenium. I can fill in all the fields except the 'month' field and I don't really understand why. I don't get any error, the field is simply not filled in. I am sure that the values are generated correctly, but I cannot understand why I cannot fill in the month field. This is the part of the code in question:

from faker import Faker
fake = Faker()

day = fake.day_of_month()
month = fake.month()
year = random.randint(1982, 1995)

driver.find_element(By.ID, "day").send_keys(day)
time.sleep(3)
#driver.find_element(By.ID, "month").send_keys(month)
#time.sleep(3)
#m = Select(driver.find_element(By.ID, "month"))
#m.select_by_value(month)
driver.find_element(By.NAME, "birthday_month").send_keys(month)
time.sleep(3)
driver.find_element(By.NAME, "birthday_year").send_keys(year)
time.sleep(3)

Day and year are filled in correctly, as opposed to month. I have tried everything, including not having 'Faker' generate the random values, but nothing. Can you help me?

1 Answers

One reason it's not working could be that fake.month() function returns integer values while Facebook registration form declares string values such as 'May' 'June' etc. I suggest you try with a list of months.

Related