From 890ef3fdf489c2745245c8cd81f6c5854483be1d Mon Sep 17 00:00:00 2001 From: Bogdan Condurache Date: Mon, 27 Jun 2022 12:58:24 +0300 Subject: [PATCH] Use `which()` to get Firefox path on Mac OS The Firefox binary under Mac OS was using a hardcoded path. This was failing when trying to manipulate PATH env var to use firefox from a different location or if Firefox was installed in a different place. Fixes #10686 --- py/selenium/webdriver/firefox/firefox_binary.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/py/selenium/webdriver/firefox/firefox_binary.py b/py/selenium/webdriver/firefox/firefox_binary.py index 79e5d2c958f7f..ff66f8325334d 100644 --- a/py/selenium/webdriver/firefox/firefox_binary.py +++ b/py/selenium/webdriver/firefox/firefox_binary.py @@ -150,7 +150,11 @@ def _get_firefox_start_cmd(self): """Return the command to start firefox.""" start_cmd = "" if self.platform == "darwin": # small darwin due to lower() in self.platform - start_cmd = "/Applications/Firefox.app/Contents/MacOS/firefox-bin" + ffname = "firefox" + start_cmd = self.which(ffname) + # use hardcoded path if nothing else was found by which() + if not start_cmd: + start_cmd = "/Applications/Firefox.app/Contents/MacOS/firefox-bin" # fallback to homebrew installation for mac users if not os.path.exists(start_cmd): start_cmd = os.path.expanduser("~") + start_cmd