eclipse - Selenium Java - How To Find Element That Dynamically Changes Type? -


i'm writing tests login page using selenium webdriver in eclipse. password field on login page first loaded text field (passwordtext) security reasons. when user places cursor username or password field password field type changed password (password) using javascript.

the problem selenium test cannot find password field. comes error 'org.openqa.selenium.nosuchelementexception: unable locate element: {"method":"id","selector":"password"}'

code using:

driver.get(baseurl + "/login"); driver.findelement(by.id("username")).clear(); driver.findelement(by.id("username")).sendkeys("username1"); driver.findelement(by.id("password")).clear(); driver.findelement(by.id("password")).sendkeys("mypassword"); 

how can write code correctly find password field?

i have worked out answer , add here else similar issue.

the resolution first find field first id - passwordtext , sendkeys field using id has changed after cursor focus - password.

driver.findelement(by.id("username")).clear(); driver.findelement(by.id("username")).sendkeys("username1"); driver.findelement(by.id("passwordtext")).clear(); driver.findelement(by.id("password")).sendkeys("mypassword"); 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -