Selenium Live Project Tutorial


Selenium Tutorial
Selenium Live Project Tutorial

Functional Test Automation using Selenium,

1) Project Information
2) Project Description
3) Stake holders of the Project
4) Interfaces of the Project /AUT
5) Features to be Tested in Admin Interface
6) Features to be Tested in User Interface
7) Test Requirements, Test Scenarios, and Test Cases.
8 Derive Smoke Test Cases for Admin Interface
9) Derive Smoke Test cases for User Interface
10) Derive Comprehensive (All Possible) Test Cases for Admin Interface
11) Derive Comprehensive (All Possible) Test Cases for User Interface
-------------------------------------------
1) AUT / Project Information

Domain: Ecommerce
(An Area- General, Project Business Area-Software Development/Testing)

Important Domains in the IT Industry:

BFSI,
Banking,
Insurance,
ERP,
Telecom,
Healthcare,
Ecommerce,
Retail Market,
Others... (Anti Virus, Games, System Software etc...)

AUT - Application Under Test
-------------------------------------------
Sub-Domain: Business to Customer (B2C)
(Ecommerce - Business to Business (B2B), B2C, C2B, C2C)

Application: Online shopping web portal

Application Environment: LAMP (Linux, Apache, MySQL, and PHP)

Type of the AUT: gcrShop (Internet Public Application)
-------------------------------------------
2) Project Description

This Web portal has 2 important interfaces 1) Admin Interface (Maintenance), 2) User Interface (Business Operations)
Categories:
i) Some Web developers develop Web portals and provide interface (for business operations) between manufacturers and Customers,
Ex: Snapdeal, Flipcart etc...

ii) Some Manufactures develop their own portal for online shopping,
Ex: telibuy.in etc...

Note: Our AUT (www.gcrit.com) is first category of Project,
-------------------------
In Admin interface, manufacturers first Register, Add Categories, Edit Categories, and Delete categories,
Add Products, Edit Products, delete Products, Track Reports/Status, 
Portal owner Admin user Add Currencies, Edit Currencies, Delete Currencies, and Set default Currency etc...

In User Interface, anybody can launch the Application, View products, Search products, Customer Registration,
Customer Login, Buy Products (select products, Update Quantity, Checkout, Track Orders, etc...)
-------------------------
Web Developer /Web Portal developer provides interface between Manufacturers and Customers,
Manufacturers  show their products, and sell,
Financial Service providers (Ex: Paypal etc...) provide Payment transactions,
Customers view products info, search products, Register, login, Buy products, Track orders etc...
-------------------------------------------
3) Stake Holders of the Project

i) Web Portal Developer/s...
ii) Manufacturer/s
iii) Financial Service provider/s
iv) Distributers of the Manufacturer/s
v) Courier service provider/s
vi) Customers (General, and Registered Customers...)
-------------------------------------------
4) Interfaces of the Project /AUT

This (gcrit.com) Application has two important Interfaces,

i) gcrShop Admin Interface (Handle (Add/Edit/Delete)Master Data, Maintenance of the App/Business...)

Master Data: Required Data for Running the Application.

(Ex: In Banking Application, Add Bank info, Branches, ATMs, Products, Bank history...)

Maintenance of the Business / Application.
--------------------
gcrShop Admin Interface details:

URL: http://www.gcrit.com/build3/admin

http - Hyper Text Transfer protocol 
www - World Wide Web
gcrit.com - Web Domain / Web Address
build3 - Folder
admin - Sub-Folder
Admin Login:
Username: admin
password: admin@123
--------------------
ii) gcrShop User Interface (Business Operations (View product, search products, registration, login, 
buy products, handle orders, etc...)

gcrShop User Interface Details:

URL: http://www.gcrit.com/build3/

Note: No restrictions, anybody can use the application, but if you want buy products then you need to
register (Free) and Login...
------------------------
www.gcrit.com/build3/

www - World Wide Web 
gcrit.com - Web Domain / Web Address 
build3 - Folder 
-----------------------
http://us.sulekha.com/

us - Sub Domain
sulekha.com - Domain

http://www.korada.com/telugu/

korada.com - Domain
telugu - Folder
-------------------------------------------
5) Features to be Tested in Admin Interface

