I created a java class and written logic for password and confirm password in the class. while calling the class in another class by creating class object, it is showing null pointer exception.
public class Verify_password {
WebDriver driver;
String pwd = "password";
String confirm_pwd = "password";
String wrong_pwd="yogesh";
public void password_match(){
//Password = confirm password
driver.findElement(By.id("encrypted_pwd")).clear();
driver.findElement(By.id("confirm_pwd")).clear();
driver.findElement(By.id("encrypted_pwd")).sendKeys(pwd);
driver.findElement(By.id("confirm_pwd")).sendKeys(confirm_pwd);
driver.findElement(By.id("submit-btn")).click();
if(pwd ==confirm_pwd){
System.out.println("Password Match");
}
else{
System.out.println("Password doesn't Match");
}
}
Calling this class to another class by:
Verify_password password1 = new Verify_password();
password1.password_match1();
Can someone verify and confirm that is it okay or not?
Thanks