Wanted to locate an element with python selenium 4. My code:
x = s.find_element(By.XPATH,"//input[@id='fieldname3_1']")
The HTML looks like
<input aria-label="" id="fieldname3_1" name="fieldname3_1" type="text" value="" aria-invalid="false">
My error:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@id='fieldname3_1']"}
CodePudding user response:
Check the id
value, also use WebDriveWait
for the elements to load.
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")