mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 02:31:45 +01:00
## ℹ️ Description This pull request fixes Windows browser auto-detection failures reported by users where `diagnose`/startup could not find an installed browser even when Chrome or Edge were present in standard locations. It also makes diagnostics resilient when auto-detection fails by avoiding an assertion-driven abort and continuing with a clear failure log. - Link to the related issue(s): Issue #815 - Describe the motivation and context for this change. - Users reported `Installed browser could not be detected` on Windows despite having a browser installed. - The previous Windows candidate list used a mix of incomplete paths and direct `os.environ[...]` lookups that could raise when variables were missing. - The updated path candidates and ordering were aligned with common Windows install locations used by Playwright’s channel/executable resolution logic (Chrome/Edge under `LOCALAPPDATA`, `PROGRAMFILES`, and `PROGRAMFILES(X86)`). ## 📋 Changes Summary - Expanded Windows browser path candidates in `get_compatible_browser()` to include common Google Chrome and Microsoft Edge install paths, while keeping Chromium and PATH fallbacks. - Replaced unsafe direct env-var indexing with safe retrieval (`os.environ.get(...)`) and added a fallback derivation for `LOCALAPPDATA` via `USERPROFILE\\AppData\\Local` when needed. - Kept legacy Chrome path candidates (`...\\Chrome\\Application\\chrome.exe`) as compatibility fallback. - Updated diagnostics flow to catch browser auto-detection assertion failures and continue with `(fail) No compatible browser found` instead of crashing. - Added/updated unit tests to verify: - Windows detection for LocalAppData Chrome/Edge/Chromium paths. - Missing Windows env vars no longer cause key lookup failures and still surface the intended final detection assertion. - `diagnose_browser_issues()` handles auto-detection assertion failures without raising and logs the expected failure message. ### ⚙️ Type of Change Select the type(s) of change(s) included in this pull request: - [x] 🐞 Bug fix (non-breaking change which fixes an issue) ## ✅ Checklist Before requesting a review, confirm the following: - [x] I have reviewed my changes to ensure they meet the project's standards. - [x] I have tested my changes and ensured that all tests pass (`pdm run test`). - [x] I have formatted the code (`pdm run format`). - [x] I have verified that linting passes (`pdm run lint`). - [x] I have updated documentation where necessary. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Hardened Windows browser auto-detection: checks additional common installation locations for Chrome/Chromium/Edge and treats detection failures as non-fatal, allowing diagnostics to continue with fallback behavior and debug logging when no browser is found. * **Tests** * Expanded Windows detection tests to cover more path scenarios and added cases verifying failure-mode diagnostics and logging. * **Style** * Minor formatting tweak in default configuration. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
115 KiB
115 KiB