Selenium Scraper Issue “WebDriver.__init__() got an unexpected keyword argument ‘executable_path'”

I am encountering an error when trying to use Selenium with Scrapy. The error message is: WebDriver.init() got an unexpected keyword argument ‘executable_path’

I am using a custom middleware in middlewares.py where I only use the executable_path keyword argument in one spot. According to the Selenium documentation, this is a valid argument and should be used as shown below:

class selenium.webdriver.chrome.service.Service(
    executable_path=None,
    port: int = 0,
    service_args: List[str] | None = None,
    log_output: int | str | IO[Any] | None = None,
    env: Mapping[str, str] | None = None,
    **kwargs
)[source]

Here is the relevant section of my middlewares.py:

from scrapy import signals
from scrapy_selenium import SeleniumMiddleware
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.chrome.options import Options

class CustomSeleniumMiddleware(SeleniumMiddleware):
    @classmethod
    def from_crawler(cls, crawler):
        settings = crawler.settings
        driver_name = settings.get('SELENIUM_DRIVER_NAME')
        driver_executable_path = settings.get('SELENIUM_DRIVER_EXECUTABLE_PATH')
        driver_arguments = settings.get('SELENIUM_DRIVER_ARGUMENTS', [])
        browser_executable_path = settings.get('SELENIUM_BROWSER_EXECUTABLE_PATH', None)

        options = Options()
        for argument in driver_arguments:
            options.add_argument(argument)

        service = ChromeService(executable_path=driver_executable_path)
        driver = webdriver.Chrome(service=service, options=options)

        middleware = cls(driver_name, driver_executable_path, driver_arguments, browser_executable_path, driver)
        crawler.signals.connect(middleware.spider_closed, signal=signals.spider_closed)
        return middleware

    def __init__(self, driver_name, driver_executable_path, driver_arguments, browser_executable_path, driver):
        self.driver = driver
        super().__init__(driver_name, driver_executable_path, driver_arguments, browser_executable_path)

    @staticmethod
    def create_options(arguments):
        chrome_options = Options()
        for argument in arguments:
            chrome_options.add_argument(argument)
        return chrome_options

Based on the Selenium documentation, I expected that using the executable_path keyword argument would correctly set up the Chrome service. However, I am getting the error that it is an unexpected keyword argument.

Here are the steps I have tried so far:

Verified the ChromeService class from Selenium documentation, which indicates that executable_path is a valid argument.
Ensured that the executable_path provided is correct and points to the chromedriver executable.
Updated Selenium to the latest version to ensure compatibility.
Despite these steps, I am still encountering the error. I am not sure if I am misinterpreting the documentation or if there is an issue elsewhere in my code or environment setup.

Any help in resolving this issue would be greatly appreciated.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật