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
Dont open new tab, if we are already inside a new tab
Magnus Müller4c10628ff254
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.pyindex 5452247d1..e8c24acad 100644--- a/browser_use/browser/session.py+++ b/browser_use/browser/session.py@@ -536,6 +536,18 @@ class BrowserSession(BaseModel):target_id = None+ # If new_tab=True but we're already in a new tab, set new_tab=False+ if event.new_tab:+ try:+ current_url = await self.get_current_page_url()+ from browser_use.utils import is_new_tab_page++ if is_new_tab_page(current_url):+ self.logger.debug(f'[on_NavigateToUrlEvent] Already in new tab ({current_url}), setting new_tab=False')+ event.new_tab = False+ except Exception as e:+ self.logger.debug(f'[on_NavigateToUrlEvent] Could not check current URL: {e}')+# check if the url is already open in a tab somewhere that we're not currently on, if so, short-circuit and just switch to ittargets = await self._cdp_get_all_pages()for target in targets: