0

How to retrieve the password from the password text box. I tried by using below code but it's not working.

driver.findElement(By.id("Passwd")).getAttribute("value")

This is the HTML code of the input:

<input type="password"
      placeholder="Password"
      class="input identityinput"
      id="password"
      name="pw"
      onkeypress="checkCaps(event)"
      autocomplete="off"
      onkeyup="if(this.value != ''){
                document.getElementById('clrPw').style.display='block';
               } else {
                document.getElementById('clrPw').style.display='none';
               }"> 
3
  • Can you provide more detailes on "it's not working'? and why is your type email the label username if you are speaking about your passwordfield?
    – bish
    Jul 24, 2015 at 9:16
  • Hi bish, sorry the actual html is: <input type="password" placeholder="Password" class="input identityinput" id="password" name="pw" onkeypress="checkCaps(event)" autocomplete="off" onkeyup="if(this.value != ''){document.getElementById('clrPw').style.display='block';}else{document.getElementById('clrPw').style.display='none';}">
    – sunil
    Jul 24, 2015 at 9:22
  • Hi bish, The above html from salesforce login page.
    – sunil
    Jul 24, 2015 at 9:34

1 Answer 1

1

You search for the wrong id:

You search for id Passwd but your field has the id password so change the statement to:

 By.id("password"))
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.