Skip to content

Conversation

@Shadow243
Copy link
Member

@Shadow243 Shadow243 commented Oct 7, 2025

ref #1719 (comment)

This fix bridges the gap between modern Single Page Application navigation patterns and traditional browser automation tools

@Shadow243 Shadow243 marked this pull request as draft October 7, 2025 02:25
@Shadow243 Shadow243 force-pushed the fixed-selenium-16 branch 29 times, most recently from 8b8c988 to c801c21 Compare October 11, 2025 10:37
@Shadow243
Copy link
Member Author

Shadow243 commented Oct 14, 2025

@kroky This is now ready for review.

The Selenium test suite was experiencing intermittent failures due to navigation timing issues. The core problem was a mismatch between:

  • Modern SPA Navigation: Cypht uses fetch() API with DOM replacement for seamless page transitions
  • Traditional Selenium Detection: Tests were expecting classic browser navigation events (load, beforeunload, etc.)

This resulted in:

  • Tests proceeding before navigation completion
  • wait_for_navigation_to_complete() timing out or returning prematurely
  • Inconsistent test results, especially with slower networks or complex pages

We added comprehensive navigation state management in navigation.js

// Navigation state tracking
document.body.setAttribute('data-navigation-state', 'loading|complete|error');

// Custom events for precise detection
window.dispatchEvent(new CustomEvent('navigation-started'));
window.dispatchEvent(new CustomEvent('navigation-completed'));
window.dispatchEvent(new CustomEvent('navigation-failed'));

and upgraded wait_for_navigation_to_complete() with three detection methods:

  • Primary: Monitor data-navigation-state attribute changes
  • Fallback 1: Detect fetch requests in performance timeline
  • Fallback 2: Traditional loading indicator + DOM element detection

Please take a look and give us a feedback about our approach.

@Shadow243 Shadow243 marked this pull request as ready for review October 14, 2025 23:10
@kroky
Copy link
Member

kroky commented Oct 17, 2025

Yes, this sounds like the right approach to me. I'll merge and see how it behaves on different PRs. Thanks a lot!

@kroky
Copy link
Member

kroky commented Oct 17, 2025

However, the pipeline still fails. Can you make sure to run it several times after you push your fixes and mark it for review?

@Shadow243 Shadow243 force-pushed the fixed-selenium-16 branch 14 times, most recently from 94caeb9 to 3b2edde Compare October 17, 2025 22:15
@Shadow243 Shadow243 marked this pull request as draft October 17, 2025 22:55
@Shadow243 Shadow243 force-pushed the fixed-selenium-16 branch 6 times, most recently from 50adf24 to 6228656 Compare October 20, 2025 02:29
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.

2 participants