pydoll icon indicating copy to clipboard operation
pydoll copied to clipboard

fix: support multiple default Chrome paths on each OS

Open dannysigalovich opened this issue 9 months ago • 4 comments

  • Update _get_default_binary_location to check both "Program Files" and "Program Files (x86)" directories.
  • Ensure that Chrome is correctly located regardless of its installation path.
  • Raise an error if Chrome is not found in the default locations.

dannysigalovich avatar Mar 11 '25 08:03 dannysigalovich

Hi @dannysigalovich, first of all, thanks for your contribution! I'll review your PR now

thalissonvs avatar Mar 11 '25 14:03 thalissonvs

Also, please follow the Conventional Commits style; without it, I can't generate the releases. Just undo your commit and commit again with the fix: prefix

thalissonvs avatar Mar 11 '25 15:03 thalissonvs

Nice @dannysigalovich! You just have to fix the formatation now. Run poetry run task lint and see where's broken. Also, the tests still not passing

thalissonvs avatar Mar 11 '25 16:03 thalissonvs

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Flag Coverage Δ
tests 97.18% <100.00%> (-0.13%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pydoll/browser/chrome.py 93.75% <100.00%> (ø)
pydoll/browser/managers.py 98.76% <100.00%> (+0.01%) :arrow_up:

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov-commenter avatar Mar 12 '25 14:03 codecov-commenter

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ❌

41 - Not compliant

Non-compliant requirements:

  • Add Microsoft Edge browser support to pydoll
  • Implement Edge browser class
  • Add Edge-specific configurations and tests
  • Provide full test coverage for Edge browser
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
🔀 Multiple PR themes

Sub-PR theme: Support multiple Chrome binary paths

Relevant files:

  • pydoll/browser/chrome.py
  • pydoll/browser/managers.py

Sub-PR theme: Add tests for multiple Chrome binary paths

Relevant files:

  • tests/test_browser_managers.py
  • tests/test_chrome.py

⚡ Recommended focus areas for review

Non-English Comment

The docstring contains a comment in Portuguese "Lista de caminhos possíveis do navegador" instead of English, which is inconsistent with the rest of the codebase.

paths (list[str]): Lista de caminhos possíveis do navegador.
Missing KDoc

The PR is modifying domain classes but doesn't include KDoc format comments as required in the evaluation criteria.

browser_paths = {
    'Windows': [
        r'C:\Program Files\Google\Chrome\Application\chrome.exe',
        r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe',
    ],
    'Linux': [
        '/usr/bin/google-chrome',
    ],
    'Darwin': [
        '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
    ]
}
Execution Permission Check

The new implementation checks for executable permission (os.X_OK) which is good for security, but this might cause issues on Windows where executable permissions work differently.

if os.path.exists(path) and os.access(path, os.X_OK):

qodo-code-review[bot] avatar Mar 13 '25 08:03 qodo-code-review[bot]

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Add more Linux Chrome paths

[English]
For Linux, consider adding more common Chrome installation paths such
as '/usr/bin/chromium-browser' or '/usr/bin/chromium' to improve compatibility
with different Linux distributions that might use Chromium or have Chrome
installed in different locations.

[日本語]

Linuxの場合、異なるLinuxディストリビューションとの互換性を向上させるために、'/usr/bin/chromium-browser'や'/usr/bin/chromium'などのより一般的なChromeインストールパスを追加することを検討してください。これらのディストリビューションではChromiumを使用したり、Chromeが異なる場所にインストールされている可能性があります。

pydoll/browser/chrome.py [50-61]

 browser_paths = {
     'Windows': [
         r'C:\Program Files\Google\Chrome\Application\chrome.exe',
         r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe',
     ],
     'Linux': [
         '/usr/bin/google-chrome',
+        '/usr/bin/chromium-browser',
+        '/usr/bin/chromium',
     ],
     'Darwin': [
         '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
     ]
 }
  • [ ] Apply this suggestion
Suggestion importance[1-10]: 7

__

Why: This suggestion adds additional common Chrome/Chromium paths for Linux, which improves compatibility across different Linux distributions. This is a meaningful enhancement that increases the robustness of the browser detection functionality.

Medium
  • [ ] More
  • [ ] Author self-review: I have reviewed the PR code suggestions, and addressed the relevant ones.

qodo-code-review[bot] avatar Mar 13 '25 08:03 qodo-code-review[bot]

Nice @dannysigalovich , thank you so much for your contribution

thalissonvs avatar Mar 13 '25 16:03 thalissonvs