{"id":3557,"date":"2025-02-05T14:56:27","date_gmt":"2025-02-05T13:56:27","guid":{"rendered":"https:\/\/blog.tomayac.com\/2025\/02\/05\/testing-browser-use-a-scriptable-ai-browser-agent\/"},"modified":"2025-02-05T14:56:27","modified_gmt":"2025-02-05T13:56:27","slug":"testing-browser-use-a-scriptable-ai-browser-agent","status":"publish","type":"post","link":"https:\/\/tomayac.com\/wordpress\/2025\/02\/05\/testing-browser-use-a-scriptable-ai-browser-agent\/","title":{"rendered":"Testing browser-use, a scriptable AI browser agent"},"content":{"rendered":"\n\t\t\t<p>I'm not a big LinkedIn user, but the other day, my Google colleague Franziska\nHinkelmann\n<a href=\"https:\/\/www.linkedin.com\/posts\/fhinkel_got-low-stakes-repetitive-tasks-in-the-browser-activity-7291114697339068419-rd3R?utm_source=share&amp;utm_medium=member_desktop\">posted something<\/a>\nabout a project called\n<a href=\"https:\/\/github.com\/browser-use\/browser-use\/\">browser-use<\/a> that caught my eye:<\/p>\n<blockquote>\n<p>Got low stakes repetitive tasks in the browser? Playwright + LLMs (Gemini 2.0)\nto the rescue! Super easy to make somebody else <em>cough<\/em> agents <em>cough<\/em> do the\nwork for you, especially if you have to repeat a task for many rows in a\nGoogle Sheet.<\/p>\n<\/blockquote>\n<p>After seeing her demo, I went and tried it out myself. Here are the steps that\nworked for me on macOS:<\/p>\n<ol>\n<li>\n<p>Install <code>uv<\/code> following their\n<a href=\"https:\/\/docs.astral.sh\/uv\/getting-started\/installation\/#standalone-installer\">installation instructions<\/a>.\n(The usual caveat of first checking the source code before pasting anything\nin the Terminal applies.)<\/p>\n<pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">curl<\/span> <span class=\"token parameter variable\">-LsSf<\/span> https:\/\/astral.sh\/uv\/install.sh <span class=\"token operator\">|<\/span> <span class=\"token function\">less<\/span><\/code><\/pre>\n<\/li>\n<li>\n<p>Create a new Python environment and activate it. This is from browser-use's\n<a href=\"https:\/\/docs.browser-use.com\/quickstart\">quickstart<\/a> instructions.<\/p>\n<pre class=\"language-bash\"><code class=\"language-bash\">uv venv <span class=\"token parameter variable\">--python<\/span> <span class=\"token number\">3.11<\/span>\n<span class=\"token builtin class-name\">source<\/span> .venv\/bin\/activate<\/code><\/pre>\n<\/li>\n<li>\n<p>Install the dependencies and <a href=\"https:\/\/playwright.dev\/\">Playwright<\/a>.<\/p>\n<pre class=\"language-bash\"><code class=\"language-bash\">uv pip <span class=\"token function\">install<\/span> browser-use\nplaywright <span class=\"token function\">install<\/span><\/code><\/pre>\n<\/li>\n<li>\n<p>Create a <code>.env<\/code> file and add your OpenAI API key in the form\n<code>OPENAI_API_KEY=abc123<\/code>.<\/p>\n<\/li>\n<li>\n<p>Create an <code>agent.py<\/code> file with the source code of your agent. Here's the one\nI tried. As you can see, I'm tasking the agent with the following job: <em>&quot;Go\nto <a href=\"http:\/\/developer.chrome.com\/\">developer.chrome.com<\/a> and find out what built-in AI APIs Chrome supports&quot;.<\/em><\/p>\n<pre class=\"language-python\"><code class=\"language-python\"><span class=\"token keyword\">from<\/span> langchain_openai <span class=\"token keyword\">import<\/span> ChatOpenAI\n<span class=\"token keyword\">from<\/span> browser_use <span class=\"token keyword\">import<\/span> Agent\n<span class=\"token keyword\">import<\/span> asyncio\n<span class=\"token keyword\">from<\/span> dotenv <span class=\"token keyword\">import<\/span> load_dotenv\nload_dotenv<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>\n\n<span class=\"token keyword\">async<\/span> <span class=\"token keyword\">def<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span>\n    agent <span class=\"token operator\">=<\/span> Agent<span class=\"token punctuation\">(<\/span>\n        task<span class=\"token operator\">=<\/span><span class=\"token string\">\"Go to developer.chrome.com and find out what built-in AI APIs Chrome supports.\"<\/span><span class=\"token punctuation\">,<\/span>\n        llm<span class=\"token operator\">=<\/span>ChatOpenAI<span class=\"token punctuation\">(<\/span>model<span class=\"token operator\">=<\/span><span class=\"token string\">\"gpt-4o\"<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span>\n    <span class=\"token punctuation\">)<\/span>\n    result <span class=\"token operator\">=<\/span> <span class=\"token keyword\">await<\/span> agent<span class=\"token punctuation\">.<\/span>run<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>\n    <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>result<span class=\"token punctuation\">)<\/span>\n\nasyncio<span class=\"token punctuation\">.<\/span>run<span class=\"token punctuation\">(<\/span>main<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/code><\/pre>\n<\/li>\n<\/ol>\n<p>The coolest thing is that you can watch the agent do its job in real time and\nsee the reasoning steps in the command line.<\/p>\n<p><img src=\"https:\/\/blog.tomayac.com\/images\/browser-use.png\" alt=\"Headless browser window with all UI elements annotated.\" \/><\/p>\n<p>Here's an excerpt of the logs.<\/p>\n<pre class=\"language-bash\"><code class=\"language-bash\">INFO     <span class=\"token punctuation\">[<\/span>agent<span class=\"token punctuation\">]<\/span> \ud83d\ude80 Starting task: Go to developer.chrome.com and <span class=\"token function\">find<\/span> out what built-in AI APIs Chrome supports.\nINFO     <span class=\"token punctuation\">[<\/span>agent<span class=\"token punctuation\">]<\/span> \ud83d\udccd Step <span class=\"token number\">1<\/span>\nINFO     <span class=\"token punctuation\">[<\/span>agent<span class=\"token punctuation\">]<\/span> \ud83e\udd37 Eval: Unknown - It<span class=\"token string\">'s the starting state.\nINFO     [agent] \ud83e\udde0 Memory: Start searching for built-in AI APIs supported by Chrome on developer.chrome.com.\nINFO     [agent] \ud83c\udfaf Next goal: Navigate to developer.chrome.com\nINFO     [agent] \ud83d\udee0\ufe0f  Action 1\/1: {\"go_to_url\":{\"url\":\"https:\/\/developer.chrome.com\"}}\nINFO     [controller] \ud83d\udd17  Navigated to https:\/\/developer.chrome.com\nINFO     [agent] \ud83d\udccd Step 2\nINFO     [agent] \ud83d\udc4d Eval: Success - Navigated to the correct URL.\nINFO     [agent] \ud83e\udde0 Memory: Visited developer.chrome.com. Need to search for information on built-in AI APIs supported by Chrome.\nINFO     [agent] \ud83c\udfaf Next goal: Use search input to find information on AI APIs.\nINFO     [agent] \ud83d\udee0\ufe0f  Action 1\/1: {\"click_element\":{\"index\":9}}\nINFO     [controller] \ud83d\uddb1\ufe0f  Clicked button with index 9:\nINFO     [agent] \ud83d\udccd Step 3\nINFO     [agent] \ud83d\udc4d Eval: Success - The search bar was clicked but no input was entered yet.\nINFO     [agent] \ud83e\udde0 Memory: Need to input search query about AI APIs in Chrome using the search bar.\nINFO     [agent] \ud83c\udfaf Next goal: Enter '<\/span>AI APIs' <span class=\"token keyword\">in<\/span> the search input to <span class=\"token function\">find<\/span> relevant information.\nINFO     <span class=\"token punctuation\">[<\/span>agent<span class=\"token punctuation\">]<\/span> \ud83d\udee0\ufe0f  Action <span class=\"token number\">1<\/span>\/1: <span class=\"token punctuation\">{<\/span><span class=\"token string\">\"input_text\"<\/span>:<span class=\"token punctuation\">{<\/span><span class=\"token string\">\"index\"<\/span>:4,<span class=\"token string\">\"text\"<\/span><span class=\"token builtin class-name\">:<\/span><span class=\"token string\">\"AI APIs\"<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">}<\/span>\nINFO     <span class=\"token punctuation\">[<\/span>controller<span class=\"token punctuation\">]<\/span> \u2328\ufe0f  Input AI APIs into index <span class=\"token number\">4<\/span>\n<span class=\"token punctuation\">[<\/span>\u2026<span class=\"token punctuation\">]<\/span><\/code><\/pre>\n<p>At the end of the log messages is the agent's full response to your task,\nformatted in Markdown. FWIW, the answer is exactly correct:<\/p>\n<blockquote>\n<p>Chrome supports several built-in AI APIs, including:<\/p>\n<ol>\n<li><strong>Translator API<\/strong> - Available in origin trial for early preview\nparticipants. Use cases include on-demand translation and supporting\nmulti-language communication.<\/li>\n<li><strong>Language Detector API<\/strong> - Available in Chrome origin trial. It helps\ndetect languages without user input and can label texts for better screen\nreader pronunciation.<\/li>\n<li><strong>Summarizer API<\/strong> - Allows for local experimentation to preview program\nparticipants. It can summarize meeting transcripts, articles, and forum\nquestions.<\/li>\n<li><strong>Writer and Rewriter APIs<\/strong> - Experimental status in early preview\nprogram, used for creating and refining text content.<\/li>\n<li><strong>Prompt API<\/strong> - Allows natural language requests to Gemini Nano in Chrome,\nin an experimental early stage.<\/li>\n<\/ol>\n<p>Visit <a href=\"http:\/\/developer.chrome.com\/\">developer.chrome.com<\/a> for complete details and participation in early\ntrials.<\/p>\n<\/blockquote>\n<p>It's pretty wild what this scriptable agent is capable of doing today. Be sure\nto check out some of the other\n<a href=\"https:\/\/github.com\/browser-use\/browser-use?tab=readme-ov-file#demos\">demos<\/a> and\nalso try the browser-use <a href=\"https:\/\/github.com\/browser-use\/web-ui\">web-ui<\/a>, which\nadds a nice UI on top.<\/p>\n\n\t\t\t<p>\n\t\t\t\t<img alt=\"Thomas Steiner\" width=\"32\" height=\"32\" src=\"https:\/\/blog.tomayac.com\/feed.php?dl=https%3A%2F%2Fblog.tomayac.com%2F2025%2F02%2F05%2Ftesting-browser-use-a-scriptable-ai-browser-agent%2F&dp=%2F2025%2F02%2F05%2Ftesting-browser-use-a-scriptable-ai-browser-agent%2F&dt=Testing%20browser-use%2C%20a%20scriptable%20AI%20browser%20agent\" alt=\"\">\n\t\t\t\t<br\/>This post appeared first on <a href=\"https:\/\/blog.tomayac.com\/2025\/02\/05\/testing-browser-use-a-scriptable-ai-browser-agent\/\">https:\/\/blog.tomayac.com\/2025\/02\/05\/testing-browser-use-a-scriptable-ai-browser-agent\/<\/a>.\n\t\t\t<\/p>\n\t\t","protected":false},"excerpt":{"rendered":"<p>\t\t\tI&#8217;m not a big LinkedIn user, but the other day, my Google colleague Franziska<br \/>\nHinkelmann<br \/>\nposted something<br \/>\nabout a project called<br \/>\nbrowser-use that caught my eye:<\/p>\n<p>Got low stakes repetitive tasks in the browser? Playwright + LLMs (Gemini 2.0)<br \/>\nto the &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"intlwemo_wallet_address":"","footnotes":""},"categories":[],"tags":[],"class_list":["post-3557","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/posts\/3557","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/comments?post=3557"}],"version-history":[{"count":1,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/posts\/3557\/revisions"}],"predecessor-version":[{"id":3558,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/posts\/3557\/revisions\/3558"}],"wp:attachment":[{"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/media?parent=3557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/categories?post=3557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tomayac.com\/wordpress\/wp-json\/wp\/v2\/tags?post=3557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}