I've been trying fill input:
<input id="PASSFIELD1" class="logField" type="password" onkeyup="next(this, event);" maxlength="1" autocomplete="off" name="PASSFIELD1"></input>
To do this, I have to find this element.
I tried below things:
pass1=driver.find_element_by_name("PASSFIELD1")
pass1=driver.find_element_by_id("PASSFIELD1")
pass1= driver.find_element_by_xpath("/html/body/div[4]/div/div/div[2]/div/form/div[3]/table/tbody/tr[3]/td[2]/div/input[1]")
(path from firebug)
Even wait 100 seconds for it
self.wait.until(EC.visibility_of_element_located((By.XPATH,"/html/body/div[4]/div/div/div[2]/div/form/div[3]/table/tbody/tr[3]/td[2]/div/input[1]"))) self.assertTrue(self.driver.find_element_by_xpath("/html/body/div[4]/div/div/div[2]/div/form/div[3]/table/tbody/tr[3]/td[2]/div/input[1]"))
I always get:
selenium.common.exceptions.NoSuchElementException: Message: 'Unable to locate element: (...)
Do you know what I am doing wrong?
The easiest way to check if an element exists in a web page is with the Selenium webdriver find_elements_by_css_selector() function. If the element exists, then find_elements_by_css_selector() will return a list with those elements.
1. Change in source code of the webpage. It's possible that the source code of the webpage may have been changed since the last time you accessed it. Change your code according to the new source to solve the issue.
You can use XPath to either locate the element in absolute terms (not advised), or relative to an element that does have an id or name attribute. XPath locators can also be used to specify elements via attributes other than id and name.
The problem is that your input
tag is inside an iframe
, you need to switch to it first:
frame = driver.find_element_by_xpath('//frame[@name="main"]') driver.switch_to.frame(frame) pass1 = driver.find_element_by_id("PASSFIELD1")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With