0% found this document useful (0 votes)
38 views79 pages

ACFrOgB6jK0WfhM1ZuvHOBqx3q4rXbpoguYLcnw2et1IeZny7c VoF-UQWO5j4UuuBBhriAx3dfK3BMnPfFSruz whcsED5nFKjbYdVmoDiqO3iDjzXOwMQR8ppLWINU3tN8ObCFFpzvZF467Plz

The document outlines a series of experiments focused on testing an e-commerce web and mobile application, detailing the development of test plans, test cases, and defect reporting. It includes specific methodologies for functionality, usability, performance, security, compatibility, integration, and regression testing. Additionally, it specifies the necessary resources, tools, and deliverables required for effective testing of the application.
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)
38 views79 pages

ACFrOgB6jK0WfhM1ZuvHOBqx3q4rXbpoguYLcnw2et1IeZny7c VoF-UQWO5j4UuuBBhriAx3dfK3BMnPfFSruz whcsED5nFKjbYdVmoDiqO3iDjzXOwMQR8ppLWINU3tN8ObCFFpzvZF467Plz

The document outlines a series of experiments focused on testing an e-commerce web and mobile application, detailing the development of test plans, test cases, and defect reporting. It includes specific methodologies for functionality, usability, performance, security, compatibility, integration, and regression testing. Additionally, it specifies the necessary resources, tools, and deliverables required for effective testing of the application.
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
You are on page 1/ 79

INDEX PAGE

LIST OF EXPERIMENTS

Ex. No Date Name of the Experiment Page No Signature

1 Develop the test plan for testing an e-commerce web/mobile


application (www.amazon.in).

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 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
Exp.No.1
DEVELOP TEST PLAN DOCUMENT FOR TESTING
Date: E- COMMERCE WEB AND MOBILE APPLICATION

AIM

To develop test plan document for testing e-commerce or banking web and mobile application.

1) INTRODUCTION

The Test Plan is designed to prescribe the scope, approach, resources, and schedule of all testing
activities of the project HDFC Bank.

The plan identifies the items to be tested, the features to be tested, the types of testing to be
performed, the personnel responsible for testing, the resources and schedule required to complete
testing, and the risks associated with the plan

1.1) Scope

1.1.1) In Scope

All the feature of website HDFC Bank which were defined in software requirement specs are
need to be tested
1.1.2) Out of Scope

These features are not be tested because they are not included in the software requirement specs

 User Interfaces
 Hardware Interfaces
 Software Interfaces
 Database logical
 Communications Interfaces
 Website Security and Performance

1.2) Quality Objective

The test objectives are to verify the Functionality of website HDFC Bank, the project should
focus on testing the banking operation such as Account Management, Withdrawal, and Balance
etc. to guarantee all these operations can work normally in real business environment.

1.3) Roles and Responsibilities

The project should use outsource members as the tester to save the project cost.
2 TESTMETHODOLOGY

2.1 Overview

2.2 Test Levels

In the project HDFC Bank, there’re 3 types of testing should be conducted.

 Integration Testing (Individual software modules are combined and tested as a group)
 System Testing: Conducted on a complete, integrated system to evaluate the system’s
Compliance with its specified requirements
 /api-testing.html: Test all the API secrete for the software undertested

2.3 Bug Triage

2.4 Suspension Criteria and Resumption Requirements

If the team members report that there are 40% of test cases failed, suspend testing until the
development team fixes all the failed cases.

2.5 Test Completeness

 Specifies the criteria that denote a successful completion of a test phase


 Run rate is mandatory to be100% unless a clear reason is given.
 Pass rate is 80%, achieving the pass rate is mandatory

2.6 Project task and estimation and schedule


Schedule to complete these tasks

3 TEST DELIVERABLES

Test deliverables are provided as below

 Before testing phase


 Test plans document.
 Test cases documents
 Test Design specifications.
 During the testing

– Test Tool Simulators.

– Test Data

– Test Trace-ability Matrix–Error logs and execution logs.

After the testing cycles is over

 Test Results/reports
 Defect Report
 Installation/ Test procedures guidelines
 Release notes

4 RESOURCE & ENVIRONMENT NEEDS

4.1 Testing Tools


4.2 Test Environment

It mentions the minimum hardware and software requirements that will be used to test the Application.

Following software’s are required in addition to client-specifics software.

 Windows11 and above


 Office 2021 and above
 MS Exchange.

RESULT:

Test plan document for testing e-commerce or banking web and mobile application was created.
Exp.No.2

Date: CREATE TEST CASES FOR TESTING E-COMMERCE OR ANY


WEB AND MOBILE APPLICATION

AIM

1.To develop test cases for testing e-commerce or any web and mobile application

TEST SCENARIO–LOGIN
Test Scenario–Purchase
Test Scenario–Search

RESULT:

Test cases for testing e-commerce or any web and mobile application was developed.
Exp.No.3

Date: TEST THE E-COMMERCE APPLICATION AND REPORT THE


DEFECTS IN IT

Aim:
To test the e-commerce application and report the defects in it.

1. Functionality Testing:
● Ensure all features such as product browsing, searching, adding items to the cart, checkout process, account
creation/login, and payment processing are working correctly.
● Test various scenarios like adding different types of products (physical/digital), applying discounts, using different
payment methods, etc.
2. Usability Testing:
● Evaluate the user interface for intuitiveness and ease of navigation.
● Check if the layout is responsive across different devices and screen sizes.
● Verify that the website is accessible to users with disabilities.
3. Performance Testing:
● Test the application's response time by simulating different levels of user traffic.
● Verify the loading speed of pages, especially product listings and checkout pages.
● Ensure that the application can handle peak loads without crashing or slowing down.
4. Security Testing:
● Check for vulnerabilities such as SQL injection, cross-site scripting (XSS), and authentication flaws.
● Verify that sensitive information like payment details is encrypted during transmission.
● Test for proper session management and access control mechanisms.
5. Compatibility Testing:
● Test the application on different web browsers (Chrome, Firefox, Safari, etc.) and versions.
● Verify compatibility with various operating systems (Windows, macOS, Linux) and devices (desktops, laptops, tablets,
smartphones).
● Ensure that the website renders correctly on different resolutions and screen sizes.
6. Integration Testing:
● Test integrations with external services such as payment gateways, shipping carriers, and third-party APIs.
● Verify that data is synchronized accurately between the e-commerce platform and any external systems.
7. Regression Testing:
● Re-test previously fixed defects to ensure they haven’t reappeared.
● Test new features or changes to existing features to ensure they haven’t introduced new issues.
SEARCH FUNCTIONALITY:

Test Case Module Test Scenario Test Case Pre- requisites Test Data Step Test Step Expected Result Actual Result Status Defect ID
ID Name No.

TC0 01 Product Verify the Verify that the Browser should Username- 1 Open Browser should be Browser is opened Pass N/A
Search product search search field be installed Username browser opened
functionality accepts alphabets, Internet Password-
2 Open url Ecommerce website Ecommerce Pass N/A
numbers or connection password
should be opened website is opened
symbols. should be
present User
should be 3 Enter User should be able to User is able to Pass N/A
logged in username input username and enter username
and password and password
password
4 Click on Home page should be Home page is Pass N/A
loginbutton displayed after login displayed after
login
5 Click on the Search field should Search field Pass N/A
search field. accepts alphabets, accepts alphabets,
numbers or numbers or
symbols. symbols.

TC0 02 Product Verify the Verify that after Browser should Username- 1 Open Browser should be Browser is opened Pass N/A
Search product search entering search be installed Username browser opened
functionality text and clicking Internet Password-
2 Open url Ecommerce website Ecommerce Pass N/A
on the search connection password
should be opened website is opened
icon, the search should be
should be present user
performed. should be 3 Enter User should be able to User is able to Pass N/A
logged in username input username and enter username
and password and password
password
4 Click on Home page should be Home page is Pass N/A
loginbutton displayed after login displayed after
and user name should login
be displayed on home
page

5 Enter search Search should be Search is Pass N/A


text in the performed according performed
search field to search text according to
and click on provided by search text
the search user. provided by
icon. user.

TC0 03 Product Verify the Verify that the Browser should Username- 1 Open Browser should be Browser is opened Pass N/A
Search product search search results be installed Username browser opened
functionality should be as per Internet Password-
2 Open url Ecommerce website Ecommerce Pass N/A
the search query. connection password
should be opened website is opened
should be
present User
should be 3 Enter user should be able to User is able to Pass N/A
logged in username input username and enter username
and password and password
password
4 Click on Home page should be Home page is Pass N/A
loginbutton displayed after login displayed after
and user name should login
be displayed on home
page

5 Enter search Search should be Search is Pass N/A


text in search performed according performed
field to search text according to
and click on provided by the user. search text
the search provided by the
icon. user.
PRODUCT DETAILS

Test Module Test Scenario Test Case Pre- requisites Test Step Test Step Expected Result Actual Result Status Defect
Case ID Name Data No. ID
TC0 01 Product Verify the Verify that Browser should Userna 1 Open Browser should be Browser is Pass N/A
Details details on images of be installed me - browser opened opened
Product products Internet Userna
2 Open url Ecommerce website Ecommerce Pass N/A
Specification are connection me
should be opened website is opened
page displayed should be Passwo
correctly. present rd- 3 Enter User should be able to User is able to Pass N/A
passwo username input username and enter usernameand
rd and password password
password
4 Click on Home page should be Home page is Pass N/A
loginbutton displayed after login displayed after
login
5 Click on a The images of the The images of the Pass N/A
product product should be product are
displayed on displayed correctly. displayed
the home correctly.
page.
TC0 02 Product Verify the Verify that Browser should Userna 1 Open Browser should be Browser is Pass N/A
Details details on the price of be installed me - browser opened opened
Product the product Internet Userna 2 Open url Ecommerce website Ecommerce Pass N/A
Specification is displayed. connection me should be opened website is opened
page should be Passwo
present User rd- 3 Enter user should be able to User is able to Pass N/A
should be passwo username input username and enter usernameand
logged in rd and password password
password

4 Click on Home page should be Home page is Pass N/A


loginbutton displayed after login displayed after
and user name should login
be displayed on home
page

5 Click on a The images of the The images of the Pass N/A


product product should be product are
displayed on displayed correctly. displayed
home correctly.
TC0 03 Product Verify the Verify that Browser should Userna 1 Open Browser should be Browser is Pass N/A
Details details on the price of be installed me - browser opened opened
Product the product Internet Userna 2 Open url Ecommerce website Ecommerce Pass N/A
Specification is displayed. connection me should be opened website is opened
page should be Passwo
present User rd- 3 Enter user should be able to User is able to Pass N/Aṣ
should be passwo username input username and enter usernameand
logged in rd and password password
password
4 Click on Home page should be Home page is Pass N/A
loginbutton displayed after login displayed after
and user name should login
be displayed on home
page

5 Click on a The images of the The images of the Pass N/Aṣ


product product should be product are
displayed on displayed correctly. displayed
home correctly.

CART PAGE
Test Case ID Module Test Test Case Pre- requisites Test Data Step Test Step Expected Result Actual Result Status Defect
Name Scenario No. ID

TC0 01 Cart Page Verify the Verify that Browser should Username- 1 Open browser Browser should be opened Browser is opened Pass N/A
details on when a user be installed Username
Cart Page clicks on add Internet Password- 2 Open url Ecommerce website Ecommerce website Pass N/A
to cart, the connection password should be opened is opened
product should be
should be present
added to cart. 3 Enter User should be able to User is able to enter Pass N/A
username and input username and username and
password password password
4 Click on login Home page should be Home page is Pass N/A
button displayed after login displayed after login

5 Click on any The product page should The product page is Pass N/A
product be displayed. displayed.
displayed on
home page
6 Click on add to The product should be The product is Pass N/A
cart for the added to cart. added to cart.
product.
TC0 02 Cart Page Verify the Verify that Browser should Username- 1 Open browser Browser should be opened Browser is opened Pass N/A
details on when a user be installed Username
Cart Page clicks on add Internet Password- 2 Open url Ecommerce website Ecommerce website Pass N/A
to cart, the connection password should be opened is opened
product should be
should be present
added to cart. 3 Enter User should be able to User is able to enter Pass N/A
username and input username and username and
password password password
4 Click on login Home page should be Home page is Pass N/A
button displayed after login displayed after login

5 Click on any The product page should The product page is Pass N/A
product be displayed. displayed.
displayed on
home page
6 Click on add to The product should be The product is Pass N/A
cart for the added to cart. added to cart.
product.
TC0 03 Cart Page Verify the Verify that Browser should Username- 1 Open browser Browser should be opened Browser is opened Pass N/A
details on when a user be installed Username
Cart Page clicks on add Internet Password- 2 Open url Ecommerce website Ecommerce website Pass N/A
to cart, the connection password should be opened is opened
product should be
should be present
added to cart. 3 Enter User should be able to User is able to enter Pass N/A
username and input username and username and
password password password
4 Click on login Home page should be Home page is Pass N/A
button displayed after login displayed after login

5 Click on any The product page should The product page is Pass N/A
product be displayed. displayed.
displayed on
home page
6 Click on add to The product should be The product is Pass N/A
cart for the added to cart. added to cart.
product.

CHECKOUT AND PAYMENT


Test Module Test Test Pre- Step Expected Defec
Case Name Scena Case requisites Test Data No. Test Step Result Actual Status t ID
ID rio Result
Browser
Browser is
1 Open browser should be Pass N/A
opened
opened
Ecommerce Ecommerce
2 Open url website should website is Pass N/A
be opened opened
user should be User is able
Enter
able to input to enter
3 username and Pass N/A
username and username and
password
password password
Verify Browser
that should be Home page Home page is
delivery installed should be displayed
details Internet Username displayed after after login
Verify Click on
4 login and user and user Pass N/A
thedetails of items connectio - login
Checkout,Pay name should name is
TC0 01 on should n should Username button
ments Page be displayed displayed on
Checkout, be be Password-
on home page home page
Payments displaye present password
Page d at User Click on any
checkou should be The product The product
product
t. logged in 5 page should be page is Pass N/A
displayed on
displayed. displayed.
home page
Click on add The product The product
6 to cart for the should be is added to Pass N/A
product. added to cart. cart.
The checkout The checkout
Click on the page should be page is
N/A
7 Checkout displayed with displayed Pass
button. delivery with delivery
details. details.

Open Browser should Browser is


1 Pass N/A
browser be opened opened
Ecommerce Ecommerce
2 Open url website should website is Pass N/A
be opened opened
User is able
Enter user should be
to enter
username able to input
3 username Pass N/A
and username and
and
password password
password
Home page
Home page
is displayed
Browser should be
Verify that after login
should be Click on displayed after
delivery and user
Verify the installed 4 login login and user Pass N/A
details of Username- name is
details on Internet button name should be
items Username displayed
Checkout,Pay displayed on
TC0 Checkout, connection on home
ments Page should be Password- home page
02 Payments should be page
displayed password
Page present User
at Click on
should be
checkout. any
logged in The product The product
product
5 page should be page is Pass N/A
displayed
displayed. displayed.
on home
page

Click on
The product The product
add to cart
6 should be added is added to Pass N/A
for the
to cart. cart.
product.
The
checkout
The checkout
Click on page is
page should be
7 the displayed Pass N/A
displayed with
Checkout with
delivery details.
button. delivery
details.

Browser
Open Browser is
1 should be Pass N/A
browser opened
opened
Ecommerce
Ecommerce
website
2 Open url website is Pass N/A
should be
opened
opened
Enter user should User is able
username be able to to enter
3 input username Pass N/A
and
password username and
and password
password
Browser
Verify that should be Home page
Home page
delivery installed should be
is displayed
Verify the details of Internet Username- displayed
Checkout, after login
details on items connectio Username after login
TC0 03 Payments Click on and user
Checkout,Pay should be n should Password- 4 and user Pass N/A
Page login name is
ments Page displayed be present password name should
button displayed
at User be displayed
on home
checkout. should be on home
page
logged in page

Click on any The


The product
product product
5 page should Pass N/A
displayed on page is
be displayed.
home page displayed.
The product The
Click on add
should be product is
6 to cart for the Pass N/A
added to added to
product.
cart. cart.
The
The checkout checkout
Click on the page should page is
7 Checkout be displayed displayed Pass N/A
button. with delivery with
details. delivery
details.

MY ORDER

Test Module Name Test Scenario Test Case Pre- requisites Test Data Step Test Step Expected Result Actual Result Status Defect
Case No. ID
ID
TC0 01 My Orders Verify the Verify that the Browser should be Username - 1 Open browser Browser should be opened Browser is opened Pass N/A
Page details on user should be installed Internet Username
Orders Page able to track connection should Password-
the order on be present password
2 Open url Ecommerce website Ecommerce website is Pass N/A
My orders page.
should be opened opened

3 Enter username User should be able to User is able to enter Pass N/A
and password input username and username and
password password

4 Click on Home page should be Home page is displayed Pass N/A


loginbutton displayed after login after login

5 Click on My The orders by the user The product page is Pass N/A
orders button should be displayed. displayed.

6 Click on Tracking information Tracking information is Pass N/A


Trackorder should be displayed for displayed for that order.
for an order. that order.

TC0 02 My Orders Verify the Verify that the Browser should be Username - 1 Open browser Browser should be opened Browser is opened Pass N/A
Page details on user should be installed Internet Username
Orders Page able to track connection should Password-
the order on be present password
2 Open url Ecommerce website Ecommerce website is Pass N/A
My orders page.
should be opened opened

3 Enter username User should be able to User is able to enter Pass N/A
and password input username and username and
password password

4 Click on Home page should be Home page is displayed Pass N/A


loginbutton displayed after login after login

5 Click on My The orders by the user The product page is Pass N/A
orders button should be displayed. displayed.

6 Click on Tracking information Tracking information is Pass N/A


Trackorder should be displayed for displayed for that order.
for an order. that order.

TC0 03 My Orders Verify the Verify that the Browser should be Username - 1 Open browser Browser should be opened Browser is opened Pass N/A
Page details on user should be installed Internet Username
Orders Page able to track connection should Password-
the order on be present password
2 Open url Ecommerce website Ecommerce website is Pass N/A
My orders page.
should be opened opened

3 Enter username User should be able to User is able to enter Pass N/A
and password input username and username and
password password

4 Click on Home page should be Home page is displayed Pass N/A


loginbutton displayed after login after login

5 Click on My The orders by the user The product page is Pass N/A
orders button should be displayed. displayed.

CUSTOMER SERVICE

Test Module Test Scenario Test Case Pre- Test Data Step Test Step Expected Actual Status Defect ID
Case Name requisites No. Result Result
ID
TC0 01 Customer Verify the Verify that Browser Username - 1 Open Browser should Browser is Pass N/A
Service Page details on customer should be Username browser be opened opened
Customer service installed Password -
Service Page options Internet password 2 Open url Ecommerce Ecommerce Pass N/A
should be connection website should website is
present on should be be opened opened
the website. present 3 Enter user should be user is able to Pass N/A
username able to input enter
and username and username and
password password password

4 Click on Home page Home page is Pass N/A


login should be displayed
button displayed after after login
login
5 Click on Customer care Customer care Pass N/A
the page is page is
contact displayed. displayed.
customer
care
button.
TC0 02 Customer Verify the Verify that Browser Username - 1 Open Browser should Browser is Pass N/A
Service Page details on customer should be Username browser be opened opened
Customer service installed Password -
Service Page options Internet password 2 Open url Ecommerce Ecommerce Pass N/A
should be connection website should website is
present on should be be opened opened
the website. present 3 Enter user should be user is able to Pass N/A
username able to input enter
and username and username and
password password password
4 Click on Home page Home page is Pass N/A
login should be displayed
button displayed after after login
login
5 Click on Customer care Customer care Pass N/A
the page is page is
contact displayed. displayed.
customer
care
button.
TC0 03 Customer Verify the Verify that Browser Username - 1 Open Browser should Browser is Pass N/A
Service Page details on customer should be Username browser be opened opened
Customer service installed Password -
Service Page options Internet password 2 Open url Ecommerce Ecommerce Pass N/A
should be connection website should website is
present on should be be opened opened
the website. present 3 Enter user should be user is able to Pass N/A
username able to input enter
and username and username and
password password password
4 Click on Home page Home page is Pass N/A
login should be displayed
button displayed after after login
login

