Before leveraging AI-powered test generation, this framework provides a comprehensive suite of Playwright demo tests—ranging from basic to advanced—using real-world scenarios on K11softwaresolutions.com.
What you'll learn:
- Playwright setup and configuration
- Writing your first E2E test
- Advanced selectors and assertions
- Component and API testing
- Context-aware flows with XState
- Data-driven and parameterized testing
- Robust error handling and reporting
Explore the tests/ directory for hands-on examples and best practices. These demos serve as a foundation for mastering Playwright before moving to AI-augmented automation.
This module enables AI-driven Playwright test generation using OpenAI's API and prompt templates.
- AI-powered Playwright test generation from prompt templates and config data
- CSV-driven test data, API endpoints, and DB config support
- Secure API key management via
.env
- Set up OpenAI API Key:
- Copy
.env.exampleto.envand add your OpenAI API key:OPENAI_API_KEY=your-openai-api-key-here
- Copy
- Install dependencies:
- Run:
npm install
- Run:
- Configure appConfig:
- Edit
config/appConfig.jsto set paths for test data, API endpoints, and DB config.
- Edit
- Edit prompt templates:
- Update or create prompt files in
prompts/(e.g.,playwright_login_test_generation.txt).
- Update or create prompt files in
- Run the generator:
- Execute:
node ai/generate_generic_tests_ai.js - The generated test will be saved to
tests/mab/AI_GeneratedTest.spec.js.
- Execute:
- Add new prompt templates for different test scenarios
- Update
ai/generate_generic_tests_ai.jsto use your desired prompt file - Extend demo tests in
tests/for new learning modules
.envis gitignored by default.- Never commit your API key.
- Ensure your OpenAI API key is valid and set in
.env. - If you see
Missing credentialserrors, check your.envsetup. - For OpenAI API errors, verify your network and API quota.
See prompts/playwright_login_test_generation.txt for a sample login test prompt.
MIT
Experimental Stage: This framework is currently in an experimental phase. Features and workflows may change, and reliability is not guaranteed for production use. Feedback and contributions are welcome!
- More advanced Playwright demo modules
- Support for Playwright API and DB test generation
- Multi-prompt scenario chaining
- Improved error handling and reporting
- Integration with CI/CD pipelines
- Customizable output file locations
- Enhanced prompt templating and variable injection
- Support for other AI providers (Azure, Anthropic, etc.)
- Automated test validation and coverage analysis