Data Driven Testing together with Batch Testing

Data Driven Testing in addition to Batch Testing using Selenium

i) Data Driven Testing
ii) Batch Testing
--------------------------------------------
i) Data Driven Testing

1) What is Data Driven Testing?

Testing the Same Functionality amongst multiple inputs

2) Why Data driven Testing?

For Positive in addition to Negative Testing

3) How to ship Data Driven Testing

By Reading Test Data from external files (Text File/Excel File...)
-----------------------------------------------------------
Example:

Data Driven Testing for Login Functionality past times Reading Test Data from a Text File.

Test Case: Verify Login Functionality inwards gcrShop Admin Interface

Test Steps:
i) Launch the Browser
ii) Navigate to "http://gcrit.com/build3/admin/"
iii) Enter Username
iv) Password
v) Click "Login" Button
-----------------------
Input Data/Test Data

Refer: input.txt

Verification Points:

1) Capture the URL later on Login in addition to Compare amongst Expected:
Expected: http://www.gcrit.com/build3/admin/index.php

2) Capture the Error Message in addition to Compare amongst Expected
Expected: Error: Invalid administrator login attempt.
-------------------------------------------------------------
Write Selenium WebDiver Test Case

public aeroplane DataDrivenTesting {
public static WebDriver driver;
public static String Error_Messge;
public static void main(String[] args) throws InterruptedException, IOException {
FileReader file = novel FileReader("C:/Users/gcreddy/Desktop/Input.txt");
BufferedReader br = novel BufferedReader(file);
int Count =0;
int Iteration =0;
String line;
while ((line = br.readLine()) != null){
Count = Count+1;

if (Count > 1){
Iteration = Iteration+1;
String [] inputData = line.split(", ", 2);
driver = novel FirefoxDriver();
driver.get("http://gcrit.com/build3/admin/");
driver.findElement(By.name("username")).sendKeys(inputData[0]);
driver.findElement(By.name("password")).sendKeys(inputData[1]);
driver.findElement(By.id("tdb1")).click();
Thread.sleep(3000);
String url = driver.getCurrentUrl();
//System.out.println(url);
if (! url.contains("http://www.gcrit.com/build3/admin/index.php")){
Error_Messge = driver.findElement(By.className("messageStackError")).getText();
}

if (url.contains("http://www.gcrit.com/build3/admin/index.php")){
System.out.println("Iteration "+Iteration + " -Admin Login Successful -Passed");
}
else if ((! url.contains("http://www.gcrit.com/build3/admin/index.php")) && (Error_Messge.contains("Error: Invalid administrator login attempt."))){
System.out.println("Iteration "+Iteration + " -Admin Login Unsuccessful in addition to Showing Correct Error Message - Passed");
}
else {
System.out.println("Iteration "+Iteration + " -Admin Login Unsuccessful in addition to Not Showing Correct Error message - Failed");
}
driver.close();
}
}
}
}
--------------------------------------------------------------
Assignment:

Verify the maximum Login attempts (Invalid input) for Admin Login Functionality
---------------------------------------------------------------
ii) Batch Testing

Executing Series of Tests

AUT (Application Under Test)
gcrShop Admin Interface (http://www.gcrit.com/build3/admin/)

Test Cases:
1) Verify Admin Login Functionality
2) Verify "Manufacturers" Link Existence inwards the index page of the application (After login to Application)
3) Verify Redirect Functionality betwixt Admin in addition to User Interface (After Login to Admin Interface)
---------------------------------------------------
1) Verify Admin Login Functionality

i) Launch the Browser
ii) Navigate to "http://gcrit.com/build3/admin/"
iii) Enter Username
iv) Password
v) Click "Login" Button
-----------------------
Input Data/Test Data
Username: admin
password: admin@123

Verification Point:
Capture the URL later on Login in addition to Compare amongst Expected:
Expected: http://www.gcrit.com/build3/admin/index.php
-----------------------------------------------------------------
2) Verify "Manufacturers" Link Existence inwards the index page of the application (After login to Application)

i) Launch the Browser
ii) Navigate to "http://gcrit.com/build3/admin/"
iii) Enter Username
iv) Password
v) Click "Login" Button
-----------------------
Input Data/Test Data
Username: admin
Password: admin@123

