Skip to content

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

If click fails just raise error, because in the next step we will get the new state again

Magnus Müllerf9511deb4b1d
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.py
index a91253d5d..6bb6297b9 100644
--- a/browser_use/controller/service.py
+++ b/browser_use/controller/service.py
@@ -188,14 +188,7 @@ class Controller(Generic[Context]):
return ActionResult(extracted_content=msg, include_in_memory=True, long_term_memory=msg)
except Exception as e:
error_msg = str(e)
- if 'Execution context was destroyed' in error_msg or 'Cannot find context with specified id' in error_msg:
- # Page navigated during click - refresh state and return it
- logger.info('Page context changed during click, refreshing state...')
- await browser_session.get_state_summary(cache_clickable_elements_hashes=True)
- raise BrowserError('Page navigated during click. Refreshed state provided.')
- else:
- logger.warning(f'Element not clickable with index {params.index} - most likely the page changed')
- raise BrowserError(error_msg)
+ raise BrowserError(error_msg)
@self.registry.action(
'Click and input text into a input interactive element',