Tips for Writing Effective AI Prompts
Overview
The quality of an AI-generated test depends heavily on the quality of the prompt behind it. Whether you're generating a full draft test or writing a self-healing snippet, the same principles apply: write for intent, be specific about what matters, and give the agents enough context to make good decisions without over-constraining it.
Write for intent, not for UI specifics
The most important habit when writing AI prompts is to describe what the user is trying to accomplish, not the exact buttons they need to click. Rainforest's AI is good at navigating common UI patterns on its own. What it needs from you is the goal.
This matters especially for self-healing snippets. When a test fails and Rainforest falls back to your original prompt to regenerate the steps, that prompt needs to accurately reflect your intent. If your prompt is too tightly coupled to the current UI, a minor layout change can prevent self-healing from working even when the underlying flow is unchanged.
Less reliable: "Click the blue Create Account button and check the terms of service checkbox" More reliable: "Create an account using dummy data"
The first prompt will fail to self-heal if the button color changes or the terms checkbox is removed. The second will adapt to those changes automatically.
Be specific about what matters
High-level prompts work, but they require more trial and error. The more context you give the AI about your app and the specific flow you're testing, the more likely it is to generate the right steps on the first try.
Breaking a long flow into shorter prompts is often more reliable than writing one long prompt for an entire workflow.
Less reliable: "Buy a product" More reliable: Three separate prompts covering "select a product", "add it to the cart and proceed to checkout", and "complete the form and place the order"
Use test data variables in prompts
You can reference test data directly in your prompts using double curly brackets. Rather than hardcoding values into a prompt, reference variables so the AI generates steps that use your actual test data.
Example: "Fill the form using {{logins.firstname}} and {{logins.email}}"
If you want the AI to generate its own dummy values rather than referencing specific data, you can simply say "fill the form using dummy data" and it will handle that on its own.
Use site rules for context that applies to every test
If you find yourself writing the same background information into every prompt, add it to your site rules instead. Site rules let you give the AI standing context about your app so you don't have to repeat it in each individual prompt.
Good candidates for site rules include: the purpose of your app, the typical user role for testing, any app-specific terminology the AI should understand, and known quirks in your UI that the AI would otherwise need to discover on its own.
Avoid language that introduces unpredictability
Prompts that reference dynamic or variable content, like "any product" or "one of the options", will produce tests that are slower and more prone to flakiness. If the state of your app changes between runs, the AI has to work harder to self-heal, and no AI gets it right 100% of the time.
Where possible, write prompts that point to specific, stable elements. If the content really is dynamic, consider using conditional blocks or masking rather than relying on AI to handle the unpredictability.
Flaky: "Add any product to the cart" More stable: "Search for 'blue hoodie' and add it to the cart" or use a manual step with masking to select the first product in a list regardless of what it is.
Be careful with too much detail
Over-specifying a prompt introduces a different kind of failure. If you instruct the AI to "click the Create New User button" and that button doesn't exist or has been renamed, the AI will get stuck trying to find it rather than accomplishing the underlying goal.
Write at the level of detail that reflects what you actually care about testing. If the label on a button is not what's being tested, don't put it in the prompt.
Updated 5 days ago
