fix(selenium_module): Windows cross-platform compatibility (#723)#725
Open
anupddas wants to merge 1 commit into
Open
fix(selenium_module): Windows cross-platform compatibility (#723)#725anupddas wants to merge 1 commit into
anupddas wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Issue #723 — EyeWitness fails on Windows because
selenium_module.pywas written exclusively for Linux environments.Root Causes Fixed
1.
find_chromedriver()— Linux-only pathsThe original function only searched
/usr/bin/chromedriver,/snap/…, etc.Fix: delegate to
platform_mgr.get_chromedriver_paths()(already present inplatform_utils.py) which includes:C:\Program Files\ChromeDriver\chromedriver.exeC:\Program Files (x86)\ChromeDriver\chromedriver.exe%LOCALAPPDATA%\ChromeDriver\chromedriver.exe2. Linux-only Chrome flags passed unconditionally
--no-sandbox,--disable-dev-shm-usage,--no-zygoteare 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_locationset for ChromeWithout 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 tooptions.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; registeratexit.register(shutil.rmtree, …)so it is cleaned up automatically.5. Linux-only error messages
Both the
ImportErrorblock and thecreate_driver()exception handler printedsudo apt install …on all platforms.Fix: check
platform_mgr.is_windowsand print the appropriate guidance (chromedriver.exe download URLs,setup.ps1, etc.).6.
check_browsers_available()— Linux names onlyThe function only searched for
google-chrome,chromium-browser,chromium— none of which exist on Windows.Fix: use
platform_mgr.get_chromium_paths()and platform-conditionalshutil.which()names.Testing
C:\Program Files\ChromeDriver\--show-seleniumflag works (skips--headless=newargument)Related
Closes #723