Conclusion
Thus, the e-commerce application is tested and the defects are reported successfully.
Exp.No.4
DEVELOP THE TEST PLAN AND DESIGN THE TEST CASES FOR AN
Date: INVENTORY CONTROL SYSTEM

Aim

To develop the test plan and design the test cases for an inventory control system.

Test Plan for an Inventory Control System

1. Introduction

The Inventory Control System is designed to efficiently manage inventory, track stock levels,
and ensureaccurate stock information. This test plan outlines the testing approach, scope,
objectives, and methodologies to verify the functionality, performance, and usability of the
system.

2. Objectives

The primary objectives of this test plan are to:

● Validate that the Inventory Control System meets the functional requirements.
● Verify the accuracy and consistency of inventory tracking.
● Assess system performance under varying loads.
● Ensure the system’s security mechanisms are effective
● Evaluate the system’s usability and user-friendliness.

3. Test Scope

The testing will cover the following aspects of the Inventory Control System:

● User authentication and authorization.


● Adding, updating, and deleting products in the inventory.
● Monitoring stock levels and receiving alerts for low stock.
● Generating various inventory reports.
● User interfaces for different user roles (admin, manager, employee).

4. Test Environment

● Hardware: Servers, workstations, mobile devices for testing different platforms.Software:


● Inventory Control System build, web browsers, databases.
● Network: LAN/WAN with various network conditions (latency, bandwidth).
● Test Data: Realistic inventory data and user scenarios for testing.
5. Test Data

Test data will include a range of products, quantities, prices, and suppliers. Both normal and
boundarytest cases will be created to cover various scenarios. Data will be structured to
validate different calculations and reports.

6. Test Cases

A comprehensive list of test cases will be created for functional, performance, security, and
usabilitytesting. Each test case will include:
● Test case ID
● Description of the scenario
● Preconditions
● Steps to execute the test
● Expected results
● Actual results Pass/fail status.

7. Types of Testing

● Unit Testing: Testing individual modules and functions.


● Integration Testing: Testing interactions between different system components.
● Functional Testing: Validating functional requirements.
● Performance Testing: Evaluating system response times and resource usage.
● Security Testing: Checking for vulnerabilities and unauthorized access.
● Usability Testing: Assessing user-friendliness and navigation.

8. Test Schedule

Testing Phases and Estimated Timeline:

● Unit Testing: 1 week


● Integration Testing: 2 weeks
● Functional Testing: 2 weeks
● Performance Testing: 1 week
● Security Testing: 1 week
● Usability Testing: 1 week

9. Defect Management

● Defects will be logged using a defect tracking tool.


● Defects will be classified by severity (critical, major, minor) and priority.
● Defects will be retested after resolution.

10. Risk Assessment

● Identified risks include data loss, system downtime, security breaches.


● Mitigation strategies include regular data backups, redundancy, and security protocols.
11. Test Deliverables

● Test cases document


● Test execution results and defect reports
● Performance testing results and analysis
● Usability testing observations and feedback

12.Resources

Test Manager: Responsible for overall test coordination.

Testers: Responsible for test execution, logging defects, and retesting.

13. Exit Criteria

● All high-priority defects are resolved.


● Key performance indicators meet predefined targets.
● All test cases are executed and passed.

14.Approval

This test plan requires approval from relevant stakeholders before testing commences.

15.Appendix

● Glossary of terms
● References used in the test plan
TEST CASES FOR INVENTORY MANAGEMENT SYSTEM
Test
Sl.no Action Steps Input Data Experienced Actual result Status
Case
result
s
Enter It should accept Invoice no.
1 TC−1 Invoice no Input*1021* Pass
Invoice no invoice no. isaccepted
Enter Input*27/11/20 It should accept Bill date
2 TC−2 Bill date Pass
Bill 21* bill date is
date accepted
Item name should Item name is
Item Select item
3 TC−3 − be automatically automatically Pass
name name
reflected reflected
Available It should reflect Item stock is
Click on
4 TC−4 item − automatically item reflected Pass
text box
stock stock automatically
Enter item Item quantity Item quantity is
5 TC−5 Quantity Input*5000* Pass
quantity should be accepted accepted
Price should be
Click on Price is reflected
6 TC−6 Price − reflected Pass
text box automatically
automatically
Total should be
Click on Total is reflected
7 TC−7 Total − reflected Pass
text box automatically
automatically
Enter Receive bill date
Receive Input*29/1/202 Receive bill date
8 TC−8 receive bill should be Pass
bill date 1 is accepted
date accepting
It should be adding
Click on Item is added to
9 TC−9 Add item − item reflecting in Pass
add item the database
database
Sr.No Action Steps Input Expected Actual Status
Data Result Result

1 username and Open the - The The fieldsare Pass


password field application and fields visible
check should
we
visible
2 username Open the Username The The user Pass
application and entered name
enter username user should be
name visible
should
be
visible
3 password Open the Password The The entered Pass
application and entered password is
enter a password password hidden
should

behidden
4 Check actions Open the Correct Login Login page is Pass
followed by application and password successful appeared
entering enter correct and page
username and username and username should
password password appear

5 Counting Open the Wrong 3 attempts 3 attempts Pass


attempts application and username should be are given for
under wrong and given for the user
username and password theuser
password

6 Blocking Open application Wrong The user The user is Pass


user from and enter wrong username should blocked
further username and and from login
attempts password for more password beblocked
than 3 times from login

7 Attempt 1 Open application Wrong 2 attempts 2 attempts Pass


and enter wrong username left left message
username and and message isdisplayed
password for once password should be
displayed
8 Attempt 2 Open application Wrong 1 attempt 1 attempt Pass
and enter wrong username leftmessage left message
username and and should be isdisplayed
password for password displayed
twice
RESULT:

Thus, the test plan and the test cases for an inventory control system are developed and
designedsuccessfully.
Exp.No.5
EXECUTE THE TEST CASES AGAINST A CLIENT SERVER OR
Date: DESKTOP APPLICATION AND IDENTIFY THE DEFECTS.

AIM:
To execute the test cases against a client server or desktop application and identify the
defects.

ALGORITHM:

1. Initialize Attempt Counter:

● Set the attempt variable to 3 to keep track of login attempts.

2. Retrieve Input Values:


● Get the values entered in the username and password fields.

3. Check Credentials:
● Verify if the entered username is "Form" and the password is "123".

4. Successful Login:
● If credentials match, display a success message and redirect to success.html.

5. Invalid Credentials:
● If credentials do not match, decrement the attempt variable by 1.

6. Display Remaining Attempts:


● If attempts remain, alert the user about the number of attempts left.

7. Disable Fields on Exceeding Attempts:


● If the number of attempts reaches 0, disable the username, password, and
submitbutton fields.
8. Handle Login Button Click:
● Bind the validate () function to the onclick event of the login button.

9. Redirect on Successful Login:


● In success.html, display a success message upon successful login.

10. Ensure Proper Code Execution:


● Ensure JavaScript file (login.js) is properly included in the HTML file.
● Ensure HTML elements have appropriate IDs and names to be accessed by
JavaScriptfunctions.
Program
//1.html

<html>

<head>

<title>Javascript Login Form Validation</title>

<!--IncludeJSFileHere -->

<script type="text/javascript" src="login.js"></script>

</head>

<body>

<div class="container">

<div class="main">

<h2>Javascript Login Form Validation</h2>

<form id="form_id" method="post" name="myform">

<label>UserName:</label>

<input type="text" name="username" id="username"/>

<label>Password:</label>

<input type="password" name="password" id="password"/>

<input type="button" value="Login" id="submit" onclick="validate()"/>

</form>

<span><b class="note">Note:</b>For this demo use following username and password.

<br/><b class="valid">UserName: Form<br/>Password:123</b></span>

</div>

</div>

</body>

</html>
//login.js
var attempt =3; //Variable to count number of attempts.

//BelowfunctionExecutesonclickofloginbutton.

function validate()

var

username=document.getElementById("username").v

alue;var

password=document.getElementById("password").v

alue; if(username=="Form" && password=="123")

alert("Login successfully");

window.location="success.html";//Redirecting To

Other Page.return false;

else {

attempt --; // Decrementing by one.

alert("You have left "+attempt"

attempt;");

// Disabling fields after

3attempts.if(attempt ==0) {

document.getElementById("username").disabled=true;

document.getElementById("password").disable

d =true;

document.getElementById("submit").disabled

=true; return false;

}
}

//success.html
<html>

<head>

<title>Javascript Login Form Validation</title>

</head>

<body>

<h2>SuccessfulLogin!</h2>

</body>

</html>

RESULT:

Thus, the test cases against a client server or desktop application have been written and thedefects are identified
Successfully.
Exp.No.6
TEST THE PERFORMANCE OF THE E-COMMERCE APPLICATION
Date:

AIM:

E-Commerce applications are designed in such a way that customers can easily make
purchasesat any time of the day, irrespective of where they are located. If an e-Commerce
application malfunctions during peak hours, not only will it cause customer dissatisfaction,
but it will also lead to revenue loss for the business.

To avoid such situations, companies can invest in performance testing of e-


Commerce applications that focuses on issues related to speed, stability, and scalability.
Hence, in the wake of increasing demand for online shopping, it is necessary to do
performance testing of the e-Commerceapplication and to ensure that the application is
stable and scalable enough to serve all customer requirements.

Goals of E-Commerce Performance Testing

Performance testing is carried out on e-Commerce software to ensure that the


platform is functioning as expected. Let’s explore why e-Commerce application performance
testing is importantand how it affects the app’s overall quality:

● Reduce Risks: Many times, making major and considerable changes to a site can cause
notablestrategic changes or even trigger significant losses. However, testing these changes in
a plannedmanner can help eliminate the chances of these uncertain revenue losses
● Increase Conversion Rates: By testing every aspect of an application and ensuring a
smoothvisitor experience through site optimization, the application conversion rate is
bound to increase.
● Improve User Engagement: Testing tells which page element or process affects a user’s
onsite journey and helps in rectifying the issues faster. The better the user experience, the
greater theonsite engagement.

Benefits of E-Commerce Application Performance Testing

Performance testing, when done effectively and consistently, can greatly boost
conversions while also enhancing the overall experience of site users. The following
reasons explain the significance of testing and optimization:

● Coupon codes or gift vouchers are provided to increase product sales and performance
tests ensure that coupon codes work well when applied to users in bulk. Multiple systems
like emailservers, social network sites, and enterprise content management systems are
involved in thebackend and the performance test ensures flawless functioning of various
features like product images/videos, and social media in such an integrated system.
● e-Commerce applications usually have more users than any other application and
validation ofusers is a must to filter out genuine customers. Performance test helps in
validating multiple sign-up and invoice email notifications in parallel.
● Augmented Reality (AR) is an advanced-level feature provided by modern e-Commerce
websitesso that customers can feel better without seeing products in person. With
augmented reality performance testing, we can make the feature more efficient and pleasing
to the eye.
● A recommendation system is a program that generates online recommendations using
severalalgorithms, artificial intelligence, and data analysis. A well-designed
recommendation systemhelps in better customer acquisition and retention. It is developed
for both new and existing customers with different behavior for different customer types.
Performance testing helps inmaking the recommendation system a faster system, to retain
online shoppers.
● Chatbots interact with online shoppers to improve the user experience, and any delay in
providing the required information may switch users to a competitor’s application.
Performancetests speed up chatbots to answer customer queries.
● Reviews are very important to increase the sale of a product. The majority of users prefer
visitingthe review listing page to get instant user feedback. Performance test helps in
optimizing customer review listing load time.
● e-Commerce applications attract the maximum number of customers during annual sales
events.Backend servers should be set with the optimal settings, keeping future users’ traffic
in mind. Performance tests help in identifying the servers’ optimum locations to manage a
higher numberof users.

Common Performance Testing Issues

Some common challenges faced in implementing performance testing are as follows:

● Slow DB server: Database size increases with the increase in product items of all ages, so
ensureto optimize DB queries.
● Faster Integrated Systems Communication: Multiple systems like email servers, social
media accounts, and payment channels are involved in the functioning of an e-Commerce
applicationto ensure that integrated systems work well under a heavy load.
● System Scaling: Brands cannot predict user load during peak hours; hence, the need of the
houris to be ready with tested scalable systems.
● Immoderate Scripts: Few E-Commerce applications are associated with third- party scripts
thatare running in the background like Google Analytics and Ads, and these widgets can
be a significant contributor to page load time.
● Slow Servers: Server resources and applications should be optimized to deliver content as
quicklyas possible after addressing any content-related performance issues.
● Massive Media: Oftentimes, images, videos, and other media are uploaded by non-
technical employees that aren’t familiar with the impact of loaded heavy files. It’s
important to ensurethese assets are optimized to maximize performance
Main Features to be Tested in E-Commerce Applications
Your e-Commerce website’s success depends on choosing the features to test to ensure that it
performsflawlessly. Some of the major features that require testing are as follows:

● Searching For a Product: e-Commerce sites provide various search filters to make the
search experience faster, which include price range, product type, country, and age. Hence,
ensure thatsearching for a product among billions of records does not halt the system and
return the expected records.
● Virtual Reality: Modern E-Commerce sites provide advanced-level features to visualize
products. Online shoppers can now see how they would look wearing an item virtually
Hence, we need toensure the smooth movement of virtual images for a better experience.
● Testing Payment Gateway Integration: Failed transactions are one of the main reasons why
most customers exit an application without completing the purchase. So, it’s important to
ensure theproper functioning of payment gateways.
● Product Details Page: A fast product listing is important because every consumer
will beattracted to the product by how it’s presented and how it’s visible to them.

Best Practices for Performance Testing

Mentioned below are some of the best practices for testing e-Commerce applications:

● Test all CDNs (content delivery networks) by repeating time-bound hot transactions
multipletimes.
● Performance testing of big data plays an important role to ensure faster decompression
andcompression cycles to speed up the application’s speed.
● Online shopping has opened doors worldwide for businesses. Vendors shifted their servers
to the cloud for better user coverage. Hence, tests from various geo-locations need to be
performed to identify latency issues and to ensure that the geographical location of a user
doesnot affect the speed of the application.
● Test individual servers before integration system testing to find bottlenecks like email
servers,social accounts, DB servers, and enterprise content management systems.
● Volume testing plays a crucial role in seeing how storage systems function with or
without aheavy load, hence including it in the test scope is a good practice.

Role of QA Source
Testing experts at QA Source have years of experience in running performance tests on a
wide range ofdomains including e-Commerce, media streaming, legal, human resources,
eLearning, healthcare, enterprise content management, financial, and many more. QA
Source assists teams in setting up theperformance test lab and identifying the best-fit
performance test scenarios to ensure the best user experience. Following are our high-level
performance testing services to meet the performance test requirement:
● Performance test plan
● Test data setup
● Simulation of test cases
● Generate performance test suite results
● Identify bottlenecks and follow up with the Dev team to fix them
● Generate daily status reports

RESULT:
Performance testing of e-Commerce applications is a crucial part of any Business’s
success. It helps eCommerce applications generate better user experience, safeguard user data
security, and ensuremobile responsiveness, security, and a quick load time. It is vital to
conduct quick and effective application performance testing from time to time to ensure that
the application is offering an exceptional customer experience to maximize revenue for
businesses.
Exp.No.7
AUTONMATE TESTING OF E-COMMERCE APPLICATION USING
Date: SELENIUM

AIM:

To automate the testing of e-commerce applications using selenium.

ALGORITHM:

1. Import the necessary libraries such as time and web driver from Selenium.
2. Create an instance of the WebDriver, specifying the browser (e.g., Chrome).
3. Use the WebDriver to navigate to the registration page URL.
4. Find the username input field on the registration form using a suitable method.
5. Use JavaScript to set the value of the username field to the desired username.
6. Find the password input field on the form using an appropriate method.
7. Utilize JavaScript to set the value of the password field to the desired password.
8. Locate the submit button and click it to submit the form.
9. If the form submission opens a new window or tab (e.g., a success page), switch to it.
10. Verify that the submission was successful (e.g., by checking for a success message).

Program

//1.html
<html>

<head>

<title>Javascript Login Form Validation</title>

<!--IncludeJSFileHere -->

<script type="text/javascript" src="login.js"></script>

</head>

<body>

<div class="container">

<div class="main">

<h2>Javascript Login Form Validation</h2>

<form id="form_id" method="post" name="myform">


<label>UserName:</label>

<input type="text" name="username" id="username"/>

<label>Password:</label>

<input type="password" name="password" id="password"/>

<input type="button" value="Login" id="submit" onclick="validate ()"/>

</form>

<span><b class="note">Note:</b>For this demo use following username and password.

<br/><b class="valid">UserName: Form<br/>Password:123</b></span>

</div>

</div>

</body>

</html>

//success.html

<html>

<head>

<title>Javascript Login Form Validation</title>

</head>

<body>

<h2>SuccessfulLogin!</h2>

</body>

</html>
Selenium code for User Registration
import time
from selenium import WebDriver browser =
WebDriver. Chrome() browser.
Get('http://127.0.0.1:5500/1.html') #time.sleep(5)
uname = browser.find_element("id", 'username')
browser.execute_script("arguments[0].value = 'Form';",
uname)#time.sleep(5)upass = browser.find_element("id",
'password') browser.execute_script("arguments[0].value = '123';",
upass)#time.sleep(5) browser.find_element("id",
'submit').click()#time.sleep(5)
newURl =
browser.window_handles[0]
browser.get(newURl)

