0% found this document useful (0 votes)
15 views88 pages

Sta Record

The document outlines the structure and objectives of the Software Testing and Automation lab course (CCS366) for the Department of Computer Science and Engineering, including course objectives, program outcomes, and specific lab experiments. It details the assessment criteria, including performance indicators for pre-lab, procedures, data observations, and post-lab questions. Additionally, it includes a comprehensive test plan for an e-commerce application, emphasizing the importance of effective test case design and execution.

Uploaded by

yusuf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views88 pages

Sta Record

The document outlines the structure and objectives of the Software Testing and Automation lab course (CCS366) for the Department of Computer Science and Engineering, including course objectives, program outcomes, and specific lab experiments. It details the assessment criteria, including performance indicators for pre-lab, procedures, data observations, and post-lab questions. Additionally, it includes a comprehensive test plan for an e-commerce application, emphasizing the importance of effective test case design and execution.

Uploaded by

yusuf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Name of the Student :

Register Number :

Department / Semester :

Subject Title / Code :


DEPARTMENT OF COMPUTER SCIENCE AND
ENGINEERING

BONAFIDE CERTIFICATE

Certified that this is the bonafide record of the work done by

_____________________________ [Link]._________________________

Studying _________ year of _ branch for the

Laboratory during the

academic year 2023 – 2024.

Signature of the lab in-charge Signature of HOD/CSE

Submitted for the university examination held on

Internal Examiner External Examiner


DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Vision of the Department

Emerge as a renewed department for globally competent Computer Science Engineers.

Mission of the Department

1. To impart quality education, problem solving and entrepreneurship skills in Computer


science and Engineering.

2. To facilitate research based innovative projects in Computer Science and Engineering.

3. To develop moral, ethical values and social responsibility among students.

Program Educational Objective (PEOs)

PEO1: Graduates shall pursue higher education and research, or have a successful career in
industries or as entrepreneurs.
PEO2: Graduates shall have the ability and attitude to adapt to emerging technological changes
PEO3: Graduates shall exhibit leadership abilities, professional ethics, communication skills,
interpersonal skills and life-long learning.

Program Specific Objective (PSOs)

PSO1: Apply software engineering principles and practices for developing quality software for
scientific and business applications to meet societal needs.
PSO2: Adapt to emerging information and communication tools and technologies (ICT) to
innovate ideas and solutions to existing/novel problems.
Program Outcomes (POs)

PO1 - Engineering knowledge: Apply the knowledge of mathematics, science, engineering


fundamentals, and an engineering specialization to the solution of complex engineering problems.
PO2 - Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of mathematics,
natural sciences, and engineering sciences.
PO3 - Design/development of solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate consideration
for the public health and safety, and the cultural, societal, and environmental considerations.
PO4 - Conduct investigations of complex problems: Use research-based knowledge and research
methods including design of experiments, analysis and interpretation of data, and synthesis of the
information to provide valid conclusions.
PO5 - Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities with
an understanding of the limitations.
PO6 - The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the
professional engineering practice.
PO7 - Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and need for
sustainable development.
PO8 - Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
PO9 - Individual and team work: Function effectively as an individual, and as a member or leader
in diverse teams, and in multidisciplinary settings.
PO10 - Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and write
effective reports and design documentation, make effective presentations, and give and receive clear
instructions.
PO11 - Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and leader
in a team, to manage projects and in multidisciplinary environments.

PO12 - Life-long learning: Recognize the need for, and have the preparation and ability to engage
in independent and life-long learning in the broadest context of technological change.
CCS366 SOFTWARE TESTING AND AUTOMATION

COURSE OBJECTIVES:
 To understand the basics of software testing
 To learn how to do the testing and planning effectively
 To build test cases and execute them
 To focus on wide aspects of testing and understanding multiple facets of testing
 To get an insight about test automation and the tools used for test automation

LIST OF EXPERIMENTS:
1. Develop the test plan for testing an e-commerce web/mobile application ([Link]).
2. Design the test cases for testing the e-commerce application
3. Test the e-commerce application and report the defects in it.
4. Develop the test plan and design the test cases for an inventory control system.
5. Execute the test cases against a client server or desktop application and identify the defects.
6. Test the performance of the e-commerce application.
7. Automate the testing of e-commerce applications using Selenium.
8. Integrate TestNG with the above test automation.
9. Mini Project:
a. Build a data-driven framework using Selenium and TestNG
b. Build Page object Model using Selenium and TestNG
c. Build BDD framework with Selenium, TestNG and Cucumber

Lab Requirements : For a batch of 30 students


Operating Systems : Windows
Front End Tools : Eclipse IDE , JDK , SELENIUM, TESTNG
C

CCS366- SOFTWARE TESTING AND AUTOMATION


NBA CODE FOR THE SUBJECT: C312
SEMESTER: 6 (23-24 EVEN)

CO-Code Course Outcome Description


Understand the basic concepts of software testing and the need for software
C312.1
testing
C312.2 Design Test planning and different activities involved in test planning

C312.3 Design effective test cases that can uncover critical defects in the application

C312.4 Carry out advanced types of testing

C312.5 Automate the software testing using Selenium and Testing

CO Code PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2

C312.1 3 2 2 2 2 - - - - 1 - 2 2 2

C312.2 3 3 3 3 2 - - - 2 2 1 2 2 2

C312.3 3 2 2 2 2 - - - - 1 - 2 2 3

C312.4 3 2 2 2 1 2 - 2 - 1 2 2 2 3

C312.5 3 3 3 3 3 2 2 1 2 2 1 2 3 3
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Name of Lab Course CCS366 / SOFTWARE TESTING AND AUTOMATION
Semester & Year VI & III
Name of the Student
Registration No
Name of the Evaluator Mrs. [Link], AP-CSE
Marks scored out of 20
RUBRIC ASSESSMENT FOR LAB COURSE
Performance
Level 1 (0-1) Level 2 (2-4) Level 3 (5)
Indicators
Explanation to, the Pre Explanation to, the Pre Explanation to, the Pre lab
lab questions and lab questions and questions and objective of the
Pre Lab objective of the objective of the experiment, is, where
Questions, experiment, is, where experiment, is, where compared to the expectation of
Objectives compared to the compared to the the faculty is highly
(P –I) expectation of the expectation of the satisfactory.
faculty is not faculty is partially
satisfactory. satisfactory.
Explanation to the Explanation to the Explanation to the procedure
procedure of the procedure of the of the experiment, is, where
experiment, is, where experiment, is, where compared to the expectation of
Procedures
compared to the compared to the the faculty is highly
(P-II)
expectation of the expectation of the satisfactory.
faculty is not faculty is partially
satisfactory. satisfactory.
Calculation of the Calculation of the Calculation of the observed
Data / observed values and observed values and values and validation of the
Observations validation of the results validation of the results results of the experiment
(P-III) of the experiment of the experiment precise.
inaccurate. approximate.
Explanation to the post Explanation to the post Explanation to the post lab
lab questions and lab questions and questions and conclusions of
Post Lab conclusions of the conclusions of the the experiments, is, where
Questions, experiments, is, where experiments, is, where compared to the expectation of
Conclusions compared to the compared to the the faculty is highly
(P-IV) expectation of the expectation of the satisfactory.
faculty is not faculty partially
satisfactory. satisfactory.
INDEX
[Link]. Date Name Of The Experiment Page
Sign
No.
Developing the Test Plan for Testing an E-commerce
1
Web/Mobile Application

Designing the Test Cases for Testing the E-commerce


2
Application
Test the E-commerce Application and Report the
3 Defects

Test Plan and Design the Test Cases for an Inventory


4
Control System
Execute the Test Cases against a Client-
Server or Desktop Applicationand Identify
5
the Defects

6 Test the Performance of the E-commerce Application

7 Study of Selenium Framework

Automation on testing of e-commerce applications


8
using Selenium

9 Study of TestNG Framework

10 Program Using TestNG annotations

11 Integration of TestNG with test automation

12 Build Page object model using Selenium and TestNG


Register No: _______________________________________

Assessment Sheet

P-I P-II P-III P-IV Total


[Link] Date Experiment
(5) (5) (5) (5) (20)
Developing the Test Plan for Testing an
1
E-commerce Web/Mobile Application
Designing the Test Cases for Testing the
2
E-commerce Application
Test the E-commerce Application and
3 Report the Defects

Test Plan and Design the Test Cases for


4
an InventoryControl System
Execute the Test Cases against
a Client-Server or Desktop
5 Applicationand Identify the
Defects

Test the Performance of the E-commerce


6
Application

7 Study of Selenium Framework

Automation on testing of e-commerce


8
applications using Selenium

9 Study of TestNG Framework

10 Program Using TestNG annotations

Integration of TestNG with test


11
automation
Build Page object model using Selenium
12
and TestNG

TOTAL (OUT OF 20)

SIGNATURE OF THE EVALUATOR


Ex. No. 1: Developing the Test Plan for Testing an E-commerce Web/Mobile Application

Aim:

To develop a comprehensive test plan for testing e-commerce web/mobile application


[Link].

Components and Attributes of Test Plan


1. Identify the Scope: Determine the scope of testing, including the features and
functionalities that need to be tested.

2. Define Test Objectives: Specify the primary objectives of testing, such as functional
testing, usability testing, performance testing, security testing, etc.

3. Identify Test Environment: Define the platforms, browsers, devices, and operating
systems on which the application will be tested.

4. Determine Test Deliverables: Decide on the documents and artifacts that will be
generated during the testing process, such as test cases, test reports, and defect logs.

5. Create Test Strategy: Develop an overall approach for testing, including the testing
techniques, entry and exit criteria, and the roles and responsibilities of the testing team.

6. Define Test Scope and Schedule: Specify the timeline for each testing phase and the
scope of testing for each phase.

7. Risk Analysis: Identify potential risks and their impact on the testing process, and devise
risk mitigation strategies.

8. Resource Planning: Allocate the necessary resources, including the testing team, hardware,
and software required for testing.
9. Test Case Design: Prepare detailed test cases based on the requirements and
functionalities of the e-commerce application.

10. Test Data Setup: Arrange test data required for executing the test cases effectively.

11. Test Execution: Execute the test cases and record the test results.

12. Defect Reporting: Document any defects encountered during testing and track
their resolution.

1
Test Plan for e-commerce Web Application

1. Scope:

The goal of the e-commerce website is to allow a user to find what they are looking for quickly and easily.
The website will allow a user to search for an item, select a search suggestion, narrow down a search by
selecting different filters for an item, view details about an item, add an item to a cart, E-Commerce Website
Test Plan Page 4 continue shopping, and then checkout when they are ready. The development of this e-
commerce website aligns with the business objective to increase growth and profitability.

2. Test Objectives

The purpose of the e-commerce website is to allow customers a way to quickly find and purchase what they
desire from a range of options. This document refers to version 1.0 of the e-commerce Website

3. Test Environment:

The e-commerce website needs to have cross-platform functionality, as well as be mobile responsive. The
website should function on all major web browsers, including Chrome, Internet Explorer, Edge, Bing, Yahoo,
and Safari. In addition, it should function properly on both Mac and Windows operating systems, as well as
iOS and Android.

4. Test Deliverables

The testing process generates the documents such as test cases, test reports, and defect logs.

5. Test Strategy:

Walkthroughs, Inspection, Technical review and Informal reviews may be used for checking the e-
commerce application. Functional, Non-functional, Performance testing, Load testing will be done
during e-com testing. Testing teams are identified based on automation familiarity and application
knowledge.

6. Test Schedule:
Schedule is prepared for testing e-com application that includes URL entry, user verification,
product search. Schedule is prepared along with tester name and test date.

7. Risk Analysis
Risk on ecom application testing to be considered in payment process.

8. Resource Planning
Testing team, required hardware, software, browser and development code are arranged before testing.

9. Test Case
Test case for URL, user login with password, various product search are prepared along with expected output.

10. Test Data Setup: Test data required for executing the test cases are arranged effectively for e-com
application.

2
11. Test Execution: Given developer code is executed with the help of automated tool using prepared
test cases and results are compared with expected output.

12. Defect Reporting: Results and test status are recorded as test report along with
bug report and it is sent to test manager.

Result:

Thus the test plan for e-commerce application was prepared using the standard components of test
plan.

3
[Link]. 2: Designing the Test Cases for Testing the E-commerce Application

Aim:

The aim of this experiment is to design a set of comprehensive and effective test cases fortesting the
e-commerce application [Link].

Procedure to design a Testcase

1. Understand Requirements: Familiarize yourself with the functional and non-functional requirements of
the e-commerce application.
2. Identify Test Scenarios: Based on the requirements, identify different test scenarios that cover all aspects
of the application.
3. Write Test Cases: Develop test cases for each identified scenario, includingpreconditions, steps to be
executed, and expected outcomes.
4. Cover Edge Cases: Ensure that the test cases cover edge cases and boundaryconditions to verify the
robustness of the application.
5. Prioritize Test Cases: Prioritize the test cases based on their criticality and relevanceto the application.
6. Review Test Cases: Conduct a peer review of the test cases to ensure their accuracyand completeness.
7. Optimize Test Cases: Optimize the test cases for reusability and maintainability.

Test Case Design:

The test case design should include the following components for each test case:

1. Test Case ID: A unique identifier for each test case.


2. Test Scenario: Description of the scenario being tested.
3. Test Case Description: Detailed steps to execute the test.
4. Precondition: The necessary conditions that must be satisfied before executing the test case.
5. Test Steps: The sequence of actions to be performed during the test.
6. Expected Result: The outcome that is expected from the test.

4
Model 1

Test Case for e-commerce

Expected Actual
Process No. Test Case Steps Description Status Result Result Comment

Navigate to the Verify user User can


User
TC001 registration registration Done successfully
Registration
page. process. register.

Navigate to the Verify user User can


TC002 User Login Done successfully
login page. loginprocess.
log in.

Enter a Verify search Search results


Search functionality
TC003 keyword in the Done relevant to the
Functionality
search bar. . keyword.

Test
Verify adding Product is
Case Browsethe
TC004 Add to Cart products to Done added to the
Design product catalog.
the cart. shopping cart.

Click on the Verify the Items in the


ShoppingCart
TC005 shoppingcart shopping cart Done shopping cart
Validation
icon. contents. are displayed.

Checkout
Click on the Verify the Not process
Checkout
TC006 "Checkout " proceeds
Process checkout Started
button.
as expected.

5
Model 2:
Test Case for Home Page

Test Module Test Scenario Test Case


Case ID Name

TC001 Home Page Verify the details on Home Verify that home page is displayed
page after login or not.

TC002 Home Page Verify the details on Home Verify that user name is displayed
page on home page or not

TC003 Home Page Verify the details on Home Verify that featured products are
page displayed on home page

TC004 Home Page Verify the details on Home Verify that Search Functionality is
page present on home page.

TC005 Home Page Verify the details on Home Verify the home page of
page application on different browsers.

TC006 Home Page Verify the details on Home Verify the alignment on the home
page page

TC007 Home Page Verify the details on Home Verify that products displayed on
page home page are clickable.

TC008 Home Page Verify the details on Home Verify that when user clicks on a
page product, user should be redirected
to product specification page.

TC009 Home Page Verify the details on Home Verify that user profile section is
page present on home page.

TC0010 Home Page Verify the details on Home Verify that products displayed on
page home page are categorized.

6
Test Case for Search Functionality

Test Module
Test Scenario Test Case
Case ID Name
TC001 Product Verify the product search Verify that search field accepts
Search functionality alphabets, numbers or symbols.

TC002 Product Verify the product search Verify that after entering search
Search functionality text and clicking on search icon,
the search should be performed.

TC003 Product Verify the product search Verify that the search results
Search functionality should be as per the search query.

TC004 Product Verify the product search Verify that user should be able to
Search functionality search based on product
name,brand name or product
specification.

TC005 Product Verify the product search Verify that filter should be present
Search functionality for filtering the search results bases
on Brand, Price, Reviews or
Ratings.

TC006 Product Verify the product search Verify that sorting options should
Search functionality be present on search results page.

TC007 Product Verify the product search Verify that the number of search
Search functionality results displayed on one page.

TC008 Product Verify the product search Verify that there should be
Search functionality navigation button(Next and
Previous) for navigation to pages.

TC009 Product Verify the product search Verify that user should be perform
Search functionality search in different categories for
example, Movies, Books, Grocery
etc.

7
Test Case Product Details

Test Module Test Scenario Test Case


Case ID Name
TC001 Product Verify the details on Product Verify that images of product are
Details Specification page displayed correctly.

TC002 Product Verify the details on Product Verify that price of product is
Details Specification page displayed.

TC003 Product Verify the details on Product Verify that product reviews are
Details Specification page mentioned.

TC004 Product Verify the details on Product Verify that product specifications
Details Specification page are displayed.

TC005 Product Verify the details on Product Verify that information about IN-
Details Specification page Stock/Out-Stock are displayed.

TC006 Product Verify the details on Product Verify that seller ratings should be
Details Specification page displayed.

TC007 Product Verify the details on Product Verify that all the variations of
Details Specification page product are displayed.

TC008 Product Verify the details on Product Verify that shipping information
Details Specification page about product are displayed.

TC009 Product Verify the details on Product Verify that payment options are
Details Specification page mentioned on product page.

TC0010 Product Verify the details on Product Verify that product suggestions
Details Specification page related to product should be
displayed.

8
Test Case for Cart Page

Test
Module
Case Test Scenario Test Case
Name
ID
TC001 Cart Page Verify the details on Cart Verify that when user clicks on add
Page to cart, the product should be added
to cart.

TC002 Cart Page Verify the details on Cart Verify that user should be able to
Page continue shopping after adding items
to cart.

TC003 Cart Page Verify the details on Cart Verify that item quantity should be
Page increased if user adds same item in
cart again.

TC004 Cart Page Verify the details on Cart Verify that total amount of all items
Page should be displayed to user.

TC005 Cart Page Verify the details on Cart Verity that the amount displayed to
Page user

should include the taxes and


shipping charges as per location.

TC006 Cart Page Verify the details on Cart Verify that user should not be able to
Page add items in cart beyond a certain
limit.

TC007 Cart Page Verify the details on Cart Verify that when user clicks on
Page remove from cart button the item
should be removed from cart.

TC008 Cart Page Verify the details on Cart Verify that user should be able to
Page apply coupons or vouchers at
checkout from cart.

TC009 Cart Page Verify the details on Cart Verify that items in cart should be
Page present if user logs out and logs in
again.

9
Test Case for Check Out, Payment Page

Test Module
Test Scenario Test Case
Case ID Name
TC001 Checkout, Verify the details on Verify that payments options
Payments Checkout,Payments Page applicable for the order should be
Page displayed at checkout.

TC002 Checkout, Verify the details on Verify that delivery details of items
Payments Checkout,Payments Page should be displayed at checkout.
Page

TC003 Checkout, Verify the details on Verify that user should get order
Payments Checkout,Payments Page details by message or email.
Page

TC004 Checkout, Verify the details on Verify that user should be directed
Payments Checkout,Payments Page to home page after checkout.
Page

TC005 Checkout, Verify the details on Verify that user should be


Payments Checkout,Payments Page displayed payment options such as
Page Credit Card, Debit Card, Net
Banking etc.

TC006 Checkout, Verify the details on Verify that if user is not registered
Payments Checkout,Payments Page then payment should be done as
Page Guest user.

TC007 Checkout, Verify the details on Verify that user should be provided
Payments Checkout,Payments Page with an option to save the payment
Page method.

TC008 Checkout, Verify the details on Verify that session should be timed
Payments Checkout,Payments Page out if payment is not done for a
Page certain time.

TC009 Checkout, Verify the details on Verify that user details should be
Payments
Page Checkout,Payments Page displayed on payment page for
registered customers.

TC001 0 Checkout, Verify the details on Verify that on successful payment


Payments Checkout,Payments Page email or text message should be
Page delivered to customer along with
unique order number.

10
Test Case for My Order Page

Module
Test Case ID Test Scenario Test Case
Name
TC001 My Orders Verify the details on Orders Verify that user should be able to track the
Page Page order on My orders page.
TC002 My Orders Verify the details on Orders Verify that user should be able to change the
Page Page delivery date and time.
TC003 My Orders Verify the details on Orders Verify that user should be able to cancel the
Page Page order
TC004 My Orders Verify the details on Orders Verify that user should be able to return the
Page Page order after delivery of order.
TC005 My Orders Verify the details on Orders Verify that user should be able to exchange
Page Page the order from My orders page.
TC006 My Orders Verify the details on Orders Verify that user should be able to provide
Page Page feed back and reviews about the item
delivered.

CUSTOMER SERVICE PAGE

Test Case
Module Name Test Scenario Test Case
ID
TC001 Customer Verify the details on Customer Verify that customer service
Service Page Service Page options should be present on the
website.
TC002 Customer Verify the details on Customer Verify that different modes of
Service Page Service Page customer service such as Email,
Chat or Call should be mentioned.
TC003 Customer Verify the details on Customer Verify that waiting time to
Service Page Service Page connect to customer service shold
be displayed to user.
TC004 Customer Verify the details on Customer Verify that customer service
Service Page Service Page should be available in different
languages.
TC005 Customer Verify the details on Customer Verify that the timings of
Service Page Service Page customerservice option should be
displayed to user.

Result:

Thus the set of well-defined test cases are prepared for testing the e-commerce application.

11
Ex. No. 3: Test the E-commerce Application and Report the Defects

Aim:

The aim of this experiment is to execute the designed test cases and identify defects or issues in the
e-commerce application.

Algorithm:

1. Test Environment Setup: Set up the testing environment with the required hardware, software, and
test data.

2. Test Case Execution: Execute the test cases designed in Experiment 2, following thespecified steps.

3. Defect Identification: During test execution, record any discrepancies or issues encountered.

4. Defect Reporting: Log the identified defects with detailed information, including steps to reproduce,
severity, and priority.

5. Defect Tracking: Track the progress of defect resolution and verify fixes as theyare implemented.

6. Retesting: After defect fixes, retest the affected areas to ensure the issues are resolved.

7. Regression Testing: Conduct regression testing to ensure new changes do not introducenew defects.

12
Sample 1 – Not able to do Login

Defect ID E_Comm_User_login_defect_001
Defect Title After enter the username and password in e-commerce
application, when submit button is clicked, it is not navigating to
home page of e-commerce web page
Defect Description/ 1. Enter user name in e-commerce page
Steps to reproduce 2. Enter password
3. Click on submit button

Expected Result Navigate to E-Commerce application home page


Actual Result Not navigating to home page of e-commerce web page in a
specified user login. No error message displayed
Evidence/attachment

Severity High
Priority Medium
Module affected Product search and add product to My cart
Environment Google Chrome Browser
Windows 7 OS
Selenium Framework
Reported by Tester XYZ
Reported on 03-02-2024
Status New
Assigned To Developer ABC

13
Sample 2 : Not able to add product in My cart

Result:
Thus the E-Com application was tested and error occurred during testing process was
recorded as defect report.

14
Ex. No. 4: Test Plan and Design the Test Cases for an InventoryControl System

Aim:

To create a comprehensive test plan and design test cases foran Inventory Control
System.

Algorithm:
Follow the same algorithm as described in Experiment 1 for developing the test plan
for an inventory control system.

Follow the same algorithm as described in Experiment 2 for designing test cases for an
inventory control system.

Test Plan:

Expected Actual
Process No. Test Steps Description Status Result Result Comment
Case
The test plan
1. Review the includesall
requirements and Verify essential
Test Scope of project the scope features.
Plan TC001 Testing documentation. of testing. Done
2. Identify the
modulesto be
tested.
3. Determine the
out-of- scope
items.
1. Review the The test
requirements and Verify the objectivesare
Test project test clearly
TC002 Objectives documentation. objectives Done defined.
.
2. Discuss with
stakeholders to
understand
expectations.

15
1. Identify the
hardwareand Verify the The test
Test software required Not environment is
TC003 Environme requirements environments Starte defined.
nt . . d

2. Set up the
required
hardware and
software.

1. Determinethe All necessary


documents and Verify the documents
Test artifacts to be required Not are listed.
TC004 Deliverabl deliverables Starte
produced.
es . d

2. Create
templates for
test reports,
defect logs,etc.

1. Decide onthe Verify the


testing approach overall The test
Test and techniques. approach Not strategyis
TC005 Strategy for testing. Starte defined.
d

16
Expectedd Actual
Process No. Test Case Steps Description Status Result Result Comment

2.
Determine
the entry
and exit
criteria.
1. Define the
Test Scope timelinefor Verify the The schedule
and each testing schedule Not isestablished
TC006 Schedule phase. for testing. Started .

2. Determine
the scope of
testing for
each phase.

TC007 Risk 1. Identify Verify risk Not Potential risks


Analysis potential analysis Started are identified
risks in the and with
testing mitigation mitigationn
process. strategies. plans.
2. Discuss risk
mitigation
strategies with
the team.
Resource 1. Allocate Verify the Not Resources
Planning the required availability of Started needed for
TC008 resources for resources. testingare
testing. allocated.
2. Determine
the roles and
responsibilities
of the team.

17
Test Case Design:

Expected Actual
Process No. Test Case Steps Description Status Result Result comment

1. Review the Verify the All


Test Case Module A - requirements functionality Not functionalities of
Design Functionality related to of ModuleA. Started Module A are
TC001 Test Module A. tested.

2. Identify test
scenariosfor
Module A.
3. Develop
detailed test
cases for
ModuleA.
1. Review the Verify the
Module B requirements integration Module Bis
- related to of Module Not successfully
TC002 Integration Module B. B with Started integrated.
Test others.
2. Identify
integration
points with
other
modules.
3. Design test
cases for
testing
integration
scenarios.

18
Expected Actual
Process No. Test Case Steps Description Status Result Result Comment
1. Review the Verify the Module C
Module C - performance performance performs
Performance requirements of ModuleC. Not optimally
TC003 Test Started under load.
for Module C.
2.
Determine
performance
metrics tobe
measured.
3. Develop
performance
test cases for
ModuleC.
1. Review the
Module D usability Verify the Module D is
- Usability requirements usability of Not user- friendly
TC004 Test for Module D. ModuleD. Started andintuitive.

2. Identify
usability
aspects to
be tested.
3. Create
test cases for
evaluating
Module D's
usability.
Module E is
1. Review the protected
security Verify the against
TC005 Module E - requirements security of Not security
Security Test for Module E. Started threats.
Module E.
2. Identify
potential
security
vulnerabilities
3. Design
security test
cases to assess
Module E.

Result:
Thus the well-structured test plan and a set oftest cases ready for testing the Inventory
Control System.

19
Ex. No. 5: Execute the Test Cases against a Client-Server or Desktop Applicationand
Identify the Defects

Aim:

To execute the test cases against a client-server ordesktop application and identify
defects.

Algorithm:
1. Test Environment Setup: Set up the testing environment, including the client-server or
desktop application, required hardware, and test data.

2. Test Case Execution: Execute the test cases designed in Experiment 2 against the application.

3. Defect Identification: During test execution, record any discrepancies or issues encountered.

4. Defect Reporting: Log the identified defects with detailed information, including
steps to reproduce, severity, and priority.

5. Defect Tracking: Track the progress of defect resolution and verify fixes as they
are implemented.

6. Retesting: After defect fixes, retest the affected areas to ensure the issues are resolved.

7. Regression Testing: Conduct regression testing to ensure new changes do not introduce
new defects.

20
Test Case Table:

Expected Actual
Process No. Test Case Steps Description Status Result Result Comment
User can
Test Case 1. Launch the Verify user Not successfully
Execution TC001 User Login application. login process. Started log in.

2. Enter valid
login
credentials.
3. Click on the
"Login" button.
Invalid data
shows
1. Accessa Verify data appropriate
TC002 Data Validation data input validation on Not error
form. the form. Started messages.

2. Enter invalid
data inthe form
fields.
3. Submit
the form.
1. Access Verify file File is
the file upload Not uploaded
TC003 File Upload upload functionality Started successfully
feature. . .
2. Select a file
from the
system.
3. Click on the
"Upload"
button.
Application
Verify the gracefully
Network 1. application's Not handles
TC004 Connectivity Disconnect the response. Started disconnection
network. .
2. Attemptto
performan
action
requiring
network
access.
1. Simulate Verify Application
Concurrent concurrent user application Not performs well
TC005 Users sessions. performance Started under load.
.
2. Perform
actions
simultaneously
.
1. Test the Application
application Verify cross- works on all
on different platform Not specified
TC006 Compatibility platforms. compatibility Started platforms.
. 21
2. Execute
tests on
various
browsers.

1. Monitor Data is
network traffic Verify correctly
Client-Server between client communication Not transmitted
TC007 Communication and server. integrity. Started and received.

Result:
Test cases are created and executed against client server application for file uploading.

22
Ex. No. 6: Test the Performance of the E-commerce Application

Aim:

The aim of this experiment is to test the performance of the e-commerceapplication


[Link].

Algorithm:
1. Identify Performance Metrics: Determine the performance metrics to be measured, such as
response time, throughput, and resource utilization.

2. Define Test Scenarios: Create test scenarios that simulate various user interactions andloads on
the application.

3. Performance Test Setup: Set up the performance testing environment withappropriate hardware
and software.

4. Execute Performance Tests: Run the performance tests using the defined scenarios andcollect
performance data.

5. Analyze Performance Data: Analyze the collected data to identify any performance bottlenecks
or issues.

6. Performance Tuning: Implement necessary optimizations to improve theapplication's


performance.

23
Performance Table:
Test Actual Com
Process Test Case Steps Description Status Expected Result
Case Id Result ment
The home page loads
Response Measure the
Performance 1. Access the home Not within the specified
TC00 1 Time for response
Testing page of the e- Started response time
Home Page time.
commerce application. Threshold
2. Use a performance
testing tool to record
the time.
3. Analyze the
recorded data to
determine response
time.
The application can
Throughput 1. Simulate peak-hour
Measure the Not handle peak- hour
TC00 2 during Peak traffic on the
throughput Started traffic without
Hours application
significant delays.
2. Execute
performance tests
during peak hours.
3. Analyze the data to
determine the
throughput.
1. Monitor CPU, Measure
Resource Not
TC00 3 memory, and network resource
Utilization Started
usage during testing. utilization.
2. Execute
performance tests
while monitoring
resources.
3. Analyze the data to
assess resource
utilization.
1. Simulate multiple Measure app
Concurrent
TC00 4 concurrent users performance
Users
accessing the app. under load.
2. Increase the number
of concurrent users
gradually.
3. Record the
application's behavior
with increased load.
Measure
1. Apply maximum
system The system recovers
Stress load to test the Not
TC00 5 behavior gracefully after stress
Testing system's breaking Started
under extreme is removed.
point.
load.
2. Apply the
maximum user load
the application can
handle.
3. Observe the
application's response
under stress.

24
Test Actual Com
Process Test Case Steps Description Status Expected Result
Case Id Result ment
1. Identify
Improve
Performance performance Not
TC00 6 application
Tuning bottlenecks and areas Started
performance.
of improvement.
2. Analyze the
performance test
results.
3. Implement
necessary
optimizations

Result:
Thus the performance test results and any optimizations made to improve the
application's performance.

25
[Link]. 7: Study of Selenium Framework

Aim
To study about Selenium framework for automated testing.

Description
Selenium WebDriver is a web framework that permits you to execute cross-browser tests.
This tool is used for automating web-based application testing to verify that it performs
expectedly.
Selenium WebDriver allows you to choose a programming language to create test scripts. As
discussed earlier, it is an advancement over Selenium RC to overcome a few limitations.
Selenium WebDriver is not capable of handling window components, but this drawback can be
overcome by using tools like Sikuli, Auto IT, etc.

Selenium WebDriver Framework Architecture


WebDriver Architecture is made up of four major components:
1. Selenium Client library
2. JSON wire protocol over HTTP
3. Browser Drivers
4. Browsers

Selenium Client Libraries/Language Bindings


Selenium provides support to multiple libraries such as Ruby, Python, Java, etc as language
bindings have been developed by Selenium developers to provide compatibility for multiple
languages. For instance, if you want to use the browser driver in Python, use the Python Bindings.
You can download all the supported language bindings of your choice from the official site of
Selenium.

JSON Wire Protocol 26


JSON is an acronym for JavaScript Object Notation. It is an open standard that provides a
transport mechanism for transferring data between client and server on the web. It provides

27
support for various data structures like arrays and objects which makes it easier to read and write
data from JSON.

Browser Drivers
Selenium provides drivers specific to each browser and without revealing the internal logic of
browser functionality, the browser driver interacts with the respective browser by establishing a
secure connection. These browser drivers are also specific to the language which is used for test
case automation like C#, Python, Java, etc.

Benefits and Limitations of Selenium WebDriver


Benefits of Selenium WebDriver

 It is one of the most popular Open-Source tools and is easy to get started with for testing
web-based applications. It also allows you to perform cross browser compatibility testing.
 Supports multiple operating systems like Windows, Mac, Linux, Unix, etc.
 It provides compatibility with a range of languages, including Python, Java, Perl, Ruby, etc.
 Provides support for modern browsers like Chrome, Firefox, Safari, and Internet Explorer.
 Selenium WebDriver completes the execution of test scripts faster when compared to other
tools
 More Concise API (Application Programming interface) than Selenium RC’s
 It also provides compatibility with iPhoneDriver, HtmlUnitDriver, and AndroidDriver

28
Limitations of Selenium WebDriver

 Support for new browsers is not readily available when compared to Selenium RC
 For the automatic generation of test results, it doesn’t have a built-in command

Selenium Components
Selenium is mainly comprised of a suite of tools, which include:

 Selenium IDE
 Selenium RC
 Selenium WebDriver
 Selenium Grid

29
Selenium IDE
Selenium IDE (Integrated Development Environment) is mainly a Firefox plugin. It is one of the
simplest frameworks in the Selenium Suite. It allows us to record and playback the scripts. If you
wish to create scripts using Selenium IDE, you need to use Selenium RC or Selenium WebDriver
to write more advanced and robust test cases.

In Selenium IDE, the test case execution is very slow, and the report generation step for the test
cases is not good as compared with other components. It doesn’t support test case execution in
parallel or remote execution.

Few drawbacks of Selenium IDE are:

1. It restricts the test case execution to the Firefox browser.


2. It doesn’t extend the support to mobile-based testing like iPhone/Android testing.
3. The execution of test cases is very slow and the report generation step is not good
when compared with other components.

2. Selenium Remote Control

Selenium RC (officially deprecated by selenium)allows testers to write automated web


application UI test in any of the supported programming languages. It also involves an HTTP
30
proxy server which enables the browser to believe that the web application being tested comes
from the domain provided by proxy server.

Selenium WebDriver is a web framework that permits you to execute cross-browser tests. This
tool is used for automating web-based application testing to verify that it performs expectedly.
Selenium WebDriver allows you to choose a programming language to create test scripts. As
discussed earlier, it is an advancement over Selenium RC to overcome a few limitations.
Selenium WebDriver is not capable of handling window components, but this drawback can be
overcome by using tools like Sikuli, Auto IT, etc.

Selenium WebDriver Framework Architecture


WebDriver Architecture is made up of four major components:

5. Selenium Client library


6. JSON wire protocol over HTTP
7. Browser Drivers
8. Browsers

Selenium Client Libraries/Language Bindings


Selenium provides support to multiple libraries such as Ruby, Python, Java, etc as language
bindings have been developed by Selenium developers to provide compatibility for multiple
languages. For instance, if you want to use the browser driver in Python, use the Python Bindings.
You can download all the supported language bindings of your choice from the official site of
Selenium.

31
JSON Wire Protocol
JSON is an acronym for JavaScript Object Notation. It is an open standard that provides a
transport mechanism for transferring data between client and server on the web. It provides
support for various data structures like arrays and objects which makes it easier to read and write
data from JSON.

Browser Drivers
Selenium provides drivers specific to each browser and without revealing the internal logic of
browser functionality, the browser driver interacts with the respective browser by establishing a
secure connection. These browser drivers are also specific to the language which is used for test
case automation like C#, Python, Java, etc.

Benefits and Limitations of Selenium WebDriver


Benefits of Selenium WebDriver

 It is one of the most popular Open-Source tools and is easy to get started with for testing
web-based applications. It also allows you to perform cross browser compatibility testing.
 Supports multiple operating systems like Windows, Mac, Linux, Unix, etc.
 It provides compatibility with a range of languages, including Python, Java, Perl, Ruby, etc.
 Provides support for modern browsers like Chrome, Firefox, Safari, and Internet Explorer.
 Selenium WebDriver completes the execution of test scripts faster when compared to other
tools
 More Concise API (Application Programming interface) than Selenium RC’s
 It also provides compatibility with iPhoneDriver, HtmlUnitDriver, and AndroidDriver

Limitations of Selenium WebDriver


 Support for new browsers is not readily available when compared to Selenium RC
 For the automatic generation of test results, it doesn’t have a built-in command

Selenium Components
Selenium is mainly comprised of a suite of tools, which include:

 Selenium IDE
 Selenium RC
 Selenium WebDriver
 Selenium Grid

Selenium IDE
Selenium IDE (Integrated Development Environment) is mainly a Firefox plugin. It is one of the
simplest frameworks in the Selenium Suite. It allows us to record and playback the scripts. If you
wish to create scripts using Selenium IDE, you need to use Selenium RC or Selenium WebDriver
to write more advanced and robust test cases.

In Selenium IDE, the test case execution is very slow, and the report generation step for the test
cases is not good as compared with other components. It doesn’t support test case execution in
parallel or remote execution.

Few drawbacks of Selenium IDE are:


32
1. It restricts the test case execution to the Firefox browser.
2. It doesn’t extend the support to mobile-based testing like iPhone/Android testing.
3. The execution of test cases is very slow and the report generation step is not good
when compared with other components.
Selenium Remote Control
Selenium RC (officially deprecated by selenium) allows testers to write automated web
application UI test in any of the supported programming languages. It also involves an HTTP
proxy server which enables the browser to believe that the web application being tested comes
from the domain provided by proxy server.

Selenium RC comes with two components.


1. Selenium RC Server (acts as a HTTP proxy for web requests).
2. Selenium RC Client (library containing your programming language code).

The figure given below shows the architectural representation of Selenium RC.

SRC Architecture

Selenium RC (Remote Control) was the first version of Selenium that allowed testers to write
automated tests in any programming language and execute them on various browsers. The
architecture of Selenium RC consists of three main components: the Selenium Server, the client
library, and the browser drivers.

The Selenium Server acts as a bridge between the client library and the browser drivers. It
receives commands from the client library and communicates with the browser drivers to execute
the commands on the target browser. The Selenium Server can be installed and run on any
machine that has a supported browser and programming language environment.

The client library is a programming language-specific library that interacts with the Selenium
Server to automate the testing of web applications. It provides a set of APIs that allow testers to
write test scripts in their preferred programming language, such as Java, Python, Ruby, etc.

The browser drivers are platform-specific components that interact with the target browser to
execute commands and retrieve results. They provide a standard API that the Selenium Server
uses to communicate with the browser. The browser drivers are responsible for launching and
controlling the target browser, and they can be downloaded and installed separately for each
browser.

Selenium RC is replaced by Selenium WebDriver, a more modern and efficient automation tool.
However, understanding the architecture of Selenium RC can help understand the evolution of
Selenium and the concepts behind modern automation testing frameworks.

33
Selenium Web Driver
Selenium WebDriver is the successor to Selenium RC. Selenium WebDriver accepts commands (sent in
Selenese, or via a Client API) and sends them to a browser. This is implemented through a browser-specific
browser driver, which sends commands to a browser and retrieves results. Most browser drivers actually launch
and access a browser application (such as Firefox, Google Chrome, Internet Explorer, Safari, or Microsoft
Edge); there is also an HtmlUnit browser driver, which simulates a browser using the headless browser
HtmlUnit.
Selenium WebDriver does not need a special server to execute tests. Instead, the WebDriver directly starts
a browser instance and controls it. However, Selenium Grid can be used with WebDriver to execute tests on
remote systems (see below). Where possible, WebDriver uses native operating system level functionality rather
than browser-based JavaScript commands to drive the browser. This bypasses problems with subtle differences
between native and JavaScript commands, including security restrictions.
Selenium GRID
Selenium Grid is a server that allows tests to use web browser instances running on remote machines. With
Selenium Grid, one server acts as the hub. Tests contact the hub to obtain access to browser instances. The hub
has a list of servers that provide access to browser instances (WebDriver nodes), and lets tests use these
instances. Selenium Grid allows running tests in parallel on multiple machines and to manage different browser
versions and browser configurations centrally (instead of in each individual test).
The ability to run tests on remote browser instances is useful to spread the load of testing across several
machines and to run tests in browsers running on different platforms or operating systems. The latter is
particularly useful in cases where not all browsers to be used for testing can run on the same platform.

Advantages of Selenium Tool Suite


1. Open-Source
2. Multi-Browser and Multi-Platform Support
3. Easy to Evolve
4. Flexible and Customizable
5. Highly Scalable

Result

Thus the detailed information about selenium was studied and it will be used in testing automation.

34
[Link]. 8: Automation on testing of e-commerce applications using Selenium.

Aim:

To automate the testing of an e-commerce web application ([Link]) using Selenium


WebDriver, which will help improve testing efficiencyand reliability.

Algorithm:
1. Set up the environment:
- Install Java Development Kit (JDK) and configure the Java environment variables.
- Install an Integrated Development Environment (IDE) like Eclipse.
- Download Selenium WebDriver and the required web drivers for the browsers youintend to
test (e.g., ChromeDriver, GeckoDriver for Firefox).

2. Create a new Java project in the IDE:


- Set up a new Java project in the IDE and include the Selenium WebDriver library.

3. Develop test cases:


- Identify the key functionalities and scenarios to test in the e-commerce application.
- Design test cases covering various aspects like login, search, product details, add tocart,
checkout, etc.

4. Implement Selenium automation scripts:


- Write Java code using Selenium WebDriver to automate the identified test cases.
- Utilize different Selenium commands to interact with the web elements, navigatethrough
pages, and perform various actions.

5. Execute the automated test cases:


- Run the automated test scripts against the e-commerce application.
- Observe the test execution and identify any failures or defects.

6. Analyze the test results:


- Review the test execution results to identify any failed test cases.
- Debug and fix any issues with the automation scripts if necessary.

7. Report defects:
- Document any defects found during the automated testing process.
- Provide detailed information about each defect, including steps to reproduce andexpected
results.

35
Program

