python – Selenium webdriver error : ‘NoneType’ object has no attribute ‘to_capabilities’

I am trying to run the following lines of code on Python, but I am thrown the error :

” Cell In[11], line 10
driver = webdriver.Remote(service.service_url,options)

File ~/anaconda3/envs/algo/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py:189 in init
capabilities = options.to_capabilities()

AttributeError: ‘NoneType’ object has no attribute ‘to_capabilities'”

Would be very helpful if anyone can share thoughts on resolving this!

Code:

    token_path = "api_key.txt"
    key_secret = open(token_path,'r').read().split()
    kite = KiteConnect(api_key = key_secret[0])
    service = webdriver.chrome.service.Service('./chromedriver')
    service.start()
    options = webdriver.ChromeOptions()
    options = options.to_capabilities()
    driver = webdriver.Remote(service.service_url,options)
    driver.get(kite.login_url())

Read more here: Source link