To set up the environment for this project, please follow the steps below:
- Python Version: Ensure that your Python version is 3.9. You can check your Python version by running the following command in your terminal:
python --version. - Install Dependencies: Use the
pippackage manager to install the necessary dependencies listed in therequirements.txtfile. Run the following command in your project directory:pip install -r requirements.txt. - OpenAI API Key: This project requires a valid OpenAI API key to access models with vision capabilities. You need to set the API key as a system environment variable named
OPENAI_API_KEY. - ADB Installation: The system requires the Android Debug Bridge (ADB) tool to control Android devices via ADB commands. You can verify that ADB is correctly installed by running the following command:
adb --version.
The project's codebase is organized into the following directories and key files:
- prompt folder: This directory contains modules responsible for constructing prompts used for interactions with large language models. It includes predefined templates and functions for generating prompts dynamically.
- roles folder: This directory contains implementations of various agents involved in the project. Each agent has a specific role and functionality within the system, facilitating the orchestration and execution of tasks.
- uied folder: Built upon the project UIED, this directory focuses on extracting GUI widgets using traditional computer vision algorithms and OCR models. The extracted widgets are used to support the operations of the Observer agent.
- core.py: This is the main file responsible for executing the core process of scenario-based automated GUI testing. It coordinates the different agents, orchestrating their actions to perform the necessary tests and interactions.
- device.py: This file handles the control and management of the devices under test. It includes functions to interact with the devices, send commands, and receive responses.
- llm.py: This file is responsible for interfacing with large language model services. It includes functions for making requests to the models and handling the responses, enabling the project to leverage the capabilities of LLMs.
- memory.py: This file implements the context memory required by the agents. It manages the storage and retrieval of information, allowing agents to maintain and utilize context across different interactions and sessions.
- config.py: This file handles the configuration settings of the project. It reads and manages configuration information, ensuring that all components have access to the necessary parameters and settings.
To configure and run the project, please follow these steps: (Suppose the project root directory is /scengen)
-
Set Configuration Variables:
-
self.ROOT_INPUTandself.ROOT_OUTPUTintestbot/uied/CONFIG.py(recommended setting:/scengen/data/inputand/scengen/data/output) -
self.output_rootintestbot/uied/detect.py(recommended setting:/scengen/data/output) -
self.model_folderintestbot/uied/detect_text/ocr.py(recommended setting:/scengen/testbot/uied/detect_text/inference/)
-
-
Add Configuration Information:
Add the configuration information for the apps and the test scenarios in
testbot/conf.json. Ensure that the relevant apps are installed on the device under test.Here is an example configuration:
{ "apps": [ { "id": "A1", "name": "QQ Mail", "package": "com.tencent.androidqqmail", "launch-activity": "com.tencent.qqmail.launcher.desktop.LauncherActivity", }, { "id": "A2", "name": "FairEmail", "package": "eu.faircode.email", "launch-activity": ".ActivityMain", } ], "scenarios": [ { "id": "S1", "name": "send email", "description": "send an email to friend", "extra-info": { "friend's email": "example@example.com", "email subject": "example", "email content": "example" } }, { "id": "S4", "name": "take photo", "description": "take a photo", "extra-info": {} } ] }The
extra-infofield is optional and can be added based on the actual testing needs.More details can be found in our demo
conf.json. -
Run the Project
To execute the tests, run the
test.pyscript with the appropriate APP ID and SCENARIO ID:python test.py <APP-ID> <SCENARIO-ID>(Replace<APP-ID>and<SCENARIO-ID>with the IDs you configured inconf.json)