From de0a144b923eaa8ea821f483942683490f00d811 Mon Sep 17 00:00:00 2001 From: Bogdan Condurache Date: Wed, 29 Jun 2022 09:22:54 +0200 Subject: [PATCH] Use `which()` to get Firefox path on Mac OS (#10818) 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 Co-authored-by: Simon K Co-authored-by: Diego Molina --- 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