網站:DeepL
要翻譯的原始文本的 XPath:
//textarea[contains(@class, 'lmt__source_textarea')]
錯誤:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//textarea[contains(@class, 'lmt__source_textarea')]"}
我也在傳遞餅干。
注意:XPath 在 Chrome 開發工具中作業。
uj5u.com熱心網友回復:
要在元素中發送字符序列,您需要為element_to_be_clickable()引入WebDriverWait,您可以使用以下定位器策略:
driver.get("https://www.deepl.com/translator")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.dl_cookieBanner--buttonClose"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//textarea[@aria-labelledby='translation-source-heading']"))).send_keys("Good Boy")
注意:您必須添加以下匯入:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
瀏覽器快照:

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/473999.html
標籤:Python 硒 硒网络驱动程序 路径 网络驱动程序等待
上一篇:嘗試了所有seleniumclick選項,但click不適用于元素
下一篇:單擊第一個表格行
