Convert Figma logo to code with AI

browser-use logobrowser-use

Make websites accessible for AI agents

49,081
5,112
49,081
422

Top Related Projects

2,765

A command line tool to help build, run, and test web extensions

Automated auditing, performance metrics, and best practices for the web.

90,111

JavaScript API for Chrome and Firefox

31,345

A browser automation framework and ecosystem.

47,669

Fast, easy and reliable testing for anything that runs in a browser.

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

Quick Overview

Browser-use is a JavaScript library that provides a simple way to detect and analyze browser usage patterns. It offers functions to identify the user's browser, operating system, and device type, as well as tracking user interactions and page load times.

Pros

  • Easy to integrate into existing web projects
  • Lightweight and minimal impact on page load times
  • Provides comprehensive browser and device information
  • Customizable tracking options for specific user interactions

Cons

  • Limited documentation and examples
  • May require additional configuration for complex use cases
  • Potential privacy concerns with user tracking
  • Not actively maintained (last update over a year ago)

Code Examples

Detecting the user's browser:

import { detectBrowser } from 'browser-use';

const browserInfo = detectBrowser();
console.log(`User is using ${browserInfo.name} version ${browserInfo.version}`);

Tracking page load time:

import { trackPageLoad } from 'browser-use';

trackPageLoad().then(loadTime => {
  console.log(`Page loaded in ${loadTime} milliseconds`);
});

Monitoring user interactions:

import { trackInteraction } from 'browser-use';

trackInteraction('click', '#submit-button', event => {
  console.log('User clicked the submit button');
});

Getting Started

To use browser-use in your project, follow these steps:

  1. Install the package using npm:

    npm install browser-use
    
  2. Import the desired functions in your JavaScript file:

    import { detectBrowser, trackPageLoad, trackInteraction } from 'browser-use';
    
  3. Use the functions as needed in your code:

    const browserInfo = detectBrowser();
    console.log(`Browser: ${browserInfo.name} ${browserInfo.version}`);
    
    trackPageLoad().then(loadTime => {
      console.log(`Page load time: ${loadTime}ms`);
    });
    
    trackInteraction('click', '.menu-item', event => {
      console.log('Menu item clicked:', event.target.textContent);
    });
    

Competitor Comparisons

2,765

A command line tool to help build, run, and test web extensions

Pros of web-ext

  • More comprehensive toolset for developing and managing browser extensions
  • Actively maintained by Mozilla with regular updates and improvements
  • Extensive documentation and community support

Cons of web-ext

  • Primarily focused on Firefox extensions, may have limited functionality for other browsers
  • Steeper learning curve for beginners due to its extensive feature set

Code comparison

web-ext:

import webExt from 'web-ext';

webExt.cmd.run({
  sourceDir: '/path/to/extension',
  firefox: '/path/to/firefox',
  start: '--devtools'
}, {
  shouldExitProgram: false,
});

browser-use:

const browserUse = require('browser-use');

browserUse.launch('firefox', {
  url: 'https://example.com',
  args: ['--private-window']
});

Summary

web-ext is a more robust tool specifically designed for browser extension development, offering a wide range of features and strong community support. It's particularly well-suited for Firefox extension developers but may be overkill for simple browser automation tasks.

browser-use, on the other hand, is a lightweight library focused on browser launching and basic automation. It's more versatile in terms of supporting multiple browsers but lacks the specialized extension development features of web-ext.

Choose web-ext for comprehensive extension development, especially for Firefox. Opt for browser-use if you need a simple, cross-browser solution for basic browser automation tasks.

Automated auditing, performance metrics, and best practices for the web.

Pros of Lighthouse

  • Comprehensive web performance auditing tool with a wide range of metrics
  • Actively maintained by Google with frequent updates and improvements
  • Extensive documentation and community support

Cons of Lighthouse

  • More complex setup and usage compared to browser-use
  • Heavier resource consumption due to its comprehensive nature
  • May require more technical expertise to interpret and act on results

Code Comparison

browser-use:

const browserUse = require('browser-use');
const usage = await browserUse.getUsage();
console.log(usage);

Lighthouse:

const lighthouse = require('lighthouse');
const options = {
  logLevel: 'info',
  output: 'json',
  onlyCategories: ['performance'],
};
const runnerResult = await lighthouse('https://example.com', options);
console.log(runnerResult.report);

Summary

Lighthouse is a powerful, feature-rich tool for web performance auditing, while browser-use focuses on simpler browser usage statistics. Lighthouse offers more comprehensive analysis but requires more setup and expertise. browser-use provides a straightforward way to gather basic browser usage data with minimal configuration. The choice between the two depends on the specific needs of the project and the level of detail required in the analysis.

90,111

JavaScript API for Chrome and Firefox

Pros of Puppeteer

  • More comprehensive and feature-rich API for browser automation
  • Stronger community support and regular updates
  • Better documentation and extensive examples

Cons of Puppeteer

  • Larger package size and potentially higher resource usage
  • Steeper learning curve for beginners
  • Limited to Chromium-based browsers by default

Code Comparison

Browser-use:

const browser = require('browser-use');

(async () => {
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await page.screenshot({ path: 'screenshot.png' });
})();

Puppeteer:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await page.screenshot({ path: 'screenshot.png' });
  await browser.close();
})();

Both libraries provide similar basic functionality for browser automation, but Puppeteer offers a more extensive API and better documentation. Browser-use aims to be a simpler alternative with a focus on ease of use, while Puppeteer provides more advanced features and broader browser control capabilities. The code comparison shows that Puppeteer requires an additional step to launch and close the browser, whereas Browser-use abstracts this process.

31,345

A browser automation framework and ecosystem.

Pros of Selenium

  • Widely adopted and mature framework with extensive documentation and community support
  • Supports multiple programming languages (Java, Python, C#, etc.)
  • Offers advanced features like grid for distributed testing and remote execution

Cons of Selenium

  • Steeper learning curve and more complex setup compared to browser-use
  • Can be slower for simple automation tasks due to its comprehensive nature
  • Requires separate WebDriver installations and management

Code Comparison

Selenium (Python):

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("https://example.com")
element = driver.find_element(By.ID, "example-id")
element.click()
driver.quit()

browser-use (JavaScript):

const { chromium } = require('browser-use');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await page.click('#example-id');
  await browser.close();
})();

Both examples demonstrate opening a browser, navigating to a website, clicking an element, and closing the browser. Selenium requires more setup and verbosity, while browser-use offers a more concise syntax for basic automation tasks.

47,669

Fast, easy and reliable testing for anything that runs in a browser.

Pros of Cypress

  • More comprehensive end-to-end testing framework with built-in assertions and commands
  • Extensive documentation and active community support
  • Real-time reloading and debugging capabilities

Cons of Cypress

  • Limited to testing web applications within a browser environment
  • Steeper learning curve for beginners due to its extensive feature set
  • Potential performance issues with large test suites

Code Comparison

Cypress example:

describe('Login Test', () => {
  it('should log in successfully', () => {
    cy.visit('/login')
    cy.get('#username').type('testuser')
    cy.get('#password').type('password123')
    cy.get('#submit').click()
    cy.url().should('include', '/dashboard')
  })
})

browser-use example:

const browser = require('browser-use')

async function loginTest() {
  await browser.goto('/login')
  await browser.type('#username', 'testuser')
  await browser.type('#password', 'password123')
  await browser.click('#submit')
  assert(await browser.url().includes('/dashboard'))
}

While both libraries allow for browser automation, Cypress provides a more feature-rich environment specifically tailored for testing. browser-use offers a simpler API for general browser automation tasks but lacks built-in testing capabilities. Cypress excels in test organization and reporting, while browser-use may be more suitable for lightweight automation scripts.

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

Pros of Playwright

  • Comprehensive cross-browser automation support (Chromium, Firefox, WebKit)
  • Robust API with advanced features like network interception and mobile emulation
  • Strong community support and regular updates from Microsoft

Cons of Playwright

  • Steeper learning curve due to more complex API and features
  • Larger package size and potentially higher resource usage
  • May be overkill for simple browser automation tasks

Code Comparison

Playwright:

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await browser.close();
})();

browser-use:

const browserUse = require('browser-use');

(async () => {
  const browser = await browserUse.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await browser.close();
})();

