QAPage – Software Testing Jobs, QA Resources & Careers

QAPage Navigation & Directory
Type any keyword to search live pages, tools, or press Search to query site-wide.

Python Full Notes PDF for QA | Complete Guide for Beginners to Experienced

Python Full Notes PDF for QA Testers – Important Topics Explained

Python Notes for QA : QAPage Learning Guide · Beginner to Automation Testing · Theory, Practical Examples and Interview Preparation
These notes explain the important Python topics used in software testing. Each topic includes a simple definition, a small code example, and how a QA tester can use it in real projects.

Complete course structure

Module
Topics covered
1
Introduction to Python and its role in QA
2
Installation, IDE setup, syntax and indentation
3
Variables, constants, comments and naming rules
4
Data types and type conversion
5
Input, output and string formatting
6
Operators and expressions
7
Conditional statements
8
Loops and loop control statements
9
Strings and string methods
10
Lists and list operations
11
Tuples, sets and dictionaries
12
Functions, parameters, arguments and return values
13
Scope, modules, packages and imports
14
Object-oriented programming (OOP)
15
Exception handling and debugging
16
File handling, CSV and JSON
17
Comprehensions, iterators and useful built-ins
18
Regular expressions and data validation
19
Python coding problems for QA interviews
20
Pytest, test discovery, fixtures and parametrization
21
Selenium and Playwright automation concepts
22
API testing using Python
23
Database testing with Python
24
Logging, reports, Git and CI/CD
25
Real-time QA project and interview questions

 Introduction to Python for QA Testers

Python Notes for QA

1.1 What is Python?

Python is a programming language used to give instructions to a computer. We can write instructions to perform calculations, process information, interact with websites, and test software applications.
Python is popular among testers because its syntax is relatively easy to read. You can understand what a program does without learning complicated programming rules first.
For example, consider this program:
print("Hello, QA Tester!")
Output:
Hello, QA Tester!
The print() function displays the message on the screen.

1.2 Why do QA testers learn Python?

A manual tester checks software by interacting with an application and comparing its behavior with the expected result. An automation tester writes code to perform some of these checks automatically.
Suppose you need to test a login page with 100 different sets of test data. Performing every check manually takes time. Python can help execute repetitive checks more quickly.
It is useful for:
  • Functional testing: Verify whether application features work as expected.
  • UI automation: Automate actions such as clicking buttons and filling forms.
  • API testing: Send requests and validate responses.
  • Database testing: Execute queries and compare database records.
  • Test data management: Read and prepare test data from files.
  • Regression testing: Repeat existing tests after application changes.
  • Reporting: Record test results and identify failures.
Python does not replace a tester’s thinking. Testers still need to understand requirements, identify risks, and decide which scenarios should be tested.

1.3 Python applications in QA

Testing activity
Example
Login testing
Verify valid and invalid credentials
Form validation
Check mandatory fields and invalid email addresses
API testing
Verify status codes and response data
Database testing
Confirm that a saved customer record exists
Cross-browser testing
Execute checks on different browsers
Data validation
Compare expected and actual values
Automation reporting
Record passed and failed test cases

1.4 Python versus manual testing

Manual testing and Python automation serve different purposes.
Manual testing is useful for exploratory testing, usability checks, and scenarios that require human judgment. Automation is useful for repetitive, predictable checks that need to run frequently.
For example, a tester may manually explore a shopping website to discover usability problems, then automate the checkout regression tests using Python.

1.5 Important Python tools for QA

  • Pytest: A framework for writing and running Python tests.
  • Selenium: A browser automation tool that supports Python.
  • Playwright: A browser automation tool with Python support.
  • Requests: A library for sending HTTP requests.
  • SQL connectors: Libraries that let Python communicate with supported databases.
  • Pandas: A library for working with tabular data.
You do not need to learn all these tools on the first day. First build a strong foundation in Python.

 Python Installation, Syntax and Indentation

2.1 Installing Python

Download Python from the official website:
On Windows:
  1. Download the installer.
  2. Run the installer.
  3. Select Add Python to PATH, if that option is available.
  4. Complete the installation.
  5. Open Command Prompt.
  6. Run the following command.
python --version
If Python is configured correctly, the installed version will be displayed.
If the command does not work, try:
py --version

2.2 What is an IDE?

An IDE or code editor is an application used to write, run, and debug programs.
Common choices include:
  • Visual Studio Code
  • PyCharm
  • IDLE, which is included with many Python installations
  • Online Python environments
For learning Python automation, Visual Studio Code or PyCharm is a practical choice.

2.3 Python syntax

Syntax means the rules used to write valid code.
Example:
name = "Rahul"print(name)
Output:
Rahul
Here, name = "Rahul" stores a value, and print(name) displays it.
An incorrect statement may cause a syntax error.
For example:
if 10 > 5    print("Correct")
This code is missing a colon after the condition.
Correct version:
if 10 > 5:    print("Correct")

2.4 Indentation

Indentation means adding spaces at the beginning of a line.
Python uses indentation to identify blocks of code. Four spaces per indentation level is the common convention.
status_code = 200if status_code == 200:    print("API test passed")    print("Response received successfully")print("Test execution completed")
The first two print() statements belong to the if block. The final statement is outside that block.
Incorrect indentation can cause an IndentationError or change how a program behaves.

2.5 Comments

Comments explain what the code does. Python ignores ordinary comments when executing a program.
A single-line comment starts with #.
# Store the expected login messageexpected_message = "Welcome"# Display the expected messageprint(expected_message)
Comments are helpful when automation code becomes large or multiple testers work on the same project.

2.6 Case sensitivity

Python treats uppercase and lowercase letters differently.
username = "tester01"Username = "tester02"print(username)print(Username)
These are two separate variables.
A common beginner mistake is writing Print() instead of print(). Python recognizes print() with lowercase letters.

 Variables, Constants and Naming Rules

3.1 What is a variable?

A variable is a name that refers to a value.
username = "tester01"age = 25price = 499.50is_active = True
Here:
  • username refers to a string.
  • age refers to an integer.
  • price refers to a floating-point number.
  • is_active refers to a Boolean value.
Python does not require you to declare a variable’s type separately.

3.2 Assigning values

The assignment operator = assigns a value to a variable.
expected_result = "Login successful"actual_result = "Login successful"
We can use the values later:
print(expected_result)print(actual_result)
We can also assign a new value:
status = "Pending"status = "Passed"print(status)
Output:
Passed
The second assignment replaces the value referenced by status.

3.3 Variable naming rules

Valid examples:
username = "tester01"test_count = 10expected_status_code = 200
Invalid examples:
# 1test = 10       
# Cannot start with a number# test-count = 5  
 # Hyphen is not allowed in a variable name# class = "QA"    
 # Reserved Python keyword
Variable names can contain letters, digits and underscores, but cannot begin with a digit. Python keywords such as class, if, and for cannot be used as ordinary variable names.
Use meaningful names so that another tester can understand your code.

3.4 What is a constant?

A constant is a value intended to remain unchanged throughout a program.
Python does not enforce constants in the same way some languages do. By convention, developers write constant names in uppercase letters.
BASE_URL = "https://example.com"TIMEOUT_SECONDS = 10EXPECTED_STATUS_CODE = 200
These values might represent a test environment URL, a timeout, and an expected HTTP status code.

3.5 Multiple assignment

Python allows multiple variables to receive values in one statement.
username, role = "tester01", "QA"
It is also possible to swap two variables:
a = 10b = 20a, b = b, aprint(a)print(b)
Output:
2010
This feature can be useful in coding interviews and data-processing tasks.

 Python Data Types and Type Conversion

4.1 Why are data types important?

Data types determine what kind of information a variable represents and which operations are appropriate.
For example, adding two integers performs arithmetic, while combining two strings joins their text.
print(10 + 20)print("QA" + " Tester")
Output:
30QA Tester

