【问题标题】:Press button with Selenium in Python在 Python 中使用 Selenium 按下按钮
【发布时间】:2021-02-14 14:12:30
【问题描述】:

Path here

我需要按下按钮,但不知道怎么做

我尝试复制 xpath 但出现错误

还尝试按下 id 或 class_name 上的按钮,但也没有成功

如果您有任何想法,请将其写在 cmets 中。谢谢

到目前为止尝试过:

driver.find_element_by_xpath("//button[@class='action-button']").click()
driver.find_element_by_class_name("action-button").click()
driver.find_element_by_xpath("[@id='clearBrowsingDataConfirm']").click()
driver.find_element_by_id('[@id="clearBrowsingDataConfirm"]').click()

【问题讨论】:

    标签: python selenium xpath


    【解决方案1】:

    如果它不在 iframe 中应该可以工作。

    driver.find_element_by_id('clearBrowsingDataConfirm').click()
    

    如果是在 driver.get() 之后试试这个

    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, 'clearBrowsingDataConfirm'))).click()
    

    导入

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

    【讨论】:

    • 嗯。不工作认为我也尝试过一次。消息:没有这样的元素:无法找到元素:{"method":"css selector","selector":"[id="clearBrowsingDataConfirm"]"}
    • 也许试试下面的。
    • 发生了异常:TimeoutException 消息:........看起来从我的研究中找不到任何东西是按钮在 * / deep /它不能被硒检测到。所以我简单地尝试发送到“body”元素 send.key(Keys.ENTER) 但仍然无法以某种方式工作。
    • 它在哪个网站上?
    • 嗯,它是 chrome 选项中的一个网站 chrome://settings/clearBrowserData 我想删除 tge 浏览器缓存。
    猜你喜欢
    • 1970-01-01
    • 2022-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-26
    相关资源
    最近更新 更多