【问题标题】:Selenium webdriver cannot reach button (manually too)Selenium webdriver 无法到达按钮(也手动)
【发布时间】:2023-01-11 18:30:43
【问题描述】:

我对硒有疑问。在普通浏览器(Firefox、Chrome)中,我可以转到一个页面并单击一个按钮。在 Selenium 浏览器 (Chrome) 中 - 我不能。另外 - 我什至无法在 Selenium Chrome 中手动完成。按钮没有反应。这可能是什么原因造成的?

我的意思是黑色按钮 (Abschicken) 示例 url:https://home.mobile.de/AUTOMOBILE-WIERSCHEM#contact

任何帮助将不胜感激

【问题讨论】:

  • 手动 - 我的意思是我运行 selenium webdriver 并在那里手动单击。在普通的网络浏览器中,一切正常。

标签: selenium selenium-webdriver css-selectors webdriverwait


【解决方案1】:

你没有分享你的代码,而不是你收到的错误。
所以我不知道你做错了什么。
以下代码有效:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

options = Options()
options.add_argument("start-maximized")

webdriver_service = Service('C:webdriverschromedriver.exe')
driver = webdriver.Chrome(options=options, service=webdriver_service)
wait = WebDriverWait(driver, 10)

url = "https://home.mobile.de/AUTOMOBILE-WIERSCHEM#contact"
driver.get(url)

wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button[class*=accept]"))).click()
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button[class*=contactSend]"))).click()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-12-05
    • 2016-03-02
    • 2015-04-25
    • 2014-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-17
    相关资源
    最近更新 更多