mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
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](9f5801c82f
)
Issue: https://github.com/langchain-ai/langchain/issues/9808
Tag Maintainer: @eyurtsev
This commit is contained in:
parent
c844aaa7a6
commit
6a51672164
@ -74,6 +74,7 @@ class SeleniumURLLoader(BaseLoader):
|
|||||||
if self.browser.lower() == "chrome":
|
if self.browser.lower() == "chrome":
|
||||||
from selenium.webdriver import Chrome
|
from selenium.webdriver import Chrome
|
||||||
from selenium.webdriver.chrome.options import Options as ChromeOptions
|
from selenium.webdriver.chrome.options import Options as ChromeOptions
|
||||||
|
from selenium.webdriver.chrome.service import Service
|
||||||
|
|
||||||
chrome_options = ChromeOptions()
|
chrome_options = ChromeOptions()
|
||||||
|
|
||||||
@ -87,10 +88,14 @@ class SeleniumURLLoader(BaseLoader):
|
|||||||
chrome_options.binary_location = self.binary_location
|
chrome_options.binary_location = self.binary_location
|
||||||
if self.executable_path is None:
|
if self.executable_path is None:
|
||||||
return Chrome(options=chrome_options)
|
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":
|
elif self.browser.lower() == "firefox":
|
||||||
from selenium.webdriver import Firefox
|
from selenium.webdriver import Firefox
|
||||||
from selenium.webdriver.firefox.options import Options as FirefoxOptions
|
from selenium.webdriver.firefox.options import Options as FirefoxOptions
|
||||||
|
from selenium.webdriver.firefox.service import Service
|
||||||
|
|
||||||
firefox_options = FirefoxOptions()
|
firefox_options = FirefoxOptions()
|
||||||
|
|
||||||
@ -104,7 +109,8 @@ class SeleniumURLLoader(BaseLoader):
|
|||||||
if self.executable_path is None:
|
if self.executable_path is None:
|
||||||
return Firefox(options=firefox_options)
|
return Firefox(options=firefox_options)
|
||||||
return Firefox(
|
return Firefox(
|
||||||
executable_path=self.executable_path, options=firefox_options
|
options=firefox_options,
|
||||||
|
service=Service(executable_path=self.executable_path),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise ValueError("Invalid browser specified. Use 'chrome' or 'firefox'.")
|
raise ValueError("Invalid browser specified. Use 'chrome' or 'firefox'.")
|
||||||
|
Loading…
Reference in New Issue
Block a user