forked from kinoshitakenta/auto_login_EIP
feat: automates ChromeDriver management
Updates the ChromeDriver setup to use `webdriver_manager` instead of relying on a local executable. This ensures the correct ChromeDriver version is automatically downloaded and managed, improving reliability and reducing manual configuration. Removes the now unnecessary `chromedriver.exe` from the `.gitignore` file.
This commit is contained in:
parent
f66cf7aeac
commit
0b80ee79b1
|
@ -1,9 +1,6 @@
|
||||||
# module cache
|
# module cache
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|
||||||
# selenium driver
|
|
||||||
chromedriver.exe
|
|
||||||
|
|
||||||
# log file
|
# log file
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.chrome.service import Service
|
from selenium.webdriver.chrome.service import Service
|
||||||
from selenium.webdriver.chrome.webdriver import WebDriver
|
from selenium.webdriver.chrome.webdriver import WebDriver
|
||||||
|
from webdriver_manager.chrome import ChromeDriverManager
|
||||||
|
|
||||||
|
|
||||||
def get_driver() -> WebDriver:
|
def get_driver() -> WebDriver:
|
||||||
service = Service(executable_path='./chromedriver.exe')
|
|
||||||
|
|
||||||
options = webdriver.ChromeOptions()
|
options = webdriver.ChromeOptions()
|
||||||
# options.add_argument("--headless")
|
# options.add_argument("--headless")
|
||||||
options.add_argument('--disable-gpu')
|
options.add_argument('--disable-gpu')
|
||||||
options.add_experimental_option('excludeSwitches', ['enable-logging'])
|
options.add_experimental_option('excludeSwitches', ['enable-logging'])
|
||||||
driver = webdriver.Chrome(service=service, options=options)
|
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
|
||||||
driver.implicitly_wait(4)
|
driver.implicitly_wait(4)
|
||||||
|
|
||||||
return driver
|
return driver
|
||||||
|
|
Loading…
Reference in New Issue