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
Check siblings when searching for element
magmueller05d0bc7d6b49
diff --git a/browser_use/dom/views.py b/browser_use/dom/views.pyindex a4fc74313..d4cf478b0 100644--- a/browser_use/dom/views.py+++ b/browser_use/dom/views.py@@ -130,14 +130,26 @@ class DOMElementNode(DOMBaseNode):process_node(self, 0)return '\n'.join(formatted_text)- def get_file_upload_element(self) -> Optional['DOMElementNode']:+ def get_file_upload_element(self, check_siblings: bool = True) -> Optional['DOMElementNode']:+ # Check if current element is a file inputif self.tag_name == 'input' and self.attributes.get('type') == 'file':return self++ # Check childrenfor child in self.children:if isinstance(child, DOMElementNode):- result = child.get_file_upload_element()+ result = child.get_file_upload_element(check_siblings=False)if result:return result++ # Check siblings only for the initial call+ if check_siblings and self.parent:+ for sibling in self.parent.children:+ if sibling is not self and isinstance(sibling, DOMElementNode):+ result = sibling.get_file_upload_element(check_siblings=False)+ if result:+ return result+return None