-
Notifications
You must be signed in to change notification settings - Fork 8.2k
fix-typing #2869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix-typing #2869
Conversation
- Added logging for new elements detected during actions in the Agent class. - Implemented a human-like text field clearing method in DefaultActionWatchdog, utilizing Ctrl+A and Backspace. - Improved focus handling for label elements, ensuring they are only interactive if they do not have a 'for' attribute. - Updated clickable element detection logic to account for labels pointing to inputs. These changes improve the robustness of user interactions and enhance debugging capabilities.
- Enhanced the tag check to include truly interactive elements. - Removed special handling for 'label' elements, as they are now managed by other attribute checks to prevent interference with clickable elements. These updates improve the accuracy of interactive element detection in the DOM serializer.
- Added type hint for CDPSession in the _focus_element_simple method. - Enhanced logging for focus attempts, including exception details. - Reduced sleep duration in scrollIntoViewIfNeeded for better performance. - Updated text clearing logic to ensure it only occurs after successful focus. These changes enhance the robustness of element interaction and improve debugging capabilities.
Agent Task Evaluation Results: 2/3 (67%)View detailed results
Check the evaluate-tasks job for detailed task execution logs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 issues found across 3 files
React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai
to give feedback, ask questions, or re-run the review.
|
||
# ENHANCED TAG CHECK: Include truly interactive elements | ||
# ENHANCED TAG CHECK: Include truly interactive elements | ||
# Note: 'label' removed - labels are handled by other attribute checks below - other wise labels with "for" attribute can destry the real clickable element on appartments.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typos in the added comment reduce clarity: "other wise", "destry", and "appartments.com".
Prompt for AI agents
Address the following comment on browser_use/dom/serializer/clickable_elements.py at line 98:
<comment>Typos in the added comment reduce clarity: "other wise", "destry", and "appartments.com".</comment>
<file context>
@@ -94,14 +94,14 @@ def is_interactive(node: EnhancedDOMTreeNode) -> bool:
- # ENHANCED TAG CHECK: Include truly interactive elements
+ # ENHANCED TAG CHECK: Include truly interactive elements
+ # Note: 'label' removed - labels are handled by other attribute checks below - other wise labels with "for" attribute can destry the real clickable element on appartments.com
interactive_tags = {
'button',
</file context>
# Note: 'label' removed - labels are handled by other attribute checks below - other wise labels with "for" attribute can destry the real clickable element on appartments.com | |
# Note: 'label' removed - labels are handled by other attribute checks below; otherwise labels with "for" attribute can destroy the real clickable element on apartments.com |
'type': 'keyDown', | ||
'key': 'a', | ||
'code': 'KeyA', | ||
'modifiers': 2, # Ctrl modifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Meta (Cmd) on macOS for select-all; set modifiers to 4 on Darwin to ensure Ctrl/Cmd+A works cross-platform.
(This reflects your team's feedback about using tabs for indentation in fix suggestions.)
Prompt for AI agents
Address the following comment on browser_use/browser/watchdogs/default_action_watchdog.py at line 649:
<comment>Use Meta (Cmd) on macOS for select-all; set modifiers to 4 on Darwin to ensure Ctrl/Cmd+A works cross-platform.
(This reflects your team's feedback about using tabs for indentation in fix suggestions.)</comment>
<file context>
@@ -583,80 +584,184 @@ async def _type_to_page(self, text: str):
+ 'type': 'keyDown',
+ 'key': 'a',
+ 'code': 'KeyA',
+ 'modifiers': 2, # Ctrl modifier
+ 'windowsVirtualKeyCode': 65,
},
</file context>
'text': char, | ||
'key': char, | ||
'code': key_code, | ||
'windowsVirtualKeyCode': ord(char.upper()) if char.isalpha() else ord(char), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deriving windowsVirtualKeyCode from ASCII leads to wrong virtual key codes for punctuation; either omit this field for printable chars or map to correct VK codes to avoid mis-typed input.
Prompt for AI agents
Address the following comment on browser_use/browser/watchdogs/default_action_watchdog.py at line 846:
<comment>Deriving windowsVirtualKeyCode from ASCII leads to wrong virtual key codes for punctuation; either omit this field for printable chars or map to correct VK codes to avoid mis-typed input.</comment>
<file context>
@@ -698,145 +803,67 @@ async def _input_text_element_node_impl(self, element_node, text: str, clear_exi
'text': char,
'key': char,
+ 'code': key_code,
+ 'windowsVirtualKeyCode': ord(char.upper()) if char.isalpha() else ord(char),
},
session_id=cdp_session.session_id,
</file context>
'-': 'Minus', | ||
'_': 'Underscore', | ||
'@': 'At', | ||
'!': 'Exclamation', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using non-standard 'Exclamation' for 'code' is incorrect; map to the proper base key code (e.g., 'Digit1') and handle Shift via modifiers for reliable typing behavior.
(This reflects your team's feedback about using tabs for indentation in fix suggestions.)
Prompt for AI agents
Address the following comment on browser_use/browser/watchdogs/default_action_watchdog.py at line 597:
<comment>Using non-standard 'Exclamation' for 'code' is incorrect; map to the proper base key code (e.g., 'Digit1') and handle Shift via modifiers for reliable typing behavior.
(This reflects your team's feedback about using tabs for indentation in fix suggestions.)</comment>
<file context>
@@ -583,80 +584,184 @@ async def _type_to_page(self, text: str):
+ '-': 'Minus',
+ '_': 'Underscore',
+ '@': 'At',
+ '!': 'Exclamation',
+ '?': 'Question',
+ ':': 'Colon',
</file context>
…ionWatchdog - Updated key code mappings for special characters to reflect correct usage with modifiers. - Enhanced text field clearing method to use platform-specific modifiers (Cmd for macOS, Ctrl for others) for a more human-like interaction. - Removed unnecessary `windowsVirtualKeyCode` assignments for printable characters to prevent incorrect virtual key code usage. These changes improve the accuracy of character input handling and enhance the robustness of text field interactions.
await asyncio.sleep(0.01) | ||
|
||
# Small delay between characters to look human (realistic typing speed) | ||
await asyncio.sleep(0.001) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Text Input Sequence Fails CDP Standards
The _input_text_element_node_impl
method's text input sequence deviates from standard CDP. It omits the crucial char
event and incorrectly places the text
parameter in keyDown
events, which can lead to unreliable input on some sites. Furthermore, it fails to send necessary modifier keys (e.g., Shift) for special characters, potentially causing incorrect input for characters like _
or @
.
2 Critical fixes: