Skip to content

fix(selenium_module): Windows cross-platform compatibility (#723)#725

Open
anupddas wants to merge 1 commit into
RedSiege:masterfrom
anupddas:fix/windows-selenium-compat
Open

fix(selenium_module): Windows cross-platform compatibility (#723)#725
anupddas wants to merge 1 commit into
RedSiege:masterfrom
anupddas:fix/windows-selenium-compat

Conversation

@anupddas
Copy link
Copy Markdown

Problem

Issue #723 — EyeWitness fails on Windows because selenium_module.py was written exclusively for Linux environments.

Root Causes Fixed

1. find_chromedriver() — Linux-only paths

The original function only searched /usr/bin/chromedriver, /snap/…, etc.
Fix: delegate to platform_mgr.get_chromedriver_paths() (already present in platform_utils.py) which includes:

  • C:\Program Files\ChromeDriver\chromedriver.exe
  • C:\Program Files (x86)\ChromeDriver\chromedriver.exe
  • %LOCALAPPDATA%\ChromeDriver\chromedriver.exe

2. Linux-only Chrome flags passed unconditionally

--no-sandbox, --disable-dev-shm-usage, --no-zygote are Linux process-model / container flags. Passing them on Windows causes ChromeDriver to emit warnings and can crash the browser session.
Fix: gate them behind if platform_mgr.is_linux:.

3. No binary_location set for Chrome

Without an explicit path, Selenium falls back to PATH, which is often empty or ambiguous on Windows.
Fix: call platform_mgr.find_chromium_executable() (which checks both PATH and the well-known Windows install directories) and assign the result to options.binary_location.

4. No temporary Chrome profile on Windows

Automation using the user's default Chrome profile fails when that profile is locked by a running browser, or is a managed/work/AAD-synced profile.
Fix: on Windows, create a tempfile.mkdtemp() directory and pass it as --user-data-dir; register atexit.register(shutil.rmtree, …) so it is cleaned up automatically.

5. Linux-only error messages

Both the ImportError block and the create_driver() exception handler printed sudo apt install … on all platforms.
Fix: check platform_mgr.is_windows and print the appropriate guidance (chromedriver.exe download URLs, setup.ps1, etc.).

6. check_browsers_available() — Linux names only

The function only searched for google-chrome, chromium-browser, chromium — none of which exist on Windows.
Fix: use platform_mgr.get_chromium_paths() and platform-conditional shutil.which() names.

Testing

  • Linux (Ubuntu/Kali) — existing headless behaviour unchanged
  • Windows 10/11 — Chrome installed at default path
  • Windows with ChromeDriver in PATH
  • Windows with ChromeDriver in C:\Program Files\ChromeDriver\
  • --show-selenium flag works (skips --headless=new argument)

Related

Closes #723

Resolves RedSiege#723
- find_chromedriver(): now delegates to platform_mgr.get_chromedriver_paths() so Windows paths (C:\Program Files\ChromeDriver\chromedriver.exe etc.) are searched alongside Linux/macOS paths.

- create_driver(): gate --no-sandbox, --disable-dev-shm-usage, --no-zygote behind `if platform_mgr.is_linux` - these are Linux process-model flags that destabilise Chrome on Windows.

- create_driver(): set options.binary_location via platform_mgr.find_chromium_executable() so Selenium always has an explicit Chrome path instead of relying on PATH.

- create_driver(): on Windows, create a temp --user-data-dir per run (cleaned up via atexit) to avoid locked/managed/work-profile failures.

- Error messages in create_driver() and import block are now platform-aware (Windows gives winget/choco/chromedriver.exe guidance; Linux keeps the existing apt/setup.sh advice).

- check_browsers_available(): use platform_mgr paths and binary names so Chrome detection works on all three platforms.
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.

Compatibility Issues with Windows, specifically with selenium_module.py

1 participant