diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-01-26 12:49:52 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-01-26 12:49:52 +0100 |
commit | 1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b (patch) | |
tree | 845e5d27d9f94c16215da60aaee0ad36f5a35344 /g4f/webdriver.py | |
parent | New minimum requirements (#1515) (diff) | |
download | gpt4free-1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b.tar gpt4free-1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b.tar.gz gpt4free-1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b.tar.bz2 gpt4free-1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b.tar.lz gpt4free-1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b.tar.xz gpt4free-1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b.tar.zst gpt4free-1eb7dc05e59433de149ec16d9b2fe19b3fa4b24b.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/webdriver.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/g4f/webdriver.py b/g4f/webdriver.py index d2009ddc..66b3956e 100644 --- a/g4f/webdriver.py +++ b/g4f/webdriver.py @@ -3,13 +3,15 @@ from __future__ import annotations try: from platformdirs import user_config_dir from selenium.webdriver.remote.webdriver import WebDriver + from selenium.webdriver.remote.webelement import WebElement from undetected_chromedriver import Chrome, ChromeOptions from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC + from selenium.webdriver.common.keys import Keys has_requirements = True except ImportError: - WebDriver = type + from typing import Type as WebDriver has_requirements = False from os import path @@ -197,4 +199,9 @@ class WebDriverSession: print(f"Error closing WebDriver: {e}") self.default_driver.quit() if self.virtual_display: - self.virtual_display.stop()
\ No newline at end of file + self.virtual_display.stop() + +def element_send_text(element: WebElement, text: str) -> None: + script = "arguments[0].innerText = arguments[1]" + element.parent.execute_script(script, element, text) + element.send_keys(Keys.ENTER)
\ No newline at end of file |