Develop Browser Agents: Integrating LLMs,Playwright,Browser-Use and Web-UI

KailashPathak
7 min readFeb 5, 2025

--

Browser Use is a tool or platform designed to enable AI agents (such as OpenAI’s GPT models or other large language models) to interact with and control web browsers in an intelligent and automated way. It essentially bridges the gap between AI capabilities and real-world browser interactions, making it possible for AI systems to perform tasks like navigating websites, extracting data, filling out forms, clicking buttons, and more — just as a human user would.

The primary goal of Browser Use is to make websites accessible and actionable for AI agents by abstracting away the complexities of browser automation. Instead of requiring developers to write intricate scripts to locate and interact with webpage elements, Browser Use simplifies this process by extracting all interactive elements (like buttons, input fields, links, etc.) and providing a structured interface for AI agents to interact with.

Key Characteristics of Browser Use

AI-Driven Automation :

  • Browser Use leverages AI to understand and interact with web pages. For example, it can analyze the content of a webpage, identify relevant actions (like clicking a button or filling out a form), and execute those actions autonomously.

Vision + HTML Extraction :

  • It combines visual understanding (recognizing elements on the screen) with HTML structure extraction (parsing the underlying code of a webpage). This dual approach ensures that AI agents can interact with both static and dynamic web elements, even if they don’t have clear identifiers like IDs or classes.

Multi-tab Management :

  • Browser Use can handle multiple browser tabs simultaneously, allowing AI agents to perform complex workflows that involve interacting with several web pages at once.

Element Tracking :

  • The tool tracks the exact actions performed by the AI agent (e.g., clicking a button or filling out a form) and can replicate those actions consistently, even if the website layout changes slightly. This is particularly useful for creating self-healing tests in QA automation.

Custom Actions :

  • Users can extend Browser Use by adding custom actions, such as saving data to files, performing database operations, sending notifications, or handling human input during specific steps in the automation process.

Self-Correcting :

  • Browser Use includes intelligent error handling and automatic recovery mechanisms. If something goes wrong during automation (e.g., a missing element or a network timeout), the tool can detect the issue and attempt to recover automatically, ensuring that workflows continue without interruption.

Compatibility with Multiple LLMs :

  • Browser Use supports various large language models (LLMs), including OpenAI’s GPT-4, Anthropic’s Claude, and Meta’s Llama 2. This flexibility allows users to choose the best AI model for their specific needs.

How Browser Use Works

Extracting Interactive Elements :

  • Browser Use scans a webpage and extracts all interactive elements (buttons, input fields, links, forms, etc.). It then provides a structured representation of these elements that AI agents can understand and interact with.

AI Interaction :

  • Once the interactive elements are identified, AI agents can perform actions like clicking buttons, filling out forms, navigating between pages, or extracting data. The AI agent can also analyze the content of the webpage and make decisions based on the information it finds.

Automation Workflows :

  • Browser Use allows users to create complex automation workflows. For example, an AI agent could navigate through an e-commerce site, add items to a shopping cart, and complete a purchase — all without human intervention.

Error Handling and Recovery :

  • If something goes wrong during the automation process (e.g., a missing element or a slow-loading page), Browser Use can detect the issue and attempt to recover automatically. This ensures that workflows continue smoothly, even in unpredictable environments.

Installation Guide for Browser Use

Getting started with Browser Use is straightforward, but it requires some initial setup to ensure everything runs smoothly. Below is a detailed installation guide based on the prerequisites and steps you’ve provided. This guide will walk you through setting up Browser Use locally on your machine.

Prerequisites

Before you begin, ensure that your system meets the following requirements:

Python 3.11 or higher :

  • You can check your Python version by running the command
python --version

Git : Git is required to clone the repository

Local Installation

Step 1: Clone the Repository

git clone https://github.com/browser-use/web-ui.git
cd web-ui

Step 2: Set Up Python Environment

We recommend using uv for managing the Python environment.

Using uv (Recommended) For mac

curl -LsSf https://astral.sh/uv/install.sh | sh

Create a Virtual Environment :

Run the following command to create a virtual environment with Python 3.11: bash

uv venv -- python 3.11

Activate the Virtual Environment :

  • Windows (Command Prompt) :
.venv\Scripts\activate
  • macOS/Linux :
source .venv/bin/activate

Once activated, you should see (.venv) in your terminal prompt, indicating that the virtual environment is active.

Step 3: Install Dependencies

Now that your environment is set up, it’s time to install the necessary dependencies.

Install Python Packages : Use the following command to install the required Python packages listed in requirements.txt:

uv pip install -r requirements.txt

Step 4: Install Playwright

Playwright is a browser automation library used by Browser Use.

To install it, run the command

playwright install

Local Setup Guide for Browser Use WebUI

Once you’ve completed the installation steps for Browser Use , you can start running the WebUI locally. This guide will walk you through launching the application, customizing its settings, and configuring it to use your own browser if needed.

Running the WebUI

After completing the installation steps, you can start the Browser Use WebUI by running the following command:

python webui.py --ip 127.0.0.1 --port 7788

The WebUI provides several options to customize its behavior. Here’s a breakdown of the available flags:

  • --ip: The IP address to bind the WebUI to.
  • Default : 127.0.0.1 (localhost)
  • --port: The port to bind the WebUI to.
  • Default : 7788
  • --theme: The theme for the user interface.

Accessing the WebUI

Once the WebUI is running, open your web browser and navigate to:

http://127.0.0.1:7788

Once the above command is executed , You should see the Browser Use interface, where you can interact with the tool and configure AI-driven browser automation tasks.

LLM Configuration

In LLM configuration select language model e.g gemini gemini provide the free API key.

Generate the API keys from the link attached below.

In the below screenshot you can see we have added the API keys which we generated with above link.

Run Agent

In Run agent lets give the prompt “go to amazon.in and type ‘Playwright’ click search and give me the first url”

Prompt 
"go to amazon.in and type 'Playwright' click search and give me the first url"

In the below screenshot you can see when as we run the prompt it will open the chromium browser and Interacting with the whole DOM of the page.

Finally it will enter the value Playwright in the search box and you can see in below screenshot.

In the below screenshot you can see it give us the FIRST url

In the backend you can see all the logs are executed, whatever agent performing its log all logs in the backend.

Result

In the result tab you can see the final result , Model action ,Model Thoughts, Trace file and Agent History.

Video

We can download the video by clicking on the link provided or Under the recording tab you can see the attached video.

In the VIDEO You can see all steps that Agent has performed.

Below are some screenshots

Conclusion

The integration of Large Language Models (LLMs) , Playwright , Browser-Use , and Web-UI represents a groundbreaking leap in the world of browser automation and AI-driven workflows.

By combining these powerful tools, you can create intelligent browser agents capable of performing complex tasks with minimal human intervention. From automating repetitive processes to enabling dynamic QA testing and real-time decision-making, the possibilities are both vast and transformative.

Reference

https://browser-use.com/

--

--

KailashPathak
KailashPathak

Written by KailashPathak

Author of book "Web Automation Testing Using Playwright", is a certified PMI-ACP®, ITIL®, PRINCE2 Practitioner®, ISTQB, professional.

Responses (2)