Skip to content

Conversation

@RohitR311
Copy link
Collaborator

@RohitR311 RohitR311 commented Nov 13, 2025

What this PR does?

Always get the latest fresh button when executing click action during robot execution.

Fixes:
elementHandle.dispatchEvent: Execution context was destroyed, most likely because of a navigation Call log: - waiting for locator(':scope')

Summary by CodeRabbit

  • Refactor
    • Improved button interaction handling to enhance stability and reliability in navigation workflows. Internal mechanics were optimized for better consistency across different interaction scenarios.

@RohitR311 RohitR311 changed the title fix: button click action during robot execution fix(maxun-core): button click action during robot execution Nov 13, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2025

Walkthrough

Replace direct button element clicks with Playwright locator-based actions using page.locator(workingSelector).first() in maxun-core/src/interpret.ts. Changes affect both primary navigation flows and error-handling fallbacks without altering public API signatures.

Changes

Cohort / File(s) Summary
Click interaction refactoring
maxun-core/src/interpret.ts
Replaced hard-coded button element clicks and dispatch events with Playwright locator-based interactions (page.locator(workingSelector).first().click() and .dispatchEvent('click')). Changes applied across navigation paths, pagination, and error-handling fallbacks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Review the locator selectors used to ensure they match intended button targets
  • Verify that .first() correctly handles scenarios where multiple elements match the selector
  • Confirm error-handling fallback behavior remains consistent with the new locator-based approach

Possibly related PRs

Suggested labels

Type: Bug, Scope: UI/UX

Suggested reviewers

  • amhsirak

Poem

🐰 With whiskers twitching, I rejoice,
No more direct clicks—now Playwright's voice!
Locators guide us, selector by name,
Navigation flows, now more tame. 🎯

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main change: replacing hard-coded button interactions with locator-based actions to fix button click issues during robot execution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch button-fix

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 69ad028 and 288614b.

📒 Files selected for processing (1)
  • maxun-core/src/interpret.ts (2 hunks)
🔇 Additional comments (1)
maxun-core/src/interpret.ts (1)

1172-1197: LGTM! Locator-based clicks correctly prevent stale element errors.

The change from button.click() to page.locator(workingSelector).first().click() (and similar for dispatchEvent) is the correct fix for the "Execution context was destroyed" error. Locators re-query elements on each action, avoiding stale ElementHandle references when navigation occurs.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@amhsirak amhsirak merged commit f175b9f into develop Nov 20, 2025
1 check passed
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.

3 participants