3

I have been using a simple Python2.7 script using Selenium with Chromedriver to open a browser and download some files. Lately, I got an error saying that Chromedriver is outdated (Chrome version must be between 70 and 73) while my Chrome was ver. 75. So I downloaded ChromeDriver 75.0.3770.90 which should be OK for my Chrome version, but I got another error saying "selenium.common.exceptions.WebDriverException: Message: invalid argument: unrecognized capability: chromeOptions".

I have found some tips on the Internet saying that a way ChromeOptions should be used had changed, but I am unable to find how these changes exactly should look like in Python code. I'll be grateful for any helpful hint or solution.

def browser(full_url):

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    import time


    options = Options()
    options.add_experimental_option("prefs", {
      "download.default_directory": r"C:\Users\%s\AppData\Local\Temp\\" % getpass.getuser(),
      "download.prompt_for_download": False,
      "download.directory_upgrade": True,
      "safebrowsing.enabled": True
    })
    options.add_argument("--window-size=640,480")
    driver = webdriver.Chrome(chrome_options=options)



    try:
        driver.get(full_url)
        print("\nURL successfully Accessed\n")
        time.sleep(9)

    finally:
        driver.close()

browser(full_url)

Error I got:

Traceback (most recent call last):
  File "C:\Users\M\Documents\Skrypty\domains.py", line 59, in <module>
    browser(full_url)
  File "C:\Users\M\Documents\Skrypty\domains.py", line 46, in browser
    driver = webdriver.Chrome(chrome_options=options)
  File "C:\Python27\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__
    desired_capabilities=desired_capabilities)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 98, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 188, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 256, in execute
    self.error_handler.check_response(response)
  File "C:\Python27\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
miclis
  • 55
  • 1
  • 7

1 Answers1

3

Just me guessing here but I encountered this as well. I used Python 2.7 and Selenium 3.4.1. I couldn't replicate the problem with Python 3.7 and with Selenium 3.14.0. So the changes lie probably in the changed Selenium. You should look into that.

EDIT: Yeah I just updated Selenium (to 3.14.0) and the problem went away. Now I got the driver working with both Python 2.7 and 3.7

kermis
  • 31
  • 1