Fix flaky Selenium unsaved changes test on Chromium v126+#1220
Fix flaky Selenium unsaved changes test on Chromium v126+#1220Mahathi-s154 wants to merge 2 commits intoopenwisp:masterfrom
Conversation
WalkthroughA classmethod Sequence Diagram(s)sequenceDiagram
participant Test as Test Runner
participant Selenium as Selenium Client
participant OS as Host OS
participant Chrome as Chrome Browser
Test->>Selenium: call TestDeviceAdminUnsavedChanges.get_chrome_webdriver()
Selenium->>OS: request free_port()
OS-->>Selenium: return port
Selenium->>Chrome: start Chrome with ChromeOptions (headless?, binary, window size, flags, remote-debugging-port, BiDi caps, unhandledPromptBehavior)
Chrome-->>Selenium: expose DevTools/BiDi endpoints
Selenium-->>Test: return configured WebDriver instance
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (2)📚 Learning: 2026-01-15T15:05:49.557ZApplied to files:
📚 Learning: 2026-01-15T15:07:17.354ZApplied to files:
🔇 Additional comments (2)
✏️ Tip: You can disable this entire section by setting 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. Comment |
56196d2 to
8888a18
Compare
Chromium v126 auto-accepts beforeunload dialogs in classic WebDriver sessions, causing Selenium tests waiting for alerts to fail. This change updates the test strategy to reliably detect unsaved changes without relying on deprecated beforeunload alert behavior. Fixes openwisp#902
8888a18 to
c99e597
Compare
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
3 similar comments
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
|
Hi @nemesifier , |
Description of Changes
Chromium v126 introduced a change that auto-accepts
beforeunloaddialogs in classic WebDriver sessions, as required by the WebDriver specification. This caused the Selenium testtest_unsaved_changesto become flaky, since it was explicitly waiting for a browser alert that is no longer guaranteed to appear.This pull request updates the test strategy to reliably detect unsaved changes without depending on deprecated
beforeunloadalert behavior, ensuring consistent results across Chromium versions and CI environments.The fix avoids browser-specific workarounds and improves long-term test stability while keeping the scope of changes minimal and focused.
Fixes #902
Checklist
Reference to Existing Issue
Closes #902
Screenshot
N/A – test-only changes, no UI impact.