MCPcopy
hub / github.com/FlareSolverr/FlareSolverr / find_chrome_executable

Function find_chrome_executable

src/undetected_chromedriver/__init__.py:868–910  ·  view source on GitHub ↗

Finds the chrome, chrome beta, chrome canary, chromium executable Returns ------- executable_path : str the full file path to found executable

()

Source from the content-addressed store, hash-verified

866
867
868def find_chrome_executable():
869 """
870 Finds the chrome, chrome beta, chrome canary, chromium executable
871
872 Returns
873 -------
874 executable_path : str
875 the full file path to found executable
876
877 """
878 candidates = set()
879 if IS_POSIX:
880 for item in os.environ.get("PATH").split(os.pathsep):
881 for subitem in (
882 "google-chrome",
883 "chromium",
884 "chromium-browser",
885 "chrome",
886 "google-chrome-stable",
887 ):
888 candidates.add(os.sep.join((item, subitem)))
889 if "darwin" in sys.platform:
890 candidates.update(
891 [
892 "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
893 "/Applications/Chromium.app/Contents/MacOS/Chromium",
894 ]
895 )
896 else:
897 for item in map(
898 os.environ.get,
899 ("PROGRAMFILES", "PROGRAMFILES(X86)", "LOCALAPPDATA", "PROGRAMW6432"),
900 ):
901 if item is not None:
902 for subitem in (
903 "Google/Chrome/Application",
904 ):
905 candidates.add(os.sep.join((item, subitem, "chrome.exe")))
906 for candidate in candidates:
907 logger.debug('checking if %s exists and is executable' % candidate)
908 if os.path.exists(candidate) and os.access(candidate, os.X_OK):
909 logger.debug('found! using %s' % candidate)
910 return os.path.normpath(candidate)

Callers 1

__init__Method · 0.85

Calls 3

updateMethod · 0.80
existsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected