繁体   English   中英

如何使用 Selenium 和 Python 3.8 在 HTML 中单击输入元素

[英]How to click in an input element in a HTML using Selenium with Python 3.8

我对 Selenium 和 Python 很陌生...

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

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

我已经尝试了以下步骤:

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

driver.find_element_by_class_name("XTCLo x3qfX") by class 名称

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

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

以下导入的结果是什么:

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();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM