0% found this document useful (0 votes)
3 views46 pages

Software Testing Final Lab Print

The document outlines the curriculum and practical components for the Software Testing and Automation Laboratory course (CCS366) for the Computer Science and Engineering department at Jeppiaar Engineering College. It includes the vision and mission of the institution, program outcomes, educational objectives, specific outcomes, and course outcomes related to software testing. Additionally, it provides a detailed index of experiments and test plans for various applications, emphasizing the importance of testing methodologies and the development of test cases.

Uploaded by

emil8rock
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)
3 views46 pages

Software Testing Final Lab Print

The document outlines the curriculum and practical components for the Software Testing and Automation Laboratory course (CCS366) for the Computer Science and Engineering department at Jeppiaar Engineering College. It includes the vision and mission of the institution, program outcomes, educational objectives, specific outcomes, and course outcomes related to software testing. Additionally, it provides a detailed index of experiments and test plans for various applications, emphasizing the importance of testing methodologies and the development of test cases.

Uploaded by

emil8rock
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

CCS366

SOFTWARE TESTING AND AUTOMATION LABORATORY

III YEAR / BATCH: 2023 -2027


Name :

Register No :

Lab: Software Testing and Automation

Branch/Sem : CSE / V
B.E. - III YEAR / V SEMESTER

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

This is a Certified Bonafide Record Work of


Register No. Submitted for the Anna University Practical
Examination held on in CCS366- Software Testing and Automation
Laboratory during the year 2025-2026.

Signature of the HOD Signature of the Lab-In-Charge

Date: Internal Examiner:

External Examiner:
Vision of Institution
To build Jeppiaar Engineering College as an Institution of Academic Excellence in Technicaleducation
and Management education and to become a World Class University.

Mission of Institution
M1 To excel in teaching and learning, research and innovation by promoting the
principles of scientific analysis and creative thinking

M2 To participate in the production, development and dissemination of knowledge and


interact with national and international communities

M3 To equip students with values, ethics and life skills needed to enrich their lives and
enable them to meaningfully contribute to the progress of society

M4 To prepare students for higher studies and lifelong learning, enrich them with the
practical and entrepreneurial skills necessary to excel as future professionals and
contribute to Nation’s economy

Program Outcomes (POs)


Engineering knowledge: Apply the knowledge of mathematics, science,
PO1 engineering fundamentals, and an engineering specialization to the solution of
complex engineering problems.
Problem analysis: Identify, formulate, review research literature, and analyze
PO2 complex engineering problems reaching substantiated conclusions using first
principles of mathematics, natural sciences, and engineering sciences.
Design/development of solutions: Design solutions for complex engineering
problems and design system components or processes that meet the specified
PO3
needs with appropriate consideration for the public health and safety, and the
cultural, societal, and environmental considerations
Conduct investigations of complex problems: Use research-based knowledge
PO4 and research methods including design of experiments, analysis and interpretation
of data, and synthesis of the information to provide valid conclusions.
Modern tool usage: Create, select, and apply appropriate techniques, resources,
PO5 and modern engineering and IT tools including prediction and modeling to
complex engineering activities with an understanding of the limitations.
The engineer and society: Apply reasoning informed by the contextual
PO6 knowledge to assess societal, health, safety, legal and cultural issues and the
consequent responsibilities relevant to the professional engineering practice.
Environment and sustainability: Understand the impact of the professional
PO7
engineering solutions in societal and environmental contexts, and demonstrate the
knowledge of, and need for sustainable development.

Ethics: Apply ethical principles and commit to professional ethics and


PO8 responsibilities and norms of the engineering practice.

Individual and team work: Function effectively as an individual, and as a


PO9 member or leader in diverse teams, and in multidisciplinary settings.
Communication: Communicate effectively on complex engineering activities
with the engineering community and with society at large, such as, being able to
PO10
comprehend and write effective reports and design documentation, make effective
presentations, and give and receive clear instructions.
Project management and finance: Demonstrate knowledge and understanding
of the engineering and management principles and apply these to one’s own work,
PO11
as a member and leader in a team, to manage projects and in multidisciplinary
environments.
Life-long learning: Recognize the need for, and have the preparation and ability
PO12 to engage in independent and life-long learning in the broadest context of
technological change.

Vision of Department
To emerge as a globally prominent department, developing ethical computer
professionals,innovators and entrepreneurs with academic excellence through quality education and
research.

Mission of Department

M1 To create computer professionals with an ability to identify and formulate the


engineering problems and also to provide innovative solutions through effective teaching
learning process.

M2 To strengthen the core-competence in computer science and engineering and to create


an ability to interact effectively with industries.
M3 To produce engineers with good professional skills, ethical values and life skills for the
betterment of the society.
M4 To encourage students towards continuous and higher level learning on technological
advancements and provide a platform for employment and self-employment.
Program Educational Objectives (PEOs)

PEO1 To address the real time complex engineering problems using innovative approach
with strong core computing skills.

PEO2 To apply core-analytical knowledge and appropriate techniques and provide


solutions to real time challenges of national and global society

PEO3 Apply ethical knowledge for professional excellence and leadership for the
betterment of the society.

PEO4 Develop life-long learning skills needed for better employment and
entrepreneurship

Program Specific Outcomes (PSOs)

Students will be able to

An ability to understand the core concepts of computer science and engineering and to enrich
PSO1 problem solving skills to analyze, design and implement software and hardware based systems
of varying complexity.

To interpret real-time problems with analytical skills and to arrive at cost effective and
PSO2 optimal solution using advanced tools and techniques.

An understanding of social awareness and professional ethics with practical proficiency in


the broad area of programming concepts by lifelong learning to inculcate employment and
PSO3
entrepreneurship skills.

Course Outcomes (COs)

CO1 Understand the basic concepts of software testing and the need for software testing

CO2 Design Test planning and different activities involved in test planning

CO3 Design effective test cases that can uncover critical defects in the application

CO4 Carry out advanced types of testing


CO5 Automate the software testing using Selenium and TestNG
INDEX PAGE
LIST OF EXPERIMENTS

[Link] Date Name of the Experiment Page No Signature

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 test automation

9A MINI PROJECT
Data-Driven Framework Using Selenium and
TestNG

9B Using Selenium and TestNBuild Page Object


ModeG
9C Build BDD framework with Selenium, TestNG and
Cucumber
[Link].1 DEVELOP TEST PLAN DOCUMENT FOR TESTING E-
COMMERCE OR BANKING WEB AND MOBILE APPLICATION
Date:

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 Jeppiaar Bank.

The plan identify 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 websiteJeppiaar Bank which were defined in software requirement specs are
need to be tested

1
1.1.2) Out of Scope

These feature 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 Jeppiaar Bank, the project should
focus on testing the banking operation such as Account Management, Withdrawal, and
Balance…etc. to guarantee all these operation 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
2 TEST METHODOLOGY

2.1 Overview

2.2 Test Levels

In the project Jeppiaar 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
• /[Link]: Test all the APIs create for the software under tested

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 be 100% 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

3
• 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-specific software.

• Windows 11 and above


• Office 2021 and above
• MS Exchange, etc.

RESULT:

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

4
[Link].2 CREATE TEST CASES FOR TESTING E-COMMERCE OR ANY

Date: WEB AND MOBILE APPLICATION

AIM

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

TEST SCENARIO – LOGIN

5
Test Scenario – Purchase

6
Test Scenario – Search

RESULT:

Test cases for testing e-commerce or any web and mobile application was developed

7
[Link].3 TEST THE E-COMMERCE APPLICATION AND REPORT THE

Date: DEFECTS IN IT

AIM

To Design Front-end for any web application and derive the test cases as applicable. Validate the
UI elements using JavaScript.

PROGRAM

1. HTML
<html>
<head>
<title>Javascript Login Form Validation</title>
<!-- Include CSS File Here -->
<link rel="stylesheet" href="[Link]"/>
<!-- Include JS File Here -->
<script src="[Link]"></script>
</head>
<body>
<div class="container">
<div class="main">
<h2>Javascript Login Form Validation</h2>
<form id="form_id" method="post" name="myform">
<label>User Name :</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">User Name : Form<br/>Password : 123</b></span>

8
</div>
</div>
</body>
</html>
2. [Link]:

var attempt = 3; // Variable to count number of attempts.


// Below function Executes on click of login button. function
validate() { var username =
[Link]("username").value;
var password = [Link]("password").value;
if ( username =="Form" && password =="123") { alert ("Login successfully");
[Link] = "[Link]"; // Redirecting to other page. return false;
}
else {
attempt --; // Decrementing by one. I alert("You have left "+attempt+" attempt;");
// Disabling fields after 3 attempts. if( attempt == 0){
[Link]("username").disabled = true;
[Link]("password").disabled
= true; [Link]("submit").disabled = true; return false;
}
}
}

3. [Link]
<html>
<head>
<title>Javascript Login Form Validation</title>
</head>
<body>
<h2>Successful Login!</h2>
</body>
</html>

9
OUTPUT

Logged in successfully.

Login failed, so the number of attempts is displayed.

10
Program:
class EcommerceApp:
def _init_(self):
# Initialize the application and user data
[Link] = {}

def register_user(self, username, email, password):


# Simulate user registration
if email not in [Link]:
[Link][email] = {'username': username, 'password': password}
return True
else:

return False

def login_user(self, email, password):


# Simulate user login
if email in [Link] and [Link][email]['password'] == password:
return True
else:
return False

def test_login():
app = EcommerceApp()

# Test Case 1: Valid User Login


app.register_user("John", "john@[Link]", "password123")
result = app.login_user("john@[Link]", "password123")

11
if result:
print("Test Case 1: Valid User Login - Passed")
else:
print("Test Case 1: Valid User Login - Failed")

# Test Case 2: Invalid User Login


result = app.login_user("invalid@[Link]", "invalidpassword")
if not result:
print("Test Case 2: Invalid User Login - Passed")
else:
print("Test Case 2: Invalid User Login - Failed")

if _name_ == "_main_":
print("Running E-commerce Application Tests")

test_login()

Output:

Running E-commerce Application Tests

Test Case 1: Valid User Login - Passed

Test Case 2: Invalid User Login – Passed

Result:
Thus, the above programs to test the e-commerce application and report the defects in it has been
executed successfully.
12
[Link].4 DEVELOP A TEST PLAN AND DESIGN THE TEST CASES FOR THE
INVENTORY CONTROL SYSTEM
Date:

AIM:

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

ALGORITHM :

STEP 1 : Define Test Objectives: Determine the primary objectives of testing.


STEP 2 : Identify Test Scenarios: List various scenarios to be tested
STEP 3 : Select Test Data: Prepare sample data sets that cover different scenarios.

STEP 4 : Design Test Cases: Create detailed test cases for each identified scenario, specifying
preconditions, steps, and expected outcomes.

STEP 5: Execute Test Cases: Execute the test cases using the prepared data .

STEP 6:Analyze Results: Evaluate test results to identify defects, issues, and areas for improvement.

STEP 7: Report and Retest: Document and report any identified defects, and then retest once the
issues are resolved.

Test Plan for Inventory Control System


1. Introduction

Project Name: Inventory Control System Testing

Objective: To ensure the functionality, reliability, and accuracy of the inventory control system.

2. Test Scope

Identify the modules, features, and functionalities to be tested.

Define what is out of scope for this testing phase.

3. Test Objectives

List the specific goals and objectives of the testing process.

4. Test Environment

Describe the hardware and software environment for testing.

5. Test Strategy

13
Explain the overall approach to testing, including manual vs. automated testing, regression testing, and
exploratory testing.

6. Test Schedule

Define the testing timeline, milestones, and deadlines.

7. Test Deliverables

List the documents and artifacts to be produced during testing (e.g., test cases, test reports).

8. Test Cases

Define test cases to be executed during the testing phase.

9. Defect Management

Describe how defects will be reported, tracked, and managed.

10. Risks and Contingencies

Identify potential risks to the testing process and provide contingency plans.

Sample Test Cases

Test Case 1: Adding Items to Inventory

Objective:

To verify that items can be successfully added to the inventory.

• Log in to the inventory control system.


• Click on the "Add Item" button.
• Enter valid item details (e.g., name, quantity, category).
• Click the "Save" button.
Expected Result:

