Automation Testing Prompts

This section provides prompts designed to help you create effective automated test scripts and frameworks using AI. These prompts ensure maintainable and reliable test automation.

Basic Automation Test Generation

Important Notes

Some important notes that can help with is to iterate your prompts, meaning that you take a bigger task and break it down into smaller ones. So instead of ask chatGPT to build a whole automation stack with one prompt, better to focus on one part of the automation and edit manually when needed. This process I find yields the best results.

Basic Automation Test Generation

Prompt Template

Generate automated test scripts for:
[Feature/System]: [Brief description]

Technology Stack:
- Framework: [Name]
- Language: [Name]
- Tools: [List]

Test Requirements:
1. [Requirement 1]
2. [Requirement 2]
...

Please include:
- Test Structure
- Page Objects
- Test Data
- Assertions
- Error Handling

Example Usage

Generate automated test scripts for:
User Authentication: Login and registration flows

Technology Stack:
- Framework: Selenium WebDriver
- Language: Python
- Tools: pytest, Page Object Model

Test Requirements:
1. Login with valid credentials
2. Login with invalid credentials
3. Password reset flow
4. Registration process
5. Session management

Please include:
- Test Structure
- Page Objects
- Test Data
- Assertions
- Error Handling

Advanced Automation Testing

Framework Setup

Generate automation framework setup for:
[Project Name]: [Description]

Components:
1. Test Runner
2. Page Objects
3. Utilities
4. Reporting
5. CI/CD Integration

Include:
- Project Structure
- Dependencies
- Configuration
- Helper Functions
- Reporting Setup

API Automation

Generate API automation scripts for:
[API Service]: [Description]

Coverage Areas:
1. Endpoint Testing
2. Request/Response Validation
3. Authentication
4. Error Handling
5. Performance Checks

Include:
- Test Cases
- Request Templates
- Response Validation
- Error Scenarios
- Integration Tests

Best Practices

When using these prompts:
  1. Follow Design Patterns
    • Page Object Model
    • Factory Pattern
    • Builder Pattern
    • Strategy Pattern
  2. Maintain Code Quality
    • Clean code principles
    • Code organization
    • Documentation
    • Version control
  3. Handle Test Data
    • Data management
    • Test data generation
    • Data cleanup
    • Data isolation
  4. Implement Reporting
    • Test results
    • Screenshots
    • Logs
    • Metrics

Tips for Better Results

  1. Start with Framework
    • Choose appropriate tools
    • Set up project structure
    • Configure dependencies
    • Implement base classes
  2. Organize Tests
    • Logical grouping
    • Clear naming
    • Proper structure
    • Easy maintenance
  3. Handle Dependencies
    • External services
    • Database
    • File system
    • Network
  4. Implement CI/CD
    • Automated builds
    • Test execution
    • Reporting
    • Notifications

Common Pitfalls to Avoid

  1. Poor Framework Design
    • ❌ “Write test scripts”
    • ✅ “Implement Page Object Model with reusable components and proper abstraction”
  2. Missing Error Handling
    • ❌ “Basic test cases”
    • ✅ “Comprehensive test cases with proper error handling and recovery mechanisms”
  3. Inadequate Reporting
    • ❌ “Run tests”
    • ✅ “Run tests with detailed reporting, screenshots, and performance metrics”
  4. Poor Maintenance
    • ❌ “Fix when broken”
    • ✅ “Regular code reviews, updates, and refactoring to maintain code quality”

Example Output Structure

Automation Framework: User Authentication
Version: 1.0
Date: [Current Date]

1. Project Structure

   - Test Runner
   - Page Objects
   - Utilities
   - Reports
   - Config

2. Test Cases

   - Login Tests
   - Registration Tests
   - Password Reset Tests
   - Session Tests

3. Page Objects

   - Login Page
   - Registration Page
   - Dashboard Page
   - Profile Page

4. Test Data

   - Test Users
   - Test Credentials
   - Test Scenarios
   - Data Management

5. Reporting

   - Test Results
   - Screenshots
   - Logs
   - Metrics

6. CI/CD Integration
   - Build Pipeline
   - Test Execution
   - Reporting
   - Notifications

Resources