From bf4887bb262efdbb761e106a5e5b25458348fa7f Mon Sep 17 00:00:00 2001 From: "Daniel T." Date: Tue, 24 Jun 2025 13:06:19 +0200 Subject: [PATCH] Refines file input detection logic Enhances logic to accurately identify file input elements by checking element's tag and type attributes, reducing false positives in file upload detection. --- browser_use/controller/service.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/browser_use/controller/service.py b/browser_use/controller/service.py index 9e9508ebf..edbd424cc 100644 --- a/browser_use/controller/service.py +++ b/browser_use/controller/service.py @@ -240,7 +240,8 @@ class Controller(Generic[Context]): initial_pages = len(browser_session.tabs) # if element has file uploader then dont click - if await browser_session.is_file_input_by_index(params.index): + # Check if element is actually a file input (not just contains file-related keywords) + if element_node and element_node.tag_name.lower() == 'input' and element_node.attributes.get('type', '').lower() == 'file': msg = f'Index {params.index} - has an element which opens file upload dialog. To upload files please use a specific function to upload files ' logger.info(msg) return ActionResult(extracted_content=msg, include_in_memory=True, success=False, long_term_memory=msg)