硒 - python:send_keys不发送数据

发布于 2025-02-01 08:10:32 字数 693 浏览 3 评论 0原文

我有问题。 我正在尝试使用硒填写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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红颜悴 2025-02-08 08:10:32

它不起作用的一个原因是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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文