First post - verifying the error messages in Facebook

66 views
Skip to first unread message

T E

unread,
Jul 14, 2021, 7:49:12 AM7/14/21
to Selenium Users
Hi all, 
I am new to this forum.
I have been trying to automate Sign-Up in Facebook. 
I have automated a successful sign-up but I have some doubts on how to verify the error messages in Facebook Sign-Up if I leave any required field blank. I am a complete newbie btw. 
This is what I am trying to do : 
1. Launch the URL : https://www.facebook.com/
2. Enter the First name and Last name
3. Leave the Email/Phone field blank :
4. Leave the password field blank :
5. Select dob and gender 
6. Click on Sign-up 
Now till Step 6 everything I did well but now after clicking sign-up I want to read the error messages and I need to print it in console 
I have no idea how to locate that specific error element 

IDE : Eclipse 
Language : Java
Selenium version : 3.14
OS : Win 10 64bit

I'm attaching some screenshots in that I need to capture that particular errors through selenium(java). 

Thanks 
error1.png
error1.png

mohanap...@gmail.com

unread,
Jul 18, 2021, 7:02:43 AM7/18/21
to Selenium Users

String exp = "Enter  a combination of atleast 6 numbers,letters and punctuvation......";      
  //identify actual error message      
  WebElement m = driver.findElement(By.className("xxxxx"));    
   String act = m.getText();     
  System.out.println("Error message is: "+ act);      
  //verify error message with Assertion   
    Assert.assertEquals(exp, act);      
 driver.quit();
Reply all
Reply to author
Forward
0 new messages