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

2024-07-08 14:33:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我对使用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


Tags: 版本inputbyhtmltypedriverselenium步骤
1条回答
网友
1楼 · 发布于 2024-07-08 14:33:01

以下导入的结果是什么:

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

相关问题 更多 >

    热门问题