How To Validate a Login Page with Validations in Selenium Webdriver ?

1 Test if user is able to login successfully. A User must be registered already correct username,correct password 1)Enter input(correct )username and password on the respective fields 2)click submit/login User must successfully login to the web page (note down the results you have observed)
2 Test if unregistered users is not able to login to the site A incorrect username,incorrect password 1)Enter input(incorrect )username and password on the respective fields 2)click submit/login Proper error must be displayed and prompt to enter login again (note down the results you have observed)
3 Test with valid username and empty password such that login must get failed B User must be registered already valid username and empty password 1)enter the valid username in the user id and enter no password in the password field Proper error must be displayed and prompt to enter login again (note down the results you have observed)
4 Test with empty username and valid password such that login must get failed B registered user’s password empty username and valid password 1)leave the username empty in the user id and enter a valid user’s password in the password field Proper error must be displayed and prompt to enter login again (note down the results you have observed)
5 Test with empty username and empty password and check if login fails A 1)Enter nothing in the mail id and password field 2)click submit button Proper error must be displayed and prompt to enter login again
Murali Train Asked on December 16, 2014 in Selenium WebDriver.
Add Comment
1 Answer(s)

Hello Murali,

The answer is quite simple (As per me), create separate method for each validation, for ex:


import java.util.concurrent.TimeUnit;

import org.openqa.selenium.*;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.testng.annotations.AfterMethod;

import org.testng.annotations.AfterTest;

import org.testng.annotations.Test;
public class Validations {

private WebDriver driver;
@Test

public void valid() throws Exception {

driver = new FirefoxDriver();

driver.get("https://accounts.google.com/");

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

driver.findElement(By.id("Email")).sendKeys("abc");

driver.findElement(By.id("Passwd")).sendKeys("xyz");

driver.findElement(By.id("signIn")).click();

}
@Test

public void invalid_BlankPassword() throws Exception {

driver = new FirefoxDriver();

driver.get("https://accounts.google.com/");

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

driver.findElement(By.id("Email")).sendKeys("abc");

driver.findElement(By.id("Passwd")).sendKeys("");

driver.findElement(By.id("signIn")).click();

}
@AfterMethod

public void tearDown() throws Exception {

driver.quit();

}

}

SACHIN Vice Professor Answered on December 16, 2014.

Hi Sachin

Thank you for your valuable reply.

I got solution almost, but I have one small doubt.

1. Here you were written two methods, One for valid and second for invalid with blank password , Right ?

Then I have question, we need to write different methods like

1.  username and password Blank and capture error message
2. Username blank and capture error message
3, password blank and capture error message
4…..etc

Is it Correct ?

And as per my question, we will get error pop for every invalid test case, then how we capture error pop in the script ?

In real time,

1. what approach is used to validate a webpage ?

2. Is valid and invalid test case scripts are written parallel or written scripts separate for valid and invalid test cases ?

Thanks in Advance!!!!!

on December 17, 2014.

Yes, this is good if you write like this. OR else one method you can write but but other/another tester should also understand what you have written. Test Scripts should be readable.Error message is DEPEND on your application (Ex: Just text or alert).If error message are displaying beside/above/below your mandatory fields then use getText() method to get the error message, if it is alert then use getText() method  to get text from the alert.1. what approach is used to validate a webpage ?Ans: It’s depend on Tester to Tester. And what you mean by validate & what is verify then?. What is the difference?.2. Is valid and invalid test case scripts are written parallel or written scripts separate for valid and invalid test cases ?Ans: It’s depend on Tester to Tester.PLEASE learn basics from toolsqa.com.

on December 19, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.