【问题标题】:How can I click on the <li class> element?如何点击 <li class> 元素?
【发布时间】:2021-03-30 01:17:13
【问题描述】:

我想在下拉菜单中单击蓝色部分进行选择 enter image description here

【问题讨论】:

    标签: python-3.x selenium selenium-webdriver drop-down-menu selenium-chromedriver


    【解决方案1】:
    driver.find_element((By.XPATH, "//ul[@class='selectbox-list']/li[2]")).click()
    

    只需将 .click() 的第二个 li 定位为 xpath。

    【讨论】:

    • 感谢您的回答。但我有错误。 raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: 'using' must be a string (Session info: chrome=89.0.4389.90)
    • 尝试只使用 driver.find_element_by_xpath("")。
    【解决方案2】:

    driver.find_element((By.XPATH, "//li[@class='ellipsis1']")).click()

    它点击代码中突出显示的第一个元素

    【讨论】:

      猜你喜欢
      • 2014-10-14
      • 1970-01-01
      • 2023-01-13
      • 2013-10-06
      • 1970-01-01
      • 1970-01-01
      • 2021-05-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多