i was automating the angular application login page using selenium web driver and i need some solution for validating
i have tried to identify the element and found but, while validating the fields for login, it by passes the if condition
here is my code
un = driver.findElement(By.xpath("//*[@id='mat-input-0']"));
un.sendKeys("");
Thread.sleep(500);
boolean une = un.getText().isEmpty();
pw = driver.findElement(By.xpath("//*[@id='mat-input-1']"));
pw.sendKeys("Password123");
Thread.sleep(1000);
boolean pwe = pw.getText().isEmpty();
//System.out.println("text--->"+un.getText());
//System.out.println(pw);
//WebElement element=pw;
//String u = un.getText();
//String p = un.getText();
//if(un!=null && pw!=null && (!un.getText().isEmpty()&&!pw.getText().isEmpty()))
//if(un!=null && pw!=null && (une!=true && pwe!=true))
//if((un!=null && un.getText()!=null && !un.getText().isEmpty()) && (pw!=null && pw.getText()!=null && !pw.getText().isEmpty()))
if(un!=null && pw!=null && (une=false) && (pwe=false))
{
driver.findElement(By.xpath("//button[@class='eta-float mat-raised-button mat-primary']")).click();
Thread.sleep(1000);
//logout menu
driver.findElement(By.xpath("/html/body/app-root/div/mat-toolbar/mat-toolbar-row/button[3]")).click();
Thread.sleep(2000);
//logout option
driver.findElement(By.xpath("/html/body/div/div[2]/div/div/div/button[1]"));
driver.quit();
}
else
{
System.out.println("Please provide valid credentials!");
}
everytime only else part is executed