package ecomm;

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class Seltest {

public static void main(String[] args) {


// TODO Auto-generated method stub
[Link]( "[Link]", "C:\\sta-vg\\sw\\chromedriver-win64\\[Link]");
WebDriver driver = new ChromeDriver();

[Link]("[Link]
[Link]().window().maximize();
[Link]([Link]("//div[@id='nav-signin-tooltip']//span")).click();
[Link]([Link]("ap_email")).sendKeys("+919788522652");
[Link]([Link]("continue")).click();
[Link]([Link]("ap_password")).sendKeys("gomathi123");
[Link]([Link]("signInSubmit")).click();
WebElement searchBox=[Link]([Link]("twotabsearchtextbox"));
[Link]("agni chiragugal"+[Link]);
List<WebElement> allResults=[Link]([Link]("//a/span[contains(@class,'a-text-normal')]"));

for(WebElement book:allResults)
{
if([Link]().contains("Agni Chiragugal - Tamil"))
{
[Link]();
[Link]("entered");

}else if([Link]().contains("Maanavar Agni Siragugal"))


{
[Link]();
[Link]("entered maanavar");
}
}

[Link]("E-commerce application automated using Selenium");

36
37
38
39
[Link]. 9: Study of TestNG Framework

Aim

To study in detail about TestNG testing framework to implement Automated Tesing using different
test cases.

Description
TestNG – Test Next Generation

TestNG is a testing framework for the Java programming language .

The design goal of TestNG is to cover a wider range of test categories: unit, functional, end-to-
end, integration, etc., with more powerful and easy-to-use functionalities.

Main Features are:

 Annotations.
 Run your tests in arbitrarily big thread pools with various policies available (all methods in their
own thread, one thread per test class, etc…).
 Test that your code is multithread safe.
 Flexible test configuration.
 Support for data-driven testing (with @DataProvider).
 Support for parameters.
 Powerful execution model (no more TestSuite).
 Supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven, etc…).
 Embeds BeanShell for further flexibility.
 Default JDK functions for runtime and logging (no dependencies).
 Dependent methods for application server testing.

40
TestNG

Advantages of TestNG
 Grouping: Using TestNG, we can perform a lot of complex automation testing because of its
ability to group test cases and execute the groups. However, in JUnit, we cannot perform Group
Tests.
 Extend Classes: In TestNG, we don’t need to extend any classes. In JUnit, we have to use extend
classes.
 Mandatory Annotations: In TestNG, there are no constraints for any type of mandatory
annotations. Whereas, in JUnit, we have to use mandatory annotations like @BeforeClass and
@AfterClass.
 Wider Range of Annotations: TestNG has a wider range of Annotations support like
@Before/After Suite, @Before/After Test, @Before/After Groups. JUnit has only a few
annotations.
 Dependency Test: In TestNG, we can use the “dependsOnMethods” to perform the dependency
test. However, JUnit doesn’t support this feature.
 Parallel Test Execution: In TestNG, we can perform parallel test execution if run through XML.
However, JUnit doesn’t support this feature.
 Parameterized Tests: TestNG’s parameterized tests are very user-friendly and flexible in nature
as we can provide the values either in the XML file or inside the class. JUnit has many limitations
while using this feature.
 Test Order: TestNG is better than JUnit when test execution is done in a specific order. Methods
with lower priority value will be executed first.
 Listeners: TestNG supports various types of listeners and can be used by adding annotations.
There is no mechanism in JUnit to add listeners using annotations.
 HTML Reports: TestNG has rich HTML report generations for its test cases. It generates three
types of reports i.e. Console output, HTML Report, and [Link]. However, JUnit does not
create HTML Reports of its own. We have to use the ANT tool for the same

41
Before You Begin Writing Test With TestNG:

1. Install the TestNG in Eclipse


2. Java Development Kit (JDK)
3. Add TestNG Maven dependency for your [Link]
4. Start writing test scenario with the help of TestNG annotations (Note: annotations can be used
in Java version 1.5 or higher)
5. Convert your test code into the [Link] file
6. Compile and run your test.
Sample Program

package example1;

import [Link].*;

public class SimpleTest {

@BeforeClass
public void setUp() {
// code that will be invoked when this test is instantiated
}

@Test(groups = {"fast"})
public void aFastTest() {
[Link]("Fast test");
}

@Test(groups = {"slow"})
public void aSlowTest() {
[Link]("Slow test");
}

42
TestNG Annotations, Explanations, and Examples
Annotations differ from project to project depending on their requirements. Though the
requirements change, the execution flow will be the same for every single project. The following
are TestNG annotations, with explanations and examples for each below.
 @BeforeSuite
 @BeforeTest
 @BeforeClass
 @BeforeMethod
 @Test
 @AfterMethod
 @AfterClass
 @AfterTest
 @AfterSuite

The Workflow of TestNG

43
1) @Test

In any automation script, @Test annotation is the important part, where we write code/business
logic. If something needs to be automated, that particular code needs to be inserted into the test
method. The test method then executes @Test by passing attributes. Here are some attributes
that are used to pass in the test methods.

 dependsOnGroups: In this attribute, we can get a group of the list to the particular method it
depends on.
Example: @Test (groups = { "Organization" ,"Employee" })

 alwaysRun: This attribute can be used whenever we get a situation to run a method
continuously, even if the parameters of the process fail.
Example: @Test(alwaysRun = true)

 dataProviderClass: dataProviderClass is class used to provide the data to the dataProvider, so


let’s give the class name “Computer.”
dataProvider: It is used for providing any data to the parameterization.
Example: @Test (dataProvider = "Computer")

 dependsOnMethods: Methods are used to execute its dependent method in the same way
dependsOnMethods works.
Example: @Test (dependsOnMethods = { "start", "init" })

44
2) @BeforeMethod and @AfterMethod

@BeforeMethod allows the method to execute before the execution of each @Test methods,
whereas @afterMethod is executed after the execution of each @Test methods.

45
3) @BeforeClass and @AfterClass
The method annotated with @BeforeClass will execute only once before the first test method
in that particular class is invoked. You can then initialize or configure set-up for all the
conventional test methods. The @AfterClass annotation will be executed only once, after all
the test methods of that particular class have been invoked. In the below output, you can see
that @BeforeClass and @AfterClass are executed at the very beginning and very end, so we
can conclude that they are both used only once.

4) @BeforeTest and @AfterTest


The @BeforeTest methods run after @beforeSuite. For frameworks like smoke testing,
@BeforeTest is used for creating an initial data set up and prior to running other test methods,
whereas @AfterTest annotation will run after the other tests are complete.

5) @BeforeSuite and @AfterSuite


With the help of @BeforeSuite annotation, we can set up and start the Selenium Webdrivers.
The @AfterSuite annotation is used to stop the Selenium Webdrivers.

Result

Thus the TestNG framework was studied in detail for the automated testing with Test cases.

46
Ex. No. 10 Program Using TestNG annotations

Aim
To Write a java program using simple TestNG annotations.
Procedure
1. Set up the environment
- Install Java Development Kit (JDK) and configure the Java environment variables.
- Install an Integrated Development Environment (IDE) like Eclipse.
- Install TestNG software

2. Create a new Java project in the IDE

3. Convert to Maven Project

4. Edit [Link] file with selenium dependencies.

5. Create Package under Project

6. Create a java class under package using Testcase annotation.

7. Implement Selenium automation scripts.

47
Program

package CareCse;

import [Link];
import [Link];
import [Link];
import [Link];

public class csetest {

@BeforeSuite
public void bsuite()
{

[Link]("Using Before Suite Anotation: Sample TestNG Test case Checking");

}
@BeforeTest
public void btest()
{
[Link]("Using Before Test Anotation: Before test Check");

}
@Test
public void f1()
{
[Link]("Using Test Anotation: During Test");
}
@AfterTest
public void Atest()
{
[Link]("Using After Test Anotation : After test Check");
}
}

48
Output
[RemoteTestNG] detected TestNG version 7.4.0
Using Before Suite Anotation: Sample TestNG Test case Checking
Using Before Test Anotation: Before test Check
Using Test Anotation: During Test
Using After Test Anotation : After test Check
PASSED: f1

===============================================
Default test
Tests run: 1, Failures: 0, Skips: 0
===============================================

===============================================
Default suite
Total tests run: 1, Passes: 1, Failures: 0, Skips: 0
===============================================

Result

Thus the simple Java program was return and tested using TestNG framework and Test output was verified.

49
[Link] INTEGRATION OF TestNG WITH TEST AUTOMATION

Aim:

To Write a java program using Selenium and integrate with TestNG for e-commerce web
application automation.

Algorithm:
1. Set up the environment:
- Install Java Development Kit (JDK) and configure the Java environment variables.
- Install an Integrated Development Environment (IDE) like Eclipse.
- Download Selenium WebDriver and the required web drivers for the browsers youintend to test (e.g.,
ChromeDriver, GeckoDriver for Firefox).
- Down load TestNG software in Eclipse IDE.

2. Create a new Java project in the IDE:


- Set up a new Java project in the IDE and include the Selenium WebDriver library.

3. Create a new Java project in the IDE

4. Convert to Maven Project

5. Edit [Link] file with selenium dependencies.

6. Create Package under Project

7. Create java classes under package for Browser, Userlogin and product search

8. Implement Selenium automation scripts:


- Write Java code using Selenium WebDriver to automate the identified test cases.
- Utilize different Selenium commands to interact with the web elements, navigatethrough
pages, and perform various actions.

9. Execute the automated test cases:


- Run the automated test scripts against the e-commerce application.
- Observe the test execution and identify any failures or defects.

10. Analyze the test results:


- Review the test execution results to identify any failed test cases.
- Debug and fix any issues with the automation scripts if necessary.

50
51
52
53
Result:

Thus the Program for e-commerce automation was successfully integrated with TestNG and result verified using
TestNG report.

54
Ex. No. 12 BUILD PAGE OBJECT MODEL USING SELENIUM AND TestNG

AIM:

Page Object Model (POM):

The Page Object model is an object design pattern in Selenium, where web pages are represented a
classes,the various elements on the page are defined as variables in the class and all possible user
interaction can then be implemented as methods in the class.
Cucumber:

Cucumber is one such open-source tool, which supports Behavior Driven Development(BDD). In simple
words, Cucumber can be defined as a testing framework, driven by plain English. It serves as
documentation,automated tests, and development aid – all in [Link] List

1. Cucumber Java – 7.14.0


2. Cucumber TestNG – 7.14.0
3. Java 11
4. Maven – 3.8.6
5. Selenium – 4.14.0
6. TestNG – 7.8.0
7. WebDriverManager – 5.5.3

55
Project
Structure

56
Implementation Steps
Step 1- Download and Install Java
Cucumber and Selenium need Java to be installed on the system to run the tests. Click here to learn
How to install Java.
Step 2 – Setup Maven
To build a test framework, we need to add a number of dependencies to the project. Click here to
learn How to install Maven.
Step 3 – Install Cucumber Eclipse Plugin (Only for Eclipse)
The cucumber plugin is an Eclipse plugin that allows eclipse to understand the Gherkin syntax.
When we are working with cucumber we will write the feature files that contain Feature, Scenario, Given,
When, Then, And, But, Tags, Scenario Outline, and Examples. By default, eclipse doesn’t understand
these keywords so it doesn’t show any syntax highlighter. Cucumber Eclipse Plugin highlights the
keywords present in Feature File. Refer to this tutorial to get more detail – How to setup Cucumber
with Eclipse.
Step 4 – Create a new Maven Project
To create a new Maven project, go to the File -> New Project-> Maven-> Maven project-> Next -> Enter
Group ID & Artifact ID -> Finish.

57
Click here to learn How to create a Maven project.
Step 5 – Create source folder src/test/resources to create test scenarios in the Feature file
A new Maven Project is created with 2 folders – src/main/java and src/test/java. To create test scenarios
, we need a new source folder called – src/test/resources. To create this folder, right-click on test directory
->select New ->Directory, and then it shows Maven Source Directories as resources as shown below.

Double-click on the resources directory and a new source directory under your new Maven project is
created as shown in the below image.

58
Step 6 – Add Selenium, TestNG, and Cucumber dependencies to the project
Add below mentioned Selenium, TestNG, and Cucumber dependencies to the project. I have added
WebDriverManager dependency to the [Link] to download the driver binaries automatically. To know
more about this,
please refer to this tutorial – How to manage driver executables using WebDriverManager.

1 <properties>
2 <[Link]>UTF-8</[Link]>
3 <[Link]>7.14.0</[Link]>
4 <[Link]>4.14.0</[Link]>
5 <[Link]>5.5.3</[Link]>
6 <[Link]>7.8.0</[Link]>
7 <[Link]>2.4</[Link]>
8 <[Link]>3.11.0</[Link]>
9 <[Link]>3.1.2</[Link]>
10 <[Link]>11</[Link]>
11 <[Link]>11</[Link]>
12 </properties>
13
14 <dependencies>
15
16 <dependency>
17 <groupId>[Link]</groupId>
18 <artifactId>cucumber-java</artifactId>
19 <version>${[Link]}</version>
20 </dependency>
21
22 <dependency>
23 <groupId>[Link]</groupId>

59
24 <artifactId>cucumber-testng</artifactId>
25 <version>${[Link]}</version>
26 <scope>test</scope>
27 </dependency>
28
29 <!-- Selenium -->
30 <dependency>
31 <groupId>[Link]</groupId>
32 <artifactId>selenium-java</artifactId>
33 <version>${[Link]}</version>
34 </dependency>
35
36 <!-- Web Driver Manager -->
37 <dependency>
38 <groupId>[Link]</groupId>
39 <artifactId>webdrivermanager</artifactId>
40 <version>${[Link]}</version>
41 </dependency>
42
43 <!-- TestNG -->
44 <dependency>
45 <groupId>[Link]</groupId>
46 <artifactId>testng</artifactId>
47 <version>${[Link]}</version>
48 <scope>test</scope>
49 </dependency>
50
51 <!-- Apache Common -->
52 <dependency>
53 <groupId>[Link]</groupId>
54 <artifactId>[Link]</artifactId>
55 <version>${[Link]}</version>
56 </dependency>
57
58 </dependencies>
Step 7 – Add Maven Compiler Plugin and Surefire Plugin
The compiler plugin is used to compile the source code of a Maven project. This plugin has two goals,

which are already bound to specific phases of the default lifecycle:

 compile – compile main source files


 testCompile – compile test source files
1 <plugins>
2 <plugin>
3 <groupId>[Link]</groupId>