RESULT:
Thus, the execution of the ecommerce application using the selenium is
successfully executed.
Exp.No.8
INTERGRATING TESTNG WITH THE TEST AUTOMATION
Date:

AIM:

To integrate the TestNG with the test automation.

ALGORITHM:

TestNG is a powerful testing framework, an enhanced version of JUnit which was in use for a long time
before TestNG came into existence. NG stands for 'Next Generation'.

TestNG framework provides the following features –


 Annotations help us organize the tests easily.
 Flexible test configuration.
 Test cases can be grouped more easily.
 Parallelization of tests can be achieved using TestNG.
 Support for data-driven testing.
 Inbuilt reporting.

Installing TestNG for Eclipse

Step 1 − Launch Eclipse and select 'Install New Software'.


Step 2 − Enter the URL as 'http://beust.com/eclipse' and click 'Add'

Step 3 − The dialog box 'Add Repository' opens. Enter the name as 'TestNG' and click 'OK'

Step 4 − Click 'Select All' and 'TestNG' would be selected as shown in the figure
Step 5 − Click 'Next' to continue.
Step 6 − Review the items that are selected and click 'Next'.

Step 7 − "Accept the License Agreement" and click 'Finish'.


Step 8 − TestNG starts installing and the progress would be shown follows.
Step 9 − Security Warning pops up as the validity of the software cannot be established. Click 'Ok'

Step 10 − The Installer prompts to restart Eclipse for the changes to take effect. Click 'Yes'.

TestNG-Eclipse Setup

Step 1 − Launch Eclipse and create a 'New Java Project' as shown below.

Step 2 − Enter the project name and click 'Next'.


Step 3 − Navigate to "Libraries" Tab and Add the Selenium Remote Control Server JAR file by clicking on
"Add External JAR's" as shown below.
Step 4 − The added JAR file is shown here. Click 'Add Library.
Step 5 − The 'Add Library' dialog opens. Select 'TestNG' and click 'Next' in the 'Add Library' dialog box.
Step 6 − The added 'TestNG' Library is added and it is displayed as shown below.
Step 7 − Upon creating the project, the structure of the project would be as shown below.
Step 8 − Right-click on 'src' folder and select New >> Other.

Step 9 − Select 'TestNG' and click 'Next'.


Step 10 − Select the 'Source Folder' name and click 'Ok'.
Step 11 − Select the 'Package name', the 'class name', and click 'Finish'.
Step 12 − The Package explorer and the created class would be displayed.

