【问题标题】:Python selenium select divPython 硒选择 div
【发布时间】:2021-05-19 14:17:54
【问题描述】:
driver = webdriver.Chrome()
driver.get("https://discord.com/register")
   

driver.find_element_by_xpath("//input[@class='inputDefault-_djjkz input-cIJ7To' and @type='email']").send_keys(mail)
driver.find_element_by_xpath("//input[@class='inputDefault-_djjkz input-cIJ7To' and @type='text']").send_keys(name)
driver.find_element_by_xpath("//input[@class='inputDefault-_djjkz input-cIJ7To' and @type='password']").send_keys(name)

我有问题。
我做 autogenerator acounts discord.mail,password,name 的工作。但是对于 date 我有问题,因为他们没有输入。请帮帮我

【问题讨论】:

    标签: python python-3.x selenium selenium-webdriver python-3.6


    【解决方案1】:

    要打开选择月份,您可以使用

    driver.find_element_by_xpath("//div[contains(@class,'inputMonth')]").click()
    

    然后选择某个月份,例如

    driver.find_element_by_xpath("//div[@id='react-select-5-option-1']").click()
    

    这里的最后一个数字是列表中选项的数量。

    同样你可以选择日期和年份

    【讨论】:

    • driver.find_element_by_xpath("//div[@id='react-select-5-option-1']").click() 不起作用
    • 您是否在第一次点击和第二次点击之前添加了一些等待/延迟?下拉列表需要一些时间才能打开。
    • raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":" //div[@id='react-select-5-option-1']"}(会话信息:chrome=90.0.4430.212)
    • 尝试 "//div[@class='css-1yz4bi9-option']" 并告诉我现在是否有效。
    • 我正在尝试获取该项目,但是当我单击此项目时隐藏
    猜你喜欢
    • 2015-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多