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

Chromedriver is not retrun correct path , exact location of error/ need to modify in this function "__get_binary(self, files, driver_name)" #667

Open
DarshanUTHUK opened this issue Jul 26, 2024 · 7 comments

Comments

@DarshanUTHUK
Copy link

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}")
@DarshanUTHUK
Copy link
Author

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 .

@DarshanUTHUK
Copy link
Author

@SergeyPirogov please look this issue with solutions which i have sent in this

@thomvas
Copy link

thomvas commented Jul 26, 2024

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

@DarshanUTHUK
Copy link
Author

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

@DarshanUTHUK
Copy link
Author

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}")

@DarshanUTHUK
Copy link
Author

please check above code tell whether this can usefull

@CalebePrates
Copy link

chrome_path = ChromeDriverManager().install()
if "THIRD_PARTY_NOTICES.chromedriver" in chrome_path:
    chrome_path = chrome_path.replace("THIRD_PARTY_NOTICES.chromedriver", "chromedriver")

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

No branches or pull requests

3 participants