This project demonstrates how to use Playwright with Python to connect to an AgentStation Workstation and perform an automated web browsing sequence.
You can set up this project using the following steps:
- Python 3.8 or later
- pip
- An AgentStation API key
-
Create and Activate a Virtual Environment (optional but recommended)
- Create a virtual environment:
python -m venv venv
- Activate the virtual environment:
source venv/bin/activate # On Windows, use: venv\Scripts\activate
- Create a virtual environment:
-
Navigate to the Playwright Python Directory
- Open a terminal and navigate to the
playwright/python
directory.
- Open a terminal and navigate to the
-
Install Dependencies
- Run
pip install -r requirements.txt
to install the required dependencies.
- Run
-
Set Up Environment Variables
-
Set your AgentStation API key as an environment variable:
export AGENTSTATION_API_KEY=your_api_key
-
-
Run the project using the following command:
python main.py
-
The script will:
- Request a new workstation from the AgentStation API
- Wait for the workstation to initialize (10 seconds)
- Connect to the browser using Playwright
- Perform the following automated sequence:
- Navigate to Google
- Search for "agentstation.ai"
- Click the first search result
- Navigate to the AgentStation launch page
- Ask if you want to run another demo
- Clean up resources when finished
- Interactive demo that can be run multiple times
- Graceful error handling and resource cleanup
- Configurable timeouts and viewport settings
- Detailed console logging of each step
- Ability to monitor workstation status at app.agentstation.ai/workstations
Required environment variables:
AGENTSTATION_API_KEY
: Your AgentStation API key
This project is licensed under the MIT License.