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

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -