Software Testing Lab Record Set2
Software Testing Lab Record Set2
AIM
To test the performance of an e-commerce application ([Link]) using Apache JMeter by simulating
multiple concurrent users and measuring response time, throughput, and error rate under load.
ALGORITHM
1. Install and launch Apache JMeter.
2. Create a Test Plan with a Thread Group (simulated users).
3. Add HTTP Request samplers for key pages: Home, Search, Product Detail, Cart, Checkout.
4. Add Listeners: View Results Tree, Summary Report, Response Time Graph.
5. Configure load: 50 users, ramp-up 10 seconds, 3 iterations.
6. Run the test and collect metrics: Response Time (ms), Throughput (req/sec), Error %.
7. Analyze bottlenecks and document observations.
PROCEDURE
Step 1 – Install JMeter:
# Download Apache JMeter 5.6+
wget [Link]
tar -xvzf [Link]
cd apache-jmeter-5.6.3/bin && ./[Link] # Linux/Mac
# Windows: double-click [Link]
Step 6 – Run: Click the green Play button. Save results to [Link].
PERFORMANCE METRICS (Sample Results)
Page Avg Min (ms) Max (ms) Throughput Error %
Response (req/s)
(ms)
Home Page 320 210 850 45.2 0.0%
Search 540 380 1200 32.1 0.0%
(laptop)
Product Detail 480 310 990 38.5 0.0%
Cart Page 290 190 610 51.3 0.0%
Checkout 720 500 1850 21.4 2.0%
Page
Performance Thresholds:
• Acceptable: Avg response < 1000ms, Error % < 1%
• Checkout page exceeded 1% error threshold — bottleneck identified
RESULT
Performance testing of [Link] was successfully conducted using Apache JMeter with 50
concurrent users. Home, Search, Product, and Cart pages met performance benchmarks. The
Checkout page was identified as a bottleneck with 2% error rate and 720ms avg response, requiring
optimization.
EXPERIMENT 2: Automate the Testing of E-Commerce Applications Using
Selenium
AIM
To automate the functional testing of an e-commerce application ([Link]) using Selenium
WebDriver with Python, covering product search, product detail verification, and cart operations.
ALGORITHM
1. Initialize Chrome WebDriver with options.
2. Navigate to [Link].
3. Automate product search using the search bar.
4. Verify search results are displayed.
5. Click on the first product and verify product title and price are visible.
6. Add product to cart and verify cart count increases.
7. Apply assertions at each step and print results.
8. Close the browser.
PROCEDURE
Step 1 – Install dependencies:
pip install selenium webdriver-manager pytest
CODE
test_ecommerce_automation.py
import time
from selenium import webdriver
from [Link] import By
from [Link] import Keys
from [Link] import WebDriverWait
from [Link] import expected_conditions as EC
from [Link] import Service
from webdriver_manager.chrome import ChromeDriverManager
def init_driver():
opts = [Link]()
opts.add_argument('--start-maximized')
opts.add_argument('--disable-notifications')
driver = [Link](
service=Service(ChromeDriverManager().install()), options=opts)
driver.implicitly_wait(10)
return driver
if __name__ == '__main__':
driver = init_driver()
wait = WebDriverWait(driver, 15)
try:
first = test_search(driver, wait)
test_product_detail(driver, wait, first)
test_add_to_cart(driver, wait)
print('\n[ALL AUTOMATION TESTS PASSED]')
except AssertionError as e:
print(f'[ASSERTION FAIL] {e}')
except Exception as e:
print(f'[ERROR] {e}')
finally:
[Link](2)
[Link]()
EXPECTED OUTPUT
[PASS] Search returned 24 results
[PASS] Product detail page: boAt Rockerz 450 Bluetooth On Ear Headphones...
[PASS] Price found: ₹1,299
[PASS] Item added to cart. Cart count: 1
RESULT
E-commerce application testing was successfully automated using Selenium WebDriver with Python.
Product search, product detail verification, price display, and cart addition were all automated with
appropriate assertions. All test steps passed successfully.
EXPERIMENT 3: Integrate TestNG with the Above Test Automation
AIM
To integrate TestNG (Testing Next Generation) framework with Selenium WebDriver automation tests
written in Java, enabling structured test execution, grouping, parallel runs, and HTML report generation.
ALGORITHM
1. Set up a Maven project with Selenium and TestNG dependencies.
2. Write test class using @Test, @BeforeMethod, @AfterMethod annotations.
3. Use @DataProvider for data-driven testing.
4. Configure [Link] for test suite definition.
5. Run tests via Maven (mvn test) or TestNG plugin.
6. Generate and review HTML report in test-output/ folder.
PROCEDURE
Step 1 – Maven [Link] dependencies:
<dependencies>
<dependency>
<groupId>[Link]</groupId>
<artifactId>selenium-java</artifactId>
<version>4.18.1</version>
</dependency>
<dependency>
<groupId>[Link]</groupId>
<artifactId>testng</artifactId>
<version>7.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>[Link]</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.7.0</version>
</dependency>
</dependencies>
CODE
[Link]
import [Link].*;
import [Link].*;
import [Link].*;
import [Link];
import [Link].*;
import [Link].*;
@BeforeMethod
public void setUp() {
[Link]().setup();
ChromeOptions opts = new ChromeOptions();
[Link]("--start-maximized");
driver = new ChromeDriver(opts);
wait = new WebDriverWait(driver, [Link](10));
[Link]("[Link]
}
[Link]([Link]("twotabsearchtextbox")));
[Link]("laptop");
[Link]();
[Link]([Link]("laptop"));
[Link]([Link]().toLowerCase().contains("laptop"));
[Link]("[PASS] Search results page loaded");
}
[Link]([Link]("twotabsearchtextbox")));
[Link]();
[Link](keyword);
[Link]();
[Link]([Link](keyword));
[Link]("[PASS] Search for '" + keyword + "' successful");
}
@DataProvider(name = "searchKeywords")
public Object[][] searchData() {
return new Object[][] {
{"mobile phone"},
{"books"},
{"headphones"}
};
}
@AfterMethod
public void tearDown() {
if (driver != null) [Link]();
}
}
RESULT
TestNG was successfully integrated with Selenium WebDriver Java automation. Tests were
structured with @BeforeMethod/@AfterMethod lifecycle hooks, @DataProvider for data-driven
testing, and [Link] for suite configuration. HTML reports were generated in test-output/ showing
pass/fail status for all 5 test executions.
EXPERIMENT 4: Execute Test Cases Against a Client-Server/Desktop
Application and Identify Defects
AIM
To execute functional test cases against a client-server or desktop application and systematically
identify, document, and classify defects found during testing.
ALGORITHM
1. Set up the client-server test environment (connect client to server DB).
2. Prepare test data in the server database.
3. Execute test cases for: Login, CRUD operations, data validation, concurrency, reporting.
4. Record actual vs expected results for each test case.
5. Log defects with complete details for any mismatch.
6. Classify defects by severity and priority.
7. Prepare a defect summary report.
PROCEDURE
Step 1 – Environment: Client machine (Windows 10) connects to MySQL Server 8.0 via LAN.
Application: Desktop ERP v3.2.
Step 2 – Test Execution: Execute all prepared test cases systematically.
Step 3 – Defect Logging: For each failed test case, record in defect log below.
DEFECT REPORT
Defect ID Description Severity Priority Steps to
Reproduce
DEF001 Edit salary value High P2 Open record >
not saved Edit salary > Save
> Reopen → Old
value shown
DEF002 Delete ignores FK Critical P1 Add dept with
constraint employees >
Delete dept →
Employees
orphaned
DEF003 App crash on Critical P1 2 users open
concurrent edit same record >
Both click Save
simultaneously
DEF004 PDF report High P2 Reports > Monthly
generated blank > Select month >
Export PDF →
Blank PDF
DEF005 Numeric field Medium P3 Open salary field
accepts alphabets > Type 'abc' >
Save → Accepted
without error
DEF006 Session never Medium P3 Login > Leave idle
times out 40 min > Perform
action → Still
logged in
DEFECT SUMMARY
Severity Count Defect IDs
Critical 2 DEF002, DEF003
High 2 DEF001, DEF004
Medium 2 DEF005, DEF006
Total 6 –
RESULT
Test execution against the client-server desktop ERP application was completed. Out of 10 test
cases, 4 passed and 6 failed. Six defects were logged including 2 Critical (data loss on FK delete,
app crash on concurrent access), 2 High, and 2 Medium severity issues. All defects are ready for
developer handoff.
EXPERIMENT 5: Develop Test Plan and Design Test Cases for an Inventory
Control System
AIM
To develop a comprehensive test plan and design structured test cases for an Inventory Control
System (ICS) covering all core modules: Product Management, Stock Operations, Supplier
Management, Purchase Orders, and Reporting.
ALGORITHM
1. Analyze ICS requirements and identify all modules.
2. Define test objectives, scope, and out-of-scope items.
3. Select testing techniques: Functional, BVA, ECT, Integration.
4. Identify test environment, tools, and test data.
5. Define entry and exit criteria.
6. Design test cases for each module.
7. Review and baseline the test plan document.
RESULT
A comprehensive test plan and 15 test cases were successfully developed for the Inventory Control
System. The test plan covers scope, objectives, environment, entry/exit criteria, schedule, and team
responsibilities. Test cases include BVA at reorder level boundaries (9, 10, 11 units) and cover all 5
core modules.
EXPERIMENT 6: Perform Basic Security Testing – SQL Injection Simulation
AIM
To perform basic security testing on a web application by simulating SQL Injection (SQLi) attacks to
identify vulnerabilities in login forms and search fields, and to verify that the application properly
sanitizes user inputs.
ALGORITHM
1. Identify input fields in the web application (login, search, registration).
2. Prepare a set of SQL injection payloads.
3. Enter each payload in the input fields and submit.
4. Observe server response: error messages, unexpected login, data exposure.
5. Automate SQLi testing using Python requests library.
6. Document findings: vulnerable vs protected inputs.
7. Suggest remediation for vulnerable fields.
PROCEDURE
Step 1 – Manual Testing on Local Test Application (DVWA – Damn Vulnerable Web App):
• Set up DVWA locally using XAMPP/Docker
• Navigate to Login page ([Link]
• Enter payload in Username: admin'-- and any password → Observe if login succeeds
VULNERABLE_INDICATORS = [
'mysql_fetch', 'syntax error', 'sql', 'ORA-',
'ODBC', 'you have an error in your SQL syntax',
'Warning: mysql', 'unclosed quotation mark'
]
print('='*60)
print(' SQL INJECTION VULNERABILITY SCANNER')
print('='*60)
for pl in PAYLOADS:
vuln, reason = test_sqli(TARGET_URL, pl)
status = '[VULNERABLE]' if vuln else '[SAFE]'
print(f'{status} Payload: {pl[:35]:<35} | Reason: {reason}')
print('='*60)
REMEDIATION
• Use Parameterized Queries / Prepared Statements (never concatenate user input in SQL)
• Use ORM frameworks (SQLAlchemy, Hibernate) which escape inputs automatically
• Implement input validation and whitelist allowed characters
• Apply Web Application Firewall (WAF) rules
• Use least-privilege DB accounts
RESULT
SQL Injection security testing was successfully performed on DVWA (authorized test environment).
Four SQLi vulnerabilities were identified including authentication bypass and data extraction via
UNION attacks. An automated Python scanner was developed to detect vulnerabilities. Remediation
recommendations including prepared statements and input sanitization were documented.
EXPERIMENT 7: Build a Complete Testing Workflow – Test Plan, Test Cases,
Execution, Defect Report
AIM
To build a complete end-to-end software testing workflow for an e-commerce application demonstrating
all phases: Test Planning → Test Case Design → Test Execution → Defect Reporting → Test
Summary.
ALGORITHM
1. Phase 1 – Test Planning: Define scope, objectives, resources, schedule.
2. Phase 2 – Test Design: Write test cases using functional and boundary techniques.
3. Phase 3 – Test Execution: Run test cases, record pass/fail, capture evidence.
4. Phase 4 – Defect Reporting: Log defects with severity, priority, steps.
5. Phase 5 – Test Summary: Calculate metrics, prepare closure report.
RESULT
A complete end-to-end testing workflow was successfully built and executed for [Link]. All 5
phases were completed: Test Plan defined, 10 test cases designed, tests executed (7 pass / 3 fail), 3
defects logged (0 Critical, 2 High, 1 Medium), and a test summary report with metrics was prepared.
Release is on hold pending resolution of 2 High-priority defects.
EXPERIMENT 8: Integrate Selenium Tests with TestNG and Generate Reports
AIM
To integrate Selenium WebDriver test automation with the TestNG framework (Java) and generate
detailed HTML and Extent Reports showing test execution results, pass/fail status, and screenshots.
ALGORITHM
1. Create Maven project with Selenium + TestNG + ExtentReports dependencies.
2. Write test classes annotated with TestNG annotations.
3. Create a TestNG listener class to hook into pass/fail events.
4. Configure [Link] with suite, tests, and listener.
5. Run tests via mvn test.
6. Open generated HTML report and ExtentReport in browser.
PROCEDURE
Step 1 – Add ExtentReports dependency to [Link]:
<dependency>
<groupId>[Link]</groupId>
<artifactId>extentreports</artifactId>
<version>5.1.1</version>
</dependency>
CODE
[Link] – Report Setup
import [Link].*;
import [Link];
@Override
public void onTestStart(ITestResult result) {
test = [Link]([Link]().getMethodName());
}
@Override
public void onTestSuccess(ITestResult result) {
[Link]("Test PASSED");
}
@Override
public void onTestFailure(ITestResult result) {
[Link]([Link]());
// Capture screenshot on failure
// TakesScreenshot ts = (TakesScreenshot) driver;
// String path = [Link](OutputType.BASE64);
// test.addScreenCaptureFromBase64String(path, "Failure Screenshot");
}
@Override
public void onFinish(ITestContext context) {
[Link](); // Write report to disk
}
}
@Listeners([Link])
public class AmazonTests {
WebDriver driver;
WebDriverWait wait;
@BeforeClass
public void setUp() {
[Link]().setup();
driver = new ChromeDriver();
[Link]().window().maximize();
wait = new WebDriverWait(driver, [Link](10));
}
@Test(groups = {"smoke"})
public void verifyTitle() {
[Link]("[Link]
[Link]([Link]().contains("Amazon"));
}
@Test(groups = {"functional"})
public void verifySearchFunctionality() {
[Link]("[Link]
WebElement search = [Link](
[Link]([Link]("twotabsearchtextbox")));
[Link]("smartphone");
[Link]();
[Link]([Link]().contains("smartphone"));
}
@AfterClass
public void tearDown() {
if (driver != null) [Link]();
}
}
Reports generated:
• TestNG Native: target/surefire-reports/[Link]
• ExtentReport: reports/[Link] (with pass/fail charts, system info, screenshots)
REPORT FEATURES
Feature TestNG HTML Report ExtentReport
Pass/Fail status Yes Yes
Pie chart summary No Yes
Screenshots on fail No Yes (with listener)
System info No Yes
Execution time Yes Yes
Filtering by status No Yes
RESULT
Selenium tests were successfully integrated with TestNG and ExtentReports. The TestListener
captured pass/fail events and generated a rich HTML report at reports/[Link] with pie
charts, test details, system information, and failure stack traces. The [Link] suite ran smoke and
functional groups with 2 passes and 1 expected exception test.
EXPERIMENT 9: Unit Testing Using JUnit for a Simple Calculator Application
AIM
To write a program demonstrating unit testing using the JUnit 5 framework for a simple Calculator
application, covering addition, subtraction, multiplication, division, and exception handling for division by
zero.
ALGORITHM
1. Create a Calculator class with methods: add, subtract, multiply, divide.
2. Add input validation (throw ArithmeticException for division by zero).
3. Create a JUnit test class with @Test methods for each calculator operation.
4. Use assertions: assertEquals, assertThrows, assertTrue, assertNotNull.
5. Add @BeforeEach to initialize Calculator before each test.
6. Run tests with Maven or IDE (IntelliJ/Eclipse).
7. View test results in the JUnit runner or Surefire report.
PROCEDURE
Step 1 – [Link] dependency:
<dependency>
<groupId>[Link]</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>
CODE
[Link] – Class Under Test
public class Calculator {
class CalculatorTest {
Calculator calc;
@BeforeEach
void setUp() {
calc = new Calculator(); // Fresh instance before each test
}
@Test
@DisplayName("Add negative numbers")
void testAddNegative() {
assertEquals(-3.0, [Link](-5, 2), "-5 + 2 should equal -3");
}
@Test
@DisplayName("Add with zero")
void testAddZero() {
assertEquals(7.0, [Link](7, 0));
}
@Test
@DisplayName("Subtract resulting in negative")
void testSubtractNegativeResult() {
assertEquals(-3.0, [Link](2, 5));
}
@Test
@DisplayName("Multiply by zero")
void testMultiplyByZero() {
assertEquals(0.0, [Link](100, 0));
}
@Test
@DisplayName("Division by zero throws ArithmeticException")
void testDivideByZero() {
ArithmeticException ex = assertThrows(
[Link],
() -> [Link](10, 0),
"Expected ArithmeticException for division by zero"
);
assertTrue([Link]().contains("Division by zero"));
}
@Test
@DisplayName("Square root of 25 = 5")
void testSqrt() {
assertEquals(5.0, [Link](25));
}
@Test
@DisplayName("Square root of negative throws IllegalArgumentException")
void testSqrtNegative() {
assertThrows([Link], () -> [Link](-9));
}
@AfterEach
void tearDown() {
calc = null;
}
}
Run Tests:
mvn test # Output in target/surefire-reports/
RESULT
Unit testing using JUnit 5 was successfully demonstrated for a Calculator application. 12 test cases
were written covering addition, subtraction, multiplication, division, power, square root, and exception
handling (division by zero, sqrt of negative). All 12 tests passed. The @BeforeEach lifecycle ensured
test isolation, and @DisplayName provided readable test names in the report.
EXPERIMENT 10: Automate Login Functionality Using Selenium WebDriver
AIM
To automate the complete login functionality of a web application ([Link]) using Selenium
WebDriver with Python, covering valid login, invalid login, empty fields, and password visibility toggle
scenarios.
ALGORITHM
1. Initialize Chrome WebDriver and maximize window.
2. Navigate to [Link] login page.
3. TC1 – Valid Login: Enter valid email and password → assert successful login.
4. TC2 – Invalid Password: Enter valid email, wrong password → assert error message.
5. TC3 – Empty Email: Submit without email → assert required field error.
6. TC4 – Empty Password: Enter email, skip password → assert error.
7. TC5 – Special Characters in Email: Enter malformed email → assert validation.
8. Print results for each test case.
9. Close browser.
PROCEDURE
Step 1 – Install dependencies:
pip install selenium webdriver-manager pytest pytest-html
CODE
login_page.py – Page Object
from [Link] import By
from [Link] import WebDriverWait
from [Link] import expected_conditions as EC
class LoginPage:
URL = '[Link]
EMAIL = ([Link], 'ap_email')
CONTINUE = ([Link], 'continue')
PASSWORD = ([Link], 'ap_password')
SIGN_IN = ([Link], 'signInSubmit')
ERROR = ([Link], 'auth-error-message-box')
ALERT = (By.CSS_SELECTOR, '.a-alert-content')
GREETING = ([Link], 'nav-link-accountList-nav-line-1')
def open(self):
[Link]([Link])
def click_continue(self):
self._click([Link])
def click_signin(self):
self._click(self.SIGN_IN)
def get_error_text(self):
try:
return self._find([Link]).text
except:
try:
return self._find([Link]).text
except:
return ''
def is_logged_in(self):
try:
text = [Link](
EC.presence_of_element_located([Link])).text
return 'Hello' in text or 'Account' not in text
except:
return False
@[Link](scope='function')
def driver():
opts = [Link]()
opts.add_argument('--start-maximized')
opts.add_argument('--disable-notifications')
drv = [Link](
service=Service(ChromeDriverManager().install()), options=opts)
yield drv
[Link]()
TEST RESULTS
TC Scenario Input Expected Actual Status
TC1 Valid Login Correct email Login Dashboard PASS
+ password successful loaded
TC2 Invalid Correct email Error message Error PASS
Password + wrong pwd shown displayed
TC3 Empty Email Blank email Required field Error shown PASS
field error
TC4 Empty Valid email + Password Error shown PASS
Password blank pwd required error
TC5 Malformed 'notanemail@ Invalid email Error shown PASS
Email @' error
RESULT
Login functionality of [Link] was successfully automated using Selenium WebDriver with Python
and the Page Object Model. Five test scenarios were automated covering valid login, invalid
password, empty email, empty password, and malformed email inputs. All 5 test cases passed with
appropriate assertions. An HTML report was generated at reports/login_report.html.