summaryrefslogtreecommitdiffstats
path: root/g4f/webdriver.py
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-03-16 20:02:15 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-03-16 20:02:15 +0100
commitf797ec828ce3b5965796b437878e14b6eec6235b (patch)
treecc39a3df291ad30f55df34f52d31d73afcd9a827 /g4f/webdriver.py
parentMerge pull request #1691 from hlohaus/retry (diff)
downloadgpt4free-f797ec828ce3b5965796b437878e14b6eec6235b.tar
gpt4free-f797ec828ce3b5965796b437878e14b6eec6235b.tar.gz
gpt4free-f797ec828ce3b5965796b437878e14b6eec6235b.tar.bz2
gpt4free-f797ec828ce3b5965796b437878e14b6eec6235b.tar.lz
gpt4free-f797ec828ce3b5965796b437878e14b6eec6235b.tar.xz
gpt4free-f797ec828ce3b5965796b437878e14b6eec6235b.tar.zst
gpt4free-f797ec828ce3b5965796b437878e14b6eec6235b.zip
Diffstat (limited to '')
-rw-r--r--g4f/webdriver.py8
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
)