Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Fix typos discovered by codespell

Christian Clausse7c3f43808e1
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 68bfa89bc..92cc8ca59 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -23,3 +23,10 @@ repos:
- id: detect-private-key
- id: mixed-line-ending
- id: fix-byte-order-marker
+
+ - repo: https://github.com/codespell-project/codespell
+ rev: v2.4.1
+ hooks:
+ - id: codespell # See pyproject.toml for args
+ additional_dependencies:
+ - tomli
diff --git a/README.md b/README.md
index ec3693706..0860f50f8 100644
--- a/README.md
+++ b/README.md
@@ -137,7 +137,7 @@ Tell your computer what to do, and it gets it done.
### Rerunning tasks
- [ ] LLM as fallback
-- [ ] Make it easy to define workfow templates where LLM fills in the details
+- [ ] Make it easy to define workflow templates where LLM fills in the details
- [ ] Return playwright script from the agent
### Datasets
diff --git a/browser_use/agent/message_manager/service.py b/browser_use/agent/message_manager/service.py
index b75ea7d9d..76aab4955 100644
--- a/browser_use/agent/message_manager/service.py
+++ b/browser_use/agent/message_manager/service.py
@@ -62,7 +62,7 @@ class MessageManager:
self._add_message_with_tokens(task_message, message_type='init')
if self.settings.sensitive_data:
- info = f'Here are placeholders for sensitve data: {list(self.settings.sensitive_data.keys())}'
+ info = f'Here are placeholders for sensitive data: {list(self.settings.sensitive_data.keys())}'
info += 'To use them, write <secret>the placeholder name</secret>'
info_message = HumanMessage(content=info)
self._add_message_with_tokens(info_message, message_type='init')
diff --git a/browser_use/agent/system_prompt.md b/browser_use/agent/system_prompt.md
index 0de6eab90..5f7eff0a1 100644
--- a/browser_use/agent/system_prompt.md
+++ b/browser_use/agent/system_prompt.md
@@ -49,7 +49,7 @@ Common action sequences:
5. TASK COMPLETION:
- Use the done action as the last action as soon as the ultimate task is complete
- Dont use "done" before you are done with everything the user asked you, except you reach the last step of max_steps.
-- If you reach your last step, use the done action even if the task is not fully finished. Provide all the information you have gathered so far. If the ultimate task is completly finished set success to true. If not everything the user asked for is completed set success in done to false!
+- If you reach your last step, use the done action even if the task is not fully finished. Provide all the information you have gathered so far. If the ultimate task is completely finished set success to true. If not everything the user asked for is completed set success in done to false!
- If you have to do something repeatedly for example the task says for "each", or "for all", or "x times", count always inside "memory" how many times you have done it and how many remain. Don't stop until you have completed like the task asked you. Only call done after the last step.
- Don't hallucinate actions
- Make sure you include everything you found out for the ultimate task in the done text parameter. Do not just say you are done, but include the requested information of the task.
diff --git a/browser_use/browser/browser.py b/browser_use/browser/browser.py
index 782575799..28f9509b5 100644
--- a/browser_use/browser/browser.py
+++ b/browser_use/browser/browser.py
@@ -110,7 +110,7 @@ class Browser:
"""
Playwright browser on steroids.
- This is persistant browser factory that can spawn multiple browser contexts.
+ This is persistent browser factory that can spawn multiple browser contexts.
It is recommended to use only one instance of Browser per your application (RAM usage will grow otherwise).
"""
@@ -180,7 +180,7 @@ class Browser:
# Check if browser is already running
response = requests.get('http://localhost:9222/json/version', timeout=2)
if response.status_code == 200:
- logger.info('🔌 Re-using existing browser found running on http://localhost:9222')
+ logger.info('🔌 Reusing existing browser found running on http://localhost:9222')
browser_class = getattr(playwright, self.config.browser_class)
browser = await browser_class.connect_over_cdp(
endpoint_url='http://localhost:9222',
diff --git a/browser_use/browser/chrome.py b/browser_use/browser/chrome.py
index 9e8ab34a6..60027b5c6 100644
--- a/browser_use/browser/chrome.py
+++ b/browser_use/browser/chrome.py
@@ -71,7 +71,7 @@ CHROME_DETERMINISTIC_RENDERING_ARGS = [
# chrome://gpu
'--enable-webgl', # enable web-gl graphics support
'--font-render-hinting=none', # make rendering more deterministic by ignoring OS font hints, may also need css override, try: * {text-rendering: geometricprecision !important; -webkit-font-smoothing: antialiased;}
- '--force-color-profile=srgb', # make rendering more deterministic by using consitent color profile, if browser looks weird, try: generic-rgb
+ '--force-color-profile=srgb', # make rendering more deterministic by using consistent color profile, if browser looks weird, try: generic-rgb
'--disable-partial-raster', # make rendering more deterministic (TODO: verify if still needed)
'--disable-skia-runtime-opts', # make rendering more deterministic by avoiding Skia hot path runtime optimizations
'--disable-2d-canvas-clip-aa', # make rendering more deterministic by disabling antialiasing on 2d canvas clips
diff --git a/browser_use/browser/context.py b/browser_use/browser/context.py
index cb9f3f56e..1545374ee 100644
--- a/browser_use/browser/context.py
+++ b/browser_use/browser/context.py
@@ -889,7 +889,7 @@ class BrowserContext:
# Get all cross-origin iframes within the page and open them in new tabs
# mark the titles of the new tabs so the LLM knows to check them for additional content
# unfortunately too buggy for now, too many sites use invisible cross-origin iframes for ads, tracking, youtube videos, social media, etc.
- # and it distracts the bot by openeing a lot of new tabs
+ # and it distracts the bot by opening a lot of new tabs
# iframe_urls = await dom_service.get_cross_origin_iframes()
# for url in iframe_urls:
# if url in [tab.url for tab in tabs_info]:
@@ -1379,7 +1379,7 @@ class BrowserContext:
try:
tab_info = TabInfo(page_id=page_id, url=page.url, title=await asyncio.wait_for(page.title(), timeout=1))
except asyncio.TimeoutError:
- # page.title() can hang forever on tabs that are crashed/dissapeared/about:blank
+ # page.title() can hang forever on tabs that are crashed/disappeared/about:blank
# we dont want to try automating those tabs because they will hang the whole script
logger.debug('⚠ Failed to get tab info for tab #%s: %s (ignoring)', page_id, page.url)
tab_info = TabInfo(page_id=page_id, url='about:blank', title='ignore this tab and do not use it')
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.py
index dc526bc36..b167c676a 100644
--- a/browser_use/controller/service.py
+++ b/browser_use/controller/service.py
@@ -57,7 +57,7 @@ class Controller(Generic[Context]):
data: output_model
@self.registry.action(
- 'Complete task - with return text and if the task is finished (success=True) or not yet completly finished (success=False), because last step is reached',
+ 'Complete task - with return text and if the task is finished (success=True) or not yet completely finished (success=False), because last step is reached',
param_model=ExtendedOutputModel,
)
async def done(params: ExtendedOutputModel):
@@ -73,7 +73,7 @@ class Controller(Generic[Context]):
else:
@self.registry.action(
- 'Complete task - with return text and if the task is finished (success=True) or not yet completly finished (success=False), because last step is reached',
+ 'Complete task - with return text and if the task is finished (success=True) or not yet completely finished (success=False), because last step is reached',
param_model=DoneAction,
)
async def done(params: DoneAction):
@@ -299,7 +299,7 @@ class Controller(Generic[Context]):
# Content Actions
@self.registry.action(
- 'Extract page content to retrieve specific information from the page, e.g. all company names, a specifc description, all information about, links with companies in structured format or simply links',
+ 'Extract page content to retrieve specific information from the page, e.g. all company names, a specific description, all information about, links with companies in structured format or simply links',
)
async def extract_content(
goal: str, should_strip_link_urls: bool, browser: BrowserContext, page_extraction_llm: BaseChatModel
diff --git a/docs/customize/browser-settings.mdx b/docs/customize/browser-settings.mdx
index c5dfb6754..1d7903b9e 100644
--- a/docs/customize/browser-settings.mdx
+++ b/docs/customize/browser-settings.mdx
@@ -161,8 +161,8 @@ async def run_search():
Highlight interactive elements on the screen with colorful bounding boxes.
- **viewport_expansion** (default: `500`)
- Viewport expansion in pixels. With this you can controll how much of the page is included in the context of the LLM. If set to -1, all elements from the entire page will be included (this leads to high token usage). If set to 0, only the elements which are visible in the viewport will be included.
- Default is 500 pixels, that means that we inlcude a little bit more than the visible viewport inside the context.
+ Viewport expansion in pixels. With this you can control how much of the page is included in the context of the LLM. If set to -1, all elements from the entire page will be included (this leads to high token usage). If set to 0, only the elements which are visible in the viewport will be included.
+ Default is 500 pixels, that means that we include a little bit more than the visible viewport inside the context.
### Restrict URLs
diff --git a/docs/customize/sensitive-data.mdx b/docs/customize/sensitive-data.mdx
index 5b012d0dd..3bb5f6c66 100644
--- a/docs/customize/sensitive-data.mdx
+++ b/docs/customize/sensitive-data.mdx
@@ -43,7 +43,7 @@ if __name__ == '__main__':
In this example:
1. The model only sees `x_name` and `x_password` as placeholders.
2. When the model wants to use your password it outputs x_password - and we replace it with the actual value.
-3. When your password is visable on the current page, we replace it in the LLM input - so that the model never has it in its state.
+3. When your password is visible on the current page, we replace it in the LLM input - so that the model never has it in its state.
Warning: Vision models still see the image of the page - where the sensitive data might be visible.
diff --git a/examples/custom-functions/action_filters.py b/examples/custom-functions/action_filters.py
index 7976ab9d3..ef7c60280 100644
--- a/examples/custom-functions/action_filters.py
+++ b/examples/custom-functions/action_filters.py
@@ -64,7 +64,7 @@ async def main():
llm = ChatOpenAI(model_name='gpt-4o')
# Create the agent
- agent = Agent( # disco mode will not be triggered on apple.com because the LLM wont be able to see that action available, it should work on Google.com though.
+ agent = Agent( # disco mode will not be triggered on apple.com because the LLM won't be able to see that action available, it should work on Google.com though.
task="""
Go to apple.com and trigger disco mode (if dont know how to do that, then just move on).
Then go to google.com and trigger disco mode.
diff --git a/examples/custom-functions/notification.py b/examples/custom-functions/notification.py
index 3f73b9640..971697cc2 100644
--- a/examples/custom-functions/notification.py
+++ b/examples/custom-functions/notification.py
@@ -21,7 +21,7 @@ async def done(text: str):
# To send emails use
# STEP 1: go to https://support.google.com/accounts/answer/185833
- # STEP 2: Create an app password (you cant use here your normal gmail password)
+ # STEP 2: Create an app password (you can't use here your normal gmail password)
# STEP 3: Use the app password in the code below for the password
yag = yagmail.SMTP('[email protected]', 'your_app_password')
yag.send(
diff --git a/examples/features/restrict_urls.py b/examples/features/restrict_urls.py
index 2f4ce0952..f481277e0 100644
--- a/examples/features/restrict_urls.py
+++ b/examples/features/restrict_urls.py
@@ -13,7 +13,7 @@ from browser_use.browser.browser import Browser, BrowserConfig
llm = ChatOpenAI(model='gpt-4o', temperature=0.0)
task = (
- 'go to google.com and search for openai.com and click on the first link then extract content and scroll down - whats there?'
+ "go to google.com and search for openai.com and click on the first link then extract content and scroll down - what's there?"
)
allowed_domains = ['google.com']
diff --git a/examples/features/validate_output.py b/examples/features/validate_output.py
index afe96083e..332c4fdda 100644
--- a/examples/features/validate_output.py
+++ b/examples/features/validate_output.py
@@ -1,5 +1,5 @@
"""
-Demostrate output validator.
+Demonstrate output validator.
@dev You need to add OPENAI_API_KEY to your environment variables.
"""
diff --git a/examples/integrations/discord/discord_example.py b/examples/integrations/discord/discord_example.py
index 259e68cc6..c7435d854 100644
--- a/examples/integrations/discord/discord_example.py
+++ b/examples/integrations/discord/discord_example.py
@@ -29,7 +29,7 @@ Five Steps to create and invite a Discord bot:
* Click “Authorize”.
--> Note: The person adding the bot needs "Manage Server" permissions.
6. Run the code below to start the bot with your bot token.
-7. Write e.g. "/bu whats the weather in Tokyo?" to start a browser-use task and get a response inside the Discord channel.
+7. Write e.g. "/bu what's the weather in Tokyo?" to start a browser-use task and get a response inside the Discord channel.
"""
import os
diff --git a/examples/integrations/slack/README.md b/examples/integrations/slack/README.md
index deea9dba4..3184dbc14 100644
--- a/examples/integrations/slack/README.md
+++ b/examples/integrations/slack/README.md
@@ -38,14 +38,14 @@ Steps to create and configure a Slack bot:
6. Invite the bot to a channel:
* Use the `/invite @your-bot-name` command in the Slack channel where you want the bot to be active.
7. Run the code in `examples/slack_example.py` to start the bot with your bot token and signing secret.
-8. Write e.g. "$bu whats the weather in Tokyo?" to start a browser-use task and get a response inside the Slack channel.
+8. Write e.g. "$bu what's the weather in Tokyo?" to start a browser-use task and get a response inside the Slack channel.
## Installing and Starting ngrok
To expose your local server to the internet, you can use ngrok. Follow these steps to install and start ngrok:
1. Download ngrok from the official website: https://ngrok.com/download
-2. Create a free account and follow the offical steps to install ngrok.
+2. Create a free account and follow the official steps to install ngrok.
3. Start ngrok by running the following command in your terminal:
```sh
ngrok http 3000
diff --git a/examples/use-cases/google_sheets.py b/examples/use-cases/google_sheets.py
index 73a2a2d87..5602c8122 100644
--- a/examples/use-cases/google_sheets.py
+++ b/examples/use-cases/google_sheets.py
@@ -102,7 +102,7 @@ async def input_selected_cell_text(browser: BrowserContext, text: str):
page = await browser.get_current_page()
await page.keyboard.type(text, delay=0.1)
- await page.keyboard.press('Enter') # make sure to commit the input so it doesnt get overwritten by the next action
+ await page.keyboard.press('Enter') # make sure to commit the input so it doesn't get overwritten by the next action
await page.keyboard.press('ArrowUp')
return ActionResult(extracted_content=f'Inputted text {text}', include_in_memory=False)
@@ -128,7 +128,7 @@ async def update_range_contents(browser: BrowserContext, range: str, new_content
# - https://github.com/philc/sheetkeys/blob/master/content_scripts/commands.js
# - https://support.google.com/docs/answer/181110?hl=en&co=GENIE.Platform%3DDesktop#zippy=%2Cmac-shortcuts
-# Tip: LLM is bad at spacial reasoning, don't make it navigate with arrow keys relative to current cell
+# Tip: LLM is bad at spatial reasoning, don't make it navigate with arrow keys relative to current cell
# if given arrow keys, it will try to jump from G1 to A2 by pressing Down, without realizing needs to go Down+LeftLeftLeftLeft
diff --git a/examples/use-cases/shopping.py b/examples/use-cases/shopping.py
index 4ba67ac99..cf6e80bef 100644
--- a/examples/use-cases/shopping.py
+++ b/examples/use-cases/shopping.py
@@ -77,7 +77,7 @@ At this stage, check the basket on the top right (indicates the price) and check
- If the total order **is below CHF 99**, add **a liquid soap refill** to reach the minimum. If it;s still you can buy some bread, dark chockolate.
- At this step, check if you have bought MORE items than needed. If the price is more then CHF200, you MUST remove items.
- If an item is not available, choose an alternative.
-- if an age verification is needed, remove alchoholic products, we haven't verified yet.
+- if an age verification is needed, remove alcoholic products, we haven't verified yet.
---
diff --git a/pyproject.toml b/pyproject.toml
index 7030dfdb7..a2add2367 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -47,6 +47,10 @@ dependencies = [
urls = { "Repository" = "https://github.com/browser-use/browser-use" }
+[tool.codespell]
+ignore-words-list = "bu"
+skip = "*.json"
+
[tool.ruff]
line-length = 130
fix = true
diff --git a/tests/test_vision.py b/tests/test_vision.py
index 91c01b667..9851b1a6f 100644
--- a/tests/test_vision.py
+++ b/tests/test_vision.py
@@ -23,7 +23,7 @@ controller = Controller()
# use this test to ask the model questions about the page like
# which color do you see for bbox labels, list all with their label
-# whats the smallest bboxes with labels and
+# what's the smallest bboxes with labels and
@controller.registry.action(description='explain what you see on the screen and ask user for input')
@@ -40,7 +40,7 @@ async def done(text: str) -> str:
agent = Agent(
- task='call explain_screen all the time the user asks you questions e.g. about the page like bbox which you see are labels - your task is to expalin it and get the next question',
+ task='call explain_screen all the time the user asks you questions e.g. about the page like bbox which you see are labels - your task is to explain it and get the next question',
llm=llm,
controller=controller,
browser=Browser(config=BrowserConfig(disable_security=True, headless=False)),