Basic Assertions & Pytest Fundamentals
(10 Questions)
1. Calculator Operations Testing
python
"""
Create tests for a calculator that verify:
- Addition of positive and negative numbers
- Division with proper error handling for zero
- Multiplication with decimal numbers
- Power operations
Use assertions to validate all results
"""
2. String Manipulation Assertions
python
"""
Test string operations on real text from [Link]
- Extract and verify page title
- Check if specific text exists on page
- Verify string length constraints
- Test case sensitivity in text comparisons
"""
3. List & Data Structure Assertions
python
"""
Test data processing functions:
- Verify list sorting algorithms
- Check dictionary key-value pairs
- Test set operations (union, intersection)
- Validate list comprehensions with assertions
"""
4. Exception Handling Tests
python
"""
Create tests that verify proper exception handling:
- Division by zero errors
- File not found exceptions
- Invalid type conversions
- Custom exception classes with messages
"""
5. Boolean Logic Assertions
python
"""
Test complex boolean conditions:
- Multiple AND/OR conditions
- Truthy/falsy value evaluations
- None type checking
- Empty collection validations
"""
6. Type Checking Assertions
python
"""
Create comprehensive type validation tests:
- Verify function return types
- Check parameter type enforcement
- Test type conversion functions
- Validate custom class instances
"""
7. Mathematical Function Testing
python
"""
Test mathematical operations with edge cases:
- Fibonacci sequence generation
- Prime number identification
- Statistical calculations (mean, median)
- Geometric formula validations
"""
8. File Operations Assertions
python
"""
Test file handling operations:
- File creation and deletion
- Read/write permissions
- File content validation
- Binary file operations
"""
9. Date & Time Assertions
python
"""
Test datetime functionality:
- Date comparisons and differences
- Timezone conversions
- Date formatting strings
- Age calculation validations
"""
10. Regular Expression Assertions
python
"""
Test regex pattern matching:
- Email validation patterns
- Phone number formats
- Password strength rules
- URL parsing and validation
"""
Selenium Web Interactions (10 Questions)
11. Login Page Automation
python
"""
Automate login on [Link]
- Test successful login with valid credentials
- Verify login failure with invalid credentials
- Check error message assertions
- Validate page redirection after login
"""
12. Form Validation Testing
python
"""
Test form submissions on practice websites:
- Required field validations
- Email format checking
- Password confirmation matching
- Form submission success/failure
"""
13. E-commerce Product Testing
python
"""
Automate [Link]
- Verify product listing count
- Test add to cart functionality
- Validate cart item counter
- Check product price calculations
"""
14. Navigation & Breadcrumb Testing
python
"""
Test website navigation:
- Verify page title changes
- Check URL updates after navigation
- Test back/forward button functionality
- Validate breadcrumb trail consistency
"""
15. Dynamic Content Assertions
python
"""
Test dynamic web elements:
- Verify loading spinner disappears
- Check AJAX content updates
- Test infinite scroll functionality
- Validate real-time search results
"""
16. Dropdown & Select Operations
python
"""
Test dropdown functionality:
- Verify default selected options
- Test all available options
- Check multi-select capabilities
- Validate selection change events
"""
17. Checkbox & Radio Button Testing
python
"""
Test form input elements:
- Verify checkbox toggle states
- Test radio button exclusivity
- Check bulk selection/deselection
- Validate required field markings
"""
18. File Upload Testing
python
"""
Test file upload functionality:
- Verify supported file types
- Check file size limitations
- Test multiple file uploads
- Validate upload progress indicators
"""
19. Modal & Popup Testing
python
"""
Test modal dialog interactions:
- Verify modal opening/closing
- Test ESC key and overlay clicks
- Check modal content accuracy
- Validate focus trapping
"""
20. Responsive Design Testing
python
"""
Test responsive web elements:
- Verify element visibility at different resolutions
- Test hamburger menu functionality
- Check layout changes on resize
- Validate mobile vs desktop views
"""
Advanced Functionality Testing (10
Questions)
21. Shopping Cart Workflow Testing
python
"""
Test complete e-commerce cart functionality:
- Add/remove items from cart
- Update item quantities
- Calculate subtotal, tax, and total
- Validate cart persistence across sessions
"""
22. Search Functionality Testing
python
"""
Test search features comprehensively:
- Verify search result relevance
- Test empty search queries
- Validate search filters and sorting
- Check search result pagination
"""
23. User Registration Flow Testing
python
"""
Test complete user registration process:
- Form validation for all fields
- Password strength enforcement
- Email verification process
- Duplicate user registration prevention
"""
24. Payment Gateway Integration
python
"""
Test payment processing functionality:
- Credit card format validation
- Expiry date checking
- CVV verification
- Successful/failed payment scenarios
"""
25. Order Management System
python
"""
Test order processing workflow:
- Order creation and confirmation
- Order status updates
- Order cancellation flow
- Order history tracking
"""
26. Inventory Management Testing
python
"""
Test stock management functionality:
- Product availability updates
- Low stock warnings
- Out-of-stock scenarios
- Inventory count accuracy
"""
27. User Profile Management
python
"""
Test user profile functionality:
- Profile information updates
- Password change process
- Email preference settings
- Account deletion workflow
"""
28. Multi-language Support Testing
python
"""
Test internationalization features:
- Language switcher functionality
- Date/time format changes
- Currency conversion display
- Right-to-left language support
"""
29. Social Media Integration
python
"""
Test social features functionality:
- Social login options (Google, Facebook)
- Social sharing capabilities
- User review and rating system
- Social media feed integration
"""
30. Notification System Testing
python
"""
Test notification functionality:
- Email notification triggers
- In-app notification display
- Notification preference settings
- Notification read/unread status
"""
Sample Solution Template for Question 23
(User Registration):
python
import pytest
from selenium import webdriver
from [Link] import By
from [Link] import WebDriverWait
from [Link] import expected_conditions as EC
class TestUserRegistration:
@[Link]
def driver(self):
driver = [Link]()
[Link]("[Link]
yield driver
[Link]()
def test_successful_registration(self, driver):
"""Test complete user registration flow"""
# Fill registration form
driver.find_element([Link], "firstName").send_keys("John")
driver.find_element([Link], "lastName").send_keys("Doe")
driver.find_element([Link], "email").send_keys("[Link]@[Link]")
driver.find_element([Link], "password").send_keys("SecurePass123!")
driver.find_element([Link], "confirmPassword").send_keys("SecurePass123!")
# Submit form
driver.find_element([Link], "register-btn").click()
# Verify successful registration
WebDriverWait(driver, 10).until(
EC.url_contains("success")
)
assert "Registration Successful" in driver.page_source
assert driver.find_element(By.CLASS_NAME, "success-message").is_displayed()
def test_password_mismatch(self, driver):
"""Test registration with mismatched passwords"""
# Fill form with different passwords
driver.find_element([Link], "password").send_keys("Password123")
driver.find_element([Link], "confirmPassword").send_keys("DifferentPassword")
driver.find_element([Link], "register-btn").click()
# Verify error message
error_message = driver.find_element(By.CLASS_NAME, "error-message")
assert "Passwords do not match" in error_message.text