Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

I've been trying to 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:

  1. pass1=driver.find_element_by_name("PASSFIELD1")

  2. pass1=driver.find_element_by_id("PASSFIELD1")

  3. 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)

  4. 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?

1 Answer

0 votes
by (62.9k points)

 The problem is that your input tag is inside an iframe, you need to switch to(Method which gives you access to switch frames and windows) it first:

frame = driver.find_element_by_xpath('//frame[@name="main"]') driver.switch_to.frame(frame) pass1 = driver.find_element_by_id("PASSFIELD1")

I hope this helps!

If you wish to Learn Selenium visit this Selenium Training by Intellipaat.

Browse Categories

...