Skip to content

Commit

Permalink
Add Edge browser support using EdgeChromiumDriverManager (#3058)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicholas Tindle <nick@ntindle.com>
Co-authored-by: k-boikov <64261260+k-boikov@users.noreply.github.com>
  • Loading branch information
3 people authored May 13, 2023
1 parent 2f7beeb commit b958386
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ OPENAI_API_KEY=your-openai-api-key
### BROWSER
## HEADLESS_BROWSER - Whether to run the browser in headless mode (default: True)
## USE_WEB_BROWSER - Sets the web-browser driver to use with selenium (default: chrome).
## Note: set this to either 'chrome', 'firefox', or 'safari' depending on your current browser
## Note: set this to either 'chrome', 'firefox', 'safari' or 'edge' depending on your current browser
# HEADLESS_BROWSER=True
# USE_WEB_BROWSER=chrome
## BROWSE_CHUNK_MAX_LENGTH - When browsing website, define the length of chunks to summarize (in number of tokens, excluding the response. 75 % of FAST_TOKEN_LIMIT is usually wise )
Expand Down
7 changes: 7 additions & 0 deletions autogpt/commands/web_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.common.by import By
from selenium.webdriver.edge.options import Options as EdgeOptions
from selenium.webdriver.firefox.options import Options as FirefoxOptions
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.safari.options import Options as SafariOptions
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.firefox import GeckoDriverManager
from webdriver_manager.microsoft import EdgeChromiumDriverManager

import autogpt.processing.text as summary
from autogpt.commands.command import command
Expand Down Expand Up @@ -78,6 +80,7 @@ def scrape_text_with_selenium(url: str) -> tuple[WebDriver, str]:
"chrome": ChromeOptions,
"safari": SafariOptions,
"firefox": FirefoxOptions,
"edge": EdgeOptions,
}

options = options_available[CFG.selenium_web_browser]()
Expand All @@ -96,6 +99,10 @@ def scrape_text_with_selenium(url: str) -> tuple[WebDriver, str]:
# Requires a bit more setup on the users end
# See https://developer.apple.com/documentation/webkit/testing_with_webdriver_in_safari
driver = webdriver.Safari(options=options)
elif CFG.selenium_web_browser == "edge":
driver = webdriver.Edge(
executable_path=EdgeChromiumDriverManager().install(), options=options
)
else:
if platform == "linux" or platform == "linux2":
options.add_argument("--disable-dev-shm-usage")
Expand Down

0 comments on commit b958386

Please sign in to comment.