feat: allow to provide the driver and options to be used by Selenium (#316)

This commit is contained in:
Lucas Gomide
2025-05-30 09:13:11 -03:00
committed by GitHub
parent 5d5377cfb9
commit 72b3a8c70a
2 changed files with 29 additions and 8 deletions

View File

@@ -91,9 +91,16 @@ class SeleniumScrapingTool(BaseTool):
"`selenium` and `webdriver-manager` package not found, please run `uv add selenium webdriver-manager`"
)
options: Options = Options()
options.add_argument("--headless")
self.driver = webdriver.Chrome(options=options)
if 'driver' not in kwargs:
if 'options' not in kwargs:
options: Options = Options()
options.add_argument("--headless")
else:
options = kwargs['options']
self.driver = webdriver.Chrome(options=options)
else:
self.driver = kwargs['driver']
self._by = By
if cookie is not None:
self.cookie = cookie