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
Create hashes of state in multi act
magmueller25196b57d19d
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.pyindex 3f3a6b712..40fa5a1fe 100644--- a/browser_use/controller/service.py+++ b/browser_use/controller/service.py@@ -190,6 +190,9 @@ class Controller:results = []first_action = Trueawait self.browser.remove_highlights()+ session = await self.browser.get_session()+ cached_selector_map = session.cached_state.selector_map+ cached_hashes = set(e.hash.attributes_hash for e in cached_selector_map.values())for action in actions:if not first_action:@@ -197,6 +200,12 @@ class Controller:results.append(await self.act(action))if results[-1].is_done or results[-1].error:break+ new_state = await self.browser.get_state()+ # hash all elements. if it is a subset of cached_state its fine - else break (new elements on page)+ new_hashes = set(e.hash.attributes_hash for e in new_state.selector_map.values())+ if not new_hashes.issubset(cached_hashes):+ logger.debug('New elements on page - stopping')+ breakreturn results@time_execution_sync('--act')