AI-POWERED QUALITY ENGINEERING
Learn. Automate. Test Smarter.
Practical guides on Generative AI, AI agents, AI tools, Playwright, Selenium, API testing and modern software testing.

Prompt Engineering for QA Engineers: Practical Examples and Prompts

Arjya Garai | October 11, 2026 | 0 comments

Generative AI tools such as ChatGPT, Claude, and Gemini are becoming useful assistants for software testing. But the quality of their responses depends heavily on how we ask questions and provide context.




This is where prompt engineering becomes important. For QA engineers, prompt engineering means giving AI clear instructions, relevant requirements, testing scenarios, and an expected output format to get more useful results.

In this guide: Learn practical prompting techniques for test case generation, API testing, automation code generation, and debugging.

What Is Prompt Engineering?

Prompt engineering is the process of designing and improving instructions given to an AI model to achieve a desired result.

Basic prompt:

Generate test cases for login.

This prompt provides very little context.

Improved prompt:

You are assisting a QA engineer testing a web application's login feature. The username and password are mandatory. Generate positive, negative, boundary, and security-related test scenarios. Present the results in a table with Scenario, Test Data, and Expected Result.

The second prompt provides context, scope, and a clear output format, helping the AI generate more relevant suggestions.

1. Use a Clear Prompt Structure

A useful starting point for QA prompts is:

Role + Context + Requirement + Testing Scope + Expected Output
  • Role: Act as a software QA engineer.
  • Context: An e-commerce application.
  • Requirement: Customers can add products to their cart.
  • Testing scope: Positive, negative, boundary, and edge cases.
  • Expected output: A table containing scenarios and expected results.

You do not need to include every element in every prompt. Add the details that matter to the task.

2. Prompt for Test Case Generation

Suppose you receive a requirement for a subscription feature. Try the following prompt:

Example prompt

Act as an experienced QA engineer. Based on the requirement below, generate functional test scenarios for subscription creation. Include positive, negative, boundary, payment failure, duplicate submission, and error-handling scenarios. Provide the scenario, preconditions, test steps, test data, and expected result in a table.

Requirement: A customer can create a subscription using a valid payment method. The subscription should be created only after successful payment.

Possible scenarios include:

  • Create a subscription with valid customer details.
  • Attempt subscription creation with an invalid payment method.
  • Verify the behavior when payment fails.
  • Retry subscription creation after a failed payment.
  • Attempt to create a duplicate subscription.
  • Verify that a subscription is not created before successful payment.

Review all generated scenarios against the actual business rules before using them.

3. Prompt for API Testing

AI can help identify API testing scenarios before you start implementation.

Example prompt

Act as an API testing specialist. Review the API specification below and suggest scenarios for successful requests, missing fields, invalid data types, invalid authentication, unauthorized access, boundary values, error responses, and duplicate requests. Include expected HTTP status codes only when supported by the specification. Clearly identify assumptions.

Provide the relevant API specification or sanitized request and response examples. AI-generated status codes and expected responses must be verified against the actual API contract.

4. Prompt for Automation Code Generation

If you use Playwright, AI can help create a starting point for an automated test. Try this prompt:

Example prompt

Act as a Playwright test automation engineer using TypeScript. Write a test for the login feature using the requirements below. Use stable locators, meaningful assertions, and appropriate waiting strategies. Avoid fixed timeouts unless necessary. Explain assumptions and identify selectors that need to be verified against the application.

Include the login requirements and example HTML or accessible selectors when available.

Always execute and review the generated code. AI may invent selectors, misunderstand application behavior, or produce code that needs adjustments.

5. Prompt for Debugging Automation Failures

Instead of simply asking AI to fix an error, provide evidence and ask it to investigate the likely causes.

Example prompt

Help me investigate this Playwright test failure. Analyze the error message, relevant test code, and available logs. Identify the most likely causes, explain how to verify each cause, and suggest the smallest appropriate code change. Do not assume the application is defective without evidence.

Include the relevant error message, a sanitized code snippet, and useful logs. This encourages investigation rather than an unsupported code change.

6. Common Prompt Engineering Mistakes

  • Too little context: Important business rules are missing.
  • Vague instructions: The desired testing scope is unclear.
  • No output format: Results are difficult to review or reuse.
  • Unverified assumptions: AI fills gaps with potentially incorrect information.
  • Blindly accepting code: Generated automation may be unreliable.
  • Sharing confidential data: Sensitive credentials, customer information, and proprietary details should not be shared without appropriate authorization.

7. A Simple Way to Improve Your Prompts

  1. Start by asking AI to generate test scenarios.
  2. Add acceptance criteria and business rules.
  3. Specify positive, negative, boundary, and edge cases.
  4. Request a structured output.
  5. Ask AI to identify gaps and assumptions.
  6. Validate the final output against the actual requirements.

This iterative approach is often more useful than trying to write a perfect prompt on the first attempt.

Final Thoughts

Prompt engineering is a practical skill for modern QA engineers. It can help with test design, API testing, automation code generation, debugging, and documentation.

The key is to provide clear context, define the task, specify the expected output, and verify the result.

Better Prompts + QA Expertise + Proper Validation = More Useful AI Assistance

AI can accelerate your testing workflow, but the QA engineer remains responsible for understanding requirements, assessing risk, and deciding what should be tested.

Frequently Asked Questions

What is prompt engineering in software testing?

It is the practice of giving AI clear, contextual instructions to assist with testing activities such as test design, API testing, and automation.

Can prompt engineering improve test case generation?

Clear requirements, testing scope, and output formats can help AI produce more relevant test case suggestions. The results still require QA review.

Can I use AI to generate Playwright tests?

Yes. AI can generate a starting point for Playwright tests, but selectors, assertions, waiting strategies, and test behavior should be verified.

Should I share project requirements with AI tools?

Follow your organization's AI and data-security policies. Remove sensitive information and never share credentials or confidential customer data without explicit authorization.

Related Reading

Disclaimer: This article is for educational purposes. AI tools and their capabilities may change over time. Verify generated technical information and follow your organization's security and privacy policies.

Category: , , , , ,

0 comments