Gemini Prompt to Create E2E Tests
End-to-end (E2E) tests are essential to guarantee an application's overall correct functioning, yet writing them is often time-consuming and repetitive. Gemini, Google's AI model, excels at generating structured code and can dramatically accelerate the creation of complete E2E test suites. By providing the technical context of your application — tech stack, critical user journeys, and the test framework used — Gemini can produce robust test scenarios covering both main flows and edge cases. Whether you use Playwright, Cypress, or Selenium, the AI adapts to your framework's conventions to generate directly usable code. The prompt engineering approach allows you to precisely specify the desired coverage level, the selector patterns to favor, and the test data management strategy. The result: maintainable, readable tests aligned with your team's best practices, produced in a fraction of the usual time.
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
You are a senior QA engineer specialized in end-to-end testing. I am working on a [APPLICATION_TYPE: web/mobile/desktop] application built with [TECH_STACK: e.g. React, Node.js, PostgreSQL].
E2E test framework used: [FRAMEWORK: Playwright/Cypress/Selenium]
Base URL: [URL]
Here is the user journey to test:
[DESCRIBE_THE_COMPLETE_FLOW_STEP_BY_STEP]
Generate a complete E2E test suite following these rules:
- Use resilient selectors (data-testid, ARIA roles) — never fragile CSS selectors
- Each test must be independent and idempotent
- Include test data setup and teardown
- Handle loading states and asynchronous waits explicitly
- Cover the happy path, error cases (invalid form, network timeout, 403/404), and edge cases
- Add comments explaining the business logic tested
- Use the Page Object Model pattern for reusability
- Include meaningful assertions at every key step
Structure your response as follows:
- Required Page Objects with their methods
- Configuration file and fixtures
- Test suite organized by feature
- Helper for seeding test data
Personalize this prompt with Léa
Answer 3 questions and Léa tailors the prompt to your situation.
Why this prompt works
This prompt works because it assigns a precise expert role to Gemini and provides all the technical context needed to generate code tailored to your environment. The numbered rules act as quality constraints that eliminate common anti-patterns (fragile selectors, coupled tests, implicit waits). The enforced output structure forces a result organized according to the Page Object Model pattern, directly integrable into a professional codebase.
Use Cases
Variants
Expected Output
You get a complete and structured E2E test suite: Page Objects encapsulating interactions with each page, fixtures for data seeding, and test files organized by feature covering the happy path and error cases. The generated code uses resilient selectors, properly handles asynchronous operations, and includes business comments to facilitate long-term maintenance.
Frequently Asked Questions
Which E2E testing framework does Gemini handle best?
Gemini produces excellent results with Playwright and Cypress, the two most documented frameworks in its training data. Playwright is recommended for projects requiring multi-browser support and native parallelization, while Cypress is better suited for frontend teams prioritizing developer experience. Always specify the framework and its version in your prompt to get up-to-date syntax and avoid deprecated APIs.
How can I ensure long-term maintainability of tests generated by Gemini?
Three key practices ensure maintainability: first, require the Page Object Model pattern in your prompt to encapsulate selectors and interactions per page. Second, enforce the use of data-testid selectors instead of style-dependent CSS selectors, which break with every visual refactoring. Third, ask Gemini to add comments explaining the business intent of each test, not just the technical action. Always review the generated code and adapt variable names and file structure to your team's conventions.
Can Gemini generate E2E tests from user stories or mockups?
Yes, Gemini can transform user stories into E2E test scenarios if you clearly articulate them in your prompt. Describe each story using the format 'As a [role], I want [action] so that [benefit]' followed by detailed acceptance criteria. For mockups, Gemini (in multimodal version) can analyze screenshots and infer the interactive elements to be tested. Combine both approaches—story + screenshot—to achieve the most comprehensive coverage.
Learn more
Check the full skill on Prompt Guide to master this technique from A to Z.
View on Prompt Guide📬 Get new prompts every week
Join our newsletter and never miss a prompt.
Similar Prompts
Generate Mocks and Fixtures for Your Automated Tests
A prompt to automatically generate realistic mocks, stubs and data fixtures adapted to your test framework and use cases.
Automatically Generate Unit Tests with AI
Automatically generate an exhaustive unit test suite covering nominal cases, edge cases, and error cases for any source code.
Create a Python Automation Script
Create a professional Python automation script with CLI configuration, structured logging, error handling, and tests.
Analyze and Optimize Algorithmic Complexity
Analyze the Big O complexity of your algorithms and optimize them with appropriate data structures and more efficient algorithms.