This tool supports:
- ✅ OpenAI (cloud-based, high quality)
- ✅ Ollama (local, free & unlimited)
- Generate Selenium WebDriver scripts using Java + TestNG
- Follows Page Object Model (POM)
- Generates:
- Page Object classes
- Test class
- testng.xml
- Config-driven architecture (switch models easily)
- Supports both cloud and local LLMs
- Beginner-friendly and extensible
.
├── config.py
├── tools.py
├── main.py
├── requirements.txt
├── .env
├── test_cases/
│ ├── input/
│ │ └── sample_test_case.txt
│ └── output/
- Python 3.14+
- pip
- Any one of these:
- OpenAI API Key
- Ollama installed locally
git clone git@github.com:mfaisalkhatri/selenium-ai-test-generator.git
cd selenium-ai-test-generator
python -m venv venv
Activate it:
Mac/Linux
source venv/bin/activate
Windows
venv\Scripts\activate
pip install -r requirements.txt
Create a .env file:
OPENAI_API_KEY=your_api_key_here
⚠️ Do not commit.envto GitHub
Edit the file:
test_cases/input/sample_test_case.txt
Title: Application Login scenario
Precondition: User is registered in the application.
Steps:
1. Open Chrome browser
2. Navigate to https://ecommerce-playground.lambdatest.io/index.php?route=account/login
3. Enter "Johndoe881@email.com" in the E-Mail Address field
4. Enter "Password@321" in the Password field
5. Click on the Login Button
5. Add an assert statement to check that "My Account" page is displayed.
Update config.py to choose your provider:
provider = "openai"provider = "ollama"Download from: https://ollama.com
ollama serveollama pull deepseek-coderollama run llama3python main.pyGenerated Selenium WebDriver test automation scripts are stored in a newly created folder named using the current date and time, located at:
test_cases/output/
- Switch to Ollama:
provider = "ollama"- Ensure Ollama is running:
ollama serve
pip install -r requirements.txt
- When using OpenAI, Keep temperature low (0.2–0.3) for stable outputs
- Use Ollama for unlimited local test script generation
- Use OpenAI for higher quality scripts
- Never commit
.envorvenv
- Discuss your queries by writing to me @
mohammadfaisalkhatri@gmail.comOR ping me on any of the social media sites using the below link: