【问题标题】:Python - Selenium | Can´t click buttonPython - 硒 |不能点击按钮
【发布时间】:2021-02-20 03:58:27
【问题描述】:

我想自动化注册页面。一切正常。但是有一个“下一步”按钮,我无法自动按下它。谁能帮帮我?

【问题讨论】:

    标签: python selenium selenium-webdriver xpath webdriverwait


    【解决方案1】:

    要点击文本为 Weiter 的元素,您可以使用以下任一Locator Strategies

    • 使用xpath

      driver.find_element_by_xpath("//button[@type='submit' and text()='Weiter']").click()
      

    理想情况下,点击你需要诱导WebDriverWaitelement_to_be_clickable()的元素,你可以使用以下Locator Strategies之一:

    • 使用XPATH

      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@type='submit' and text()='Weiter']"))).click()
      
    • 注意:您必须添加以下导入:

      from selenium.webdriver.support.ui import WebDriverWait
      from selenium.webdriver.common.by import By
      from selenium.webdriver.support import expected_conditions as EC
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多