English | 中文 A tool for generating test cases based on the current webpage and requirement documents.
- 📋 Test Case Generation: Automatically generate test cases based on the current page and requirement document content, solving the problem of poor quality test cases generated from a single requirement document.
- 🔐 Multiple Login Methods: Supports login with username/password and cookies.
- 📊 Excel Export: Supports exporting test cases to Excel format.
- 📝 Requirement Association: Automatically associates test cases with requirement documents.
- 🛠️ Customizable: Flexible configuration options to suit different project needs.
- 📄 Multiple Document Formats: Supports requirement documents in various formats including plain text, Markdown, and Word (DOCX).
- 🌐 Web Interface: Provides a beautiful and user-friendly web interface for easier use.
- Ensure Python 3.9 or higher is installed.
- Clone or download this repository.
- Install dependencies:
pip install -r requirements.txt
- Install Playwright:
playwright install
You can use the web interface for a more user-friendly experience:
# Start the web interface
python main.py --web
Then open your browser and navigate to http://localhost:5000
to access the interface.
Note: You can change the default port by setting the
APP_PORT
environment variable in your.env
file.
The image above shows the AITestCase web interface where you can configure test parameters such as URL, login method, and requirement documents in a simple and intuitive way.
The image above shows the result page after AITestCase generates test cases, where you can view test results and download the Excel file.
# Basic usage
python main.py --url <website URL>
# Login with username and password
python main.py --url <website URL> --username <username> --password <password>
# Login with cookies
python main.py --url <website URL> --cookies "<cookie string>"
# Use requirements documents (supports .txt, .md, .docx)
python main.py --url <website URL> --requirements "requirement1.docx,requirement2.md,requirement3.txt"
This tool supports multiple cookie formats:
- Key-Value Format (common in browser developer tools):
cookie1=value1; cookie2=value2; JSESSIONID=123456789; auth_token=abcdefg
# Login with key-value format cookies
python main.py --url https://example.com --cookies "session=abc123; token=xyz789"
python main.py --url https://example.com --username user --password pass
python main.py --url https://example.com --login-url https://example.com/login --username user --password pass --use-ai-login
This will use AI to automatically identify form elements on the login page, more accurately locating the login form than traditional methods.
View all available parameters:
python main.py --help
Configuration files are located in the config/
directory, where you can modify the following settings:
settings.py
: General settingsuser_agents.py
: User agent strings
Cookie strings can be in one of the following formats:
- Standard Key-Value:
cookieName=cookieValue; otherCookie=otherValue
GPL License
If you encounter cookie-related issues, try the following steps to troubleshoot:
-
Check Cookie Format: Ensure the cookie format is correct, preferably using the browser developer tools to export cookies
# Copy cookies in Chrome browser 1. Open Developer Tools (F12) 2. Switch to the Application/Network tab 3. Find the cookies or the cookie header in the request 4. Copy the complete cookie string
-
View Detailed Logs: Modify
config/settings.py
to set the log level to DEBUG# Set in config/settings.py LOG_LEVEL = "DEBUG" # Options: DEBUG, INFO, WARNING, ERROR
-
Try Other Login Methods: If cookie login continues to fail, try username/password login
python main.py --url https://example.com --username user --password pass
If you need to see the browser operation process, use the --show
parameter:
python main.py --url https://example.com --cookies "sessionid=abc123" --show true
This is particularly useful for debugging cookie and login issues, allowing you to observe the actual behavior and redirection of the browser.