Skip to content

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

Hacky fix just tell user to close all chrome instances

magmuellerfaf22c8c3478
diff --git a/browser_use/browser/browser.py b/browser_use/browser/browser.py
index 5790e0f8f..29826fdce 100644
--- a/browser_use/browser/browser.py
+++ b/browser_use/browser/browser.py
@@ -132,8 +132,10 @@ class Browser:
)
return browser
except Exception as e:
- logger.error(f'Failed to start a new Chrome instance: {str(e)}')
- raise
+ logger.error(f'Failed to start a new Chrome instance.: {str(e)}')
+ raise RuntimeError(
+ ' To start chrome in Debug mode, you need to close all existing Chrome instances and try again otherwise we can not connect to the instance.'
+ )
else:
try:
disable_security_args = []
diff --git a/browser_use/browser/context.py b/browser_use/browser/context.py
index db9ef4931..a7e32ec57 100644
--- a/browser_use/browser/context.py
+++ b/browser_use/browser/context.py
@@ -862,6 +862,10 @@ class BrowserContext:
selector_map = await self.get_selector_map()
return await self.get_locate_element(selector_map[index])
+ async def get_dom_element_by_index(self, index: int) -> DOMElementNode | None:
+ selector_map = await self.get_selector_map()
+ return selector_map[index]
+
async def save_cookies(self):
"""Save current cookies to file"""
if self.session and self.session.context and self.config.cookies_file: