diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2023-12-06 12:02:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-06 12:02:41 +0100 |
commit | f962993b8dac225d85f9fbb59be188e263af1c0b (patch) | |
tree | ae153b027ad5a2679b4f1fde881d61cc0e1276b4 /g4f/webdriver.py | |
parent | ~ | g4f `v-0.1.9.1` (diff) | |
parent | Improve docker image (diff) | |
download | gpt4free-f962993b8dac225d85f9fbb59be188e263af1c0b.tar gpt4free-f962993b8dac225d85f9fbb59be188e263af1c0b.tar.gz gpt4free-f962993b8dac225d85f9fbb59be188e263af1c0b.tar.bz2 gpt4free-f962993b8dac225d85f9fbb59be188e263af1c0b.tar.lz gpt4free-f962993b8dac225d85f9fbb59be188e263af1c0b.tar.xz gpt4free-f962993b8dac225d85f9fbb59be188e263af1c0b.tar.zst gpt4free-f962993b8dac225d85f9fbb59be188e263af1c0b.zip |
Diffstat (limited to 'g4f/webdriver.py')
-rw-r--r-- | g4f/webdriver.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/g4f/webdriver.py b/g4f/webdriver.py index 288eed0e..f0fa1fba 100644 --- a/g4f/webdriver.py +++ b/g4f/webdriver.py @@ -4,6 +4,8 @@ import time from platformdirs import user_config_dir from selenium.webdriver.remote.webdriver import WebDriver from undetected_chromedriver import Chrome, ChromeOptions +import os.path +from . import debug try: from pyvirtualdisplay import Display @@ -19,12 +21,16 @@ def get_browser( ) -> WebDriver: if user_data_dir == None: user_data_dir = user_config_dir("g4f") + if debug.logging: + print("Open browser with config dir:", user_data_dir) if not options: options = ChromeOptions() - options.add_argument("window-size=1920,1080"); if proxy: options.add_argument(f'--proxy-server={proxy}') - return Chrome(options=options, user_data_dir=user_data_dir, headless=headless) + driver = '/usr/bin/chromedriver' + if not os.path.isfile(driver): + driver = None + return Chrome(options=options, user_data_dir=user_data_dir, driver_executable_path=driver, headless=headless) class WebDriverSession(): def __init__( |