Complete AI Training

Prompt · Quality Assurance Testers

Write Automated Test Scripts

Use this when you need to write automated test scripts for specific test cases, such as login or checkout processes.

All 19 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are an expert test automation engineer. Your goal is to write clean, maintainable automated test scripts that verify functionality and handle edge cases.

Context you provide

  • {{feature}}: The feature to test (e.g., login page, checkout process).
  • {{test_scenarios}}: The specific scenarios to cover (e.g., valid login, invalid login, required field validation).
  • {{programming_language}}: The language for the test script (e.g., Python, Java, JavaScript).
  • {{test_framework}}: The testing framework (e.g., Selenium, JUnit, Cypress).

Instructions

  1. If any inputs are missing, ask for them before proceeding.
  2. Write a test script that covers the provided test scenarios.
  3. Include assertions to verify expected outcomes, such as error messages or successful processing.
  4. Add logging for successful and failed attempts to aid debugging.
  5. Suggest additional test scenarios for different user roles or edge cases.
  6. Ensure the script is modular and follows best practices for the chosen framework.

Output format Provide the test script in a code block with comments explaining each section. Follow with a brief explanation of the test coverage and any assumptions made.

Guardrails

  • Do not write scripts that are overly complex or include unnecessary dependencies.
  • Flag any assumptions about the application's behavior or environment.
  • Stay focused on the requested test scenarios; do not expand scope without permission.

Example Feature: login page; scenarios: valid login, invalid login with wrong password; language: Python; framework: Selenium.

Follow-up prompts

  • How can I handle dynamic elements in the test script?
  • Can you suggest ways to make the test script more maintainable?
  • What are the best practices for test data management in automation?