Batch Testing as well as Data Driven Testing inwards Selenium

Batch Testing, Data Driven Testing inward Selenium

Batch Testing, Data Driven Testing inside Batch Testing

Batch Testing: Executing serial of Tests.

Data Driven Testing: Executing the Same functionality amongst multiple sets of Test Data.

Batch Testing inward Selenium:

i) Batch Testing using Testing Framework (JUnit/TestNG) Annotations
ii) Batch Testing without using Testing Framework Annotations (using programming features)
-----------------------------------------------------
AUT (Application Under Test)
gcrShop Web Portal ("www.gcrit.com/build3/admin/")

Test Cases:
1) Verify Admin Login Functionality

2) Verify "Manufacturers" Link (Element) beingness inward index page of the Application(after Login to Application)

3) Verify Redirect Functionality betwixt Admin in addition to User Interfaces.

4) Data Driven Testing for Admin Login Functionality
-----------------------------------------------------
1) Verify Admin Login Functionality
Test Steps:

i) Launch the Browser
ii) Navigate to Admin Interface ("http://www.gcrit.com/build3/admin/")
iii) Enter Username
iv) Enter Password
v) Click "Login" Button

Input Data:
Username = admin
Password = admin@123

Verification Point
Capture the Current URL in addition to Compare amongst Expected

Expected URL: "http://www.gcrit.com/build3/admin/index.php"

Inspect Element:

Username -Edit box - lift - username
Password - edit box - lift - password
Login - Button - id - tdb1
-----------------------------------------------------
2) Verify "Manufacturers" Link (Element) beingness inward index page of the Application (after Login to Application)
Pre-Condition: Login to Application

Verification Point:
Check the Existence of "Manufacturers" Link, if exists thus give-up the ghost otherwise fail.

Exception Handling
Insert "NoSuchElementException"
----------------------------------------
3) Verify Redirect Functionality betwixt Admin in addition to User Interfaces.

Pre-Condition: Login to Application

Click "Online Catalog" Link inward Index page.

Verification Point
Capture the Current URL in addition to Compare amongst expected

Expected URL:
http://www.gcrit.com/build3/
------------------------------------------------------
4) Data Driven Testing for Admin Login Functionality

Test Steps:

i) Launch the Browser
ii) Navigate to Admin Interface ("http://www.gcrit.com/build3/admin/")
iii) Enter Username
iv) Enter Password
v) Click "Login" Button

Input Data:
Source File / Test Data file: input.txt

Verification Point
Capture the Current URL in addition to Compare amongst Expected

Expected URL: "http://www.gcrit.com/build3/admin/index.php"

Inspect Element:

Username -Edit box - lift - username
Password - edit box - lift - password
Login - Button - id - tdb1
-----------------------------------------------------
Create Reusable Components (User defined Methods)

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

public cast Class1 {
public static WebDriver driver;   
public static String line;
//Launch Browser
public void launchBrowser(){
System.setProperty("webdriver.chrome.driver", "E:/chromedriver.exe");
driver = novel ChromeDriver();   
}
//Close Browser
public void closeBrowser(){
driver.close();   
}
//Adming Login
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, IOException {
//Create Object
Class1 obj = novel Class1();

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

if (Url.equals("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 (Element) Existence inward index page of the Application(after Login to Application)
obj.launchBrowser();
obj.adminLogin("admin", "admin@123");
Thread.sleep(3000);
try
{
if (driver.findElement(By.linkText("Manufacturers")).isDisplayed()){
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");
Thread.sleep(3000);
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: -Redirecting from Admin to User Interface - Passed");
}
else
{
System.out.println("Test Case 3: -Not Redirecting from Admin to User Interface - Failed");
}
obj.closeBrowser();
//-----------------------------------------
//Test Case 4: Data Driven Testing for Admin Login Functionality
FileReader file = novel FileReader("C:\\Users\\gcreddy\\Desktop\\input.txt");   
BufferedReader br = novel BufferedReader(file);

int Count = 0;
while ((line = br.readLine()) != null) {
Count = Count+1;
if (Count > 1){
obj.launchBrowser();
String [] inputData = line.split(", ", 2);
obj.adminLogin(inputData[0], inputData[1]);
Thread.sleep(4000);
String url3 = driver.getCurrentUrl();

if (url3.equals("http://www.gcrit.com/build3/admin/index.php")){
System.out.println("Test Case 4: Iteration -" + (Count-1) + " - Admin Login Successful Passed");   
}
else {
System.out.println("Test Case 4: Iteration -" + (Count-1) + " - Admin Login Unsuccessful Failed");   
}
obj.closeBrowser();   
}
}
}
}
----------------------------------------------------

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