The code snippets show similar basic usage, but Playwright offers more advanced features and browser-specific imports.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Shows a black Browser Use Logo in light color mode and a white one in dark color mode.

Enable AI to control your browser 🤖

GitHub stars Discord Cloud Documentation Twitter Follow Twitter Follow Weave Badge

🌐 Browser-use is the easiest way to connect your AI agents with the browser.

💡 See what others are building and share your projects in our Discord! Want Swag? Check out our Merch store.

🌤️ Skip the setup - try our hosted version for instant browser automation! Try the cloud ☁︎.

Quick start

With pip (Python>=3.11):

pip install browser-use

Install Playwright:

playwright install chromium

Spin up your agent:

from langchain_openai import ChatOpenAI
from browser_use import Agent
import asyncio
from dotenv import load_dotenv
load_dotenv()

async def main():
    agent = Agent(
        task="Compare the price of gpt-4o and DeepSeek-V3",
        llm=ChatOpenAI(model="gpt-4o"),
    )
    await agent.run()

asyncio.run(main())

Add your API keys for the provider you want to use to your .env file.

OPENAI_API_KEY=
ANTHROPIC_API_KEY=
AZURE_ENDPOINT=
AZURE_OPENAI_API_KEY=
GEMINI_API_KEY=
DEEPSEEK_API_KEY=

For other settings, models, and more, check out the documentation 📕.

Test with UI

You can test browser-use with a UI repository

Or simply run the gradio example:

uv pip install gradio
python examples/ui/gradio_demo.py

Demos



Task: Add grocery items to cart, and checkout.

AI Did My Groceries



Prompt: Add my latest LinkedIn follower to my leads in Salesforce.

LinkedIn to Salesforce



Prompt: Read my CV & find ML jobs, save them to a file, and then start applying for them in new tabs, if you need help, ask me.'

https://github.com/user-attachments/assets/171fb4d6-0355-46f2-863e-edb04a828d04



Prompt: Write a letter in Google Docs to my Papa, thanking him for everything, and save the document as a PDF.

Letter to Papa



Prompt: Look up models with a license of cc-by-sa-4.0 and sort by most likes on Hugging face, save top 5 to file.

https://github.com/user-attachments/assets/de73ee39-432c-4b97-b4e8-939fd7f323b3



More examples

For more examples see the examples folder or join the Discord and show off your project.

Vision

Tell your computer what to do, and it gets it done.

Roadmap

Agent

  • Improve agent memory (summarize, compress, RAG, etc.)
  • Enhance planning capabilities (load website specific context)
  • Reduce token consumption (system prompt, DOM state)

DOM Extraction

  • Improve extraction for datepickers, dropdowns, special elements
  • Improve state representation for UI elements

Rerunning tasks

  • LLM as fallback
  • Make it easy to define workfow templates where LLM fills in the details
  • Return playwright script from the agent

Datasets

  • Create datasets for complex tasks
  • Benchmark various models against each other
  • Fine-tuning models for specific tasks

User Experience

  • Human-in-the-loop execution
  • Improve the generated GIF quality
  • Create various demos for tutorial execution, job application, QA testing, social media, etc.

Contributing

We love contributions! Feel free to open issues for bugs or feature requests. To contribute to the docs, check out the /docs folder.

Local Setup

To learn more about the library, check out the local setup 📕.

Cooperations

We are forming a commission to define best practices for UI/UX design for browser agents. Together, we're exploring how software redesign improves the performance of AI agents and gives these companies a competitive advantage by designing their existing software to be at the forefront of the agent age.

Email Toby to apply for a seat on the committee.

Swag

Want to show off your Browser-use swag? Check out our Merch store. Good contributors will receive swag for free 👀.

Citation

If you use Browser Use in your research or project, please cite:

@software{browser_use2024,
  author = {Müller, Magnus and Žunič, Gregor},
  title = {Browser Use: Enable AI to control your browser},
  year = {2024},
  publisher = {GitHub},
  url = {https://github.com/browser-use/browser-use}
}

Twitter Follow Twitter Follow

Made with ❤️ in Zurich and San Francisco

NPM DownloadsLast 30 Days