open chrome tab to a url with Selenium ChromeDriver

I’m creating an automation program and I have created a browser automation class that handles the automation and opening of the Chrome browser. I have split my code into two files which are main.py (containing all classes and methods) and automate.py (which uses the created classes and methods). Below is my source code for the two files.

I want to run the code so that the Chrome tab to opened automatically with the URL provided.

main.py

import sys
import logging
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
LOGGER = logging.getLogger()

class BrowserAutomation(object):
    def __init__(self, browser=None, time_out=1000):
        "A method to deal with browser opening"
        self.BASE_URL ="https://erita.rita.go.tz/auth"

        if not browser:
            browser = webdriver.Chrome(
                ChromeDriverManager().install(),
                options=self.chrome_options,
            )

            handles = browser.window_handles
            for _, handle in enumerate(handles):
                if handle != browser.current_window_handle:
                    browser.switch_to.window(handle)
                    browser.close()
        
        self.browser = browser
        self.wait = WebDriverWait(self.browser, time_out)
        self.cli()
        self.login()

    @property
    def chrome_options(self):
        chrome_options = Options()
        if sys.platform == "win32":
            chrome_options.add_argument("--profile-directory=Default")
            chrome_options.add_argument("--user-data-dir=C:/Temp/ChromeProfile")
        else:
            chrome_options.add_argument("start-maximized")
            chrome_options.add_argument("--user-data-dir=./User_Data")

        return chrome_options
    
    def cli(self):
        """
        LOGGER settings  [nCKbr]
        """
        handler = logging.StreamHandler()
        handler.setFormatter(
            logging.Formatter(
                "%(asctime)s - %(name)s -- [%(levelname)s] >> %(message)s"
            )
        )
        LOGGER.addHandler(handler)
        LOGGER.setLevel(logging.INFO)    
    

    def open_window(self):
        self.browser.get(self.BASE_URL)
        time.sleep(2)
        self.browser.maximize_window()

    def login(self):
        xpath = "/html/body/header/nav/div/div/div/button[2]"
        email = "/html/body/div[1]/main/div[2]/div[2]/div/div[2]/div/div/form/div[1]/div[2]/input"
        password = "/html/body/div[1]/main/div[2]/div[2]/div/div[2]/div/div/form/div[2]/div[2]/input"
        login = "/html/body/div[1]/main/div[2]/div[2]/div/div[2]/div/div/form/div[3]/div/button"
        signin_btn = self.wait.until(
            EC.presence_of_element_located(
                (
                    By.XPATH,
                    xpath,
                )
            )
        )
        signin_btn.click()

        email_field = self.wait.until(
            EC.presence_of_element_located(
                (
                    By.XPATH,
                    email,
                )
            )
        )
        time.sleep(2)
        email_field.send_keys("[email protected]")

        password_field = self.wait.until(
            EC.presence_of_element_located(
                (
                    By.XPATH,
                    password
                )
            )
        )
        password_field.send_keys("xxxx")

        login_btn = self.wait.until(
            EC.presence_of_element_located(
                (
                    By.XPATH,
                    login
                )
            )
        )
        login_btn.click()

automate.py

from main import BrowserAutomation

automate = BrowserAutomation()

But whenever I run the automate.py file I get the following error:

(venv) PS C:UsersAdministratorDesktope-ritaE-rita> python automate.py
Traceback (most recent call last):
  File "C:UsersAdministratorDesktope-ritaE-ritaautomate.py", line 3, in <module>
    automate = BrowserAutomation()
               ^^^^^^^^^^^^^^^^^^^
  File "C:UsersAdministratorDesktope-ritaE-ritamain.py", line 19, in __init__   
    browser = webdriver.Chrome(
              ^^^^^^^^^^^^^^^^^
TypeError: WebDriver.__init__() got multiple values for argument 'options'

What should I add or edit in my code for the chrome window to be open successfully?

1

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