Chromedriver is not retrun correct path , exact location of error/ need to modify in this function "__get_binary(self, files, driver_name)"
There are three files ['chromedriver-win32/LICENSE.chromedriver','chromedriver-win32/chromedriver.exe', 'chromedriver-win32/THIRD_PARTY_NOTICES.chromedriver'] in the current version of chromedriver download path. so as code tells if 'LICENSE' in f:
continue but next two iteration will be .exe and THIRD_PARTY_NOTICES.chromedriver so this logic will be not so good for this function.
def __get_binary(self, files, driver_name): if not files: raise Exception(f"Can't find binary for {driver_name} among {files}")
if len(files) == 1:
return files[0]
for f in files:
if 'LICENSE' in f:
continue
if driver_name in f:
return f
raise Exception(f"Can't find binary for {driver_name} among {files}")
we can update like this as follows:-
def __get_binary(self, files, driver_name):
if not files:
raise Exception(f"Can't find binary for {driver_name} among {files}")
if len(files) == 1:
return files[0]
if not driver_name.__contains__(".exe"):
driver_name = driver_name.join(".exe")
for f in files:
if 'LICENSE' in f:
continue
if driver_name in f:
return f
raise Exception(f"Can't find binary for {driver_name} among {files}")
as driver_name contains only a 'chromedriver'....its bettter check with extension also. where this path is used in drivers.json and also for driver executable_path .
@SergeyPirogov please look this issue with solutions which i have sent in this
as driver_name contains only a 'chromedriver'....its bettter check with extension also. where this path is used in drivers.json and also for driver executable_path .
I think this solution is only valid for Windows, but on MacOS and Linux there is no exe extension, so I don't think this type of control is a good idea
as driver_name contains only a 'chromedriver'....its bettter check with extension also. where this path is used in drivers.json and also for driver executable_path .
I think this solution is only valid for Windows, but on MacOS and Linux there is no exe extension, so I don't think this type of control is a good idea
Yeah got your point
what this code
def __get_binary(self, files, driver_name):
if not files:
raise Exception(f"Can't find binary for {driver_name} among {files}")
if len(files) == 1:
return files[0]
for f in files:
if 'LICENSE' in f:
continue
if driver_name in f:
driver_extension = "." + driver_name
if driver_extension not in f:
return f
raise Exception(f"Can't find binary for {driver_name} among {files}")
please check above code tell whether this can usefull
chrome_path = ChromeDriverManager().install()
if "THIRD_PARTY_NOTICES.chromedriver" in chrome_path:
chrome_path = chrome_path.replace("THIRD_PARTY_NOTICES.chromedriver", "chromedriver")