Skip to content

[tests] Fix ChromeDriver timeouts and restore removed Selenium tests#585

Draft
Claude wants to merge 2 commits intomasterfrom
claude/investigate-selenium-timeouts
Draft

[tests] Fix ChromeDriver timeouts and restore removed Selenium tests#585
Claude wants to merge 2 commits intomasterfrom
claude/investigate-selenium-timeouts

Conversation

@Claude
Copy link
Copy Markdown

@Claude Claude AI commented Mar 31, 2026

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #582.

Description of Changes

Selenium tests were intermittently hanging on GitHub Actions with ReadTimeoutError when ChromeDriver became unresponsive. This particularly affected websocket tests removed in PR #581.

Root causes:

  • ChromeDriver lacked explicit timeout configuration (page load, script execution, implicit waits)
  • Hard-coded 3-second waits insufficient for CI resource constraints
  • time.sleep() used instead of explicit waits for alert handling

Changes:

ChromeDriver timeout configuration (tests/utils.py)

  • Override get_chrome_webdriver() to set explicit timeouts:
    • set_page_load_timeout(60) - prevents indefinite page load hangs
    • set_script_timeout(60) - handles async script execution
    • implicitly_wait(10) - element search timeout

Configurable timeout values (tests/config.json)

  • webdriver_wait_timeout: 20 - general WebDriverWait operations
  • websocket_wait_timeout: 30 - websocket connection establishment

Alert handling improvements (tests/utils.py)

# Before: hard-coded sleep
time.sleep(2)
window_alert = driver.switch_to.alert

# After: explicit wait with timeout
WebDriverWait(driver, 5).until(EC.alert_is_present())
window_alert = driver.switch_to.alert

Test updates

  • test_device_monitoring_charts, test_forgot_password: use configurable timeouts
  • Restored test_websocket_marker: real-time location updates via websockets (30s timeout)
  • Restored test_topology_graph: network visualization with proper wait sequences
  • Restored test_create_prefix_users: RADIUS batch operations with PDF generation
  • Restored geo/location tests in test_console_errors

Documentation

Added tests/SELENIUM_FIXES.md with troubleshooting guide and best practices for future test development.

Screenshot

N/A - Test infrastructure changes only.

This commit addresses the random hangs and crashes in Selenium tests
with websockets on GitHub Actions (issue #582).

Changes:
- Added explicit timeout configuration to ChromeDriver (page load, script, implicit wait)
- Increased WebDriverWait timeout values for CI environments
- Added configurable timeout parameters (webdriver_wait_timeout, websocket_wait_timeout)
- Replaced time.sleep() with explicit WebDriverWait in alert handling
- Restored test_websocket_marker for real-time websocket communication
- Restored test_topology_graph for network topology visualization
- Restored test_create_prefix_users for RADIUS batch operations
- Added comprehensive documentation in tests/SELENIUM_FIXES.md

All restored tests now use increased timeouts and improved error handling
to prevent ChromeDriver hangs and ReadTimeoutError exceptions.

Agent-Logs-Url: https://github.com/openwisp/docker-openwisp/sessions/e6e9f9d3-3c38-4f93-9cb5-e8273e4289ac

Co-authored-by: pandafy <32094433+pandafy@users.noreply.github.com>
@Claude Claude AI changed the title [WIP] Investigate random hangs and crashes in Selenium tests with websockets [tests] Fix ChromeDriver timeouts and restore removed Selenium tests Mar 31, 2026
@Claude Claude AI requested a review from pandafy March 31, 2026 16:52
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.

[bug] Investigate random hangs and crashes in Selenium tests with websockets on GitHub Actions

2 participants