From c8b2086e2ac5d02c51abe416aff4c94410e13743 Mon Sep 17 00:00:00 2001 From: ilkecan Date: Thu, 22 Aug 2024 01:27:28 +0300 Subject: [PATCH] find_chrome_executable: Search `PATH` in order --- nodriver/core/config.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/nodriver/core/config.py b/nodriver/core/config.py index 2da4f6a..c36e412 100644 --- a/nodriver/core/config.py +++ b/nodriver/core/config.py @@ -295,22 +295,13 @@ def find_chrome_executable(return_all=False): % candidate ) - winner = None + if not rv: + raise FileNotFoundError( + "could not find a valid chrome browser binary. please make sure chrome is installed." + "or use the keyword argument 'browser_executable_path=/path/to/your/browser' " + ) - if return_all and rv: + if return_all: return rv - if rv and len(rv) > 1: - # assuming the shortest path wins - winner = min(rv, key=lambda x: len(x)) - - elif len(rv) == 1: - winner = rv[0] - - if winner: - return os.path.normpath(winner) - - raise FileNotFoundError( - "could not find a valid chrome browser binary. please make sure chrome is installed." - "or use the keyword argument 'browser_executable_path=/path/to/your/browser' " - ) + return os.path.normpath(rv[0])