3

This is my code

from selenium import webdriver
driver = webdriver.Chrome('C:\chromedriver_win32\chromedriver')
driver.get('http://google.com')

And this is an error message.

Traceback (most recent call last):
  File "D:/project/Python/TEST_selenium/chromedriver_test.py", line 16, in <module>
    driver = webdriver.Chrome(executable_path="C:\chromedriver_win32\chromedriver",chrome_options=chrome_options)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__
    desired_capabilities=desired_capabilities)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 98, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 188, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 256, in execute
    self.error_handler.check_response(response)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: invalid argument: unrecognized capability: chromeOptions

I can't figure out why an error occurs in this simple code.

This code worked a month ago. But it doesn't work now.

I've updated both chrome and chrome drivers but that doesn't fix the problem.

My chrome and chrome driver version is 77.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
고니고니
  • 33
  • 1
  • 4
  • 1
    .exe is required since you are on a Windows machine, be sure to have downloaded the Windows chromedriver binaries and not the Linux ones. – Marco D.G. Sep 18 '19 at 15:43

3 Answers3

8

Welcome to SO!

From your question, I would guess that your selenium version is out of date. I believe that going to Chrome driver 77 updated the launch behaviour.

Try pip install -U selenium and see if that resolves your issue.

zglin
  • 2,891
  • 2
  • 15
  • 26
0

Try adding your ChromeDriver.exe to the folder where you have the project or try only driver = webdriver.Chrome()

Esteban
  • 3
  • 5
0

This error message...

selenium.common.exceptions.WebDriverException: Message: invalid argument: unrecognized capability: chromeOptions

...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session due to unrecognized chromeOptions.

You need to take care of a couple of things as follows:

Your working code will be:

from selenium import webdriver

driver = webdriver.Chrome(executable_path=r'C:\chromedriver_win32\chromedriver.exe')
driver.get('http://google.com')
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352