无法定位元素:{"method":"xpath","selector":"//input[@id='fieldname3_1']"}
Unable to locate element: {"method":"xpath","selector":"//input[@id='fieldname3_1']"}
想用 python selenium 4 定位一个元素。
我的代码:
x = s.find_element(By.XPATH,"//input[@id='fieldname3_1']")
https://thearbacademy.com/arbitrage-betting-calculator/
link 页面
HTML长得像
<input aria-label="" id="fieldname3_1" name="fieldname3_1" class="field number large valid" type="text" value="" aria-invalid="false">
我的错误:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@id='fieldname3_1']"}
检查 id
值,也使用 WebDriveWait
作为要加载的元素。
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
myElem = WebDriverWait(driver, 10).until(EC.visibility_of_all_elements_located((By.ID, 'fieldname2_1')))
#myElem.send_keys("123")
想用 python selenium 4 定位一个元素。 我的代码:
x = s.find_element(By.XPATH,"//input[@id='fieldname3_1']")
https://thearbacademy.com/arbitrage-betting-calculator/
link 页面
HTML长得像
<input aria-label="" id="fieldname3_1" name="fieldname3_1" class="field number large valid" type="text" value="" aria-invalid="false">
我的错误:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@id='fieldname3_1']"}
检查 id
值,也使用 WebDriveWait
作为要加载的元素。
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
myElem = WebDriverWait(driver, 10).until(EC.visibility_of_all_elements_located((By.ID, 'fieldname2_1')))
#myElem.send_keys("123")