硒 - python:send_keys不发送数据
我有问题。 我正在尝试使用硒填写Facebook注册表格。除“月”字段之外,我可以填写所有字段,但我真的不明白为什么。我没有任何错误,该字段根本没有填写。我确定值正确生成,但是我不明白为什么我不能填写该月字段。这是有关守则的一部分:
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)
与月相比,日期和年度正确填写。我尝试了所有事情,包括没有“伪造”会产生随机值,但没有任何东西。你能帮助我吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它不起作用的一个原因是
face.month()
函数返回整数值,而Facebook注册表单则声明诸如'May'''June'等的字符串值等。我建议您尝试使用几个月列表。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.