60
4 <artifactId>maven-compiler-plugin</artifactId>
5 <version>${[Link]}</version>
6 <configuration>
7 <source>${[Link]}</source>
8 <target>${[Link]}</target>
9 </configuration>
10 </plugin>
11 <plugin>
12 <groupId>[Link]</groupId>
13 <artifactId>maven-surefire-plugin</artifactId>
14 <version>${[Link]}</version>
15 <configuration>
16 <includes>
17 <include>**/*[Link]</include>
18 </includes>
19 </configuration>
20 </plugin>
21 </plugins>
The complete [Link] looks like as shown below

1 <project xmlns="[Link] xmlns:xsi=


2 "[Link] xsi:schemaLocation=
3 "[Link]
4 <modelVersion>4.0.0</modelVersion>
5 <groupId>[Link]</groupId>
6 <artifactId>POM_CucumberTestNGDemo</artifactId>
7 <version>0.0.1-SNAPSHOT</version>
8
9 <properties>
10 <[Link]>UTF-8</[Link]>
11 <[Link]>7.14.0</[Link]>
12 <[Link]>4.14.0</[Link]>
13 <[Link]>5.5.3</[Link]>
14 <[Link]>7.8.0</[Link]>
15 <[Link]>2.4</[Link]>
16 <[Link]>3.11.0</[Link]>
17 <[Link]>3.1.2</[Link]>
18 <[Link]>11</[Link]>
19 <[Link]>11</[Link]>
20 </properties>
21
22 <dependencies>
23
24 <dependency>
25 <groupId>[Link]</groupId>
26 <artifactId>cucumber-java</artifactId>

61
27 <version>${[Link]}</version>
28 </dependency>
29
30 <dependency>
31 <groupId>[Link]</groupId>
32 <artifactId>cucumber-testng</artifactId>
33 <version>${[Link]}</version>
34 <scope>test</scope>
35 </dependency>
36
37 <!-- Selenium -->
38 <dependency>
39 <groupId>[Link]</groupId>
40 <artifactId>selenium-java</artifactId>
41 <version>${[Link]}</version>
42 </dependency>
43
44 <!-- Web Driver Manager -->
45 <dependency>
46 <groupId>[Link]</groupId>
47 <artifactId>webdrivermanager</artifactId>
48 <version>${[Link]}</version>
49 </dependency>
50
51 <!-- TestNG -->
52 <dependency>
53 <groupId>[Link]</groupId>
54 <artifactId>testng</artifactId>
55 <version>${[Link]}</version>
56 <scope>test</scope>
57 </dependency>
58
59 <!-- Apache Common -->
60 <dependency>
61 <groupId>[Link]</groupId>
62 <artifactId>[Link]</artifactId>
63 <version>${[Link]}</version>
64 </dependency>
65
66
67 </dependencies>
68
69 <build>
70 <plugins>
71 <plugin>
72 <groupId>[Link]</groupId>

62
73 <artifactId>maven-compiler-plugin</artifactId>
74 <version>${[Link]}</version>
75 <configuration>
76 <source>${[Link]}</source>
77 <target>${[Link]}</target>
78 </configuration>
79 </plugin>
80 <plugin>
81 <groupId>[Link]</groupId>
82 <artifactId>maven-surefire-plugin</artifactId>
83 <version>${[Link]}</version>
84 <configuration>
85 <suiteXmlFiles>
86 <suiteXmlFile>[Link]</suiteXmlFile>
87 </suiteXmlFiles>
88 </configuration>
89 </plugin>
90 </plugins>
</build>
</project>
Step 8 – Create a feature file in the src/test/resources
Create a folder with name features. Now, create the feature file in this folder. The feature file should be
saved with the extension .feature. This feature file contains the test scenarios created to test the
application. The Test Scenarios are written in Gherkins language in the format of Given, When,
Then, And, But.

Below is an example of Test Scenarios in the feature file. I have failed one test scenario intentionally –
@MissingUsername.
1 Feature: Login to HRM Application

63
2
3 Background:
4 Given User is on HRMLogin page "[Link]
5
6 @ValidCredentials
7 Scenario: Login with valid credentials
8
9 When User enters username as "Admin" and password as "admin123"
10 Then User should be able to login successfully and new page open
11
12 @InvalidCredentials
13 Scenario Outline: Login with invalid credentials
14
15 When User enters username as "<username>" and password as "<password>"
16 Then User should be able to see error message "<errorMessage>"
17
18 Examples:
19 | username | password | errorMessage |
20 | Admin | admin12$$ | Invalid credentials |
21 | admin$$ | admin123 | Invalid credentials |
22 | abc123 | xyz$$ | Invalid credentials |
23
24
25 @MissingUsername
26 Scenario Outline: Login with blank username
27
28 When User enters username as " " and password as "admin123"
29 Then User should be able to see a message "Required1" below Username
Step 9 – Create the classes for locators, actions, and utilities in src/main/java
Create folders – actions, locators, and utils in src/main/java.

64
Create a Java Class for each page where define WebElements as variables using Annotation @FindBy.
Create another Java class that contains methods for actions performed on WebElements. Here, I’m going
to create 2 classes for locators – LoginPageLocators and HomePageLocators as well as 2 classes
for actions – LoginPageActions and HomePageActions
The Locator class contains WebElements which are identified by @FindBy annotation as shown below:-
1 @FindBy(name = "txtUsername")
2 WebElement userName;
Action class contains methods for the action to be performed on the web elements identified in the locator
class.
The initElements is a static method of PageFactory class that is used to initialize all the web elements
located by @FindBy annotation. Only after the WebElements are initialized, they can be used in
the methods to perform actions.
1 public Login(WebDriver driver) {
2 [Link] = driver;
3 // This initElements method will create all WebElements
4 [Link](driver, this);

65
5 }
Below is the sample code of the LoginPageLocators.
1 import [Link];
2 import [Link];
3
4 public class LoginPageLocators {
5
6 @FindBy(name = "username")
7 public WebElement userName;
8
9 @FindBy(name = "password")
10 public WebElement password;
11
12 @FindBy(xpath = "//*[@id='app']/div[1]/div/div[1]/div/div[2]/div[2]/form/div[1]/div/span")
13 public WebElement missingUsernameErrorMessage;
14
15 @FindBy(xpath = "//*[@id='app']/div[1]/div/div[1]/div/div[2]/div[2]/form/div[3]/button")
16 public WebElement login;
17
18 @FindBy(xpath = "//*[@id='app']/div[1]/div/div[1]/div/div[2]/div[2]/div/div[1]/div[1]/p")
19 public WebElement errorMessage;
20
21 }
Below is the sample code for the HomePageLocators.
1 import [Link];
2 import [Link];
3
4 public class HomePageLocators {
5
6 @FindBy(xpath = "//span[@class='oxd-topbar-header-breadcrumb']/h6")
7 public WebElement homePageUserName;
8
9 }
Create the action classes for each web page. These action classes contain all the methods needed by the
step definitions. In this case, I have created 2 action classes – LoginPageActions, HomePageActions
LoginPageActions

1 import [Link];
2 import [Link];
3 import [Link];
4
5 public class LoginPageActions {
6
7 LoginPageLocators loginPageLocators = null;
8
9 public LoginPageActions() {
10

66
11 [Link] = new LoginPageLocators();
12
13 [Link]([Link](),loginPageLocators);
14 }
15
16 // Get the error message when username is blank
17 public String getMissingUsernameText() {
18 return [Link](); 19
}
20
21 // Get the Error Message
22 public String getErrorMessage() {
23 return [Link]();24
}
25
26 public void login(String strUserName, String strPassword) {
27
28 // Fill user name
29 [Link](strUserName);
30
31 // Fill password
32 [Link](strPassword);
33
34 // Click Login button
35 [Link]();
36
37 }
HomePageActions
1 import [Link];
2 import [Link];
3 import [Link];
4
5 public class HomePageActions {
6
7 HomePageLocators homePageLocators = null;
8
9 public HomePageActions() {
10
11 [Link] = new HomePageLocators();
12 [Link]([Link](),homePageLocators);13
}
14
15 // Get the User name from Home Page
16 public String getHomePageText() {
17 return [Link]();18
}

67
lOMoAR cPSD| 39861681

19
20 }
Create a Helper class where we are initializing the web driver, initializing the web driver wait,
defining the timeouts, and creating a private constructor of the class, it will declare the web driver, so
whenever we create an object of this class, a new web browser is invoked.
1 package [Link];
2
3 import [Link];
4 import [Link];
5 import [Link];
6 import [Link];
7 import [Link];
8
9 public class HelperClass {
10
11 private static HelperClass helperClass;
12
13 private static WebDriver driver;
14 public final static int TIMEOUT = 5;
15
16 private HelperClass() {
17
18 [Link]().setup();
19 ChromeOptions options = new ChromeOptions();
20 [Link]("--start-maximized");
21 driver = new ChromeDriver(options);
22 [Link]().timeouts().implicitlyWait([Link](TIMEOUT));
23 }
24
25 public static void openPage(String url) {
26 [Link](url);27
}
28
29 public static WebDriver getDriver() {
30 return driver;31
}
32
33 public static void setUpDriver() {
34
35 if (helperClass==null) {
36
37 helperClass = new HelperClass();
38 }
39 }
40
41 public static void tearDown() {

Downloaded by Priya Dharshini (priyadharshinie824@[Link])


lOMoAR cPSD| 39861681

42
43 if(driver!=null) {
44 [Link]();
45 [Link]();
46 }
47
48 helperClass = null;
49 }
50
51 }
Step 10 – Create a StepDefinition class in src/test/java
Create a Java Class called Definition where we will create the Test Code related to the Given, When
, Then of Feature file in src/test/java.

Now, we need to create the Step Definition of the Feature File – [Link].

Downloaded by Priya Dharshini (priyadharshinie824@[Link])


lOMoAR cPSD| 39861681

1 import [Link];
2 import [Link];
3 import [Link];
4 import [Link];
5 import [Link];
6 import [Link];
7 import [Link];
8
9 public class LoginPageDefinitions {
10
11 LoginPageActions objLogin = new LoginPageActions();
12 HomePageActions objHomePage = new HomePageActions();
13
14 @Given("User is on HRMLogin page {string}")
15 public void loginTest(String url) {
16
17 [Link](url);
18
19 }
20
21 @When("User enters username as {string} and password as {string}")
22 public void goToHomePage(String userName, String passWord) {
23
24 // login to application
25 [Link](userName, passWord);
26
27 // go the next page
28
29 }
30
31 @Then("User should be able to login successfully and new page open")
32 public void verifyLogin() {
33
34 // Verify home page
35 [Link]([Link]().contains("Dashboard"));
36
37 }
38
39 @Then("User should be able to see error message {string}")
40 public void verifyErrorMessage(String expectedErrorMessage) {
41
42 // Verify error message
43 [Link]([Link](),expectedErrorMessage);
44
45 }
46
lOMoAR cPSD| 39861681

47 @Then("User should be able to see a message {string} below Username")


48 public void verifyMissingUsernameMessage(String message) {
49
50 [Link]([Link](),message);
51 }
52
53 }
Step 11 – Create a Hook class in src/test/java
Create the hook class that contains the Before and After hook to initialize the web browser and
close the web browser. I have added the code to take the screenshot of the failed scenario in
@After Hook.

Below is the code for the Hooks class.

1 import [Link];
2 import [Link];
lOMoAR cPSD| 39861681

3 import [Link];
4 import [Link];
5 import [Link];
6 import [Link];
7
8 public class Hooks {
9
10 @Before
11 public static void setUp() {
12
13 [Link]();
14 }
15
16 @After
17 public static void tearDown(Scenario scenario) {
18
19 //validate if scenario has failed
20 if([Link]()) {
21 final byte[] screenshot = ((TakesScreenshot) [Link]())
22 .getScreenshotAs([Link]);
23 [Link](screenshot, "image/png", [Link]());24
}
25
26 [Link]();
27 }
}
Step 12 – Create a TestNG Cucumber Runner class in the src/test/java
Cucumber needs a TestRunner class to run the feature files. It is suggested to create a folder with
the name of the runner in the src/test/java directory and create the Cucumber TestRunner class in
this folder. Below is the code of the Cucumber TestRunner class.
lOMoAR cPSD| 39861681

Below is the code for CucumberRunnerTests class.


import [Link];
1 import [Link];
2
@CucumberOptions(tags = "", features = "src/test/resources/features/[Link]"
3
, glue = "[Link]",
4 plugin = {})
56
7
public class CucumberRunnerTests extends AbstractTestNGCucumberTests {
8 }
Note:- The name of the Runner class should end with Test otherwise we can’t run the tests using
Command Line.
Step 13 – Run the tests from TestNG
You can execute the test script by right-clicking on TestRunner class -> Run As TestNG. (Eclipse)
lOMoAR cPSD| 39861681

In the case of the IntelliJ project, right-click on the runner class and select Run ‘CucumberRunnerTests’.

The output of the above program is

Step 14 – Run the tests from [Link]


Create a [Link] as shown below and run the tests as TestNG.
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE suite SYSTEM "[Link]
3 <suite name="Suite">
4 <test name="Cucumber with TestNG Test">
5 <classes>
6 <class name="[Link]"/>
7 </classes>
8 </test><!-- Test -->
9 </suite><!-- Suite -->
lOMoAR cPSD| 39861681

The [Link] is highlighted below:

Step 15 – Run the tests from Command Line


Run the below command in the command prompt to run the tests and to get the test execution report.

1 mvn clean test


The output of the above program is

Step 16 – Cucumber Report Generation


To get Cucumber Test Reports, add [Link] under src/test/resources and add the below
instruction in the file.
1 [Link]=true
lOMoAR cPSD| 39861681

Below is the image of the Cucumber Report generated using the Cucumber Service.

In the above example, as we can see, one of the tests has failed. So, when a test fails, we have written
the code to take a screenshot of the failed step. The Attached Image shows the image of the failed
test. You can click on that to see the screenshot.
lOMoAR cPSD| 39861681

Step 17 – TestNG Report Generation


TestNG generates various types of reports under the target->surefire-reports folder like emailable-
[Link], [Link], [Link].
lOMoAR cPSD| 39861681

We are interested in the “[Link]” report. Open “[Link]“, as this is an HTML


report, and open it with the browser. The below image shows [Link].
[Link]
lOMoAR cPSD| 39861681

[Link]
TestNG also produces an “[Link]” report. The below image shows the [Link]
report.

RESULT:
Thus the application was implemented as Page object model using Selenium with
TestNG.

You might also like