Hello everyone! 👋
Welcome back to the Selenium with Python Framework Series.
In Session #12, we will learn how to implement a complete Screenshot Utility inside your Selenium Python automation framework. This is a powerful feature used in real-time projects to capture screenshots automatically on test failures.
📌 What You Will Learn in This Video
Why screenshot utilities are required in automation frameworks
How to create a screenshot utility file in Python
How to generate unique screenshot file names using timestamps
How to create screenshot storage folders automatically
Using os and datetime modules
Writing a reusable take_screenshot() function
Implementing pytest_runtest_makereport hook
Capturing screenshots only when a test fails
Accessing the WebDriver instance from failed tests
Demonstration with a purposely failing assertion to verify screenshot capture
TIMESTAMP
0:00 – Introduction to Session 12
0:08 – What is Screenshot Utility in Automation Framework
0:20 – Why We Need Screenshot Utility in Real-Time Projects
0:32 – Creating the Screenshot Utility Python File
0:50 – Importing Required Modules (os & datetime)
1:14 – Creating take_screenshot() Function
1:57 – Defining Screenshot Folder Name
2:38 – Creating Folder If Not Exists
3:36 – Generating Timestamp for Screenshot Names
4:22 – Formatting Timestamp Using strftime
4:47 – Creating Screenshot File Path
5:45 – Saving Screenshot Using WebDriver
6:11 – Print Screenshot Save Confirmation
6:34 – Using Pytest Hooks for Failure Screenshots
7:03 – Opening Test File & Adding Hook
7:16 – Adding pytest.hookimpl Decorator
7:39 – Creating pytest_runtest_makereport Function
8:11 – Waiting for Test Outcome
8:55 – Checking Test Status (Passed/Failed)
9:21 – Getting Driver Instance from Failed Test
10:06 – Calling Screenshot Utility on Failure
10:40 – Fixing Import Errors
11:10 – Creating a Test That Will Fail
11:57 – Running Test with Pytest
12:33 – Viewing Screenshot Output Folder
13:02 – Final Explanation & Summary
📁 Code Concepts Covered
os.path.exists()
os.makedirs()
datetime.now()
strftime()
Pytest hook mechanism
File path building for screenshots
Saving images with .png format
Folder creation logic
Framework integration step-by-step
📸 Real-Time Demo Included
This session shows:
✔ Creating the screenshot utility file
✔ Generating timestamped screenshot names
✔ Using f-strings for file paths
✔ Running Pytest with -v
✔ Triggering a failed test
✔ Automatically saving the screenshot inside /screenshots folder
✔ Verifying the final screenshot output
👍 If You Found This Helpful
Please support the channel by:
👉 Liking the video
👉 Subscribing for more automation tutorials
👉 Commenting your questions
👉 Sharing with your testing community
#selenium #python #pytest #automationtesting #seleniumframework #pythonautomation #sdet #softwaretesting #testingfunda #qa #automationframework #seleniumwithpython #pytesthooks #codetutorials #automationengineer
Subscribe to our channel for the latest videos
==================================
/ testingfunda
#selenium #tutorials #free #2022 #training
Watch more free Selenium Tutorials
• Selenium Java #1 | Introduction to Selenium
#JMeter #performance #testing #tutorials #free #2022 #training
Step-by-step free JMeter performance tutorials
• Postman API Testing Tutorial #1: Introduct...
#postman #API #testing #tutorial #manual #automation #free #2022 #training
Step-by-step free postman API manual and Automation Testing tutorials
• 🚀 Postman API Testing Tutorial - FULL COURSE
#java #programming #tutorials #free #2022 #training
Step-by-step free Java programming tutorials
• Java tutorial 1 - What is Java | How to In...
#cypress.io #automation #testing #tutorials #free #2022 #training
Step-by-step free cypress.io automation testing tutorials
• Cypress tutorial #1 | Cypress Architecture...
#agile #Youtube #series #free #2022 #training
Learn about agile from the free YouTube series
• Agile
#learn #software #testing #innovative #animated #videos #free #2022
Learn software testing free from innovative animated videos
• Software Testing #1 | Boundary Value Analy...
In questa pagina del sito puoi guardare il video online Selenium with Python Framework #12 | Implement Screenshot Utility della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Testing Funda by Zeeshan Asghar 18 novembre 2025, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 247 volte e gli è piaciuto 5 spettatori. Buona visione!