i) Launch the Application
ii) Admin Login to Application
iii) Redirect operation from Admin to User Interface
iv) Add/Edit/Delete Manufacturers
v) Add / Edit / Delete Categories
vi) Add / Edit / Delete Products
vii) Add/Edit/Delete/Set as default Currency
viii) User & Product Reports and Track Status
-------------------------------------------
6) Features to be Tested in User Interface

i) Launch the Application
ii) Search, View Products
iii) Customer Registration
iv) Customer Login
v) Buy Products (Login, Buy Product/s, Update Quantity, delete products, Change the Details, payment option, checkout.)
vi) Track Order status
-------------------------------------------
7) Test Requirements, Test Scenarios, and Test Cases.

Business Requirements
Software Requirements
Test Requirements
Test Scenarios (Positive & Negative)
Test Cases (* Test Data is required for some Test cases only)
------------------------
Test Requirement/s
Functional Requirement
Non Functional Requirement 
Performance Requirement
Load Test Requirement
Stress Test Requirement
Spike Test Requirement
Endurance Test Requirement...
Usability Testing
Reliability Testing
Localization Testing / Internationalization Testing 
Availability Testing
Configuration Testing
Recovery Testing
Etc...
--------------------------
Functional Test Requirement
Ex: Admin user Login to Admin Interface of the Application
---------------------
Test Scenarios:
i) Admin Login with valid Username, and Password (Positive Test Scenario) 
ii) Admin Login with invalid Username, and valid Password (Login failed attempt) (Negative scenario 1)
iii) Admin Login with valid Username, and invalid Password (Login failed attempt) (Negative scenario 2)
iv) Admin Login with invalid Username, and invalid Password (Login failed attempt) (Negative scenario 3)
v) Admin Login with Blank Username, and valid Password (Login failed attempt) (Negative scenario 4)
vi) Admin Login with Valid Username, and Blank Password (Login failed attempt) (Negative scenario 5)
Etc...
----------------------
Test Case:

Test  Case ID: TC_Ad_001
Test Case Name/Description: Admin user Login to Admin Interface of the Application (gcrShop)
Test Suite Id: TS_Ad_01
Priority:
Pre-Condition:
Steps to be Executed:
Post-Condition:
Expected Result:
Hardware and Software:
Actual Result:
Status: 
-------------------------
Test Data:
Username: admin
Password: admin@123
--------------------------
No Test Data for some Test Cases (NA)
Ex: Redirect from Admin to User Interface before Admin Login
-------------------------------------------
8) Derive Smoke Test cases for Admin Interface

i) Verify Launch the Application (Admin Interface) with valid URL
ii) Verify Required Elements availability of Login Page
iii) Verify Admin Login with valid input data to Admin Interface of the Application
iv) Verify Required Elements availability of Admin index page (after Login)
v) Verify Add Manufacturer
vi) Verify Add Category
vii) Verify Add Product
viii) verify Add Currency
ix) Set default Currency
Etc...
-------------------------------------------
9) Derive Smoke Test cases for User Interface

i) Verify Launch the User Interface of the Application with valid URL
ii) Verify Required Elements availability of User interface Homepage
iii) Verify Customer Registration to the Application with valid Input data
iv) Verify Customer Login to User Interface
v) Verify Add Product/s (Update Quantity...)
vi) Verify Change Customer Address details
vii) Verify Checkout
viii) Verify customer Track Order
Etc...
-------------------------------------------
10) Derive Comprehensive (All possible test cases) Test cases for Admin Interface

