Software Testing Lab Record 2024
Software Testing Lab Record 2024
AN AUTONOMOUS INSTITUTION
PANJAPPUR, TIRUCHIRAPPALLI–620012
CCS366
NAME:
BATCH NUMBER:
REGISTER NUMBER:
BRANCH:
TABLE OF CONTENTS
3.
Test the e-commerce application and report
the defects in it
Develop the test plan and design the test
4. cases for an inventory control system.
5.
Execute the test cases against a client server
or desktop application and identify the
defects
Test the performance of the e-commerce
6.
application.
Automate the testing of e-commerce
7.
applications using Selenium.
PEO4: Have awareness on the life-long learning and prepare them for
research development and consultancy.
PEO5: Have a successful career and work with values & social concern
bridging the digital divide and meet the requirements of Indian and
multinational companies.
Program Specific Outcome (PSO):
10. community and with society at large, such as, being able to comprehend and write
effective report and design documentation, make effective presentations, and give
and receive clear instructions.
PO11: Project management and finance:
Demonstrate knowledge and understanding of the engineering and management
11.
principles and apply these to one’s own work, as a member and leader in a team,
to manage projects and in multidisciplinary environments.
PO12: Life-long learning:
Recognize the need for, and have the preparation and ability to engage in
12.
independent and life- long learning in the broadest context of technological
change.
SARANATHAN COLLEGE OF ENGINEERING
(An Autonomous Institution)
Panjappur, Tiruchirapalli-620 012
REG.NO
MARKS OUT OF 20
Assessment Sheet
SIGNATURE OF EVALUATOR
Subject Title: SOFTWARE TESTING AND AUTOMATION
Subject Code: CCS366 COURSE
OUTCOMES
CO1 Develop the test plan for testing an e-commerce web/mobile application
CO2 Design the test cases for testing the e-commerce application.
CO3 Test the e-commerce application and report the defects in it.
CO4 Develop the test plan and design the test cases for an inventory control system.
CO5 Execute the test cases against a client server or desktop application and identify the defects.
CO’s 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3
1 3 3 2 1 2 - - - 1 1 3 2 3 2 3
2 2 3 1 1 1 - - - 2 2 1 2 1 2 3
3 2 2 1 3 1 - - - 2 3 1 2 1 3 3
4 2 1 3 2 1 - - - 1 1 1 2 3 1 2
5 2 2 1 3 1 - - - 1 3 2 1 2 1 3
Aim:
The aim of this experiment is to develop a comprehensive test plan for testing the
functionality and usability of the e-commerce web/mobile application www.amazon.in.
Algorithm:
1. Identify the Scope: Determine the scope of testing, including the features and
functionalities that need to be tested.
2. Define Test Objectives: Specify the primary objectives of testing, such as functional
testing, usability testing, performance testing, security testing, etc.
3. Identify Test Environment: Define the platforms, browsers, devices, and operating
systems on which the application will be tested.
4. Determine Test Deliverables: Decide on the documents and artifacts that will be
generated during the testing process, such as test cases, test reports, and defect logs.
5. Create Test Strategy: Develop an overall approach for testing, including the testing
techniques, entry and exit criteria, and the roles and responsibilities of the testing team.
6. Define Test Scope and Schedule: Specify the timeline for each testing phase and the
scope of testing for each phase.
7. Risk Analysis: Identify potential risks and their impact on the testing process, and devise
risk mitigation strategies.
8. Resource Planning: Allocate the necessary resources, including the testing team, hardware,
and software required for testing.
1
9. Test Case Design: Prepare detailed test cases based on the requirements and
functionalities of the e-commerce application.
10. Test Data Setup: Arrange test data required for executing the test cases effectively.
11. Test Execution: Execute the test cases and record the test results.
12. Defect Reporting: Document any defects encountered during testing and track
their resolution.
Test Plan:
The test plan should cover the following sections:
1. Introduction: Briefly describe the purpose of the test plan and provide an overview of
the e- commerce application to be tested.
3. Test Scope: Specify the features and functionalities to be tested and any limitations on testing.
7. Risk Analysis: Identify potential risks and the strategies to mitigate them.
9. Test Case Design: Include a summary of the test cases developed for the application.
10. Test Data Setup: Describe the process of arranging test data for testing.
2
11. Defect Reporting: Explain the procedure for reporting and tracking defects.
Expecte Actual
Proces No. Test Case Steps Description Status d Result Commen
s Result t
3
Risks and
Risk 1. Review Ensure mitigation
TC007 Analysi the test potential Done strategies
s plan risks are are
document. identified. mentioned.
Resources
1. Review Check needed
Resourc the test the for testing
TC008 e plan required Done are listed.
Planning document. resources
.
1. Review Test cases
and Validate the are
Test execute the prepared accurate
TC009 Case test cases. test cases. Done and
Design functional.
1. Review
the test Verify the Test data is
Test data setup availability available
TC010 Data process. of test data. Done for testing.
Setup
1. Run
the test
cases and Test results
document are recorded
TC011 Test the Execute In and
Executio outcomes. the test Progres documented
n cases. s .
1. Monitor
defect Verify the Defects are
Defect status and tracking Not tracked
TC013 Trackin updates. of defects. Started until
g resolution.
4
Program:
import time
DemoFindElementByID():
webdriver.Chrome()
driver.get("https://www.amazon.in/")
driver.find_element(by = "id",
value="twotabsearchtextbox").send_keys("cricket")
driver.get("https://www.amazon.in/ap/signin.htm")
driver.find_element(by = "id",
value="ap_email").send_keys("xyz123") driver.find_element(by="id",
value="continue").click() time.sleep(4)
findbyid = DemoFindElementByID()
findbyid.demo_find_element_by_id()
5
import time
DemoFindElementByID():
def demo_find_element_by_id(self):
driver = webdriver.Chrome()
driver.get("https://secure.yatra.com/social/common/yatra/signin.
htm")
input").send_keys("test@test.com")
btn").click()
password").send_keys("test")
time.sleep(4)
findbyid = DemoFindElementByID()
findbyid.demo_find_element_by_id()
6
Explanation:
The test plan is a crucial document that outlines the entire testing process. It ensures that all
aspects of the e-commerce application are thoroughly tested, and the results are
systematically documented.
Result:
Upon completion of the experiment, you will have a well-structured test plan that provides a
clear roadmap for testing the e-commerce web/mobile application www.amazon.in.
7
Experiment 2: Design the Test Cases for Testing the E-commerce Application
Aim:
The aim of this experiment is to design a set of comprehensive and effective test cases for
testing the e-commerce application www.amazon.in.
Algorithm:
1. Understand Requirements: Familiarize yourself with the functional and non-
functional requirements of the e-commerce application.
2. Identify Test Scenarios: Based on the requirements, identify different test scenarios that
cover all aspects of the application.
3. Write Test Cases: Develop test cases for each identified scenario, including
preconditions, steps to be executed, and expected outcomes.
4. Cover Edge Cases: Ensure that the test cases cover edge cases and boundary
conditions to verify the robustness of the application.
5. Prioritize Test Cases: Prioritize the test cases based on their criticality and relevance
to the application.
6. Review Test Cases: Conduct a peer review of the test cases to ensure their accuracy
and completeness.
7. Optimize Test Cases: Optimize the test cases for reusability and maintainability.
8
3. Test Case Description: Detailed steps to execute the test.
4. Precondition: The necessary conditions that must be satisfied before executing the test case.
Expected Actual
Process No. Test Case Steps Description Status Result Result Comment
1.
Test Navigate Verify User can
Case User to the user successfull
Design TC001 Registratio registration registratio Done y register.
n page. n process.
1. Verify User can
Navigate user login successfull
TC002 User Login to the process. Done y log in.
login page.
Search
1. Enter a results
keyword Verify relevant
Search in the search to the
TC003 Functionalit search bar. functionality Done keyword.
y .
Verify Product is
1. Browse adding added to
the products the
TC004 Add to Cart product to the cart. Done shopping
catalog. cart.
1. Click Items in
Shopping on the Verify the the
Cart shopping shopping shopping
TC005 Validatio cart icon. cart Done cart are
n contents. displayed.
1. Click on Checkout
9
Checkou the Verify process
t Process "Checkout the Not proceeds
TC006 " button. checkout Starte as
process. d expected.
Program:
import time
DemoFindElementByID():
def demo_find_element_by_id(self):
driver = webdriver.Chrome()
driver.get("https://secure.yatra.com/social/common/yatra/signin.
htm")
input").send_keys("test@test.com")
btn").click()
password").send_keys("test")
time.sleep(4)
findbyid = DemoFindElementByID()
findbyid.demo_find_element_by_id()
10
11
12
Explanation:
Test cases are designed to validate the functionality and behaviour of the e-commerce
application. They ensure that the application performs as intended and meets the specified
requirements.
Result:
Upon completion of the experiment, you will have a set of well-defined test cases
ready for testing the e-commerce application www.amazon.in.
13
Experiment 3: Test the E-commerce Application and Report the Defects in It
Aim:
The aim of this experiment is to execute the designed test cases and identify defects or
issues in the e-commerce application www.amazon.in.
Algorithm:
1. Test Environment Setup: Set up the testing environment with the required hardware,
software, and test data.
2. Test Case Execution: Execute the test cases designed in Experiment 2, following the
specified steps.
3. Defect Identification: During test execution, record any discrepancies or issues encountered.
4. Defect Reporting: Log the identified defects with detailed information, including
steps to reproduce, severity, and priority.
5. Defect Tracking: Track the progress of defect resolution and verify fixes as they
are implemented.
6. Retesting: After defect fixes, retest the affected areas to ensure the issues are resolved.
7. Regression Testing: Conduct regression testing to ensure new changes do not introduce
new defects.
14
Test Case Table:
Expected Actual
Process No. Test Case Steps Description Status Result Result Comment
1.
Test Navigate Verify User can
Case User to the user successfull
Design TC001 Registratio registration registratio Done y register.
n page. n process.
1. Verify User can
Navigate user login successfull
TC002 User Login to the process. Done y log in.
login page.
Search
1. Enter a results
keyword Verify relevant
Search in the search to the
TC003 Functionalit search bar. functionality Done keyword.
y .
Verify Product is
1. Browse adding added to
the products the
TC004 Add to Cart product to the cart. Done shopping
catalog. cart.
1. Click Items in
Shopping on the Verify the the
Cart shopping shopping shopping
TC005 Validatio cart icon. cart Done cart are
n contents. displayed.
1. Click on Checkout
the Verify process
Checkou "Checkout the Not proceeds
TC006 t Process " button. checkout Started as
process. expected.
15
Program:
import time
DemoFindElementByID():
def demo_find_element_by_id(self):
driver = webdriver.Chrome()
driver.get("https://www.bigbasket.com/") driver.find_element(by
= "id",
value="input").send_keys("vegetables") driver.find_element(by =
"id", value="fresh
promogranite").click()
time.sleep(4)
findbyid = DemoFindElementByID()
findbyid.demo_find_element_by_id()
16
17
Explanation:
Testing the e-commerce application aims to validate its functionality and usability. By
identifying and reporting defects, you ensure the application's quality and reliability.
Result:
Upon completion of the experiment, you will have a list of identified defects and their status
after resolution.
18
Experiment 4: Develop the Test Plan and Design the Test Cases for an Inventory
Control System
Aim:
The aim of this experiment is to create a comprehensive test plan and design test cases for
an Inventory Control System.
Algorithm:
Follow the same algorithm as described in Experiment 1 for developing the test plan
for an inventory control system.
Follow the same algorithm as described in Experiment 2 for designing test cases for an
inventory control system.
Test Plan:
Expecte Actual
Proces No. Test Case Steps Description Status d Result Commen
s Result t
The test
1. Review the plan
requirements Verify the includes
Test Scope and project scope of all
Plan TC001 of documentation testing. Done essential
Testing . features.
2. Identify
the modules
to be tested.
3.
Determine
the out-of-
scope items.
19
Expecte Actual
Proces No. Test Case Steps Description Status d Result Commen
s Result t
20
Expecte Actual
Proces No. Test Case Steps Description Status d Result Commen
s Result t
2.
Determine
the entry
and exit
criteria.
1. Define
Test the timeline Verify the The
Scope and for each schedule Not schedule is
TC006 Schedule testing for testing. Starte established
phase. d .
2. Determine
the scope of
testing for
each phase.
Potential
risks are
1. Identify Verify risk identified
potential analysis with
Risk risks in the and Not mitigatio
TC007 Analysi Starte n plans.
testing mitigation
s process. strategies. d
2. Discuss
risk
mitigation
strategies
with the team.
1. Allocate Resources
the required Verify the needed
Resourc resources for availability Not for testing
TC008 e testing. of resources. Starte are
Planning d allocated.
2. Determine
the roles and
responsibilitie
s of the team.
21
Test Case Design:
Expecte Actual
Proces No. Test Case Steps Description Status d Result Commen
s Result t
22
Expecte Actual
Proces No. Test Case Steps Description Status d Result Commen
s Result t
3. Create
test cases
for
evaluating
Module D's
usability.
Module E
1. Review is protected
the security Verify the against
Module E - requirements security Not security
TC005 Security for Module of Module Starte threats.
Test E. E. d
2.
Identify
potential
23
Expecte Actual
Proces No. Test Case Steps Description Status d Result Comment
s Result
security
vulnerabilities
.
3. Design
security test
cases to
assess
Module E.
Program:
'''
import time
def register(call): #call takes value 1 if it is called by admin() else takes 2 if called by customer()
24
login_data.keys():
if i==username:
call==1:
return login(1) #by default returns true because forcefully everyone is registered
else:
return login(2)
#if user exist then login is called and by default true value is returned
else:
login_data[username]=password name_list[username]=name
call==1:
return login(1) #by default returns true because forcefully everyone is registered else:
return login(2)
def login(call):
userexist=False #by default user doesn't exist before checking condition for i
in login_data.keys():
if i==un:
login_data[un]==pd:
print("\nLogin Successful")
return True
25
else:
return login(1) #by default returns true because forcefully everyone is registered else:
return login(2)
if userexist==False: #this will be only execute when user with specified username doesn't exist
print("\nUser not found... Please register or login with different account to continue")
if call==1:
return admin() #by default returns true because forcefully everyone is registered else:
return customer()
print("2.Register")
ch==1:
else:
while val==True:
print(" ")
print("1.Modify Menu")
print("2.Display Menu")
print("3.Logout")
choice==1:
print("1.Add item")
print("2.Delete item")
26
print("3.Go Back")
kh==1:
add_item() elif
kh==2:
delete_item() else:
continue elif
choice==2:
display_menu() else:
print("Logout Successfully")
print("2.Register")
ch==1:
while val==True:
print(" ")
print("1.Display Menu")
print("2.Order food")
print("3.Logout")
choice==1:
27
display_menu() elif
choice==2:
val=order_food() else:
print("Logout Successfully")
def add_item():
Price :"))
item_list[name]=price
global no_of_dish #by default in python we have to say compiler that this is global variable
no_of_dish+=1
def delete_item():
len(item_list)==0:
in range(len(item_list)):
if name in item_list.keys():
del(item_list[name])
28
def display_menu():
if(len(item_list))==0:
number=1 #it is used to print 1,2,3... serial no. in front of items for i
in item_list.keys():
print(number,".",i,"\t= ",item_list[i])
number+=1
def order_food():
display_menu()
if(len(item_list))==0:
order=False else:
order=True while
order==True:
bill[item_serial[dish_number]]=quantity
if cont=='Y' or cont=='y':
order=True else:
order=False
return generate_bill() #value returned by gererate_bill() function will be again returned to customer()
where order_food() is called
29
def animate_bill(): for i
in range(4):
time.sleep(0.5)
time.sleep(0.5)
time.sleep(0.5)
time.sleep(0.5)
def generate_bill():
animate_bill()
number=1
t_bill=0
for i in bill.keys():
t_bill+=one_tbill number+=1
print(" ")
t_bill+=t_bill/10
print(" ")
print(" ")
thank_msg()
Visit Again ! \
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^")
def main():
print("1.Admin panel")
print("2.Customer panel")
print("3.Exit")
choice==1:
admin()
elif choice==2:
customer() else:
31
return 0
"C:\Program Files\Python311\python.exe"
C:\Users\VSB\PycharmProjects\pythonProject1\LearningSelenium\firefoxbrowser.py
Welcome
1. Admin panel
2.Register
Login
Password :password
User not found... Please register or login with different account to continue
1.Login
2.Register
^^^^^^
admin()
32
File "C:\Users\VSB\PycharmProjects\pythonProject1\LearningSelenium\firefoxbrowser.py", line 70, in
admin
val = login(1) # val is return value of login() function #1 is for admin() login call
^^^^^^^^
^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError:
"C:\Program Files\Python311\python.exe"
C:\Users\VSB\PycharmProjects\pythonProject1\LearningSelenium\firefoxbrowser.py
Welcome
1. Admin panel
2.Register
Register
Enter Name :sen Enter
Password :sent
Login
Password :sent
Login Successful
1. Display Menu
FOOD MENU
Bill
TOTAL BILL =
0 Gst 5% =
0.00
Cgst 5% = 0.00
34
Grand Total = 0.0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ THANK
YOU
Visit Again !
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1. Display Menu
Explanation:
An inventory control system is critical for managing stock and supplies. Proper testing
ensures the system functions accurately and efficiently.
Result:
Upon completion of the experiment, you will have a well-structured test plan and a set of
test cases ready for testing the Inventory Control System.
35
Experiment 5: Execute the Test Cases against a Client-Server or Desktop Application
and Identify the Defects
Aim:
The aim of this experiment is to execute the test cases against a client-server or
desktop application and identify defects.
Algorithm:
1. Test Environment Setup: Set up the testing environment, including the client-server or
desktop application, required hardware, and test data.
2. Test Case Execution: Execute the test cases designed in Experiment 2 against the application.
3. Defect Identification: During test execution, record any discrepancies or issues encountered.
4. Defect Reporting: Log the identified defects with detailed information, including
steps to reproduce, severity, and priority.
5. Defect Tracking: Track the progress of defect resolution and verify fixes as they
are implemented.
6. Retesting: After defect fixes, retest the affected areas to ensure the issues are resolved.
7. Regression Testing: Conduct regression testing to ensure new changes do not introduce
new defects.
36
Test Case Table:
Expecte Actual
Process No. Test Case Steps Description Status d Result Result Commen
t
User can
Test Case 1. Launch Verify user Not successfull
Executio TC001 User Login the login Started y log in.
n application. process.
2. Enter
valid login
credentials.
3. Click on the
"Login"
button.
Invalid
data shows
1. Access Verify data appropriate
a data validation Not error
TC002 Data input on the form. Started messages.
Validation form.
2. Enter
invalid data in
the form
fields.
3. Submit
the form.
3. Click on
the "Upload"
button.
37
Application
Verify the gracefully
Network 1. application' Not handles
TC004 Connectivit Disconnect s response. Started disconnection
y the network. .
2. Attempt
to perform
an action
requiring
network
access.
1. Monitor Data is
network Verify correctly
Client-Server traffic communicatio Not transmitted
TC007 Communicatio between client n integrity. Started and
n and server. received.
Explanation:
Testing a client-server or desktop application ensures its functionality across different
platforms and environments.
38
39
Result:
Upon completion of the experiment, you will have a list of identified defects and their status
after resolution for the client-server or desktop application.
40
Experiment 6: Test the Performance of the E-commerce Application
Aim:
The aim of this experiment is to test the performance of the e-commerce
application www.amazon.in.
Algorithm:
1. Identify Performance Metrics: Determine the performance metrics to be measured,
such as response time, throughput, and resource utilization.
2. Define Test Scenarios: Create test scenarios that simulate various user interactions and
loads on the application.
4. Execute Performance Tests: Run the performance tests using the defined scenarios and
collect performance data.
5. Analyze Performance Data: Analyze the collected data to identify any performance
bottlenecks or issues.
Performance Table:
Expect Actua
Process No. Test Steps Descripti Status ed l Comme
Case on Result Resul nt
t
TC00 Response 1. Access The home
Performan 1 the Measure page loads
Time for home page the within the
ce of response
Testing
HomePage the e- Specified
commerce response
Application. Not time
Started threshold.
41
Expecte Actua
Process No. Test Case Steps Descriptio Statu d l Commen
n s Result Resul t
t
2. Use a
performanc
e testing
tool to
record the
time.
3. Analyze
the recorded
data to
determine
response
time.
The
applicati
on can
handle
1. Simulate peak-
Throughp peak-hour hour
ut during traffic on Measure Not traffic
TC00 Peak the the Starte without
2 Hours application throughput d significa
. . nt delays.
2. Execute
performan
ce tests
during
peak
hours.
3. Analyze
the data to
determine
the
throughput.
Resource
1. Monitor utilizatio
CPU, n
memory, and Measure remains
Resource network resource Not within
TC00 Utilizatio usage during utilizatio Starte acceptabl
3 n testing. n. d e limits.
42
Expecte Actua
Process No. Test Case Steps Descriptio Statu d l Commen
n s Result Resul t
t
3. Analyze
the data to
assess
resource
utilization.
The
1. Simulate applicatio
multiple n remains
concurrent Measure stable and
Concurre users app Not responsiv
TC00 nt Users accessing the performan Starte e under
4 app. ce under d load.
load.
2. Increase
the number
of
concurrent
users
gradually.
3. Record
the
application's
behavior
with
increased
load.
Measur
1. Apply e The
maximum system system
load to test behavio recovers
Stress the system's r under Not gracefully
TC00 Testin breaking extrem Starte after
5 g point. e load. d stress is
removed.
2. Apply the
maximum
user load the
application
can handle.
3. Observe
the
application's
response
under stress.
43
Expecte Actua
Process No. Test Case Steps Descriptio Statu d l Commen
n s Result Resul t
t
Performan
ce
bottleneck
1. Identify s are
performanc addressed
e Improve and
Performan bottlenecks application Not application
TC00 ce Tuning and areas of performanc Starte performs
6 improveme e. d better.
nt.
2. Analyze
the
performance
test results.
3. Implement
necessary
optimizations
.
44
45
Explanation:
Performance testing helps to identify bottlenecks in the e-commerce application, ensuring it
can handle real-world user loads effectively.
Result:
Upon completion of the experiment, you will have performance test results and any
optimizations made to improve the application's performance.
46
Experiment 7: Automate the testing of e-commerce applications using Selenium.
Aim:
The aim of this task is to automate the testing of an e-commerce web application
(www.amazon.in) using Selenium WebDriver, which will help improve testing efficiency
and reliability.
Algorithm:
1. Set up the environment:
- Install Java Development Kit (JDK) and configure the Java environment variables.
- Install an Integrated Development Environment (IDE) like Eclipse or IntelliJ.
- Download Selenium WebDriver and the required web drivers for the browsers you
intend to test (e.g., ChromeDriver, GeckoDriver for Firefox).
47
6. Analyze the test results:
- Review the test execution results to identify any failed test cases.
- Debug and fix any issues with the automation scripts if necessary.
7. Report defects:
- Document any defects found during the automated testing process.
- Provide detailed information about each defect, including steps to reproduce and
expected results.
Program:
class EcomTest(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
# initialize webdriver
cls.driver =
webdriver.Chrome("C:/Users/flavi/PycharmProjects/eCommerceAutomationProject/drivers/chromedriver
.exe")
cls.driver.implicitly_wait(10) cls.driver.maximize_window()
def test_01(self):
#Initialize driver and open URL driver =
self.driver
driver.get('http://tutorialsninja.com/demo/')
#Initialize Home Page Object and click phone and pda option home
= HomePage(driver)
home.click_phone_pda_option()
time.sleep(2)
48
time.sleep(2)
#See all images
iphone = iPhonePage(driver)
iphone.click_iphone_image()
time.sleep(2)
#Click next arrow 5 times for i in
range(5):
iphone.click_next_arrow() time.sleep(2)
#Take screenshot of last image and close image
driver.save_screenshot('C:/Users/flavi/PycharmProjects/eCommerceAutomationProject/Screenshots/'+'scr
eenshot#'+str(random.randint(0,101))+'.png')
iphone.click_close_button()
time.sleep(2)
#Add input quantity and add to cart
iphone.input_quantity(2) time.sleep(2)
#iphone.click_add_to_cart_button()
#time.sleep(2)
@classmethod
def tearDownClass(cls) -> None:
cls.driver.close() cls.driver.quit()
49
print("Test Completed")
#HtmlTestRunner.HTMLTestRunner(output="C:/Users/flavi/PycharmProjects/eCommerceAutomationPr
oject/Reports")
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output="C:/Users/flavi/PycharmProjects/e
CommerceAutomationProject/Reports"))
50
Console output:
Result:
The successful completion of this task will yield:
- Automated test scripts for the e-commerce application using Selenium WebDriver.
- Identification of defects, if any, in the application.
51
Experiment 8: Integrate TestNG with the above test automation.
Aim:
The aim of this task is to integrate TestNG with the existing Selenium automation scripts
for the e-commerce application, enhancing test management, parallel execution, and
reporting capabilities.
Algorithm:
1. Set up TestNG in the project:
- Add TestNG library to the existing Java project.
- Review the TestNG-generated test reports to identify any failed test cases.
- Utilize TestNG's reporting capabilities to understand the test execution status.
52
Program:
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
org.testng.annotations.BeforeClass;
import.Time
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterClass;
WebDriver driver;
@BeforeClass
System.setProperty("webdriver.chrome.driver", ".\\Driver\\chromedriver.exe");
driver=new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
53
public void openBrowser()
driver.get("https://www.browserstack.com/");
driver.findElement(By.id("signupModalButton")).click();
driver.findElement(By.id("user_full_name")).sendKeys("user_name");
driver.findElement(By.id("user_email_login")).sendKeys("email_id");
driver.findElement(By.id("user_password")).sendKeys("password");
driver.findElement(By.xpath("//input[@name='terms_and_conditions']")).click();
driver.findElement(By.id("user_submit")).click();
@AfterMethod
System.out.println(driver.getCurrentUrl());
@AfterClass
54
public void afterClass()
driver.quit();
55
Result:
- Identification of defects, if any, in the application and improved efficiency in handling test
scenarios.
- Provide detailed information about each defect, including steps to reproduce and expected
results.
56