Skip to content

Commit

Permalink
Update web_selenium.py
Browse files Browse the repository at this point in the history
using Fukol's 'if' from Significant-Gravitas#1641 (comment)
  • Loading branch information
dpicassom authored Apr 24, 2023
1 parent 91537b0 commit c4081b6
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions autogpt/commands/web_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,29 @@ def scrape_text_with_selenium(url: str) -> tuple[WebDriver, str]:
)

if CFG.selenium_web_browser == "firefox":
driver = webdriver.Firefox(
executable_path=GeckoDriverManager().install(), options=options
)
elif CFG.selenium_web_browser == "safari":
# 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)
else:
if platform == "linux" or platform == "linux2":
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--remote-debugging-port=9222")

options.add_argument("--no-sandbox")
if CFG.selenium_headless:
options.add_argument("--headless")
options.add_argument("--disable-gpu")

driver = webdriver.Chrome(
executable_path=ChromeDriverManager().install(), options=options
)
driver.get(url)
driver = webdriver.Firefox(
executable_path=GeckoDriverManager().install(), options=options
)
elif CFG.selenium_web_browser == "safari":
# 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)
else:

options.add_argument("--disable-dev-shm-usage")
options.add_argument("--remote-debugging-port=9222")
options.add_argument("--no-sandbox")
options.add_argument("--headless")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--ignore-ssl-errors=true")
options.add_argument("--ignore-certificate-errors")
options.binary_location = "F:\Program Files\Google\Chrome\Application\chrome.exe"
driver = webdriver.Chrome(
#executable_path=ChromeDriverManager().install(), options=options
executable_path="F:\user\Downloads\chromedriver_win32\chromedriver.exe", options=options

)
driver.get(url)

WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.TAG_NAME, "body"))
Expand Down

0 comments on commit c4081b6

Please sign in to comment.