| 677 | |
| 678 | |
| 679 | def find_chrome_executable(): |
| 680 | from seleniumbase.core import detect_b_ver |
| 681 | binary_location = detect_b_ver.get_binary_location("google-chrome", True) |
| 682 | if os.path.exists(binary_location) and os.access(binary_location, os.X_OK): |
| 683 | return os.path.normpath(binary_location) |
| 684 | |
| 685 | candidates = set() |
| 686 | if IS_POSIX: |
| 687 | for item in os.environ.get("PATH").split(os.pathsep): |
| 688 | for subitem in ( |
| 689 | "google-chrome", |
| 690 | "google-chrome-stable", |
| 691 | "google-chrome-beta", |
| 692 | "google-chrome-dev", |
| 693 | "google-chrome-unstable", |
| 694 | "chrome", |
| 695 | "chromium", |
| 696 | "chromium-browser", |
| 697 | ): |
| 698 | candidates.add(os.sep.join((item, subitem))) |
| 699 | if "darwin" in sys.platform: |
| 700 | gc = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" |
| 701 | candidates.update( |
| 702 | [ |
| 703 | gc, "/Applications/Chromium.app/Contents/MacOS/Chromium" |
| 704 | ] |
| 705 | ) |
| 706 | else: |
| 707 | for item in map( |
| 708 | os.environ.get, |
| 709 | ( |
| 710 | "PROGRAMFILES", |
| 711 | "PROGRAMFILES(X86)", |
| 712 | "LOCALAPPDATA", |
| 713 | "PROGRAMW6432", |
| 714 | ), |
| 715 | ): |
| 716 | for subitem in ( |
| 717 | "Google/Chrome/Application", |
| 718 | "Google/Chrome Beta/Application", |
| 719 | "Google/Chrome Canary/Application", |
| 720 | ): |
| 721 | candidates.add(os.sep.join((item, subitem, "chrome.exe"))) |
| 722 | for candidate in candidates: |
| 723 | if os.path.exists(candidate) and os.access(candidate, os.X_OK): |
| 724 | return os.path.normpath(candidate) |
| 725 | return None # Browser not found! |