From 6a51672164d7308d5b7c0700f9916b94e555096b Mon Sep 17 00:00:00 2001 From: Arjun Aravindan Date: Tue, 29 Aug 2023 22:45:18 -0400 Subject: [PATCH] Update SeleniumURLLoader to use webdriver Service in favor of deprecated executable_path parameter (#9814) Description: This commit uses the new Service object in Selenium webdriver as executable_path has been [deprecated and removed in selenium version 4.11.2](https://github.com/SeleniumHQ/selenium/commit/9f5801c82fb3be3d5850707c46c3f8176e3ccd8e) Issue: https://github.com/langchain-ai/langchain/issues/9808 Tag Maintainer: @eyurtsev --- .../langchain/document_loaders/url_selenium.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/langchain/langchain/document_loaders/url_selenium.py b/libs/langchain/langchain/document_loaders/url_selenium.py index e47da8b5fc7..a4419c8b866 100644 --- a/libs/langchain/langchain/document_loaders/url_selenium.py +++ b/libs/langchain/langchain/document_loaders/url_selenium.py @@ -74,6 +74,7 @@ class SeleniumURLLoader(BaseLoader): if self.browser.lower() == "chrome": from selenium.webdriver import Chrome from selenium.webdriver.chrome.options import Options as ChromeOptions + from selenium.webdriver.chrome.service import Service chrome_options = ChromeOptions() @@ -87,10 +88,14 @@ class SeleniumURLLoader(BaseLoader): chrome_options.binary_location = self.binary_location if self.executable_path is None: return Chrome(options=chrome_options) - return Chrome(executable_path=self.executable_path, options=chrome_options) + return Chrome( + options=chrome_options, + service=Service(executable_path=self.executable_path), + ) elif self.browser.lower() == "firefox": from selenium.webdriver import Firefox from selenium.webdriver.firefox.options import Options as FirefoxOptions + from selenium.webdriver.firefox.service import Service firefox_options = FirefoxOptions() @@ -104,7 +109,8 @@ class SeleniumURLLoader(BaseLoader): if self.executable_path is None: return Firefox(options=firefox_options) return Firefox( - executable_path=self.executable_path, options=firefox_options + options=firefox_options, + service=Service(executable_path=self.executable_path), ) else: raise ValueError("Invalid browser specified. Use 'chrome' or 'firefox'.")