4.2 Numeric data types

Integer (int)
Stores whole numbers.
test_cases = 50failed_tests = 3
Float (float)
Stores numbers with decimal points.
product_price = 499.99execution_time = 2.5
Python also supports complex numbers, although they are not commonly needed in everyday QA automation.

4.3 String (str)

A string stores text.
browser = "Chrome"page_title = "Login Page"
Strings can use single or double quotes.
message = 'Test passed'another_message = "Test passed"

4.4 Boolean (bool)

A Boolean has two possible values: True and False.
is_logged_in = Truehas_error = False
Boolean values are useful when validating conditions.
is_logged_in = Trueif is_logged_in:    print("User is logged in")

4.5 Collections

Python provides several built-in collection types.
List: Ordered and changeable.
browsers = ["Chrome", "Firefox", "Edge"]
Tuple: Ordered and immutable.
screen_size = (1920, 1080)
Set: Stores unique elements and does not guarantee a fixed display order.
status_codes = {200, 404, 500, 200}print(status_codes)
The duplicate 200 is stored only once.
Dictionary: Stores key-value pairs.
response = {    "status": 200,    "message": "Success"}

4.6 Checking a data type

Use type() to check the type of a value.
username = "tester01"age = 25print(type(username))print(type(age))
Use isinstance() when you need to check whether a value belongs to a particular type.
age = 25print(isinstance(age, int))

4.7 Type conversion

Type conversion means changing a value from one data type to another.
age_text = "25"age_number = int(age_text)print(age_number + 5)
Output:
30
Common conversion functions include:
  • int() — converts a compatible value to an integer.
  • float() — converts a compatible value to a float.
  • str() — converts a value to a string.
  • bool() — converts a value to a Boolean.
  • list() — creates a list from an iterable.
  • tuple() — creates a tuple from an iterable.
  • set() — creates a set from an iterable.
Not every conversion is valid.
# This raises ValueError:# int("hello")
This is important when testing forms. A field may accept numeric text, but invalid text should be handled correctly by the application.

Input, Output and String Formatting

5.1 The print() function

The print() function displays values.
name = "Rahul"result = "Passed"print(name)print(result)print("Tester:", name)
You can print multiple values in the same statement.

5.2 The input() function

The input() function accepts information from the user and returns it as a string.
username = input("Enter username: ")print("Username:", username)
If you need a number, convert it first.
attempts = int(input("Enter number of attempts: "))print(attempts)
Invalid numeric input can raise ValueError, so real programs should handle it appropriately.

5.3 String formatting

String formatting makes it easier to combine text and variable values.
An f-string is a convenient option.
username = "tester01"status = "Passed"print(f"Test user: {username}, Result: {status}")
Output:
Test user: tester01, Result: Passed
F-strings are especially useful for readable test messages and logging.

5.4 Practical QA example

test_name = "Login Test"expected = "Welcome"actual = "Welcome"if expected == actual:   
 result = "Passed"else: 
   result = "Failed"print(f"{test_name}: {result}")
Output:
Login Test: Passed
This example shows how a test name, expected result, actual result and outcome can be combined into a readable message.

Python Operators

Operators allow us to calculate values, compare data, and combine conditions.

6.1 Arithmetic operators

Operator
Meaning
Example
+
Addition
10 + 5
-
Subtraction
10 - 5
*
Multiplication
10 * 5
/
Division
10 / 5
//
Floor division
11 // 2
%
Remainder
11 % 2
**
Exponentiation
2 ** 3
Example:
total_price = 1000discount = 200final_price = total_price - discountprint(final_price)
Output:
800

6.2 Comparison operators

Comparison operators return a Boolean result.
expected = 200actual = 200print(expected == actual)print(expected != actual)print(expected > actual)
print(expected <= actual)
Remember:
  • == compares values.
  • = assigns a value.
  • != checks whether values are different.
  • > and < compare magnitudes.
  • >= and <= include equality.

6.3 Logical operators

The main logical operators are and, or, and not.
username_valid = Truepassword_valid = Trueprint(username_valid and password_valid)
and requires both conditions to be true.
valid_user = Truevalid_admin = Falseprint(valid_user or valid_admin)
or is true if at least one condition is true.
is_blocked = Falseprint(not is_blocked)
not reverses the Boolean value.
QA scenario: A login should succeed only when the username and password are both valid. This can be represented by username_valid and password_valid.

6.4 Membership operators

in and not in check whether a value exists in a collection.
browsers = ["Chrome", "Firefox", "Edge"]print("Chrome" in browsers)print("Safari" not in browsers)
This is useful when checking whether an expected value exists in a list of available options.

6.5 Identity operators

is and is not check whether two references point to the same object.
result = Noneprint(result is None)
Use is None when checking whether a value is None.
Do not confuse identity (is) with equality (==). For comparing ordinary test values, == is usually what you want.

Conditional Statements

Conditional statements allow a program to choose what to do based on a condition.

7.1 The if statement

status_code = 200if status_code == 200:    print("Request successful")
The message is displayed only when the condition is true.

7.2 The if-else statement

actual_result = "Passed"if actual_result == "Passed":    print("Test case passed")else:  
print("Test case failed")
If the condition is false, the else block runs.

7.3 The if-elif-else statement

Use elif when you need to check several possible conditions.
status_code = 404if status_code == 200:    print("Success")elif status_code == 404:  
print("Resource not found")elif status_code == 500: print("Server error")else: print("Unexpected status code")
Only the first matching branch runs.

7.4 Nested conditions

A nested condition is an if statement inside another conditional block.
username_valid = Truepassword_valid = Trueif username_valid:    if password_valid:    
print("Login successful") else: print("Invalid password")else: print("Invalid username")
Nested conditions are useful for representing dependent checks, although complex conditions can often be simplified for readability.

7.5 Real-time QA example

Imagine a registration form that should accept users only when the required fields are filled and the email address is valid.
fields_filled = Trueemail_valid = Trueif fields_filled and email_valid: 
print("Registration can proceed")else: print("Show validation message")
This is a simplified example of business logic. In a real application, the tester must verify the actual interface and backend behavior, not just the Python variables.

Loops and Loop Control

Loops repeat instructions without requiring the same code to be written multiple times.

8.1 The for loop

A for loop iterates over the items in a collection or another iterable.
test_cases = ["Login", "Logout", "Registration"]for test_case in test_cases:   
print("Executing:", test_case)
The variable test_case receives each item during the loop.

8.2 The range() function

range() generates a sequence of integers.
for number in range(1, 6):    print(number)
Output:
12345
The ending value is excluded. Therefore, range(1, 6) produces numbers from 1 to 5.

8.3 The while loop

A while loop continues as long as its condition is true.
attempt = 1while attempt <= 3:    print(f"Attempt {attempt}")    attempt += 1
The statement attempt += 1 increases the counter. Without a suitable stopping condition or update, the loop may run indefinitely.

8.4 The break statement

break immediately exits the nearest loop.
for status_code in [200, 201, 404, 500]:    if status_code == 404: 
print("Found an error response") break

8.5 The continue statement

continue skips the remaining statements in the current iteration and moves to the next iteration.
for number in range(1, 6):    if number == 3:      
continue print(number)
The number 3 is skipped.

8.6 The pass statement

pass is a placeholder that performs no action.
def test_logout():    pass
It is useful when sketching out a program before implementing the logic. A test containing only pass does not actually test the feature.

8.7 Nested loops

A nested loop is a loop inside another loop.
browsers = ["Chrome", "Firefox"]test_cases = ["Login", "Logout"]for browser in browsers: 
   for test_case in test_cases:  
      print(f"{browser} - {test_case}")
This produces four combinations: each test case is paired with each browser.
This idea is useful for understanding cross-browser test combinations. In actual automation, use a test framework or carefully controlled loop structure to collect individual results and handle failures correctly.

Python Notes for QA Testers

QA Page Learning Notes | Simple explanations, practical examples, and interview-focused concepts

1. Strings and Their Methods

A string is a collection of characters used to store text. In testing, strings are useful for checking error messages, page titles, usernames, and API response messages.
message = "Login Successful"print(message.upper())print(message.lower())print(len(message))print("Login" in message)
Output:
LOGIN SUCCESSFULlogin successful16True
Important string methods:
Method
Purpose
upper()
Converts text to uppercase
lower()
Converts text to lowercase
strip()
Removes whitespace from the beginning and end
replace()
Replaces part of a string
split()
Splits a string into a list
find()
Finds the position of a substring
startswith()
Checks how a string begins
endswith()
Checks how a string ends
QA example: Check whether the application displays the correct login message.
actual = "Login Successful"expected = "Login Successful"assert actual == expected
An assertion passes if both strings match exactly.

2. Lists, Tuples, Sets, and Dictionaries

These are Python collection types. They help testers store and manage test data.

List

A list stores multiple items and allows changes.
browsers = ["Chrome", "Firefox", "Edge"]browsers.append("Safari")print(browsers)
QA use: Store test cases, browser names, and input values.

Tuple

A tuple stores an ordered collection that cannot be changed after creation.
screen_size = (1920, 1080)print(screen_size[0])
QA use: Store fixed values, such as screen dimensions.

Set

A set stores unique values and removes duplicates.
status_codes = {200, 404, 200, 500}print(status_codes)
The set contains 200 only once.
QA use: Identify unique values or remove duplicate test data.

Dictionary

A dictionary stores information as key-value pairs.
user = {    "username": "tester01",    "role": "QA",    "active": True}print(user["username"])
QA use: Store user details, test data, and API response values.
Remember: Lists are changeable, tuples are immutable, sets contain unique elements, and dictionaries organize information using keys and values.

3. Functions and Reusable Test Code

A function is a reusable block of code that performs a particular task. Functions help testers avoid writing the same logic repeatedly.
def compare_results(expected, actual):    if expected == actual:       
 return "Passed"  
  return "Failed"result = compare_results("Welcome", "Welcome")
print(result)
Output:
Passed
Important concepts:
  • Parameters: Variables defined in the function.
  • Arguments: Values passed when calling the function.
  • Return: Sends a result back to the caller.
  • Default arguments: Values used when an argument is not provided.
QA use: Create reusable functions for result validation, data preparation, and common test operations.
In larger automation projects, use your testing framework’s assertions rather than returning only "Passed" or "Failed" strings.

4. Modules, Packages, and Scope

Modules

A module is a Python file containing reusable code.
For example, suppose test_utils.py contains:
def add(a, b):    return a + b
You can import and use it in another file:
from test_utils import addprint(add(10, 20))

Packages

A package organizes related Python modules into a directory structure. Packages help keep larger automation projects organized.
For example, a project might separate page classes, test cases, test data, and helper functions into different folders.

Scope

Scope determines where a variable can be accessed.
name = "QA Team"def show_name():    message = "Hello"    print(message)    print(name)show_name()
Here, name is defined outside the function, while message is local to the function.
QA use: Organize reusable utilities, share common test logic, and avoid variable conflicts in automation frameworks.

5. OOP and Page Object Model

Object-oriented programming (OOP) organizes code using classes and objects.
The main concepts are:
  • Class: A blueprint for creating objects.
  • Object: An instance of a class.
  • Inheritance: Reusing behavior from another class.
  • Encapsulation: Keeping related data and methods together.
  • Polymorphism: Allowing the same interface to have different behaviors.
  • Abstraction: Hiding unnecessary implementation details.

What is the Page Object Model (POM)?

POM is a design pattern used in UI automation. It keeps the actions and locators for a page in a separate class, making test code easier to maintain.
For example, a login page class might contain methods to enter a username, enter a password, and click the login button.
Simplified Python example:
class LoginPage:    def __init__(self, page):    
    self.page = page    def login(self, username, password):     
   self.page.get_by_label("Username").fill(username)      
  self.page.get_by_label("Password").fill(password)        
self.page.get_by_role("button", name="Login").click()
This example uses Playwright’s Python API. The labels and button name must match the actual website.
QA use: When a locator changes, you can update the page class instead of changing the same code in multiple tests.

6. Exceptions, Debugging, and File Handling

Exception handling

An exception is an error that occurs while a program is running. Python uses try and except to handle specific errors.
try:    number = int("abc")except ValueError:    print("Invalid number")
The conversion raises ValueError, so the except block runs.

Debugging

Debugging means finding and fixing problems in code.
Common techniques include:
  • Reading error messages and tracebacks.
  • Printing variable values.
  • Using breakpoints in an IDE.
  • Checking conditions step by step.

File handling

Python can read from and write to files.
with open("result.txt", "w") as file:    file.write("Login test passed")
This writes a message to a file and automatically closes the file when the block finishes.
QA use: Read test data, save execution logs, and store test results. Avoid catching every exception without investigating the actual cause.

7. CSV, JSON, and Regular Expressions

CSV stands for Comma-Separated Values. It is often used to store test data in rows and columns.
import csvwith open("users.csv", newline="") as file:   
 reader = csv.DictReader(file)   
 for row in reader:        
print(row["username"])
This example reads a CSV file containing a column named username.
QA use: Run data-driven tests using multiple usernames and passwords.

JSON

JSON is a common format for exchanging data between applications and APIs.
import jsondata = '{"status": 200, "message": "Success"}'response = json.loads(data)print(response["status"])
json.loads() converts a JSON string into Python data.
QA use: Validate API response fields, values, and data structures.

Regular expressions (Regex)

Regular expressions are patterns used to find or validate text.
import reemail = "tester@example.com"pattern = r"^[^@\s]+@[^@\s]+\.[^@\s]+$"if re.fullmatch(pattern, email): 
   print("Email format looks valid")else:  
  print("Invalid email format")
This checks a basic email format, not whether the address actually exists or can receive messages.
QA use: Validate input formats, extract values from text, and search logs for patterns.

8. Python Coding Interview Problems

QA interviews often include small coding problems to check logical thinking and knowledge of Python collections.

Reverse a string

text = "Python"print(text[::-1])
Output: nohtyP

Find duplicate values

numbers = [1, 2, 3, 2, 4, 1]duplicates = []for number in numbers: 
   if numbers.count(number) > 1 and number not in duplicates:     
   duplicates.append(number)print(duplicates)
Output: [1, 2]

Find the largest number

numbers = [10, 25, 5, 40, 15]print(max(numbers))
Output: 40

Check a palindrome

A palindrome reads the same forward and backward.
word = "madam"if word == word[::-1]:    print("Palindrome")else:    print("Not a palindrome")
Other problems worth practising include counting vowels, removing duplicates, finding the second-largest number, checking prime numbers, and counting character occurrences.
Interview tip: Learn to explain your logic, test normal and edge cases, and discuss the time and space complexity when relevant.

9. Pytest Fixtures and Parametrization

Pytest is a Python framework used to write and execute tests.

Basic test

def test_addition():    assert 2 + 3 == 5
Save this in a file such as test_math.py and run pytest -v.

Fixtures

A fixture prepares something that a test needs, such as test data, a browser page, or a database connection.
import pytest@pytest.fixturedef username():    return "tester01"def test_username(username):    assert username == "tester01"
Pytest supplies the fixture value to the test through its argument.

Parametrization

Parametrization lets us run the same test with different input values.
import pytest@pytest.mark.parametrize(    "a, b, expected",    [        (2, 3, 5),        (4, 5, 9),        (10, 5, 15)    ])
def test_addition(a, b, expected):  
  assert a + b == expected
