diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2024-03-16 20:05:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-16 20:05:35 +0100 |
commit | 930ff2b888ebb5a241d415c1a88fc688b60da980 (patch) | |
tree | cc39a3df291ad30f55df34f52d31d73afcd9a827 /g4f/webdriver.py | |
parent | Merge pull request #1691 from hlohaus/retry (diff) | |
parent | Fix GigaChat exceptions, Raise missing browser error (diff) | |
download | gpt4free-930ff2b888ebb5a241d415c1a88fc688b60da980.tar gpt4free-930ff2b888ebb5a241d415c1a88fc688b60da980.tar.gz gpt4free-930ff2b888ebb5a241d415c1a88fc688b60da980.tar.bz2 gpt4free-930ff2b888ebb5a241d415c1a88fc688b60da980.tar.lz gpt4free-930ff2b888ebb5a241d415c1a88fc688b60da980.tar.xz gpt4free-930ff2b888ebb5a241d415c1a88fc688b60da980.tar.zst gpt4free-930ff2b888ebb5a241d415c1a88fc688b60da980.zip |
Diffstat (limited to 'g4f/webdriver.py')
-rw-r--r-- | g4f/webdriver.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/g4f/webdriver.py b/g4f/webdriver.py index 2b7a7241..044ae03d 100644 --- a/g4f/webdriver.py +++ b/g4f/webdriver.py @@ -2,7 +2,7 @@ from __future__ import annotations try: from platformdirs import user_config_dir - from undetected_chromedriver import Chrome, ChromeOptions + from undetected_chromedriver import Chrome, ChromeOptions, find_chrome_executable from selenium.webdriver.remote.webdriver import WebDriver from selenium.webdriver.remote.webelement import WebElement from selenium.webdriver.common.by import By @@ -39,7 +39,7 @@ try: options = ChromeOptions() config = self._setup_backend(seleniumwire_options) options.add_argument(f"--proxy-server={config['proxy']['httpProxy']}") - options.add_argument('--proxy-bypass-list=<-loopback>') + options.add_argument("--proxy-bypass-list=<-loopback>") options.add_argument("--ignore-certificate-errors") super().__init__(*args, options=options, **kwargs) has_seleniumwire = True @@ -66,6 +66,9 @@ def get_browser( """ if not has_requirements: raise MissingRequirementsError('Install "undetected_chromedriver" and "platformdirs" package') + browser = find_chrome_executable() + if browser is None: + raise MissingRequirementsError('Install "Google Chrome" browser') if user_data_dir is None: user_data_dir = user_config_dir("g4f") if user_data_dir and debug.logging: @@ -82,6 +85,7 @@ def get_browser( options=options, user_data_dir=user_data_dir, driver_executable_path=driver, + browser_executable_path=browser, headless=headless, patcher_force_close=True ) |