【问题标题】:How to click in an input element in a HTML using Selenium with Python 3.8如何使用 Selenium 和 Python 3.8 在 HTML 中单击输入元素
【发布时间】:2020-05-09 17:05:43
【问题描述】:

我对使用 Python 的 Selenium 还是很陌生...

无论如何,我得到了以下 HTML,我想在其中找到并单击 Python 3.8 中的 “搜索字段”

<input class="XTCLo x3qfX" type="text" autocapitalize="none" placeholder="Suchen" value=""/>

我已经尝试了以下步骤:

driver.find_element_by_xpath("//input[@placeholder='Search']") 来自 XPath

driver.find_element_by_class_name("XTCLo x3qfX") 类名

上面列出的步骤都不适合我,所以我很想听听解决方案:D

Python 版本:3.8.2。 用于自动化的 Chrome 版本:81.0.4044.138

【问题讨论】:

  • 您的错误信息是什么?将其发布在问题中。谢谢。

标签: python selenium xpath


【解决方案1】:

以下导入的结果是什么:

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

还有:

element = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.XPATH, "//input[@autocapitalize]")))
element.click();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-12
    • 1970-01-01
    • 2022-11-01
    • 2021-03-28
    • 2021-03-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多