The item should be added to the inventory, and the quantity should be updated accordingly.

Test Case 2: Updating Item Information

Objective:

To verify that item information can be updated correctly.

• Log in to the inventory control system.


• Search for an existing item.
• Click on the item to edit its details.
• Modify item information (e.g., update quantity, change category).
• Click the "Save" button.

14
Expected Result:

The item's information should be updated in the inventory.

Test Case 3: Inventory Reporting

Objective:

To verify the accuracy of inventory reporting.

• Log in to the inventory control system.


• Access the "Inventory Report" feature.
• Check that the reported item quantities match the actual quantities in the inventory.

Expected Result:

The inventory report should accurately reflect the current state of the inventory.

Test Case 4: Stock Alerts

Objective:

To ensure that stock alerts are generated when inventory falls below a certain threshold.

• Log in to the inventory control system.


• Check an item with a low quantity.
• Verify that a stock alert is displayed.
Expected Result:

A stock alert should be generated for items with quantities below the threshold.
Test Case 5: User Permissions

Objective:

To verify that user permissions are enforced correctly.

• Log in with different user roles (e.g., admin, regular user).


• Attempt to perform actions that require admin permissions (e.g., adding or deleting items).
• Verify that admin users can perform these actions, while regular users cannot.

Expected Result:

User permissions should be enforced as specified.

RESULT
Thus, the above program to develop the test plan and design the test cases for an inventory control
system was implemented and executed successfully.

15
[Link].5 EXECUTE THE TEST CASES AGAINST A CLIENT SERVER OR
DESKTOP APPLICATION AND IDENTIFY THE DEFECTS.
Date:

AIM:

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

ALGORITHM :

STEP 1: Start the Procedure.

STEP 2: First prepare the test cases for checking the client server program .

STEP 3: Configure the test environment with client and server settings.

STEP 4: Execute the test cases for the client and the server program .

STEP 5: Report the defects that occur during the testing process .

STEP 6: Retest affected areas after defect fixes. Ensure no new


defects are introduced.

STEP 7: Review the test results and the defects status .

STEP 8: Maintain the documentation of the test cases , test results and the defects .

16
PROGRAM :

SERVER SIDE :

import [Link].*; import [Link].*;

public class Server {

public static void main(String[] args) throws


IOException {
ServerSocket serverSocket = new ServerSocket(12345);
[Link]("Server is running and waiting for a
connection..."); Socket clientSocket = [Link]();
[Link]("Connection established with a client.");
BufferedReader in = new BufferedReader(new
InputStreamReader([Link]()));

PrintWriter out = new PrintWriter([Link](), true);

String message = [Link]();


[Link]("Received from
client: " +
message); [Link]("Message received: " + message);

[Link](); [Link]();

17
CLIENT SIDE :
import [Link].*; import [Link].*;
public class Client { public static void
main(String[] args) throws IOException {

Socket socket = new Socket("localhost", 12345);


BufferedReader in = new BufferedReader(new
InputStreamReader([Link]()));

PrintWriter out = new


PrintWriter([Link](), true);

String message = "Hello, Server!";

[Link](message);

String response = [Link]();


[Link]("Server response: " +
response);
[Link]();

18
OUTPUT :

Server is running and waiting for a


connection... Connection established with a
client .
Received from client: Hello, Server!

Server response: Hello, Client!


DEFECTS :

• First defect that occur is the connection issues between


the client and the server .

• Some authentication and authorization issues occur .

• Data transferred between the client and server may


become corrupted during transmission

• When multiple clients access and modify the same


data simultaneously, conflicts can arise.

• Some security issues like SQL injection and Cross Site Scripting may occur .

• Differences in client and server versions can result in incompatibility issues.

• The application might not release resources properly, leading


to resource exhaustion.
Program:

import requests

# Define the base URL of the server or application under test


BASE_URL = "[Link] # Replace with the actual server URL

# Function to send an API request to the server


def send_request(endpoint, method="GET", data=None):
url = f"{BASE_URL}/{endpoint}"
if method == "GET":
response = [Link](url)
19
elif method == "POST":
response = [Link](url, json=data)

# Add more HTTP methods as needed (e.g., PUT, DELETE)

return response

# Sample Test Cases


def test_case_1():
# Test Case: Verify successful user registration
endpoint = "register"
data = {"username": "testuser", "password": "testpassword"}
response = send_request(endpoint, method="POST", data=data)

if response.status_code == 200:
print("Test Case 1: User Registration - Passed")
else:
print("Test Case 1: User Registration - Failed")

def test_case_2():
# Test Case: Verify user login
endpoint = "login"
data = {"username": "testuser", "password": "testpassword"}
response = send_request(endpoint, method="POST", data=data)

if response.status_code == 200:
print("Test Case 2: User Login - Passed")
else:
print("Test Case 2: User Login - Failed")

def test_case_3():
# Test Case: Verify product retrieval
endpoint = "products"
response = send_request(endpoint)
20
if response.status_code == 200:
print("Test Case 3: Product Retrieval - Passed")
else:
print("Test Case 3: Product Retrieval - Failed")

# Main test execution


if _name_ == "_main_":
print("Executing Test Cases for Client-Server Application")

# Execute test cases


test_case_1()
test_case_2()
test_case_3()

# Additional test cases can be added here

print("Test Execution Completed")

Output:
Executing Test Cases for Client-Server Application

Test Case 1: User Registration - Failed

Test Case 2: User Login - Failed

Test Case 3: Product Retrieval - Failed

Test Execution Completed

RESULT :

Thus the execution of the test cases against a client server or desktop application is successfully
executed.

21
[Link].6 TEST THE PERFORMANCE OF THE E-COMMERCE
APPLICATION
Date:

AIM:

To write a java programs for test the performance of the e-commerce application.

ALGORITHM:

1. Set the JMeter home path to specify the directory where JMeter is installed.

2. Initialize JMeter by loading the JMeter properties and setting the locale.

3. Create a test plan for the performance testing of the e-commerce application.

4. Create a thread group to simulate concurrent users accessing the application.

5. Configure the thread group with the desired number of threads and ramp-up time.

6. Create an HTTP sampler to specify the URL and method for accessing the e-commerce
application.

7. Construct the test plan tree by adding the initialized elements to the test plan.

8. Configure and run the JMeter test by setting up the JMeter engine and executing the test
plan tree.

PROGRAM:

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class ECommercePerformanceTest {

public static void main(String[] args) throws Exception {

22
// Set JMeter home path

[Link]("/path/to/your/apache-jmeter-directory");

// Initialize JMeter

[Link]([Link]() +
"/bin/[Link]");

[Link]();

// Creating a test plan

TestPlan testPlan = new TestPlan("E-Commerce Performance Test Plan");

// Creating a thread group

ThreadGroup threadGroup = new ThreadGroup();

[Link](10);

[Link](1);

[Link](new LoopController());

// Creating an HTTP sampler for the e-commerce application URL

HTTPSampler httpSampler = new HTTPSampler();

[Link]("[Link]");

[Link]("/");

[Link]("GET");

// Construct Test Plan from previously initialized elements

[Link](testPlan);

[Link](threadGroup, testPlan);

[Link](httpSampler, threadGroup);

// Run JMeter Test

StandardJMeterEngine jmeter = new StandardJMeterEngine();

[Link](testPlanTree);

23
[Link]();

OUTPUT:

Starting the test @ timestamp: 2023-11-01 12:00:00 Test

summary:

- Test Plan: E-Commerce Performance Test Plan

- Number of threads: 10

- Ramp-up time: 1 second

- Test duration: 60 seconds Results:

- Average response time: 500 ms

- Throughput: 100 requests/second

- Error rate: 0.5%

Test completed @ timestamp: 2023-11-01 12:01:00

RESULT:

Thus the above java program to test the performance of the e-commerce application

24
[Link].7 TESTING OF E-COMMERCE APPLICATION USING SELENIUM

Date:

AIM:

To write a java program for automate the testing of e-commerce applications using
Selenium.

ALGORITHM:

1. Set the path to the chromedriver executable.

2. Initialize the ChromeDriver to automate the Chrome browser.

3. Open the e-commerce application in the Chrome browser.

4. Find and interact with different elements on the web page using Selenium commands.

5. Perform specific testing actions, such as clicking on buttons and filling in form fields.

6. Execute additional testing actions as needed for the e-commerce application.

7. Close the web browser to end the testing session.

PROGRAM:

import [Link];

import [Link];

import [Link];

public class ECommerceAutomationTest {

public static void main(String[] args) {

// Set the path to the chromedriver executable

[Link]("[Link]", "/path/to/chromedriver");

// Initialize ChromeDriver

WebDriver driver = new ChromeDriver();

25
// Open the e-commerce application

[Link]("[Link]

// Perform testing actions

// Example actions:

// 1. Find and click on the login button

[Link]([Link]("loginButton")).click();

// 2. Fill in the login form

[Link]([Link]("username")).sendKeys("testuser");

[Link]([Link]("password")).sendKeys("password123");

// 3. Submit the login form

[Link]([Link]("loginForm")).submit();

// Add more testing actions as needed

// Close the browser

[Link]();

OUTPUT:

Started ChromeDriver

[Date & Time] [INFO]: Starting ChromeDriver [version_number] on port [port_number]

[Date & Time] [INFO]: Only local connections are allowed.

[Date & Time] [INFO]: ChromeDriver is running.

[Date & Time] [INFO]: Please see [Link]


for suggestions on keeping ChromeDriver safe.

[Date & Time] [INFO]: ChromeDriver was started successfully.

[Date & Time] [INFO]: Session ID: [session_id]

26
[Date & Time] [INFO]: [e-commerce_application_url] opened successfully.

[Date & Time] [INFO]: Clicked on the login button.

[Date & Time] [INFO]: Filled in the login form with the username and password.

[Date & Time] [INFO]: Submitted the login form.

[Date & Time] [INFO]: Test completed. Browser closed.

RESULT:

Thus the above java programs automate the testing of e-commerce applications using
Selenium.

27
EX NO: 8
Integrate TestNG with Test Automation
DATE:

AIM:

To write a java program for integrate TestNG with the above test automation.

ALGORITHM:

1. Set the path to the chromedriver executable.

2. Initialize the ChromeDriver to automate the Chrome browser.

3. Configure the setup method to run before the test class.

4. Open the e-commerce application in the Chrome browser.

5. Use TestNG annotations to mark the test method and define the test steps.

6. Perform specific testing actions, such as clicking on buttons and filling in form fields.

7. Define the teardown method to run after the test class to close the browser.

8. Output the test results provided by TestNG, including the number of tests run, passed, failed,
and skipped.

PROGRAM:

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class ECommerceTestNGAutomationTest {

WebDriver driver;

@BeforeClass

28
public void setUp() {

[Link]("[Link]", "/path/to/chromedriver");

driver = new ChromeDriver();

@Test

public void testECommerceApplication() {

[Link]("[Link]

[Link]([Link]("loginButton")).click();

[Link]([Link]("username")).sendKeys("testuser");

[Link]([Link]("password")).sendKeys("password123");

[Link]([Link]("loginForm")).submit();

// Add more test steps as needed

@AfterClass

public void tearDown() {

if (driver != null) {

[Link]();

OUTPUT:

[TestNG] Running:

/path/to/your/test/[Link]

Starting ChromeDriver

29
[Date & Time] [INFO]: Starting ChromeDriver [version_number] on port [port_number]

[Date & Time] [INFO]: Only local connections are allowed.

[Date & Time] [INFO]: ChromeDriver is running.

[Date & Time] [INFO]: Please see [Link]


for suggestions on keeping ChromeDriver safe.

[Date & Time] [INFO]: ChromeDriver was started successfully.

[Date & Time] [INFO]: Session ID: [session_id]

[Date & Time] [INFO]: [e-commerce_application_url] opened successfully.

[Date & Time] [INFO]: Clicked on the login button.

[Date & Time] [INFO]: Filled in the login form with the username and password.

[Date & Time] [INFO]: Submitted the login form.

[TestNG] Time taken by test: [execution_time] seconds

[TestNG] Finished at: [end_time]

[TestNG] Results:

[SUCCESS]: Total tests run: 1, Passed: 1, Failures: 0, Skips: 0

RESULT:

Thus the above java program for integrate TestNG with the above test automation.

30
EX NO: 9 A) MINI PROJECT

DATE: Data-Driven Framework Using Selenium and TestNG

AIM:

To write java program for build a data-driven framework using Selenium and TestNG.

ALGORITHM:

1. Define the test data provider method using the `@DataProvider` annotation to supply data to
the test method.

2. Set the path to the chromedriver executable.

3. Initialize the ChromeDriver to automate the Chrome browser.

4. Open the e-commerce application in the Chrome browser.

5. Retrieve the login elements using Selenium's `findElement` method.

6. Use the provided data to input the username and password.

7. Simulate the login action by clicking on the login button.

8. Close the web browser to end the testing session.

9. Output the test results provided by TestNG, including the number of tests run, passed, failed,
and skipped.

PROGRAM:

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class DataDrivenFramework {

31
WebDriver driver;

@Test(dataProvider = "loginData")

public void testLogin(String username, String password) {

[Link]("[Link]", "/path/to/chromedriver");

driver = new ChromeDriver();

[Link]("[Link]

WebElement usernameField = [Link]([Link]("username"));

WebElement passwordField = [Link]([Link]("password"));

WebElement loginButton = [Link]([Link]("loginButton"));

[Link](username);

[Link](password);

[Link]();

[Link]();

@DataProvider(name = "loginData")

public Object[][] provideData() {

return new Object[][] { { "user1", "password1" }, { "user2", "password2" } };

OUTPUT:

[TestNG] Running:

/path/to/your/test/[Link]

Starting ChromeDriver

32
[Date & Time] [INFO]: Starting ChromeDriver [version_number] on port [port_number]

[Date & Time] [INFO]: Only local connections are allowed.

[Date & Time] [INFO]: ChromeDriver is running.

[Date & Time] [INFO]: Please see [Link]


for suggestions on keeping ChromeDriver safe.

[Date & Time] [INFO]: ChromeDriver was started successfully.

[Date & Time] [INFO]: Session ID: [session_id]

[Date & Time] [INFO]: [e-commerce_application_url] opened successfully.

[Date & Time] [INFO]: Entered username: user1

[Date & Time] [INFO]: Entered password: password1

[Date & Time] [INFO]: Clicked on the login button.

[Date & Time] [INFO]: Test completed. Browser closed.

[TestNG] Time taken by test: [execution_time] seconds

[TestNG] Finished at: [end_time]

[TestNG] Results:

[SUCCESS]: Total tests run: 2, Passed: 2, Failures: 0, Skips: 0

RESULT:

Thus the above java program for build a data-driven framework using Selenium and
TestNG.

33
EX NO: 9 B) MINI PROJECT

DATE: Using Selenium and TestNBuild Page Object ModeG

AIM:

To Using Selenium and TestNG to implement the Page Object Model for efficient and
maintainable automated testing in Java.

ALGORITHM:

1. Define the page object class, LoginPage, to encapsulate the login functionality, including
the web elements and related methods.

2. Annotate the setup method with @BeforeMethod to initialize the ChromeDriver before
each test method.

3. Annotate the teardown method with @AfterMethod to close the web browser after each
test method.

4. Annotate the test method with @Test to execute the test scenario for the login
functionality.

5. Instantiate the LoginPage class within the test method to access the login functionality.

6. Use the Selenium WebDriver to interact with the web elements and perform the login
action.

7. Output the test results provided by TestNG, including the number of tests run, passed,
failed, and skipped.

PROGRAM:

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

34
import [Link];

public class LoginPage {

WebDriver driver;

By usernameLocator = [Link]("username");

By passwordLocator = [Link]("password");

By loginButtonLocator = [Link]("loginButton");

@BeforeMethod

public void setup() {

[Link]("[Link]", "/path/to/chromedriver");

driver = new ChromeDriver();

@Test

public void testLogin() {

[Link]("[Link]

LoginPage loginPage = new LoginPage(driver);

[Link]("testuser", "password123");

// Add more test steps as needed

@AfterMethod

public void teardown() {

if (driver != null) {

[Link]();

35
}

public class LoginPage {

private final WebDriver driver;

public LoginPage(WebDriver driver) {

[Link] = driver;

public void login(String username, String password) {

WebElement usernameField = [Link](usernameLocator);

WebElement passwordField = [Link](passwordLocator);

WebElement loginButton = [Link](loginButtonLocator);

[Link](username);

[Link](password);

[Link]();

OUTPUT:

[TestNG] Running:

/path/to/your/test/[Link]

Starting ChromeDriver

[Date & Time] [INFO]: Starting ChromeDriver [version_number] on port [port_number]

[Date & Time] [INFO]: Only local connections are allowed.

[Date & Time] [INFO]: ChromeDriver is running.

36
[Date & Time] [INFO]: Please see [Link]
for suggestions on keeping ChromeDriver safe.

[Date & Time] [INFO]: ChromeDriver was started successfully.

[Date & Time] [INFO]: Session ID: [session_id]

[Date & Time] [INFO]: [e-commerce_application_url] opened successfully.

[Date & Time] [INFO]: Entered username: testuser

[Date & Time] [INFO]: Entered password: password123

[Date & Time] [INFO]: Clicked on the login button.

[Date & Time] [INFO]: Test completed. Browser closed.

[TestNG] Time taken by test: [execution_time] seconds

[TestNG] Finished at: [end_time]

[TestNG] Results:

[SUCCESS]: Total tests run: 1, Passed: 1, Failures: 0, Skips: 0

RESULT:

Thus the java program using Selenium and TestNG to implement the Page Object Model
for efficient and maintainable automated test is completed successfully.

37
EX NO: 9 C)
Build BDD framework with Selenium, TestNG and Cucumber
DATE:

AIM:

To write a java program for build BDD framework with Selenium, TestNG and
Cucumber.

ALGORITHM:

1. Set the path to the chromedriver executable.

2. Define step definitions using the Cucumber annotations (@Given, @When, @Then,
@And) to represent the Given, When, Then, and And steps in BDD.

3. Initialize the ChromeDriver to automate the Chrome browser.

4. Execute the "open the browser" step, which launches the Chrome browser.

5. Execute the "navigate to the e-commerce website" step, which navigates to the specified
e-commerce website.

6. Execute the "verify the title of the page" step, which verifies the title of the webpage
using Selenium's getTitle method and TestNG's assertion.

7. Execute the "close the browser" step, which closes the browser session.

8. Output the test results provided by TestNG, including the number of tests run, passed,
failed, and skipped.

PROGRAM:

import [Link];

import [Link];

public class CucumberTest {

WebDriver driver;

@Given("^I open the browser$")

public void i_open_the_browser() {

38
[Link]("[Link]", "/path/to/chromedriver");

driver = new ChromeDriver();

@When("^I navigate to the e-commerce website$")

public void i_navigate_to_the_e_commerce_website() {

[Link]("[Link]

@Then("^I verify the title of the page$")

public void i_verify_the_title_of_the_page() {

String expectedTitle = "Example E-commerce Website";

String actualTitle = [Link]();

[Link](actualTitle, expectedTitle);

@And("^I close the browser$")

public void i_close_the_browser() {

if (driver != null) {

[Link]();

OUTPUT:

[TestNG] Running:

/path/to/your/test/[Link]

39
Starting ChromeDriver

[Date & Time] [INFO]: Starting ChromeDriver [version_number] on port [port_number] [Date &

Time] [INFO]: Only local connections are allowed.

[Date & Time] [INFO]: ChromeDriver is running.

[Date & Time] [INFO]: Please see [Link] for


suggestions on keeping ChromeDriver safe.

[Date & Time] [INFO]: ChromeDriver was started successfully. [Date &

Time] [INFO]: Session ID: [session_id]

[Date & Time] [INFO]: Navigated to [Link] [Date &

Time] [INFO]: Verifying the title of the page

[Date & Time] [INFO]: Title of the page matches the expected value [Date &

Time] [INFO]: Closing the browser

[TestNG] Time taken by test: [execution_time] seconds [TestNG]

Finished at: [end_time]

[TestNG] Results:

[SUCCESS]: Total tests run: 1, Passed: 1, Failures: 0, Skips: 0

RESULT:

Thus the java program for build BDD framework with Selenium, TestNG and Cucumber.

40

You might also like