Browser Use Cloud API
Browser-Use is a Python library that allows you to create browser automation scripts using AI. You can use multiple models such as GPT-4o, DeepSeek, Gemini-2.0, Claude and more. Local models such as Qwen 2.5 are also supported. The library essentially uses a Playwright browser instance to execute tasks on a (remote) browser. You can perform tasks such as:
- Navigate to Google and search for TestingBot
- Go to Reddit and open an article
- Open a new tab and go to CNN
By using the TestingBot remote browser grid, you can run multiple AI agents in parallel without worrying about setting up and managing the browsers yourself.
Additionally, TestingBot records each session with a video, logs and generated metadata are saved as well.
You can run browsers from various geographical locations and use different browser versions, on multiple operating systems.
To install browser use, please follow these steps:
- Install the Browser-Use library:
pip install browser-use
- Install the Playwright library:
pip install playwright
Connecting to a remote browser
Please see the example below on how to connect your Browser-Use agent to a remote browser in the TestingBot cloud.
The wss
URL points to the TestingBot cloud, where you can specify the browser and platform you want to use. You can also specify the name of the session.
Make sure to replace key
and secret
with your TestingBot API key and secret.
import json
import urllib.parse
import asyncio
from browser_use.browser.browser import Browser
capabilities = {
"tb:options": {
"name": "Browser Use Example"
},
"browserName": "chrome",
"browserVersion": "latest",
"platform": "WIN10"
}
encoded_capabilities = urllib.parse.quote(json.dumps(capabilities))
wss_url = f"wss://cloud.testingbot.com/playwright?key={key}&secret={secret}&capabilities={encoded_capabilities}"
browser = Browser(config=BrowserConfig(wss_url=wss_url))
# Create the agent with your configured browser
agent = Agent(
task="Go to the TestingBot homepage and click a menu item",
llm=ChatOpenAI(model='gpt-4o'),
browser=browser,
)
async def main():
await agent.run()
await browser.close()
if __name__ == '__main__':
asyncio.run(main()
When you run this example, the Browser-Use agent will connect to a remote browser in the TestingBot cloud, and execute the task specified in the task
variable.