Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
group/ungroup code moved to custom_functions
SwapnilSonker2099aabbd639
diff --git a/browser_use/browser/browser.py b/browser_use/browser/browser.pyindex 3abcf0c36..7cce435a4 100644--- a/browser_use/browser/browser.py+++ b/browser_use/browser/browser.py@@ -194,8 +194,6 @@ class Browser:'--no-startup-window','--window-position=0,0','--enable-experimental-extension-apis',- '--disable-extensions-except=/path/to/your/extension', # If using an extension- '--load-extension=/path/to/your/extension'# '--window-size=1280,1000',]+ self.disable_security_argsdiff --git a/browser_use/browser/context.py b/browser_use/browser/context.pyindex 5e5014d32..25fa86989 100644--- a/browser_use/browser/context.py+++ b/browser_use/browser/context.py@@ -1120,39 +1120,6 @@ class BrowserContext:session.cached_state = self._get_initial_state()session.current_page = await session.context.new_page()- async def group_tabs(self, tab_ids: list[int] , title: str, color: str = "blue"):- """Reset the browser session- Call this when you don't want to kill the context but just kill the state- """- # close all tabs and clear cached state- page = await self.get_current_page()-- js = f"""- chrome.tabs.group({{ tabIds: {tab_ids} }}, (groupId) => {{- chrome.tabGroups.update(groupId, {{- title: "{title}",- color: "{color}"- }});- }});- """-- await page.evaluate(js)-- async def ungroup_tabs(self, tab_ids: list[int]):- """Reset the browser session- Call this when you don't want to kill the context but just kill the state- """- # close all tabs and clear cached state- page = await self.get_current_page()-- js = f"""- for (const tabId of {tab_ids}) {{- chrome.tabs.ungroup(tabId);- }}- """-- await page.evaluate(js)-def _get_initial_state(self, page: Optional[Page] = None) -> BrowserState:"""Get the initial state of the browser"""return BrowserState(diff --git a/examples/custom-functions/group_ungroup.py b/examples/custom-functions/group_ungroup.pyindex 8262e4502..ab59f5e20 100644--- a/examples/custom-functions/group_ungroup.py+++ b/examples/custom-functions/group_ungroup.py@@ -15,6 +15,41 @@ from langchain_openai import ChatOpenAIfrom browser_use import Agent, Controllerfrom browser_use.browser.browser import Browser, BrowserConfigfrom browser_use.browser.context import BrowserContext++# async def group_tabs(self, tab_ids: list[int] , title: str, color: str = "blue"):+# """Reset the browser session+# Call this when you don't want to kill the context but just kill the state+# """+# # close all tabs and clear cached state+# page = await self.get_current_page()++# js = f"""+# chrome.tabs.group({{ tabIds: {tab_ids} }}, (groupId) => {{+# chrome.tabGroups.update(groupId, {{+# title: "{title}",+# color: "{color}"+# }});+# }});+# """++# await page.evaluate(js)++# async def ungroup_tabs(self, tab_ids: list[int]):+# """Reset the browser session+# Call this when you don't want to kill the context but just kill the state+# """+# # close all tabs and clear cached state+# page = await self.get_current_page()++# js = f"""+# for (const tabId of {tab_ids}) {{+# chrome.tabs.ungroup(tabId);+# }}+# """++# await page.evaluate(js)++# Initialize controller firstbrowser = Browser(config=BrowserConfig(