Pytest runs this test three times with different inputs.
QA use: Fixtures support setup and cleanup, while parametrization helps test multiple scenarios without duplicating test functions.

10. Selenium or Playwright with Python

Selenium and Playwright are tools for automating browser interactions.
Selenium
Playwright
Supports multiple browsers and languages
Supports multiple browsers and languages
Widely used in established automation frameworks
Provides built-in auto-waiting for many actions
Uses WebDriver-based browser automation
Uses Playwright’s browser automation APIs
Supports Python
Supports Python

Playwright example

Install the Python package and browser binaries using the official Playwright installation instructions.
from playwright.sync_api import sync_playwrightwith sync_playwright() as p: 
   browser = p.chromium.launch()   
 page = browser.new_page()  
  page.goto("https://example.com")  
  assert page.title() == "Example Domain" 
   browser.close()
This opens a browser, visits a sample website, checks its title, and closes the browser.
QA use: Automate login, registration, search, checkout, navigation, and regression scenarios. For real projects, also learn locators, assertions, browser contexts, fixtures, waits, screenshots, and reports.

11. API Testing and Database Validation

API testing checks communication between software components without requiring every test to interact with the user interface.
Important checks include:
  • HTTP status code.
  • Response body and data types.
  • Required fields.
  • Response headers.
  • Authentication and authorization.
  • Negative scenarios.
  • Response time requirements.
Example using Python’s requests library:
import requestsresponse = requests.get(    "https://jsonplaceholder.typicode.com/posts/1",    timeout=10)
assert response.status_code == 200data = response.json()assert data["id"] == 1
Install the library with pip install requests. This example uses a public sample API.

Database validation

Database testing checks whether information is stored, updated, and retrieved correctly.
For example, after registering a user, a tester might check whether the expected user record exists in the database.
A SQL query could be:
SELECT usernameFROM usersWHERE username = 'tester01';
Python can execute queries using an appropriate database connector.
QA use: Compare API results with database records, validate saved data, and check transaction outcomes. Use test environments and parameterized SQL queries rather than building SQL statements from untrusted input.

12. Logging, Reports, Git, CI/CD, and a Complete QA Project

Logging records what happens during test execution.
import logginglogging.basicConfig(level=logging.INFO)
logging.info("Test execution started")
logging.warning("Element took longer than expected")
logging.error("Login validation failed")
Logs help testers investigate failures after a test has finished.

Reports

Test reports summarize which tests passed, failed, or were skipped. Pytest can produce a basic terminal report, and plugins can generate formats such as HTML or JUnit XML.
For example:
pytest -v
For a JUnit XML report, a common command is:
pytest --junitxml=report.xml
This requires the appropriate Pytest installation. The resulting file can be consumed by compatible CI tools.

Git

Git is a version-control system that tracks changes in code.
Common commands:
git initgit add .git commit -m "Add QA automation tests"
Git helps a QA team share test code, review changes, and restore earlier versions.

CI/CD

CI/CD stands for Continuous Integration and Continuous Delivery or Deployment.
A CI pipeline can run automated tests whenever code changes are submitted. If a test fails, the team can investigate before the change is released.
A typical workflow is:
  1. A developer commits code.
  2. The CI system checks out the repository.
  3. Dependencies are installed.
  4. Automated tests run.
  5. Reports and logs are saved.
  6. The team reviews any failures.

Complete QA project example

A beginner-friendly automation project might test a login feature.
1. Test planning
Write scenarios for valid login, invalid password, empty fields, and locked accounts.
2. Test development
Use Python, Pytest, and Selenium or Playwright to automate the selected scenarios.
3. Test data and validation
Prepare input data, check actual results, and validate API or database behavior where required.
4. Reporting
Record pass/fail results, capture useful logs, and investigate failures.
5. Integration
Store the code in Git and configure CI to run the tests automatically.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top