Verification Point:
Check the beingness of "Manufacturers" Link, if exists in addition to thus run out otherwise fail

Exception Handling:
Insert "NoSuchElementException"
-------------------------------------------------------------
3) Verify Redirect Functionality betwixt Admin in addition to User Interfaces (After Login to Admin Interface)

i) Launch the Browser
ii) Navigate to "http://gcrit.com/build3/admin/"
iii) Enter Username
iv) Password
v) Click "Login" Button
vi) Click "Online Catalog" Link
-------------------------------------
Input Data/Test Data
Username: admin
Password: admin@123

Verification Point:
Capture the URL later on Redirecting in addition to Compare amongst Expected:
Expected: http://www.gcrit.com/build3/
--------------------------------------------------------
Create Reusable Components:

i) Launch Browser
ii) Login to Admin Interface 
iii) Close Browser
-------------------------------------------------------
Create Selenium Test Batch

public aeroplane BatchTesting {
public static WebDriver driver;
//Launch Browser
public void launchBrowser(){
driver = novel FirefoxDriver();
}
//Close Browser
public void closeBrowser(){
driver.close();
}
public void adminLogin(String Username, String Password){
driver.get("http://www.gcrit.com/build3/admin");
driver.findElement(By.name("username")).sendKeys(Username);
driver.findElement(By.name("password")).sendKeys(Password);
driver.findElement(By.id("tdb1")).click();
}
public static void main(String[] args) throws InterruptedException {
//Create Object
BatchTesting obj = novel BatchTesting();

//Test Case 1: Verify Admin Login Functionality
obj.launchBrowser();
obj.adminLogin("admin", "admin@123");

String url = driver.getCurrentUrl();

if (url.contains("http://www.gcrit.com/build3/admin/index.php")){
System.out.println("Test Case 1: Admin Login Successful - Passed");
}
else {
System.out.println("Test Case 1: Admin Login Unsuccessful - Failed");
}
obj.closeBrowser();
//-------------------------------------------------------
//Test Case 2: Verify "Manufacturers" Link Existence inwards the index page 
obj.launchBrowser();
obj.adminLogin("admin", "admin@123");
try
{
boolean linkExistence = driver.findElement(By.linkText("Manufacturers")).isDisplayed();

if (linkExistence == true){
System.out.println("Test Case 2: Manufacturers Link Exists - Passed");
}
}
catch (NoSuchElementException e) {
System.out.println("Test Case 2: Manufacturers Link Not Exists - Failed");
}
obj.closeBrowser();
//------------------------------------------------
//Test Case 3:Verify Redirect Functionality betwixt Admin in addition to User Interfaces
obj.launchBrowser();
obj.adminLogin("admin", "admin@123");
driver.findElement(By.linkText("Online Catalog")).click();
Thread.sleep(3000);
String url2 = driver.getCurrentUrl();

if (url2.equals("http://www.gcrit.com/build3/")){
System.out.println("Test Case 3: Redirected from Admin to User Interface - Passed");
}
else {
System.out.println("Test Case 3: Not Redirected from Admin to User Interface - Failed");
}
obj.closeBrowser();
//------------------------------------------------------
}
}
-----------------------------------------------------------
Test Case: Verify Communication betwixt 2 dissimilar Browsers

Steps:
i) Create Mozilla Firefox Browser in addition to Google Chrome Browser
ii) Launch the Two dissimilar applications
iii) Interact from i application to another
iv) Close browsers
--------------------------------------------------
WebDriver Firefoxdriver = novel FirefoxDriver();

System.setProperty("webdriver.chrome.driver", "E:/chromedriver.exe");
WebDriver ChromeDriver = novel ChromeDriver();

Firefoxdriver.get("https://www.gmail.com");
String Text = Firefoxdriver.findElement(By.tagName("h1")).getText();

ChromeDriver.get("http://www.gcrit.com/build3/create_account.php?osCsid=38s238i67jk84tno82uhfd7mk2");
ChromeDriver.findElement(By.name("firstname")).sendKeys(Text);

Firefoxdriver.close();
ChromeDriver.close();
-------------------------------------------------------------

Sumber http://www.gcreddy.com/
Post a Comment (0)
Previous Post Next Post