QA Warehouse

Your comprehensive resource for Test Cases, Scenarios, Tips & Scripts

QA Test Cases

Comprehensive test cases covering various scenarios and functionalities

TC-001 High

User Login Functionality

Objective:

Verify that users can successfully log in with valid credentials

Preconditions:
  • User account exists in the system
  • User is on the login page
Test Steps:
  1. Navigate to login page
  2. Enter valid username
  3. Enter valid password
  4. Click "Login" button
Expected Result:

User is redirected to dashboard and session is established

Test Data: Username: testuser@example.com
Password: Test@123
TC-002 High

Form Validation - Email Field

Objective:

Verify that the email field validates input correctly

Test Steps:
  1. Navigate to registration form
  2. Enter invalid email format (e.g., "invalid-email")
  3. Click submit or tab out of field
Expected Result:

Error message displayed: "Please enter a valid email address"

Test Data: Invalid: invalid-email, test@, @domain.com
Valid: user@example.com
TC-003 Medium

Search Functionality

Objective:

Verify search returns accurate results based on query

Test Steps:
  1. Navigate to search page
  2. Enter search query "automation"
  3. Click search button
  4. Verify results are displayed
Expected Result:

Relevant results displayed with query highlighted. Results are sorted by relevance.

Test Data: Query: "automation", "test", "" (empty)
TC-004 High

Payment Gateway Integration

Objective:

Verify successful payment processing and order confirmation

Preconditions:
  • User has items in cart
  • User is logged in
  • Payment gateway is configured
Test Steps:
  1. Proceed to checkout
  2. Enter valid payment details
  3. Click "Pay Now"
  4. Verify payment processing
Expected Result:

Payment processed successfully, order confirmation displayed, email sent

TC-005 Medium

Responsive Design - Mobile View

Objective:

Verify application displays correctly on mobile devices

Test Steps:
  1. Open application on mobile device (viewport: 375x667)
  2. Navigate through main pages
  3. Verify text readability
  4. Check button sizes and touch targets
  5. Verify navigation menu works
Expected Result:

All elements are visible, accessible, and properly sized. No horizontal scrolling required.

TC-006 Low

File Upload Functionality

Objective:

Verify file upload accepts only allowed file types and sizes

Test Steps:
  1. Navigate to file upload section
  2. Attempt to upload invalid file type (e.g., .exe)
  3. Attempt to upload file exceeding size limit (e.g., 10MB when limit is 5MB)
  4. Upload valid file (e.g., .jpg, 2MB)
Expected Result:

Invalid files rejected with error message. Valid file uploads successfully with progress indicator.

Test Scenarios

Real-world test scenarios covering end-to-end user journeys

E-Commerce Purchase Flow

Scenario: Complete purchase journey from product discovery to order confirmation

  • Browse products and apply filters
  • Add items to cart with quantity selection
  • Apply discount codes and verify price calculations
  • Complete checkout process with multiple payment options
  • Verify order confirmation and email notifications
  • Track order status post-purchase
E-Commerce Payment Integration

User Registration & Authentication

Scenario: New user registration with email verification and account setup

  • Register with email and password validation
  • Verify email through confirmation link
  • Complete profile setup
  • Test password reset functionality
  • Verify session management and security
  • Test account lockout after failed attempts
Security Authentication User Management

Dashboard Analytics & Reporting

Scenario: Generate and export reports with data visualization

  • Access dashboard with various metrics
  • Apply date range filters
  • View different chart types (bar, line, pie)
  • Export reports in multiple formats (PDF, CSV, Excel)
  • Verify data accuracy and real-time updates
  • Test with large datasets and performance
Analytics Reporting Performance

Cross-Browser & Device Compatibility

Scenario: Ensure consistent functionality across browsers and devices

  • Test on Chrome, Firefox, Safari, Edge
  • Verify responsive design on mobile, tablet, desktop
  • Check touch interactions on mobile devices
  • Verify browser-specific features compatibility
  • Test on different screen resolutions
  • Verify performance across devices
Cross-Browser Responsive Compatibility

API Integration & Data Synchronization

Scenario: Verify API endpoints and data consistency

  • Test GET, POST, PUT, DELETE endpoints
  • Verify request/response payloads
  • Test error handling and status codes
  • Verify data synchronization between systems
  • Test rate limiting and authentication
  • Verify API documentation accuracy
API Testing Integration Backend

Configuration & Settings Management

Scenario: User settings and application configuration

  • Update user profile information
  • Modify notification preferences
  • Change password and security settings
  • Configure application preferences
  • Verify settings persistence across sessions
  • Test role-based access to settings
Settings Configuration User Preferences

Tips & Tricks

Professional QA insights, best practices, and productivity tips

Automation

Page Object Model Best Practices

  • Separate concerns: Keep page objects focused on UI elements, not business logic
  • Reusable methods: Create generic methods like `clickButton()` and `fillInput()`
  • Wait strategies: Always use explicit waits instead of hardcoded sleeps
  • Naming conventions: Use clear, descriptive names for locators and methods
  • Maintainability: Update locators in one place when UI changes
Testing Strategy

Effective Test Case Design

  • Test pyramid: More unit tests, fewer integration tests, minimal E2E tests
  • Clear objectives: Each test case should have one clear purpose
  • Data independence: Tests should not depend on execution order
  • Positive & negative: Cover both happy paths and error scenarios
  • Boundary testing: Test edge cases and boundary conditions
Debugging

Debugging Automation Scripts

  • Screenshots: Capture screenshots on test failures automatically
  • Logging: Implement comprehensive logging at different levels
  • Video recording: Record test execution for complex failures
  • Breakpoints: Use debug mode in IDE to step through code
  • Isolate issues: Run tests individually to identify failures quickly
Performance

Optimizing Test Execution

  • Parallel execution: Run tests in parallel to reduce execution time
  • Test data management: Use factories or builders for test data
  • Selective testing: Tag tests and run only relevant suites
  • Headless mode: Use headless browsers for faster execution
  • Cache management: Clear cookies and cache when needed
CI/CD

CI/CD Integration Tips

  • Environment variables: Store sensitive data in CI/CD secrets
  • Retry mechanism: Implement retry logic for flaky tests
  • Test reporting: Generate HTML/JSON reports for better visibility
  • Notifications: Set up alerts for test failures
  • Parallel pipelines: Run different test suites in parallel stages
API Testing

API Testing Best Practices

  • Status codes: Always verify HTTP status codes
  • Response validation: Validate response structure and data types
  • Error handling: Test error responses (400, 401, 404, 500)
  • Authentication: Test various auth methods (Bearer, Basic, API keys)
  • Data validation: Verify response data matches expected values
Locator Strategy

Robust Element Locators

  • Priority order: ID > Name > CSS > XPath
  • Stable locators: Avoid using indexes or dynamic text
  • Data attributes: Use data-testid for reliable selectors
  • Relative XPath: Prefer relative over absolute XPath
  • Multiple strategies: Have fallback locators ready
Maintenance

Test Maintenance Strategies

  • Regular reviews: Review and update tests quarterly
  • Remove obsolete tests: Delete tests for deprecated features
  • Refactor flaky tests: Identify and fix unstable tests
  • Documentation: Keep test documentation updated
  • Code quality: Apply same standards as production code

Important Scripts

Reusable automation scripts and code snippets

Playwright - Page Object Model Setup

// BasePage.js
export class BasePage {
    constructor(page) {
        this.page = page;
    }

    async navigateTo(url) {
        await this.page.goto(url);
        await this.page.waitForLoadState('networkidle');
    }

    async clickElement(selector) {
        await this.page.waitForSelector(selector, { state: 'visible' });
        await this.page.click(selector);
    }

    async fillInput(selector, text) {
        await this.page.waitForSelector(selector);
        await this.page.fill(selector, text);
    }

    async getText(selector) {
        await this.page.waitForSelector(selector);
        return await this.page.textContent(selector);
    }

    async takeScreenshot(name) {
        await this.page.screenshot({ 
            path: `screenshots/${name}.png`,
            fullPage: true 
        });
    }
}

// LoginPage.js
import { BasePage } from './BasePage';

export class LoginPage extends BasePage {
    constructor(page) {
        super(page);
        this.usernameInput = '#username';
        this.passwordInput = '#password';
        this.loginButton = 'button[type="submit"]';
        this.errorMessage = '.error-message';
    }

    async login(username, password) {
        await this.fillInput(this.usernameInput, username);
        await this.fillInput(this.passwordInput, password);
        await this.clickElement(this.loginButton);
    }

    async getErrorMessage() {
        return await this.getText(this.errorMessage);
    }
}

Cypress - Custom Commands

// cypress/support/commands.js

// Custom command for login
Cypress.Commands.add('login', (username, password) => {
    cy.visit('/login');
    cy.get('[data-testid="username"]').type(username);
    cy.get('[data-testid="password"]').type(password);
    cy.get('[data-testid="login-button"]').click();
    cy.url().should('include', '/dashboard');
});

// Custom command for API calls
Cypress.Commands.add('apiRequest', (method, endpoint, body) => {
    return cy.request({
        method: method,
        url: `${Cypress.env('apiUrl')}${endpoint}`,
        headers: {
            'Authorization': `Bearer ${Cypress.env('token')}`,
            'Content-Type': 'application/json'
        },
        body: body
    });
});

// Custom command for waiting and retrying
Cypress.Commands.add('retryUntil', (selector, options = {}) => {
    const { timeout = 10000, interval = 500 } = options;
    cy.get(selector, { timeout }).should('be.visible');
});

// Usage in tests
cy.login('user@example.com', 'password123');
cy.apiRequest('GET', '/users', {}).then((response) => {
    expect(response.status).to.eq(200);
});

API Testing with Playwright

// api-helper.js
export class APIHelper {
    constructor(request) {
        this.request = request;
        this.baseURL = process.env.API_BASE_URL;
        this.token = process.env.API_TOKEN;
    }

    async get(endpoint, headers = {}) {
        const response = await this.request.get(`${this.baseURL}${endpoint}`, {
            headers: {
                'Authorization': `Bearer ${this.token}`,
                'Content-Type': 'application/json',
                ...headers
            }
        });
        return response;
    }

    async post(endpoint, body, headers = {}) {
        const response = await this.request.post(`${this.baseURL}${endpoint}`, {
            headers: {
                'Authorization': `Bearer ${this.token}`,
                'Content-Type': 'application/json',
                ...headers
            },
            data: body
        });
        return response;
    }

    async validateResponse(response, expectedStatus = 200) {
        expect(response.status()).toBe(expectedStatus);
        expect(response.ok()).toBeTruthy();
        return await response.json();
    }
}

// Usage in tests
import { test, expect } from '@playwright/test';
import { APIHelper } from './api-helper';

test('API Test - Get User', async ({ request }) => {
    const api = new APIHelper(request);
    const response = await api.get('/users/123');
    const data = await api.validateResponse(response, 200);
    expect(data.id).toBe(123);
    expect(data.email).toBeDefined();
});

Test Data Management

// test-data-generator.js
export class TestDataGenerator {
    static generateEmail() {
        const timestamp = Date.now();
        return `testuser${timestamp}@example.com`;
    }

    static generateRandomString(length = 10) {
        const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
        let result = '';
        for (let i = 0; i < length; i++) {
            result += chars.charAt(Math.floor(Math.random() * chars.length));
        }
        return result;
    }

    static generateRandomNumber(min = 1, max = 100) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    }

    static generateUserData() {
        return {
            firstName: `Test${this.generateRandomString(5)}`,
            lastName: `User${this.generateRandomString(5)}`,
            email: this.generateEmail(),
            phone: `+1${this.generateRandomNumber(2000000000, 9999999999)}`,
            password: 'Test@123456'
        };
    }

    static getTestDataFromFile(fileName) {
        const fs = require('fs');
        const path = require('path');
        const filePath = path.join(__dirname, 'test-data', fileName);
        return JSON.parse(fs.readFileSync(filePath, 'utf8'));
    }
}

// Usage
const userData = TestDataGenerator.generateUserData();
const testUsers = TestDataGenerator.getTestDataFromFile('users.json');

Wait Strategies & Synchronization

// wait-helper.js
export class WaitHelper {
    constructor(page) {
        this.page = page;
    }

    async waitForElement(selector, options = {}) {
        const { timeout = 30000, state = 'visible' } = options;
        try {
            await this.page.waitForSelector(selector, { 
                state, 
                timeout 
            });
            return true;
        } catch (error) {
            console.error(`Element ${selector} not found within ${timeout}ms`);
            return false;
        }
    }

    async waitForNetworkIdle() {
        await this.page.waitForLoadState('networkidle');
    }

    async waitForAPIResponse(url, timeout = 30000) {
        const response = await this.page.waitForResponse(
            response => response.url().includes(url) && response.status() === 200,
            { timeout }
        );
        return response;
    }

    async waitForElementToBeEnabled(selector) {
        await this.page.waitForFunction(
            selector => {
                const element = document.querySelector(selector);
                return element && !element.disabled;
            },
            selector
        );
    }

    async retryUntil(condition, maxRetries = 5, delay = 1000) {
        for (let i = 0; i < maxRetries; i++) {
            try {
                if (await condition()) {
                    return true;
                }
            } catch (error) {
                if (i === maxRetries - 1) throw error;
            }
            await this.page.waitForTimeout(delay);
        }
        return false;
    }
}

// Usage
const waitHelper = new WaitHelper(page);
await waitHelper.waitForElement('#submit-button');
await waitHelper.waitForAPIResponse('/api/users');
await waitHelper.retryUntil(async () => {
    return await page.textContent('.status') === 'Complete';
});

Screenshot & Reporting Utilities

// screenshot-helper.js
import fs from 'fs';
import path from 'path';

export class ScreenshotHelper {
    constructor(page) {
        this.page = page;
        this.screenshotDir = path.join(process.cwd(), 'screenshots');
        this.ensureDirectoryExists();
    }

    ensureDirectoryExists() {
        if (!fs.existsSync(this.screenshotDir)) {
            fs.mkdirSync(this.screenshotDir, { recursive: true });
        }
    }

    async takeScreenshot(name, options = {}) {
        const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
        const fileName = `${name}-${timestamp}.png`;
        const filePath = path.join(this.screenshotDir, fileName);
        
        await this.page.screenshot({
            path: filePath,
            fullPage: options.fullPage || false
        });
        
        return filePath;
    }

    async takeScreenshotOnFailure(testName) {
        const screenshotPath = await this.takeScreenshot(
            `failure-${testName}`,
            { fullPage: true }
        );
        console.log(`Screenshot saved: ${screenshotPath}`);
    }
}

// reporter-helper.js
export class ReporterHelper {
    static generateHTMLReport(testResults) {
        let html = `
            
            
            
                Test Report
                
            
            
                

Test Execution Report

`; testResults.forEach(result => { html += ` `; }); html += `
Test Name Status Duration Screenshot
${result.name} ${result.status} ${result.duration}ms ${result.screenshot ? `View` : 'N/A'}
`; return html; } }