Skip to content

fix(tools): report new tabs after send keys#4768

Open
haosenwang1018 wants to merge 1 commit into
browser-use:mainfrom
haosenwang1018:fix/send-keys-new-tab-feedback
Open

fix(tools): report new tabs after send keys#4768
haosenwang1018 wants to merge 1 commit into
browser-use:mainfrom
haosenwang1018:fix/send-keys-new-tab-feedback

Conversation

@haosenwang1018

@haosenwang1018 haosenwang1018 commented Apr 29, 2026

Copy link
Copy Markdown

What changed

  • Capture tab ids before send_keys and reuse the existing new-tab detection after the key event finishes.
  • This gives send_keys(keys="Enter") the same new-tab feedback/auto-switch behavior that click actions already have.
  • Add a regression test for an Enter key action that opens a new tab.

Fixes #4758 for the Enter-key path. The click path already uses this helper on current main.

Testing

  • uv run --with pytest --with pytest-asyncio python -m pytest tests/ci/test_send_keys_new_tab_detection.py -q
  • uv run --with ruff ruff check browser_use/tools/service.py tests/ci/test_send_keys_new_tab_detection.py
  • uv run --with ruff ruff format --check browser_use/tools/service.py tests/ci/test_send_keys_new_tab_detection.py

Summary by cubic

Report and auto-switch to new tabs opened by send_keys (e.g., Enter) to match click behavior. We capture tabs before the key event and reuse the existing new-tab detection.

  • Bug Fixes
    • send_keys now reports and switches to a new tab when Enter opens one, consistent with click actions.
    • Added a regression test for the Enter-key path.

Written for commit 9a4cbf2. Summary will update on new commits. Review in cubic

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Enhancement: Improved Detection of New Tabs Triggered by Click and Enter Events

2 participants