Software Testing Lab Record - IT Department
Software Testing Lab Record - IT Department
ODD SEMESTER
LAB RECORD
(REGULATION-2021)
NAME:
REGISTER NUMBER:
YEAR / SEMESTER:
BRANCH:
SRI SHANMUGHA COLLEGE OF ENGINEERING AND TECHNOLOGY
(An Autonomous Institution)
Pullipalayam, Morur (Po.), Sankari (Tk.), Salem (Dt.) - 637 304.
Certified that this is a Bonafide observation of Practical work done by Mr. /Ms. ........................................
Laboratory.
VISION
To be an institute of repute in all fields of education by implementing the best
practices akin to global standards for fostering domain knowledge and
developing research attitude among students to make them globally
competent.
MISSION
• Achieving excellence in Teaching & Learning process using state-of-the-art resources.
• Extending opportunity to upgrade faculty knowledge and skills.
• Implementing the best student training practices for requirements of industrial scenario
of the state.
• Motivating faculty and students in research activity for real time application.
VISION
To create a conducive environment for the development of academic and
innovative technocrats employable at the global level, socially responsible
and professionally competent to sustain the challenges
MISSION
M1: To develop competent and quality IT professionals by imparting state-of the art
technology learning methodologies.
M2: To promote Industry – Institution relationships among the students to become more
employable and better citizens to solve societal issues.
M3: To constantly upgrade the Faculty qualification with cutting edge technology to
achieve high status in technical and research areas.
PROGRAMME OUTCOMES
The UG program in Information Technology will prepare students to attain:
the knowledge
PO1 Engineering
ofknowledge:
mathematics,
Apply
science,
engineering fundamentals and an engineering specialization to the solution of complex
engineering problems.
PO2 Problem analysis: Identify, formulate, review research literature, and analyze
complex engineering problems reaching substantiated conclusions using first principles
of mathematics, natural sciences and engineering sciences.
PO3 Design/development of solutions: Design solutions for complex engineering
problems and design system components or processes that meet the specified needs with
societal and consideration for the public health, safety, cultural,
appropriate
environmental considerations.
PO4 Conduct investigations of complex problems: Use research-based
knowledge and
research methods including design of experiments, analysis, and interpretation
of data and
synthesis of the information to provide valid conclusions. PO5 Modern tool
usage: Create, select, apply appropriate techniques, resources, modern
engineering and IT tools including prediction and modeling to complex
engineering
activities with an understanding of the limitations. PO6 The engineer and
society: Apply reasoning informed by the contextual knowledge
to assess societal, health, safety, legal, cultural issues and the consequent
responsibilities
relevant to the professional engineering practice. PO7 Environment and
sustainability: Understand the impact of the professional
engineering solutions in societal, environmental contexts, demonstrate the
knowledge and
need for sustainable development. PO8 Ethics: Apply ethical principles, commit
to professional ethics, responsibilities and
norms of the engineering practice.
PO9 Individual and team work: Function effectively as an individual, as a
member or
leader in diverse teams and in multidisciplinary settings.
PO10 Communication: Communicate effectively on complex engineering
activities
with the engineering
comprehend, write community with society at large being able to
effective reports, design documentation, make effective presentations and
receive clear
instructions.
PO11 Project management and finance: Demonstrate knowledge, understanding
of the
PROGRAM EDUCATIONAL OBJECTIVES (PEO)
PEO 1: To ensure graduates will be proficient and core competent by utilizing the
fundamental knowledge of Basic Sciences, Engineering, Mathematics and Information
Technology for the applications of various Engineering and Technology disciplines.
PEO 2: To enable graduates to think logically and will have the capacity to understand the social,
business, environmental based hardware and software issues by designing optimal solutions
through lifelong learning.
Page
[Link]. Date Name of the Experiment No. Marks Sign
MINI PROJECT:
9 a)
BUILD A DATA-DRIVEN FRAMEWORK USING
SELENIUM AND TESTNG
• To get an insight about test automation and the tools used for test automation
COURSE OUTCOMES
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
[Link] Develop the test plan for testing an e-commerce web/mobile
application ([Link]).
Date:
Aim To develop the test Plan for Testing an E-commerce Web/Mobile Application
Introduction
The purpose of this test plan is to outline the testing approach for an e-commerce
web/mobile
application, specifically [Link]. The goal is to ensure that the application
functions as
intended, meets user requirements, and provides a seamless shopping experience.
Scope
The scope of this test plan includes testing the core functionalities of the e-commerce
application, such as browsing products, adding items to the cart, placing orders, and
managing
user accounts. It also covers testing across different platforms, including web and
mobile.
1. Validate the functionality of the e-commerce application.
Test Objectives
2. Verify that the application is user-friendly and provides a smooth shopping experience.
3. Ensure that the application is secure and protects user data.
4. Test the application's compatibility across different browsers and devices.
5. Evaluate the performance and scalability of the application under various load conditions.
6. Identify and report any defects or issues found during testing.
Test Environment
1. Web browsers: Chrome, Firefox, Safari, and Edge.
2. Mobile devices: iOS and Android.
3. Test management tool: Jira or any other preferred tool.
4. Test automation tool: Selenium WebDriver or any other preferred tool.
5. Load testing tool: JMeter or any other preferred tool.
Test Approach
1. Requirements Analysis:
Review the functional and non-functional requirements of the e-commerce application.
Identify testable features and prioritize them based on criticality.
2. Test Design:
Create test scenarios and test cases for each identified feature.
Include positive and negative test cases to cover different scenarios.
Define test data and test environment setup requirements.
3. Test Execution:
Execute test cases manually or using test automation tools.
Log defects in the test management tool and track their status.
Perform regression testing after each bug fix or application update.
4. Performance Testing:
Design and execute performance tests to evaluate the application's response time,
throughput, and scalability.
Simulate different user loads and monitor system resources during testing.
Identify performance bottlenecks and suggest improvements if needed.
5. Security Testing:
Conduct security testing to identify vulnerabilities and ensure the application protects
user data.
Test for common security issues like SQL injection, cross-site scripting (XSS), and
authentication vulnerabilities.
Implement security best practices and follow industry standards.
6. Compatibility Testing:
Test the application on different browsers, versions, and mobile devices.
Verify that the application renders correctly and functions as expected across various
platforms.
Test Deliverables
1. Test plan document.
2. Test scenarios and test cases.
3. Test execution reports.
4. Defect reports with severity and priority.
5. Performance test reports.
6. Security test reports.
Result
[Link] Design the test cases for testing the e-commerce application
Date:
Aim
To design the test cases for testing the e-commerce application
The user should be able to navigate to all the pages in the website
Search results should be displayed with the most relevant item being shown first
All data related to the product – title, price, images, and description are all visible clearly
Maintain a session for each user and test verify the session times out after a while
Validate If user is registered or not, and if not, provide an option to create an account
For sellers who want to create their catalog, they should be able to add their products, and this
flow should be tested.
Test that authenticated sellers can access authorized product creation panels under
authorized categories.
Test the maximum product creation limit to avoid adding more products to the catalog.
Test the product creation process is working fine for the seller
Test what parameters the search is based on – for example, product name, brand name,
category, etc.
Test if the search results are relevant
Test whether the search API is being called at every keystroke. (This isn’t recommended,
as it would unnecessarily cause multiple API calls to the database)
Filter Results
Example of a filter
Test if the user can filter based on all the parameters on the page
The user should be able to see results with default search criteria when at least one of the
filter parameters isn’t mandatory
Validation messages for invalid filter criteria
When at least one filter criteria are required, and the user selects none, proper error
messages are shown
All the links (size, Pincode check, etc) about the product should be functional.
Shopping Cart
An eCommerce website has many more tests or features, and testing each is very time-
consuming
and requires
website effort. Thankfully, a few tools and techniques are available to ease the
testing
process. With Browserstack:
One can go for automation test cases for ecommerce website across browsers, devices,
and operating systems.
Test for responsiveness with mobile devices and also perform performance testing
with Speedlab.
Result
[Link]
Test the e-commerce application and report the defects in it.
Date:
Aim
To test the e-commerce application and report the defects in it.
eCommerce website testing involves reviewing the website or web application for any issues
before it goes live and is open to the public. A web application requires testing on various features
like security, functionality, database, etc. The following types of testing willbe carried out here:
Functional Testing
User Interference testing
Security Testing
Browser compatibility Testing
Load and stress Testing
Database Testing
S
No. Description Inputs Expected Output
Login username,
password If the inputs are then
1. Register on the website. the user is registered.
Login Username,
Sign in to the website, choose the item
password Item is successfully
you want to buy and how many of it you
4. want to buy, and then add the chosen Item no. , name of deleted from the
item to your shopping cart and delete the item and its shopping cart if the
one item from the shopping cart quantity deletion is confirmed.
2. User Interface Testing: User interaction aspects are tested for proper operation
during user interface testing. Links, tables, forms, frames, and user interface
elements including text fields, radio buttons, check boxes, list boxes, combo boxes,
command buttons, and dialogue boxes are some of these characteristics. User
interface testing makes ensuring the program responds appropriately to mouse and
keyboard inputs and displays hyperlinks, tables, menus, error message boxes,
dialogue boxes, frames, buttons, and toolbars. There are mainly 2 types of user
interface testing: Navigation Testing: All internal and external links are tested for
functionality during the navigation process. Websites must be tested for their ability
to deliver reliable, well-organized links, as well as other navigational choices like site
maps and search engines. The following checklist can be considered for navigation
testing of an e-commerce site:
S
No. Description Expected Output
Click on every link to see how the The website’s contents can effectively be read
3. since appropriate horizontal and vertical scroll bars
material appears on each web page.
are available.
Form-Based Testing: Forms on websites must be tested to ensure that all fields function
properly. These types of forms on e-commerce sites can be seen while the user is registering or
when the user is filling in billing and shipping details. Form-based testing checks the following
concerns:
• Correct use of the tab key to go from one form field to another.
• Verifies that the data submitted in the form is in the correct format.
• Verifies that all necessary fields are filled out on the form.
S
No. Description Inputs Expected Outputs
Navigate using the tab The correct sequence is
1. key for changing the – followed while
field. navigation.
Browser Testing: There are several browsers available, and each of them behaves differently.
Although testing the web application with all browsers is impracticable, it is vital to validate the
web application with defined and prioritized platforms to assure proper operation. A browser
compatibility matrix may be developed to test the web application on multiple browsers.
Audio
Video
Text
3. Security Testing: Security is the process of protecting data from numerous attacks.
When interacting across a network, it is necessary to secure sensitive and critical
information and data. The user wishes to have a safeguard in place to protect personal,
sensitive, and financial information. We want data that is accurate, dependable, and
secure against illegal access. The primary areas of requirement include:
1. Authentication: Is the data sent by an authorized user?
2. Access Control: Is data secure against unauthorized users?
3. Transparency: Does the user receive exactly what is sent?
4. Delivery: Is the information reaching the intended recipient?
5. Reliability: How frequently does a failure occur? How long does it take for the network
recover after a failure?
to
4. Performance Testing: Performance tests, including load and stress testing, must be carried
out to make sure the web application can handle the demand during peak hours and serve the
user in a timely and dependable way.
The ability for several users to view an eCommerce web application at once is one of its main
benefits. As a result, thorough testing and monitoring of the application’s performance at peak
times is required.
Factors that influence performance testing are:
1. A number of users.
2. Response time.
3. Network Bandwidth.
4. User type.
5. Memory available.
6. Time spent averagely by a user
Performance testing includes:
Load Testing: Load testing comprises simulating several users accessing the web application
at the same time to test the web application under real-world conditions. It puts the web application
through its paces by overloading it. Load testing plans should be developed as early as practicable
in the software life cycle. Load testing includes the following measures to guarantee adequate
performance during peak hours:
1. Defining the load test environment that simulates the e-commerce website.
2. Defining the testing approach and calculating the number of users. By roughly calculating the
proportion of visitors who visit specific parts of the website, the total number of users may be
determined.
3. Identifying suitable metrics enables the practitioner to determine the system performance with
respect to the established quality benchmarks. These metrics are webpage view per hour, day,
and week, the number of concurrent users, wait time, elapsed time, etc.
4. Choosing the correct tool and running the load test. Complex online applications may be tested
using Microsoft’s Application Center Test (ACT) or Empirix’s e-Test tools.
Stress Testing: Stress testing is running a web application under more than maximum and
changing loads for extended periods of time. Unlike performance and load testing, stress testing
assesses the system’s response when it is subjected to a load that exceeds its defined limitations. It
is also used to monitor and test the dependability of a web application when available resources
are being exploited beyond their maximum capacity. The system’s
behavior is observed to identify when the system under stress test fails and how it
recovers from the failure.
The web application may be subjected to stress testing for the following reasons:
CPU and memory utilization.
Response time.
Backend database.
User types.
Concurrent users.
5. Database Testing: E-commerce is database-driven, it is critical that these apps function
effectively and protect the user’s sensitive data, such as personal information and credit
card information. Data-centric web applications must be tested to ensure error-free functioning
and greater client satisfaction. Consider the following scenario: you want to buy something from
the
an online retailer. When a user does a search using keywords and pricing preferences,
database server generates a database query. If the query does not take into account the customer’s
price choices owing to a programming error, the results will be incorrect. During database
testing, several types of defects must be verified and eliminated.
The following checklist can be considered for database testing:
Yes /
Description No
Are backup and recovery processes designed to assure the user’s uninterrupted
service?
Does the database have adequate capacity and memory to store records and manage
various administrative and user operations?
• Google Analytics
test how well Content Experiments:- Experiments allow you to
different versions of your sites perform in terms of encouraging your users to complete
specified tasks. Test up to five different versions of a page at different URLs to determine
which one generates the most conversions. It helps in usability and performance testing.
• Silverback: Silverback is a Mac-only usability testing application. It enables you to
capture screen activity, record usability testing sessions, assign assignments, and highlight
significant moments within a session.
• [Link]: [Link] offers usability testing on demand. Use one of
the configurable templates to create your exam. Choose participants by selecting
demographics for your intended audience. View videos of participants using your
website, get written responses, and ask follow-up questions.
• [Link]: [Link] lets you help in performance testing.
• Concept feedback: It gives expert opinions on usability testing.
• HotJar: This is the tool that reveals the online behavior and voice of the users.
Result:
[Link]
Develop the test plan and design the test cases for an inventory control
Date: system.
Aim
To develop the test plan and design the test cases for an inventory controlsystem.
Result
[Link]
Execute the test cases against a client server or desktop application and
Date: identify the defects.
Aim
To execute the test cases against a client server or desktop application and identify the defects.
Result
[Link]
Test the performance of the e-commerce application.
Date:
Aim
To test the performance of the e-commerce application.
models,
4) Test
etc., is Payments
essential Systems and Gateways E-commerce websites and applications
performance of an to determine if certain configurations negatively affect the
need to be able
application to handle multiple transactions at the
or a website.
same time. Testing payment systems is critical step in the QA process, and
should not be
skipped for any reason. Testing the performance of payment systems will help the
QA team
uncover any issues that can disrupt or block transactions, especially when a large
number of
users checkout at the same time. When it comes to third-party payment gateways, it
is important note that testing can be a bit
more
a challenging. This is because most payment gateways providers do not provide
favorable testing environment. While this may sound unreasonable, it is a way for
payment
gateway providers to prevent their portals from being flooded with tons of
virtualusers.
Using a sandbox environment, QA teams can overcome this challenge in creating a
safe testing
environment in order to test key scenarios on an application or site with a fully
integrated payment gateway. Result
[Link]: 7 Automate the testing of e-commerce applications using Selenium.
Date:
Aim
To Automate the testing of e-commerce applications using Selenium.
[Link] the 'User Registration and Login' of Amazon like an e-commerce website
Positive Scenario
1. Test Case - Automate the User Registration process of an e-commerce website.
Steps to Automate:
1. Open this URL [Link]
2. Click on the sign-in link.
3. Enter your email address in the 'Create and Account' section.
4. Click on Create an Account button.
5. Enter your Personal Information, Address, and Contact info.
6. Click on the Register button.
7. Validate that the user is created.
Negative Scenarios
2. Test Case - Verify invalid email address error.
Steps to Automate:
1. Open this URL [Link]
2. Click on the sign-in link.
3. Enter an invalid email address in the email box and click enter.
4. Validate that an error message is displaying saying "Invalid email address."
[Link] the 'Search Product' feature of Amazon like e-commerce website with
Selenium
1. Test Case - Automate the 'Search Product' feature of the e-commerce website with
Selenium.
Steps to Automate:
1. Open link [Link]
2. Move your cursor over the Women's link.
3. Click on the sub-menu 'T-shirts'
4. Get the Name/Text of the first product displayed on the page.
5. Now enter the same product name in the search bar present at the top of the page
details which
were displayed on T-Shirt's page.
Automation Code for Product Search: import [Link]; import
[Link]; import [Link]; import
[Link]; import
[Link]; import
[Link];
import [Link];
[Link]().setup();
WebDriver driver=new ChromeDriver();
String URL="[Link]
[Link](URL);
[Link]().window().maximize();
6. Automate the 'Buy Product' feature of Amazon like an e-commerce website with
Selenium
The most important function of an e-commerce website is buying a product, which includes
various steps like selecting a product, selecting size/color, adding to the cart, checkout, etc. You
will find every test scenario along with the automation code in the following section.
1. Test Case - Automate the end-to-end "Buy Product" feature of the e-commerce website.
Steps to Automate:
1. Open link [Link]
2. log in to the website.
3. Move your cursor over the Women's link.
4. Click on the sub-menu 'T-shirts'.
5. Mouse hover on the second product displayed.
6. 'More' button will be displayed, click on the 'More' button.
7. Increase quantity to 2.
8. Select size 'L'
9. Select color.
10. Click the 'Add to Cart' button.
11. Click the 'Proceed to checkout' button.
12. Complete the buy order process till payment.
13. Make sure that the Product is ordered.
import [Link];
//Click on Sign in
[Link]([Link]("Sign in")).click();
//Login
[Link]([Link]("email")).sendKeys("test1249@[Link]");
[Link]([Link]("passwd")).sendKeys("PKR@PKR");
[Link]([Link]("SubmitLogin")).click();
//Click on Women
[Link]([Link]("WOMEN")).click();
WebElement
SecondImg=[Link]([Link]("/html/body/div[1]/div[2]/div/div[3]/div[2]/ul/li[2]/div
/div[1]/div/a[1]/img"));
WebElement
MoreBtn=[Link]([Link]("/html/body[1]/div[1]/div[2]/div[1]/div[3]/div[2]/ul/li[2]/
div[1]/div[2]/div[2]/a[2]"));
Actions actions=new Actions(driver);
[Link](SecondImg).moveToElement(MoreBtn).click().perform();
//Change quantity by 2
[Link]([Link]("quantity_wanted")).clear();
[Link]([Link]("quantity_wanted")).sendKeys("2");
//Select size as L
WebElement Sizedrpdwn=[Link]([Link]("//*[@id='group_1']"));
Select oSelect=new Select(Sizedrpdwn);
[Link]("M");
//Select Color
[Link]([Link]("color_11")).click();
//Click on add to cart
[Link]([Link]("//p[@id='add_to_cart']//span[.='Add to cart']")).click();
//Click on proceed
[Link]([Link]("/html//div[@id='layer_cart']//a[@title='Proceed to
checkout']/span")).click();
//Checkout page Proceed
[Link]([Link]("/html/body/div[1]/div[2]/div/div[3]/div/p[2]/a[1]/span")).click();
[Link]([Link]("/html/body/div[1]/div[2]/div/div[3]/div/form/p/button/span")).clic
k();
/Agree terms&Conditions
[Link]([Link]("//*[@id=\"cgv\"]")).click();
[Link]([Link]("/html/body/div[1]/div[2]/div/div[3]/div/div/form/p/button/span")).
click();
[Link]([Link]("/html/body/div[1]/div[2]/div/div[3]/div/div/div[3]/div[2]/div/p/a")
).click();
//Confirm the order
[Link]([Link]("/html/body/div[1]/div[2]/div/div[3]/div/form/p/button/span")).clic
k();
//Get Text
String
ConfirmationText=[Link]([Link]("//div[@id='center_column']/p[@class='alert
alert-success']")).getText();
// Verify that Product is ordered
if([Link]("complete")) {
[Link]("Order Completed: Test Case Passed");
}
else {
2. Test Case - Verify that 'Add to Wishlist' only works after login.
Steps to Automate:
o Open link [Link]
o Move your cursor over the Women's link.
o Click on the sub-menu 'T-shirts'.
o Mouse hover on the second product displayed.
o 'Add to Wishlist' will appear on the bottom of that product, click on it.
o Verify that the error message is displayed 'You must be logged in to manage your
wish list.'
3. Test Case - Verify that Total Price is reflecting correctly if the user changes quantity on
the 'Shopping Cart Summary' Page.
Steps to Automate:
Result
[Link] Integrate TestNG with the above test automation.
Date:
Aim
To integrate TestNG with the above test automation.
Table of Contents
1. Dependency List
2. Implementation Steps
1. Download and Install Java
2. Download and setup Eclipse IDE on the system
3. Setup Maven
4. Create a new Maven Project
5. Add Selenium and TestNG dependencies to the project
6. Create a Test file under src/test/java
7. Test Execution through TestNG
8. Run the tests from [Link]
9. TestNG Report Generation
Dependency List
1. Selenium- 4.12.1
2. Java 8 or above
3. TestNG – 7.8.0
4. Maven – 3.8.1
5. WebdriverManager – 5.5.3
Implementation Steps
Step 1- Download and Install Java
Selenium needs Java to be installed on the system to run the tests. Click hereHow
to learn
to
install Java.
Step 2 – Download and setup Eclipse IDE on the system
The Eclipse IDE (integrated development environment) provides strong support for Java
developers, which is needed to write Java code. Click here to learn How to install Eclipse.
Step 3 – Setup Maven
To build a test framework, we need to add a number of dependencies to the project. It is a very
tedious and cumbersome process to add each dependency manually. So, to overcome this
problem, we use a build management tool. Maven is a build management tool that is used to
define project structure, dependencies, build, and test management. Click here to learn How to
install Maven.
Step 4 – Create a new Maven Project
Click here to learn How to create a Maven project
Below is the Maven project structure. Here,
Group Id – [Link]
Artifact Id – Selenium_TestNGDemo
Version – 0.0.1-SNAPSHOT
Package – com. example. Selenium_TestNGDemo
2 xsi:schemaLocation="[Link] [Link]
4.0. [Link]
3 <modelVersion>4.0.0</modelVersion>
4
5 <groupId>[Link]</groupId>
6 <artifactId>Log4j2_Demo</artifactId>
7 <version>1.0-SNAPSHOT</version>
8 <packaging>jar</packaging>
9
10 <name>Log4j2_Demo</name>
11 <url>[Link]
12
13 <properties>
14 <[Link]>4.12.1</[Link]>
15 <[Link]>7.8.0</[Link]>
16 <[Link]>5.5.3</[Link]>
17 <[Link]>3.1.2</[Link]>
18 <[Link]>3.11.0</[Link]>
19 <[Link]>UTF-8</[Link]>
20 <[Link]>11</[Link]>
21 <[Link]>11</[Link]>
22 </properties>
23
24 <dependencies>
25
26 <!-- TestNG Dependency -->
27 <dependency>
28 <groupId>[Link]</groupId>
29 <artifactId>testng</artifactId>
30 <version>${[Link]}</version>
31 <scope>test</scope>
32 </dependency>
33
34 <!-- WebDriverManager Dependency -->
35 <dependency>
36 <groupId>[Link]</groupId>
37 <artifactId>webdrivermanager</artifactId>
38 <version>${[Link]}</version>
39 </dependency>
40
41 <!-- Selenium Dependency -->
42 <dependency>
43 <groupId>[Link]</groupId>
44 <artifactId>selenium-java</artifactId>
45 <version>${[Link]}</version>
46 </dependency>
47
48 </dependencies>
49
50 <build>
51
52 <plugins>
53 <plugin>
54 <groupId>[Link]</groupId>
55 <artifactId>maven-surefire-plugin</artifactId>
56 <version>${[Link]}</version>
57 <configuration>
58 <skipTests>false</skipTests>
59 <skip>false</skip>
60 <testFailureIgnore>true</testFailureIgnore>
61 </configuration>
62 </plugin>
63
64 <plugin>
65 <groupId>[Link]</groupId>
66 <artifactId>maven-compiler-plugin</artifactId>
67 <version>${[Link]}</version>
68 <configuration>
69 <source>${[Link]}</source>
70 <target>${[Link]}</target>
71 <fork>true</fork>
72 </configuration>
73 </plugin>
74 </plugins>
75
76 </build>
77
78
</project>
After the addition of dependencies in [Link], the Maven Dependencies folder will be updated
automatically with all the JAR file related to the dependencies.
Step 6 – Create a Test file under src/test/java
@BeforeMethod – This annotated method will be run before each test method i.e say
there are
three test methods (i.e test cases), then @BeforeMethod annotated method will be
called thrice
before each test method. @AfterMethod – methods under this annotation will be
executed after each Test method. @Test – The annotated method is part of a test case.
Description – You can describe your test case under the description, stating what it
1 description = "This test validates title of login functionality"
does.
Priority – You can prioritize the order of your test methods by defining a priority. Based
on the
defined priority, the test shall execute in that order.
1priority = [Link];
import
import [Link];
1 import
import [Link];
[Link];
import
import [Link];
5 6 7 [Link];
2 3 4import 9 10 11
[Link];
import [Link];
import [Link];
12 import [Link];
13 14
15
16 17
18
19
20
By
By userName
passWord == [Link]("password");
[Link]("username");
By loginBtn =
[Link]("//*[@id='app']/div[1]/div/div[1]/div/div[2]/div[2]/form/div[3]/button");
21 By loginTitle = [Link]("//*[@id='app']/div[1]/div/div[1]/div/div[2]/h5");
22
23 By dashboardPage = [Link]("//*[@id='app']/div[1]/div[1]/header/div[1]/div[1]/span/h6");
24
25
26 @BeforeMethod
27 public void setUp() {
28
29 [Link]("Open a Chrome Web Browser");
30 [Link]().setup();
31 ChromeOptions options=new ChromeOptions();
32 [Link]("--start-maximized");
33 driver=new ChromeDriver(options);
34 [Link]().timeouts().implicitlyWait(10, [Link]);
35 [Link]("[Link]
36
[Link]("Open the application");37
}
38
39 @Test(description = "This test validates title of login functionality", priority = 0)
40 public void verifyLoginPageTitle() {
41
42 [Link]("Verify the Login page title");
43 String expectedTitle = [Link](loginTitle).getText();
44
45 [Link]("Actual Title :" + expectedTitle);
46 [Link]([Link]("Login"));47
}
48
49 @Test(description = "This test validates successful login to Home page", priority = 1)
50 public void verifyloginPage() {
51
52 [Link]("Enter Username");
53 [Link](userName).sendKeys("Admin");
54
55 [Link]("Enter Password");
56 [Link](passWord).sendKeys("admin123");
57
58 [Link](loginBtn).submit();
59
60 [Link]("New page - Dashboard is opened");
61 String newPageText = [Link](dashboardPage).getText();
62
63 [Link]("Heading of new page :" + newPageText);
64 [Link]([Link]("Dashboard"));
65
66 }
67
68 @AfterMethod
69 public void teardown() {
70
71 [Link]("Close the webpage");
72 [Link]();
73 }
74
}
Step 7 – Test Execution through TestNG
Go to the Runner class and right-click Run As TestNG Test. The tests will run as TestNG tests.
Step 8 – Run the tests from [Link]
Create a [Link] as shown below and run the tests as TestNG.
1 <?xml version = "1.0"encoding = "UTF-8"?>
2 <!DOCTYPE suite SYSTEM "[Link]
3 <suite name = "Suite1">
4 <test name = "TestNG Demo">
5 <classes>
6 <class name = "[Link].Selenium_TestNGDemo.TestNG_Demo"/>
7 </classes>
8 </test>
9 </suite>
Step 9 – TestNG Report Generation
TestNG generates various types of reports under test-output folder like [Link],
[Link], [Link].
We are interested in the “[Link]” report. Open “[Link]“, as this
is an HTML report, and open it with the browser. The below image shows emailable-
[Link].
TestNG also produces [Link]
“ ” report, and it resides under the
test-outputfolder. The
below image shows the
[Link] report. This is the latest theme of the report.
The links present on the left side are clickable. I have clicked the Times link, and you can see the
details on the right side.
Result
[Link] a) Mini Project:
Build a data-driven framework using Selenium and TestNG
Date:
Aim
To build a data-driven framework using Selenium and TestNG
TestNG provides built-in support for data-driven testing, allowing you to execute test cases with
different sets of test data. To perform data-driven testing with Selenium and TestNG, follow
these steps:
1. Use TestNG's @DataProvider annotation to define a data provider method that supplies
test data.
2. In the test method, specify the data provider method using the dataProvider attribute of
the @Test annotation.
3. Inside the data provider method, create a two-dimensional array or an iterator that
represents the test data.
4. Use the test data within the test method to perform various test actions or assertions.
Here's an example that demonstrates data-driven testing with TestNG and Selenium:
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@DataProvider(name = "searchKeywords")
public Object[][] searchKeywordsProvider() {
return new Object[][]{
{"TestNG tutorial"},
{"Selenium WebDriver"},
{"Automated testing"}
};
}
@Test(dataProvider = "searchKeywords")
public void searchTest(String searchKeyword) {
// Open the application URL
[Link]("[Link]
// Perform search
WebElement searchField = [Link]([Link]("searchField"));
WebElement searchButton = [Link]([Link]("searchButton"));
[Link](searchKeyword);
[Link]();
// Verify search results
WebElement searchResults = [Link]([Link]("searchResults"));
[Link]([Link]());
}
@AfterMethod
public void tearDown() {
// Close the browser
[Link]();
}
}
In this, the searchTest method is executed multiple times with different search
keywords provided by the data provider method searchKeywordsProvider.
Result
[Link] b) Build Page object Model using Selenium and TestNG
Date:
Aim
Create Page Objects representing pages of a web application that we want to test
Create methods for these Page Objects that represent actions we want to perform within
the pages that they represent
Create tests that perform these actions in the required order and performs checks that
make up the test scenario
Run the tests as TestNG tests and inspect the results
import [Link];
import [Link];
[Link] = driver;
[Link]([Link]("username")).sendKeys(username);
[Link]([Link]("password")).sendKeys(password);
[Link]([Link]("//input[@value='Log In']")).click();
return new ErrorPage(driver);
}
[Link]([Link]("username")).sendKeys(username);
[Link]([Link]("password")).sendKeys(password);
[Link]([Link]("//input[@value='Log In']")).click();
return new HomePage(driver);
}
} It contains a constructor that returns a new instance of the LoginPage object as well
as two
methods
and that we can use in our tests: incorrectLogin, which sends us to the error page
correctLogin, which sends us to the home page. Likewise, I’ve constructed Page
Objects for
these two pages as well. A link to those implementations can be found at the end of
this post.
Note that this code snippet isn’t optimized for maintainability – I used direct
references
A good example can be seen in the implementation of the error page Page Object:
to element properties rather than some sort of element-level abstraction, such as an
Object
package [Link];
Repository. Creating methods that perform actions on the Page Objects
import [Link];
import [Link];
public class ErrorPage {
private WebDriver driver;
[Link] = driver;
}
return [Link]([Link]("error")).getText();
}
} By implementing a getErrorText method to retrieve the error message that is
displayed on the
error page, we can call this method in our actual test script. It is considered good
practice to
separate the implementation of your Page Objects from the actual assertions that are
performed
in your test script (separation of responsibilities). If you need to perform additional
checks, just
add a method that returns the actual value displayed on the screen to the associated
page object
and add assertions to the scripts where this check needs to be performed.
Create tests that perform the required actions and execute the required checks
Now that we have created both the page objects and the methods that we want to use
for the
checks in our test scripts, it’s time to create these test scripts. This is again pretty
straightforward, as thisdriver;
WebDriver example shows (imports removed for brevity):
package [Link];
@BeforeSuite
public class TestNGPOM {
public void setUp() {
driver = new FirefoxDriver();
[Link]().timeouts().implicitlyWait(10, [Link]);
}
@Parameters({"username","incorrectpassword"})
@Test(description="Performs an unsuccessful login and checks the resulting error
message")
public void testLoginNOK(String username, String incorrectpassword) {
LoginPage lp = new LoginPage(driver);
ErrorPage ep = [Link](username, incorrectpassword);
[Link]([Link](), "The username and password could not be
verified.");
}
@AfterSuite
public void tearDown() {
[Link]();
}
}
Note the use of the page objects and the check being performed using methods in
these page
object implementations – in this case the getErrorText method in the error page page
object.
As we have designed our tests as Selenium + TestNG tests, we also need to definea
[Link] file that defines which tests we need to run and what parameter values the
parameterized testLoginOK test takes. <!DOCTYPE suite SYSTEM
<suite name="My first TestNG test>suite" verbose="1" >
"[Link]
<parameter name="username" value="john"/>
<parameter name="password" value="demo"/>
<test name="Login tests">
<packages>
<package name="[Link]" />
</packages>
</test>
</suite>
Run the tests as TestNG tests and inspect the results
Finally, we can run our tests again by right-clicking on the [Link] file in the Package
Explorer and selecting ‘Run As > TestNG Suite’. After test execution has finished, the test
results will appear in the ‘Results of running suite’ tab in Eclipse. Again, please note that
using meaningful names for tests and test suites in the [Link] file make these results much
easier to read and interpret.
Result
[Link] c)
Build BDD framework with Selenium, TestNG and Cucumber
Date:
Aim
To build BDD framework with Selenium, TestNG and Cucumber
Dependency List:
1. Cucumber Java- 7.14.0
2. Cucumber TestNG – 7.14.0
3. Java 17
4. TestNG – 7.8.0
5. Maven – 3.9.5
6. Selenium – 4.15.0
7. Maven Compiler Plugin- 3.11.0
8. Maven Surefire Plugin – 3.2.1
Project Structure
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
know How to install Java.
Step 2 – Download and setup Eclipse IDE on the system
The Eclipse IDE (integrated development environment) provides strong support for Java
developers, which is needed to write Java code. Click here to know How to install Eclipse.
Step 3 – Setup Maven
To build a test framework, we need to add a number of dependencies to the project. It is a very
tedious and cumbersome process to add each dependency manually. So, to overcome this
problem, we use a build management tool. Maven is a build management tool that is used to
define project structure, dependencies, build, and test management. Click here to know How to
install Maven. Step 4 – Install Cucumber Eclipse Plugin (Only for Eclipse IDE)
The Cucumber Eclipse plugin is a plugin that allows eclipse to understand the Gherkin syntax.
The Cucumber Eclipse Plugin highlights the keywords present in Feature File. Click here to
know more – Install Cucumber Eclipse Plugin
Step 5 – Download and install TestNG plugin
TestNG plugin is needed to run the tests as TestNG tests as mentioned in step 13. Click here to
know – How to download and install TestNG in Eclipse.
Step 6 – Create a new Maven Project
Click here to know How to create a Maven project
Below is the Maven project structure. Here,
Group Id – [Link]
Artifact Id – Cucumber_TestNG_Demo
Version – 0.0.1-SNAPSHOT
Package – com. example. Cucumber_TestNG_Demo
Step 7 – Create source folder src/test/resources to create test scenarios in Feature file
When a new Maven Project is created, it has 2 folders –
src/main/java andsrc/test/javaas shown
below image. To create test scenarios, we need a new source folder called – .
src/test/resources
To create this folder, right-click on your maven project ->select New -
>Java, and then Source Folder.
Note:- If the test execution fails with the below-shown error, that means you have Chrome
Version 111 installed on your machine which is not compatible with Selenium Version 4.8.2
and below. Please refer to this tutorial to fix the issue – Selenium Tests failing on Chrome
Version 111.
Result
TestNG paired with Maven enhances integration testing of e-commerce platforms by streamlining the testing and build process. TestNG provides advanced testing capabilities such as annotations, grouping, and parallel execution, facilitating structured and comprehensive test setups. Maven automates dependency management, project configuration, and builds processes, all critical for maintaining consistent test environments. This combination allows for easier integration of various tests into the continuous integration pipeline, improving test reliability and reducing manual overhead .
Load testing is critical early in the software life cycle of an e-commerce application to identify potential performance bottlenecks and ensure the application can handle expected user traffic effectively before significant deployment and marketing investments. Establishing load testing plans early allows for timely adjustments based on performance insights, mitigating risks of service interruptions post-launch. Commonly used tools for load testing include Microsoft Application Center Test (ACT) and Empirix’s e-Test, which provide capabilities to simulate real-world user conditions and measure system robustness under load .
The primary components to test in an e-commerce application for security include authentication, access control, transparency, delivery, and reliability. Authentication ensures the data is sent by authorized users, preventing impersonation. Access control secures data against unauthorized users, protecting sensitive user information like financial data. Transparency ensures that the user receives exactly what is sent, preventing data tampering during transmission. Delivery guarantees the information reaches the intended recipient without interception. Reliability checks ensure minimal service disruption, maintaining consistent data protection and availability, even under stress conditions .
Security testing ensures the payment processing functions of an e-commerce site are free from vulnerabilities that could expose sensitive financial data. Key elements include testing for secure transmission protocols to safeguard data during transfers, validating encryption of payment information to prevent interception, and conducting penetration testing to identify potential entry points for unauthorized access. Additionally, testing for robust authentication and authorization processes ensures that only legitimate transactions are processed, reducing risk from fraudulent activities and enhancing consumer trust .
Integrating Selenium with a Maven project benefits automated testing frameworks by managing dependencies and builds effortlessly, facilitating the integration of Selenium’s web automation capabilities. Steps to set up such a framework include installing Java and Maven, setting up the Eclipse IDE, creating a Maven project, and adding Selenium dependencies in the pom.xml file. This configuration allows for creating and running Selenium test scripts, managing them with Maven for build consistency, and using TestNG for executing and reporting, significantly improving testing efficiency and reducing complexity .
Browser compatibility testing ensures a web application behaves consistently across different web browsers, which is crucial for user experience and accessibility in e-commerce. Challenges include dealing with unique rendering engines and JavaScript engines of different browsers, making exhaustive testing impractical due to the sheer number of browser versions. An effective approach involves using a browser compatibility matrix to identify high-priority browsers and platforms, focused testing on these platforms to ensure general functionality, and employing automated tools to streamline the process and detect discrepancies .
Functional testing ensures that an e-commerce application's features work as intended, covering areas such as usability, mainline functionalities, and accessibility. Boundary value analysis (BVA) contributes by identifying defects at the edge of input ranges, ensuring robust handling of input limits. Equivalence class testing simplifies the process by categorizing inputs into equivalent partitions where test cases validate one representative input per class. These methods help efficiently create functional test cases, minimizing redundant tests and revealing potential issues with both normal and edge-case inputs .
Database testing in e-commerce applications focuses on verifying data integrity, security, and performance. Methods include ensuring that database operations such as backups, crash recovery, and transactions return the database to a consistent state and verifying the correctness of concurrent access controls to prevent data corruption. Additionally, capacity testing checks the database's ability to store and manage large volumes of data efficiently. These methods are significant as they safeguard sensitive user data from unauthorized access and ensure reliable service performance even under concurrent user demands, essential for maintaining user trust .
Key functionalities in user interface testing for an e-commerce site include verifying the proper operation of links, forms, and various interface elements like text fields, radio buttons, and checkboxes. Ensuring the correct display and responsiveness of navigational components like menus and error messages is also crucial. These functionalities are critical as they directly impact usability, influencing the ease with which users interact with the site, make purchases, and access needed information without errors or frustrations, thus enhancing the overall user experience .
Performance testing evaluates if an e-commerce application can handle the demand during peak hours by monitoring its responsiveness, stability, and scalability. Load testing, a subset of performance testing, simulates a specified number of users to verify the application can manage expected user traffic by measuring metrics like response time and throughput under common maximum loads. Stress testing goes beyond typical limits, applying extreme conditions to identify application breaking points and assess recovery capabilities, focusing on system behavior under overloads. Key metrics include the number of concurrent users, response time, network bandwidth, and system recovery time after failures .