Skip to content

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

End of file line

magmueller771194619926
diff --git a/.env.example b/.env.example
index 413c04aae..85438cdad 100644
--- a/.env.example
+++ b/.env.example
@@ -5,4 +5,4 @@ ANTHROPIC_API_KEY=
ANONYMIZED_TELEMETRY=true
# LogLevel: Set to debug to enable verbose logging, set to result to get results only. Available: result | debug | info
-BROWSER_USE_LOGGING_LEVEL=info
\ No newline at end of file
+BROWSER_USE_LOGGING_LEVEL=info
diff --git a/.gitignore b/.gitignore
index 9fe0d3b05..d5baf384c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -179,4 +179,4 @@ AgentHistoryList.json
*.gif
gcp-login.json
.vscode
-.ruff_cache
\ No newline at end of file
+.ruff_cache
diff --git a/.python-version b/.python-version
index 902b2c90c..2c0733315 100644
--- a/.python-version
+++ b/.python-version
@@ -1 +1 @@
-3.11
\ No newline at end of file
+3.11
diff --git a/browser_use/agent/prompts.py b/browser_use/agent/prompts.py
index 126707f80..9d65e8563 100644
--- a/browser_use/agent/prompts.py
+++ b/browser_use/agent/prompts.py
@@ -37,7 +37,7 @@ class SystemPrompt:
]
}
-2. ACTIONS: You can specify multiple actions in the list to be executed in sequence. But always specify only one action name per item.
+2. ACTIONS: You can specify multiple actions in the list to be executed in sequence. But always specify only one action name per item.
Common action sequences:
- Form filling: [
@@ -81,13 +81,13 @@ class SystemPrompt:
- If you fill an input field and your action sequence is interrupted, most often a list with suggestions popped up under the field and you need to first select the right element from the suggestion list.
8. ACTION SEQUENCING:
- - Actions are executed in the order they appear in the list
+ - Actions are executed in the order they appear in the list
- Each action should logically follow from the previous one
- If the page changes after an action, the sequence is interrupted and you get the new state.
- If content only disappears the sequence continues.
- Only provide the action sequence until you think the page will change.
- Try to be efficient, e.g. fill forms at once, or chain actions where nothing changes on the page like saving, extracting, checkboxes...
- - only use multiple actions if it makes sense.
+ - only use multiple actions if it makes sense.
"""
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.py
index e53850a60..c439eb91b 100644
--- a/browser_use/controller/service.py
+++ b/browser_use/controller/service.py
@@ -287,7 +287,7 @@ class Controller:
const select = document.evaluate(xpath, document, null,
XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (!select) return null;
-
+
return {
options: Array.from(select.options).map(opt => ({
text: opt.text, //do not trim, because we are doing exact match in select_dropdown_option
diff --git a/browser_use/dom/buildDomTree.js b/browser_use/dom/buildDomTree.js
index 3bc7b832f..89b635d31 100644
--- a/browser_use/dom/buildDomTree.js
+++ b/browser_use/dom/buildDomTree.js
@@ -25,7 +25,7 @@
// Generate a color based on the index
const colors = [
- '#FF0000', '#00FF00', '#0000FF', '#FFA500',
+ '#FF0000', '#00FF00', '#0000FF', '#FFA500',
'#800080', '#008080', '#FF69B4', '#4B0082',
'#FF4500', '#2E8B57', '#DC143C', '#4682B4'
];
@@ -72,7 +72,7 @@
// Calculate label position
const labelWidth = 20; // Approximate width
const labelHeight = 16; // Approximate height
-
+
// Default position (top-right corner inside the box)
let labelTop = top + 2;
let labelLeft = left + rect.width - labelWidth - 2;
@@ -155,7 +155,7 @@
'slider', 'tab', 'tabpanel', 'textbox', 'combobox', 'grid',
'listbox', 'option', 'progressbar', 'scrollbar', 'searchbox',
'switch', 'tree', 'treeitem', 'spinbutton', 'tooltip', 'a-button-inner', 'a-dropdown-button', 'click',
- 'menuitemcheckbox', 'menuitemradio', 'a-button-text', 'button-text', 'button-icon', 'button-icon-only', 'button-text-icon-only', 'dropdown', 'combobox'
+ 'menuitemcheckbox', 'menuitemradio', 'a-button-text', 'button-text', 'button-icon', 'button-icon-only', 'button-text-icon-only', 'dropdown', 'combobox'
]);
const tagName = element.tagName.toLowerCase();
@@ -435,4 +435,4 @@
return buildDomTree(document.body);
-}
\ No newline at end of file
+}
diff --git a/examples/ollama.py b/examples/ollama.py
index ded387e5b..9e0804163 100644
--- a/examples/ollama.py
+++ b/examples/ollama.py
@@ -30,4 +30,4 @@ async def main():
if __name__ == "__main__":
- asyncio.run(main())
\ No newline at end of file
+ asyncio.run(main())
diff --git a/examples/post-twitter.py b/examples/post-twitter.py
index 02a0b1d87..b25f6169c 100644
--- a/examples/post-twitter.py
+++ b/examples/post-twitter.py
@@ -77,8 +77,8 @@ def create_twitter_agent(config: TwitterConfig) -> Agent:
# Create the agent with detailed instructions
return Agent(
- task=f"""Navigate to Twitter and create a post and reply to a tweet.
-
+ task=f"""Navigate to Twitter and create a post and reply to a tweet.
+
Here are the specific steps:
1. Go to {config.base_url}. See the text input field at the top of the page that says "What's happening?"
@@ -87,11 +87,11 @@ def create_twitter_agent(config: TwitterConfig) -> Agent:
"{full_message}"
4. Find and click the "Post" button (look for attributes: 'button' and 'data-testid="tweetButton"')
5. Do not click on the '+' button which will add another tweet.
-
+
6. Navigate to {config.reply_url}
7. Before replying, understand the context of the tweet by scrolling down and reading the comments.
8. Reply to the tweet under 50 characters.
-
+
Important:
- Wait for each element to load before interacting
- Make sure the message is typed exactly as shown
@@ -114,7 +114,7 @@ async def post_tweet(agent: Agent):
print(f"Error posting tweet: {str(e)}")
-def main():
+def main():
agent = create_twitter_agent(config)
asyncio.run(post_tweet(agent))
diff --git a/examples/test_cv.txt b/examples/test_cv.txt
index d800886d9..190a18037 100644
--- a/examples/test_cv.txt
+++ b/examples/test_cv.txt
@@ -1 +1 @@
-123
\ No newline at end of file
+123
diff --git a/pytest.ini b/pytest.ini
index 664621c27..31fd5bdc3 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -26,4 +26,3 @@ filterwarnings =
ignore::DeprecationWarning
log_level = INFO
-
diff --git a/tests/mind2web_data/processed.json b/tests/mind2web_data/processed.json
index dc151f83b..553f2b97b 100644
--- a/tests/mind2web_data/processed.json
+++ b/tests/mind2web_data/processed.json
@@ -16855,4 +16855,4 @@
"[span] Final -> CLICK"
]
}
-]
\ No newline at end of file
+]