[英]Python Selenium - Any way to get send text within this textbox?
我正在嘗試 select 一個文本框來輸入一些數據,問題是我不知道如何獲取它的元素:
這就是我檢查它時得到的結果:
<input class=" input" maxlength="255" type="text" aria-describedby="" placeholder="" id="8624:0" data-aura-rendered-by="8628:0" data-interactive-lib-uid="28">
問題是,這基本上是為了填充forms,而id,render by,uid 號都變了。 有什么我可以嘗試的嗎?
要將字符序列發送到<input>
元素,您需要為element_to_be_clickable()
引入WebDriverWait ,並且可以使用以下任一定位器策略:
使用CSS_SELECTOR
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.input[type='text'][data-aura-rendered-by][aria-describedby]"))).send_keys("Smece")
使用XPATH
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@class=' input' and @type='text'][@data-aura-rendered-by and @aria-describedby]"))).send_keys("Smece")
注意:您必須添加以下導入:
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.