簡體   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