I am trying to write a java script using selenium web driver to verify if a user already exist during the sign up .
when a user access to my website he click on "become a tinze"
then he complete the form and clique on "join"
if the mail already exist message "Email Already exist" displayed .
my script successfully complete the form but it can't detect the message "Email Already exist"
here is the html code of the message that I'm trying to detect
<p name="already" style="color:Red;" class="ng-binding">Email Already exist</p>
and here is the code I use to verify if the text is displayed but it always show me detected
driver.findElement(By.cssSelector("span.ng-scope")).click();
int v = 0,i=0;
System.out.println("enter while");
while(v==0){
try{
WebElement txtbox_username = driver.findElement(By.id("firstname"));
if(txtbox_username.isDisplayed()){
v=1;
System.out.println("Complete the forme");}}
catch(NoSuchElementException nsee){
i++;
System.out.println("Try number:"+i); }}
driver.findElement(By.id("firstname")).sendKeys("haha");
driver.findElement(By.id("lastname")).sendKeys("haha");
driver.findElement(By.name("email")).sendKeys("hah@ahla.com");
driver.findElement(By.id("password")).sendKeys("yassiryakhlaf");
driver.findElement(By.id("signmeup")).click();
System.out.println(driver.findElement(By.id("firstname")).getText());
try {Boolean display = driver.findElement(By.xpath("//p[@name='already']")).getText().equals("Email Already exist");
if (display){System.out.println("detected");}
else{System.out.println("not detected");}
} catch (NoSuchElementException e) {System.out.println("nott detected");}