Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying browser binary path #646

Closed
wants to merge 2 commits into from
Closed

Allow specifying browser binary path #646

wants to merge 2 commits into from

Conversation

sohang3112
Copy link

@sohang3112 sohang3112 commented Nov 21, 2023

Fixes Issue 645.

Add a binary_path option to all DriverManager classes to manually specify location of browser. This is useful when the browser is installed in a non-standard location.

Example test script using Chrome:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.chrome.options import Options as ChromeOptions
from webdriver_manager.chrome import ChromeDriverManager

chrome_path = "/custom/path/to/chrome"

manager = ChromeDriverManager(browser_path=chrome_path)
chromedriver_path = manager.install()

options = ChromeOptions()
options.binary_location = chrome_path
driver = webdriver.Chrome(service=ChromeService(chromedriver_path), options=options)

@sohang3112
Copy link
Author

@SergeyPirogov please review my PR. Let me know if any changes are required from my side.

@sohang3112
Copy link
Author

@SergeyPirogov did you have a chance to review my PR yet?

@sohang3112
Copy link
Author

@aleksandr-kotlyar Can you please review this PR?

@MarcelWilson
Copy link

@sohang3112 good luck. I have had a PR open since Oct 9 with no feedback. 😞

@sohang3112
Copy link
Author

@MarcelWilson Last merged PR seems to be in September. Maybe the repo maintainers are taking a break (hopefully temporary!)

@ndepaola
Copy link
Contributor

ndepaola commented Dec 1, 2023

@sohang3112 you might have more luck switching to selenium's new built-in webdriver manager (functionally equivalent to this library but less buggy in my experience) https://www.selenium.dev/documentation/selenium_manager/#automated-browser-management

switching my project to it was trivial chilli-axe/mpc-autofill#192

@sohang3112
Copy link
Author

selenium's new built-in webdriver manager

@ndepaola Thanks - didn't know about this!

@aleksandr-kotlyar
Copy link
Collaborator

@sohang3112 this idea is awesome! Thank you for your time and this PR! Sorry but I have no time to check it, can you prove it works by adding some tests please? And also prove that no regression comes with it?

@sohang3112
Copy link
Author

@aleksandr-kotlyar Where should I put the tests - in tests folder or tests_xdist? (I didn't really understand the purpose of test_xdist since all 3 files in it have the same test)

And also prove that no regression comes with it?

How should I do that??

@pep8speaks
Copy link

pep8speaks commented Dec 2, 2023

Hello @sohang3112! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 106:80: E501 line too long (95 > 79 characters)
Line 108:80: E501 line too long (116 > 79 characters)

Line 167:80: E501 line too long (81 > 79 characters)

Comment last updated at 2023-12-02 05:44:23 UTC

@aleksandr-kotlyar
Copy link
Collaborator

@aleksandr-kotlyar Where should I put the tests - in tests folder or tests_xdist? (I didn't really understand the purpose of test_xdist since all 3 files in it have the same test)

And also prove that no regression comes with it?

How should I do that??

To /tests/ only would be enough.
All tests should pass.

@sohang3112
Copy link
Author

Hi. I'm closing this Pull Request, as there's already a way to do what I wanted which I didn't know before:

from webdriver_manager.firefox import GeckoDriverManager

from webdriver_manager.core.utils import read_version_from_cmd 
from webdriver_manager.core.os_manager import PATTERN

firefox_path = "/usr/bin/firefox-bin-custom"
version = read_version_from_cmd(f"{firefox_path} --version", PATTERN["firefox"])
driver_binary = GeckoDriverManager(version=version).install()

@sohang3112 sohang3112 closed this Dec 2, 2023
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.

Allow specifying browser binary location
5 participants