This project leverages Hugging Face SmolAgent to create and execute automated tests using Selenium, Pytest, and Playwright.
- Python 3.7 or higher
- Required libraries specified in
requirements.txt
-
Clone the repository
Clone the repository to your local machine:git clone https://github.com/nand1234/AI-Test-Automation-SmolAgent.git cd AI-Test-Automation-SmolAgent -
Create a Python virtual environment
python3 -m venv venv
-
Activate the virtual environment
- On Linux/Mac:
source ./venv/bin/activate - On Windows:
.\venv\Scripts\activate
- On Linux/Mac:
-
Install dependencies
Install the required libraries with:pip install -r requirements.txt
Run the API test agent using the following command:
python api-agent.pyExecute Selenium-based UI tests with:
python selenium-agent.pyRun Playwright-based tests with:
python playwright-agent.pyRun test case creatio with:
python testcase-agent.py
---
Run BDD test case execution:
python test-executor-agent.py
---
Run browser actions:
python browser_operator.py
---
-
Additional Authorized Imports
Theadditional_authorized_importsparameter enables the LLM model to interact with specified external libraries.
For example:additional_authorized_imports=["playwright", "asyncio"]
-
Installing External Libraries
Install any required external libraries with:pip install <library-name>
By default, the execution is done in your local environment. This should be safe because the only functions that can be called are the tools you provided (especially if it's only tools by Hugging Face) and a set of predefined safe functions like print or functions from the math module, so you're already limited in what can be executed.
The Python interpreter also doesn't allow imports by default outside of a safe list, so all the most obvious attacks shouldn't be an issue. You can authorize additional imports by passing the authorized modules as a list of strings in argument additional_authorized_imports upon initialization of your [CodeAgent]:
- The output of the test agents depends on the underlying LLM model used for execution.
- By default, Hugging Face uses the
HfApiModel()instance, which typically employs models like Qwen/Qwen2.5-Coder-32B-Instruct.