i) Verify Launch the Application (Admin Interface) with valid URL
ii) Verify Required Elements availability of Login Page
iii) Verify Redirect from Admin to User Interface before Admin Login
iv) Verify Admin Login with valid input data to Admin Interface of the Application
v) Verify Redirect from Admin to User Interface After Admin Login
vi) Verify Admin Login with Invalid input data (Login failed attempt) to Admin Interface of the Application
vii) Verify Admin Failed Login Attempt after 3 Failed attempts
viii) Verify Admin Login with valid input data to Admin Interface of the Application within 5 minutes
ix) Verify Admin Login with valid input data to Admin Interface of the Application after 5 minutes
x) Verify Required Elements availability of Admin Index page (After Admin Login)
xi) Verify Add Manufacturer
xii) Verify Edit Manufacturer
xiii) Verify Delete Manufacturer
xiv) Verify Add Category
xv) Verify Edit Category
xvi) Verify Delete Category
xvii) Verify Add Product
xviii) Verify Edit Product
xix) Verify Delete Product
xx) Verify Add Currency
xxi) Verify Edit Currency
xxii) Verify Delete Currency
xxiii) Verify Set a Currency a Default
xxiv) Verify Customer Reports
xxv) Verify Product Report
Etc...
-------------------------------------------
11)  Derive Comprehensive (All Possible Test Cases) Test Cases for User Interface

i) Launch gcrShop User Interface with valid URL (http://www.gcrit.com/build3/)
ii) Verify "Elements" present in the User Interface home page
iii) Verify "Products "Search"
iv) Verify "Products "Advanced Search"
v) Verify "create an account" with valid inputs (enter all mandatory fields)
vb) Verify "create an account" with invalid inputs and enter all mandatory fields
vc) Verify "create an account" with invalid inputs and without entering all mandatory fields
vi) Verify "costumer login" in to User Interface with valid inputs
vib) Verify "costumer login" in to User Interface with invalid inputs
vii) Verify "Shopping Cart" before select any product
viii) Verify "Shopping Cart" after select a product/s
a) Verify "Update" in Shopping Cart for single (selected single product only) product 
b) Verify "Update" in Shopping Cart for multiple (selected multiple products) products
c) Verify "Remove" in Shopping Cart for single (selected single product only) product 
d) Verify "Remove" in  Shopping Cart for multiple (selected multiple products) products
xii)  Verify "Checkout" before selecting and product and before login
xiii) Verify "Checkout" after selecting product/s and after login
a) Verify "Change Address" in Checkout process after selecting product/s and after login
b) Verify "Payment Option" in Checkout process after selecting product/s and after login
1) Verify with "Cash on delivery"
2) Verify with "PayPal" 
c) Verify "Add Comments" in Checkout process after selecting product/s and after login
d) Verify "Checkout" Process 
xviii) Verify Customer "LogOff" 
xix) Verify "Close Application" before LogOff
xx) Verify "Close Application" after "LogOff
Etc...
-----------------------------------------------------------------------
Derive Smoke Test Scenarios for Admin Interface

Note 1: If you write some Test Cases while Smoke Test Design, you can copy/use those Test cases for Comprehensive Test Design, Regression Testing also.

Note 2: If you execute some Test Cases while Smoke Testing, then execute those Test cases also (Don't Skip) while Comprehensive Testing.
----------------------------------------------------------------------
1) Verify "Launch Application (gcrShop Web portal Admin Interface)" using valid URL
2) Verify "Admin Login" in gcrShop Web portal Admin Interface with valid Inputs
3) Verify "Important / Required Elements availability" in gcrShop Web portal Admin Interface index page (after Logion)
4) Verify "Add Manufacturer" in gcrShop Web portal Admin Interface index page
5) Verify "Add Category" in gcrShop Web portal Admin Interface index page
6) Verify "Add Product" in gcrShop Web portal Admin Interface index page
7) Verify "Add Currency" in gcrShop Web portal Admin Interface index page
8) Verify "Track Report" in gcrShop Web portal Admin Interface index page
----------------------------------------------------------------
1) Verify "Launch Application" (Admin Interface) with Valid URL

Test Case Name: Lunch Admin Interface of the Application (gcrShop) with valid URL
Test Steps:
1) Instantiate Browser (For Selenium 3.0, it is required to Instantiate every Browser including Mozilla Firefox)
(You can launch either Firefox or Chrome or MS Edge etc...)
2) Create Browser driver instance /object
3) Navigate to gcrShop Admin Page ("http://www.gcrit.com/build3/admin/")
Verification Point
1) Verify Elements (Username, Password, Login) in the Login Page, if they are available then pass
Note: We can't use "Page Title" (It may duplicate), or URL (sometimes page may not open /white screen).
Test Data / Input Data
NA
Test Result / Status (Pass / Fail) : * After Test Case Execution 
----------------------------------------------------------------
2) Verify "Admin Login" with valid inputs

Test Case Name: Verify gcrShop Admin Login in Admin Interface with valid Inputs (Username and Password)
Test Steps: 
1) Instantiate Browser 
2) Create Browser driver instance /object
3) Navigate to gcrShop Admin Page ("http://www.gcrit.com/build3/admin/")
4) Enter valid "Username"
5) Enter valid "Password"
6) Click "Login"

Verification Point/s:
1) Capture the Browser URL (After Login) and Compare with Expected URL

Test Data / Input Data:
1) Username: "admin"
2) Password: "admin@123"

Test Result / Status (Pass / Fail):
----------------------------------------------------------------
3) Verify "Important / Required Elements Availability and check the functionality" in gcrShop Web portal Admin Interface index page (after Login)

Test Steps:
1) Instantiate Browser (For Selenium 3.0, it is required to Instantiate every Browser including Mozilla Firefox)
(You can launch either Firefox or Chrome or MS Edge etc...)
2) Create Browser driver instance /object
3) Navigate to gcrShop Admin Page ("http://www.gcrit.com/build3/admin/")
4) Enter valid "Username"
5) Enter valid "Password"
6) Enter / Click "Login" Button
* Verification for Login is Optional

Verification Point/s
Verify "Manufacturer", "Category", "Currency" and "Product" Elements availability and Check / Click...

Test Data / Input Data

Username: "admin"
Password: "admin@123"
----------------------------------------------------------------
4) Verify "Add Manufacturer" in gcrShop Web portal Admin Interface index page

Test Steps:
1) Instantiate Browser (For Selenium 3.0, it is required to Instantiate every Browser including Mozilla Firefox)
(You can launch either Firefox or Chrome or MS Edge etc...)
2) Create Browser driver instance /object
3) Navigate to gcrShop Admin Page ("http://www.gcrit.com/build3/admin/")
4) Enter valid "Username"
5) Enter valid "Password"
6) Enter / Click "Login" Button
* Verification for Login is Optional
7) Click "Manufacturer" Link
8) Select "Insert" Link
9) Enter "Manufacturer Name"
10) Upload "Manufacturer Image" * Optional
11) Enter "Manufacturer URL" * Optional

Verification Point/s
Capture Manufacturers count Before Add Manufacturer and After Add Manufacturer and Compare these two values.

Username: "admin"
Password: "admin@123"
----------------
Manufacturer Name: Ravindra
Manufacturer Image File * Optional
Manufacturer URL * Optional
----------------------------------------------------------------
Test Types
Functional Testing
Non Functional Testing
Structural Testing
Change Related Testing or Regression Testing or Conformation Testing

Non -Functional 
Functional Testing
Functionality Testing
Security Testing...

Non Functional Testing
Performance Testing
Load Testing
Stress Testing
Spike Testing
Data volume Testing...
Usability Testing
Reliability Testing 
Recovery Testing
Availability Testing
Localization Testing / Internationalization Testing
Configuration Testing
Installation Testing Etc...
----------------------------------------------------------------
5) Verify "Add Category" in gcrShop Web portal Admin Interface index page

1) Instantiate Browser (For Selenium 3.0, it is required to Instantiate every Browser including Mozilla Firefox)
(You can launch either Firefox or Chrome or MS Edge etc...)
2) Create Browser driver instance /object
3) Navigate to gcrShop Admin Page ("http://www.gcrit.com/build3/admin/")
4) Enter valid "Username"
5) Enter valid "Password"
6) Enter / Click "Login" Button
* Verification for Login is Optional
7) Click "Categories/Products" Link
8) Click "New Category" Link
9) Enter "Category Name"
10) Upload "Category Image" * Optional
11) Enter a value for Sort Order * Optional / Important
12) Click "Save" Button

Verification Point/s
Find Entered category in the Categories list and observe the sort position also

Test Data:
Username: "admin"
Password: "admin@123"
------------
Category name: abcde
Category Image File * Optional
Category Sort value": 7 * Optional
----------------------------------------------------------------
Selenium Web Driver Test Batch for Admin Login Interface Smoke Tests

package abcd;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class AdminInterface {

public static WebDriver driver;

public void launchApplication(){
driver = new FirefoxDriver();
driver.get("http://www.gcrit.com/build3/admin/");
}
public void closeApplication(){
driver.close();
}
public void adminLogin(String Username, String Password){
driver.findElement(By.name("username")).sendKeys(Username);
driver.findElement(By.name("password")).sendKeys(Password);
driver.findElement(By.id("tdb1")).click();
}
public void addManufacturers(String Name){
driver.findElement(By.linkText("Manufacturers")).click();
driver.findElement(By.className("ui-button-text")).click();
driver.findElement(By.name("manufacturers_name")).sendKeys(Name);
driver.findElement(By.id("tdb1")).click();
}
public void addCategory(String Name){
driver.findElement(By.linkText("Categories/Products")).click();
driver.findElement(By.className("ui-button-text")).click();
driver.findElement(By.name("categories_name[1]")).sendKeys(Name);
driver.findElement(By.id("tdb3")).click();
}
/*public void addProduct(String Name){
driver.findElement(By.linkText("Categories/Products")).click();
driver.findElement(By.xpath(".//*[@id='tdb2']/span[2]")).click();
driver.findElement(By.name("manufacturers_name")).sendKeys(Name);
driver.findElement(By.id("tdb1")).click();
}*/
public static void main(String[] args) throws InterruptedException {
AdminInterface obj = new AdminInterface();
//Test Case 1: Verify "Launch Application (gcrShop Web portal Admin Interface)" using valid URL
obj.launchApplication();
boolean Username = driver.findElement(By.name("username")).isDisplayed();
boolean Password = driver.findElement(By.name("password")).isDisplayed();
boolean Login = driver.findElement(By.id("tdb1")).isDisplayed();

if (Username == true && Password == true && Login == true){
System.out.println("Test Case 1: "+"Username, Password, and Login Elements Exit - Passed");
}
else
System.out.println("Test Case 1: "+"Username, Password, and Login Elements Not Exit - Failed");
obj.closeApplication();
//Test Case 2: Verify "Admin Login" in gcrShop Web portal Admin Interface with valid Inputs
obj.launchApplication();
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 2: "+"Admin Login Successful - Passed");
}
else {
System.out.println("Test Case 2: "+"Admin Login Unsuccessful - Failed");
}
obj.closeApplication();
//Test Case 3: Verify "Important / Required Elements availability" in gcrShop Web portal Admin Interface index page (after Logio
obj.launchApplication();
obj.adminLogin("admin", "admin@123");
boolean Manufacturers = driver.findElement(By.linkText("Manufacturers")).isDisplayed();
boolean CatandProduct = driver.findElement(By.linkText("Categories/Products")).isDisplayed();

if (Manufacturers == true && CatandProduct == true){
System.out.println("Test Case 3: "+"Manufacturers, Categories, and products elements Exit - Passed");
}
else
{
System.out.println("Test Case 3: "+"Manufacturers, Categories, and products elements Not Exit - Failed");
}
obj.closeApplication();
//Test Case 4: Verify "Add Manufacturer" in gcrShop Web portal Admin Interface index page
obj.launchApplication();
obj.adminLogin("admin", "admin@123");
//String Man_count = driver.findElement(By.xpath(".//*[@id='contentText']/table/tbody/tr[2]/td/table/tbody/tr/td[1]/table/tbody/tr[22]/td/table/tbody/tr/td[1]/strong[3]")).getText();
obj.addManufacturers("Ahalya3");
String Man_count = driver.findElement(By.xpath(".//*[@id='contentText']/table/tbody/tr[2]/td/table/tbody/tr/td[1]/table/tbody/tr[22]/td/table/tbody/tr/td[1]/strong[3]")).getText();
int Manf_count = Integer.parseInt(Man_count);
driver.navigate().refresh();
Thread.sleep(5000);
if (Manf_count == 196){
System.out.println("Test Case 4: "+ "Manufacturer Added - Passed");
}
else {
System.out.println("Test Case 4: "+ "Manufacturer Not Added - Failed");
}
obj.closeApplication();
}
}

------------------------------------------------------------------------------------

0 comments:

Post a Comment