Result:
EXNO : 9 DEVELOP A MINI PROJECT
DATE : BUILD A DATA-DRIVEN FRAMEWORK USING SELENIUM and TestNG
BUILD PAGE OBJECT MODEL USING SELENIUM AND TestNG
BUILD BDD FRAMEWORK WITH SELENIUM,TestNG AND CUCUMBER

AIM:

To Built a Data Driven Framework using Selenium and TestNG,


To Built a Page Object Model using Selenium and TestNG
To Built BDD Framework with Selenium,TestNG and Cucumber

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 one.Dependency 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
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.

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.

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 POM.xml 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<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3<cucumber.version>7.14.0</cucumber.version>
4<selenium.version>4.14.0</selenium.version>
5<webdrivermanager.version>5.5.3</webdrivermanager.version>
6<testng.version>7.8.0</testng.version>
7<apache.common.version>2.4</apache.common.version>
8<maven.compiler.plugin.version>3.11.0</maven.compiler.plugin.version>
9<maven.surefire.plugin.version>3.1.2</maven.surefire.plugin.version>
10<maven.compiler.source.version>11</maven.compiler.source.version>
11<maven.compiler.target.version>11</maven.compiler.target.version>
12</properties>
13
14<dependencies>
15
16<dependency>
17<groupId>io.cucumber</groupId>
18<artifactId>cucumber-java</artifactId>
19<version>${cucumber.version}</version>
20</dependency> 21
22<dependency>
23<groupId>io.cucumber</groupId>
24<artifactId>cucumber-testng</artifactId>
25<version>${cucumber.version}</version>
26<scope>test</scope>
27</dependency> 28
29<!-- Selenium -->
30<dependency>
31<groupId>org.seleniumhq.selenium</groupId>
32<artifactId>selenium-java</artifactId>
33<version>${selenium.version}</version>
34</dependency> 35
36<!-- Web Driver Manager -->
3<dependency>
38<groupId>io.github.bonigarcia</groupId>
39<artifactId>webdrivermanager</artifactId>
40<version>${webdrivermanager.version}</version>
41</dependency> 42
43<!-- TestNG -->
44<dependency>
45<groupId>org.testng</groupId>
46<artifactId>testng</artifactId>
47<version>${testng.version}</version>
48<scope>test</scope>
49</dependency> 50
51<!-- Apache Common -->
52<dependency>
53<groupId>org.apache.directory.studio</groupId>
54<artifactId>org.apache.commons.io</artifactId>
55<version>${apache.common.version}</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>org.apache.maven.plugins</groupId>
4<artifactId>maven-compiler-plugin</artifactId>
5<version>${maven.compiler.plugin.version}</version>
6<configuration>
7<source>${maven.compiler.source.version}</source>
8<target>${maven.compiler.target.version}</target>
9</configuration>
10</plugin>
11<plugin>
12<groupId>org.apache.maven.plugins</groupId>
13<artifactId>maven-surefire-plugin</artifactId>
14<version>${maven.surefire.plugin.version}</version>
15<configuration>
16<includes>
17<include>**/*Tests.java</include>
18</includes>
19</configuration>
20</plugin>
21</plugins>
The complete POM.xml looks like as shown below

1<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=


2"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
3"http://maven.apache.org/POM/4.0.0https://maven.apache.org/xsd/maven-4.0.0.xsd">
4<modelVersion>4.0.0</modelVersion>
5<groupId>com.example</groupId>
6<artifactId>POM_CucumberTestNGDemo</artifactId>
7<version>0.0.1-SNAPSHOT</version> 8
9<properties>
10<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
11<cucumber.version>7.14.0</cucumber.version>
12<selenium.version>4.14.0</selenium.version>
13<webdrivermanager.version>5.5.3</webdrivermanager.version>
14<testng.version>7.8.0</testng.version>
15<apache.common.version>2.4</apache.common.version>
16<maven.compiler.plugin.version>3.11.0</maven.compiler.plugin.version>
17<maven.surefire.plugin.version>3.1.2</maven.surefire.plugin.version>
18<maven.compiler.source.version>11</maven.compiler.source.version>
19<maven.compiler.target.version>11</maven.compiler.target.version>
20</properties>
21<dependencies>
22
23
24<dependency>
25<groupId>io.cucumber</groupId>
26<artifactId>cucumber-java</artifactId>
27<version>${cucumber.version}</version>
28</dependency> 29
30<dependency>
31<groupId>io.cucumber</groupId>
32<artifactId>cucumber-testng</artifactId>
33<version>${cucumber.version}</version>
34<scope>test</scope>
35</dependency> 36
37<!-- Selenium -->
38<dependency>
39<groupId>org.seleniumhq.selenium</groupId>
40<artifactId>selenium-java</artifactId>
41<version>${selenium.version}</version>
42</dependency> 43
44<!-- Web Driver Manager -->
45<dependency>
46<groupId>io.github.bonigarcia</groupId>
47<artifactId>webdrivermanager</artifactId>
48<version>${webdrivermanager.version}</version>
49</dependency> 50
51<!-- TestNG -->
52<dependency>
53<groupId>org.testng</groupId>
54<artifactId>testng</artifactId>
55<version>${testng.version}</version>
56<scope>test</scope>
57</dependency> 58
59<!-- Apache Common -->
60<dependency>
61<groupId>org.apache.directory.studio</groupId>
62<artifactId>org.apache.commons.io</artifactId>
63<version>${apache.common.version}</version>
64</dependency> 65
66
67</dependencies> 68
69<build>
70<plugins>
71<plugin>
72<groupId>org.apache.maven.plugins</groupId>

73<artifactId>maven-compiler-plugin</artifactId>
74<version>${maven.compiler.plugin.version}</version>
75<configuration>
76<source>${maven.compiler.source.version}</source>
77<target>${maven.compiler.target.version}</target>
78</configuration>
79</plugin>
80<plugin>
81<groupId>org.apache.maven.plugins</groupId>
82<artifactId>maven-surefire-plugin</artifactId>
83<version>${maven.surefire.plugin.version}</version>
84<configuration>
85<suiteXmlFiles>
86<suiteXmlFile>testng.xml</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
2
3Background:
4Given User is on HRMLogin page "https://opensource-demo.orangehrmlive.com/"
5
6@ValidCredentials
7Scenario: Login with valid credentials
8
9When User enters username as "Admin" and password as "admin123"
10Then User should be able to login successfully and new page open
11
12@InvalidCredentials
13Scenario Outline: Login with invalid credentials
14
15When User enters username as "<username>" and password as "<password>"
16Then User should be able to see error message "<errorMessage>" 17
18Examples:
19| username | password | errorMessage|
20| Admin| admin12$$ | Invalid credentials|
21| admin$$| admin123 | Invalid credentials|
22| abc123| xyz$$| Invalid credentials| 23
24
25@MissingUsername
26Scenario Outline: Login with blank username 27
28When User enters username as " " and password as "admin123"
29Then 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.

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 – LoginPageDefinitions.java.
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")
2WebElement 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.
1publicLogin(WebDriver driver) {
2this.driver = driver;
3// This initElements method will create all WebElements
4PageFactory.initElements(driver, this);
5}
Below is the sample code of the LoginPageLocators.
1import org.openqa.selenium.WebElement;
2import org.openqa.selenium.support.FindBy;
3
4public class LoginPageLocators { 5
6@FindBy(name = "username")
7public WebElement userName; 8
9@FindBy(name = "password")
10public WebElement password; 1
12@FindBy(xpath = "//*[@id='app']/div[1]/div/div[1]/div/div[2]/div[2]/form/div[1]/div/span")
13public WebElement missingUsernameErrorMessage; 14
15@FindBy(xpath = "//*[@id='app']/div[1]/div/div[1]/div/div[2]/div[2]/form/div[3]/button")
16public WebElement login; 17
1@FindBy(xpath = "//*[@id='app']/div[1]/div/div[1]/div/div[2]/div[2]/div/div[1]/div[1]/p")
19public WebElement errorMessage;
20
21}
Below is the sample code for the HomePageLocators.
1import org.openqa.selenium.WebElement;
2import org.openqa.selenium.support.FindBy;
3
4public class HomePageLocators {
5
6@FindBy(xpath = "//span[@class='oxd-topbar-header-breadcrumb']/h6")
7public 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
1import org.example.locators.LoginPageLocators;
2import org.example.utils.HelperClass;
3import org.openqa.selenium.support.PageFactory;
4
5public class LoginPageActions {
6
7 LoginPageLocators loginPageLocators = null; 8
9public LoginPageActions() {
10
11
12
13
14}
15
this.loginPageLocators = new LoginPageLocators(); PageFactory.initElements(HelperClass.getDriver(),loginPageLocators);
16// Get the error message when username is blank
17public String getMissingUsernameText() {
18return loginPageLocators.missingUsernameErrorMessage.getText()
19}
20
21// Get the Error Message
22public String getErrorMessage() {
23return loginPageLocators.errorMessage.getText();
24}
25
26public void login(String strUserName, String strPassword)
27
28// Fill user name
29loginPageLocators.userName.sendKeys(strUserName);
30
31// Fill password
32loginPageLocators.password.sendKeys(strPassword);
33
34// Click Login button
35loginPageLocators.login.click();
36
37}
HomePageActions
1import org.example.locators.HomePageLocators;
2import org.example.utils.HelperClass;
3import org.openqa.selenium.support.PageFactory;
4
5public class HomePageActions {
6
7HomePageLocators homePageLocators = null;
8
9public HomePageActions() {
10
11this.homePageLocators = new HomePageLocators();
12PageFactory.initElements(HelperClass.getDriver(),homePageLocators);
13}
14
15// Get the User name from Home Page
16public String getHomePageText() {
17return homePageLocators.homePageUserName.getText();
18}
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, sowhenever we create
an object of this class, a new web browser is invoked.
1 package com.example.utils;
2
3 import java.time.Duration;
4 import org.openqa.selenium.WebDriver;
5 import org.openqa.selenium.chrome.ChromeDriver;
6 import io.github.bonigarcia.wdm.WebDriverManager;
7 import org.openqa.selenium.chrome.ChromeOptions;
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 WebDriverManager.chromedriver().setup();
19 ChromeOptions options = new ChromeOptions();
20 options.addArguments("--start-maximized");
21 driver = new ChromeDriver(options);
22 driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(TIMEOUT));
23 }
24
25 public static void openPage(String url) {
26 driver.get(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()
42
43 if(driver!=null) {
driver.close();
driver.quit();
}

helperClass = null
}}
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 – LoginPageDefinitions.java.
1import io.cucumber.java.en.Given;
2 import io.cucumber.java.en.Then;
3 import io.cucumber.java.en.When;
4 import org.example.actions.HomePageActions;
5 import org.example.actions.LoginPageActions;
6 import org.example.utils.HelperClass;
7 import org.testng.Assert; 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 HelperClass.openPage(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 objLogin.login(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 Assert.assertTrue(objHomePage.getHomePageText().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 Assert.assertEquals(objLogin.getErrorMessage(),expectedErrorMessage); 44
45 }
46

47
48
49
50
51
52
53 }

@Then("User should be able to see a message {string} below Username") public void
verifyMissingUsernameMessage(String message) {

Assert.assertEquals(objLogin.getMissingUsernameText(),message);
}

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 org.openqa.selenium.OutputType;
importorg.openqa.selenium.TakesScreenshot;

2 import com.example.utils.HelperClass;
3 import io.cucumber.java.After;
4 import io.cucumber.java.Before;
5 import io.cucumber.java.Scenario;
7
8 public class Hooks {
9
10 @Before
11 public static void setUp() {
12
13 HelperClass.setUpDriver();
14 }
15
16 @After
17 public static void tearDown(Scenario scenario) {
18
19 //validate if scenario has failed
20 if(scenario.isFailed()) {
21 final byte[] screenshot = ((TakesScreenshot) HelperClass.getDriver())
22 .getScreenshotAs(OutputType.BYTES);
23 scenario.attach(screenshot, "image/png", scenario.getName());24
}
25
26 HelperClass.tearDown();
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.
Below is the code for
CucumberRunnerTests
class.
1 import
io.cucumber.testng.Abst
ractTestNGCucumberTe
sts;
32 import
io.cucumber.testng.Cuc
umberOptions;
4 @,
gCluuec=um"obregr.Oe
xpatmiopnlse(.tdaegfsin
=it"i"o,nfse"a,tures =
"src/test/resources/featu
res/LoginPage.feature"
5 plugin = {}) 6
7 public class
CucumberRunnerTests
extends
AbstractTestNGCucum
berTests {
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)

In the case of the IntelliJ project, rightclick on the runner class and select Run
‘CucumberRunnerTests’.
The output of the above program is

Step 14 – Run the tests from testng.xml


Create a TestNG.xml as shown below and run the tests as TestNG.
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
3 <suite name="Suite">
4 <test name="Cucumber with TestNG Test">
5 <classes>
6 <class name="org.example.runner.CucumberRunnerTests"/>
7 </classes>
8 </test><!-- Test --> 9 </suite><!-- Suite -->

The testng.xml 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 cucumber.properties under src/test/resources and add the
below instruction in the file.
1 cucumber.publish.enabled=true
2 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.
Step 17 – TestNG Report Generation
TestNG generates various types of reports under the target->surefire-reports folder like emailable-
report.html, index.html, testng-results.xml.
We are interested in the “emailable-report.html” report. Open “emailable-report.html“, as this is an HTML
report, and open it with the browser. The below image shows emailable-report.html.
emailable-report.html

Index.html
TestNG also produces an “index.html” report. The below image shows the index.html report.

RESULT:

You might also like