1

I've been stuck for days because of this issue and can't seem to find a solution. I can't get the chromedriver to work on my machine, no matter what I do. I've tried pretty much every setup I could possibly imagine. To list a few:

  • Chrome 64 bits, Python 64 bits
  • Chrome 32 bits, Python 32 bits
  • Chrome 64 bits, Python 32 bits
  • Chrome 32 bits, Python 64 bits

I've also tried different versions of Chrome with their corresponding chromedriver versions. I've tried different prior versions of selenium, and that is, on every previously mentioned setups.

For an actual context, here's my current setup:

  • Windows 10 Professional x64
  • Python 3.6.3 64 bits
  • Selenium 3.7.0
  • Google Chrome 62.0.3202.75 64 bits
  • Chromedriver 2.33

I will not post my code as no matter which code I use, it fails. Even the simplest most basic code that launches a chromedriver will not work. Also, it works on my colleague's machine. So to give some context, here's a code snippet I've tried that doesn't work:

from selenium import webdriver

webdriver.Chrome(executable_path="bin/chromedriver.exe")

I've also tried to add the chromedriver to my PATH and launching the chromedriver with no arguments but this doesn't work either.

The error I'm getting is this one:

selenium.common.exceptions.WebDriverException: Message: unknown error: chrome failed to start
  (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.15063 x86_64)

And here's the log that gets generated if I launch the driver with the verbose/logging parameters:

[1.979][INFO]: COMMAND InitSession {
   "capabilities": {
      "alwaysMatch": {
         "browserName": "chrome",
         "goog:chromeOptions": {
            "args": [  ],
            "extensions": [  ]
         },
         "platformName": "any"
      },
      "firstMatch": [ {

      } ]
   },
   "desiredCapabilities": {
      "browserName": "chrome",
      "goog:chromeOptions": {
         "args": [  ],
         "extensions": [  ]
      },
      "platform": "ANY",
      "version": ""
   }
}
[1.985][INFO]: Populating Preferences file: {
   "alternate_error_pages": {
      "enabled": false
   },
   "autofill": {
      "enabled": false
   },
   "browser": {
      "check_default_browser": false
   },
   "distribution": {
      "import_bookmarks": false,
      "import_history": false,
      "import_search_engine": false,
      "make_chrome_default_for_user": false,
      "show_welcome_page": false,
      "skip_first_run_ui": true
   },
   "dns_prefetching": {
      "enabled": false
   },
   "profile": {
      "content_settings": {
         "pattern_pairs": {
            "https://*,*": {
               "media-stream": {
                  "audio": "Default",
                  "video": "Default"
               }
            }
         }
      },
      "default_content_setting_values": {
         "geolocation": 1
      },
      "default_content_settings": {
         "geolocation": 1,
         "mouselock": 1,
         "notifications": 1,
         "popups": 1,
         "ppapi-broker": 1
      },
      "password_manager_enabled": false
   },
   "safebrowsing": {
      "enabled": false
   },
   "search": {
      "suggest_enabled": false
   },
   "translate": {
      "enabled": false
   }
}
[1.989][INFO]: Populating Local State file: {
   "background_mode": {
      "enabled": false
   },
   "ssl": {
      "rev_checking": {
         "enabled": false
      }
   }
}
[2.004][INFO]: Cannot switch to US keyboard layout - some keys may be interpreted incorrectly
[2.004][INFO]: Launching chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-background-networking --disable-browser-side-navigation --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-automation --enable-logging --force-fieldtrials=SiteIsolationExtensions/Control --ignore-certificate-errors --load-extension="C:\Users\OLIVIE~1.VER\AppData\Local\Temp\scoped_dir9668_31484\internal" --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12606 --safebrowsing-disable-auto-update --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\OLIVIE~1.VER\AppData\Local\Temp\scoped_dir9668_609" data:,
[2.035][INFO]: RESPONSE InitSession unknown error: chrome failed to start
[2.035][DEBUG]: Log type 'driver' lost 0 entries on destruction
[2.035][DEBUG]: Log type 'browser' lost 0 entries on destruction

I've had a look at pretty much every similar questions I could find, like this one, and this one for example, and none of the solutions I've came across helped, it's always the same error I get. I've been having the same error with the dozen of different setups I've tried.

A few months ago I remember I successfully ran the chromedriver for another project on the same machine.

I think I've provided all the necessary information, but don't hesitate to ask me in comments if I forgot something.

Thanks

Verv
  • 2,385
  • 2
  • 23
  • 37
  • What's the selenium version? – Davide Patti Nov 06 '17 at 21:00
  • @DavidePatti latest from a fresh `pip install`, so that would be `selenium 3.7.0`. I admit I didn't think about trying other versions of selenium yet. – Verv Nov 06 '17 at 21:07
  • Alright, I tried selenium `3.6.0` and `3.5.0` and it's still the same error every time. – Verv Nov 06 '17 at 21:16
  • In the error it states that it's launching `chrome.exe` and not `chromedriver.exe`... is that normal? I would have expected `chromedriver.exe`. Are you sure your path to the exe is correct? – JeffC Nov 06 '17 at 22:24

2 Answers2

2

The error says it all Cannot switch to US keyboard layout - some keys may be interpreted incorrectly. This error have introduced some more errors as:

[2.035][INFO]: RESPONSE InitSession unknown error: chrome failed to start
[2.035][DEBUG]: Log type 'driver' lost 0 entries on destruction
[2.035][DEBUG]: Log type 'browser' lost 0 entries on destruction

So basically this error is not of Selenium or Chrome as such.

Here are the 3 best possible solutions to your problem.


Update :

As you have got rid of the error Cannot switch to US keyboard layout - some keys may be interpreted incorrectly but you still see WebDriverException: Message: unknown error: chrome failed to start follow the steps as below :

  1. Uninstall Chrome through Revo Uninstaller with Moderate Memory Scan so that the unwanted registry entries are cleared.
  2. Run CCleaner tool before and after executing your Tests to wipe off all the OS chores.
  3. Reboot your system.
  4. Execute your Test as:

    driver=webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe')
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    I've tried and now I no longer get the `Cannot switch to US keyboard layout - some keys may be interpreted incorrectly` error in the output log but, other than this line being gone, the log is exactly the same, and the error when launching chromedriver remains the same as well. – Verv Nov 07 '17 at 15:33
  • Also I'm not really sure how the keyboard layout would prevent the driver from launching at all like this. – Verv Nov 07 '17 at 15:39
  • Well, after doing this I can't even install Chrome anymore. The installer throws an error saying I already have Chrome installed on this machine and that I should uninstall it first, yet I can't find the slightest trace of it on my machine.... great – Verv Nov 07 '17 at 18:22
  • @Verv That's great !!! So now we have found out the core issue. Let's solve this for once & for ever. – undetected Selenium Nov 07 '17 at 18:26
  • @Verv Did you take help of Revo Uninstaller & CCleaner before taking the Reboot? – undetected Selenium Nov 07 '17 at 18:29
  • Yes. After the reboot I tried to install Chrome and got this error. – Verv Nov 07 '17 at 18:30
  • @Verv I suppose it's the undeleted Registry Key which is creating all the chaos. Try to search for registry entries with the word `chrome` and delete all those entries. But these leftovers should have been caught either by Revo or CCleaner I suppose. – undetected Selenium Nov 07 '17 at 18:58
  • I've deleted everything I could find that had either Google or Chrome in it's name and still have the same issue... – Verv Nov 07 '17 at 19:10
  • @Verv Keep Team Viewer v12.0 installed on your system. Tomorrow morning my time share your PC let me see if I can pull out something. As a last attempt try to clean the registry with CCleaner. – undetected Selenium Nov 07 '17 at 19:18
  • Finally got it to work! Your answer wasn't the full solution but it still ended up leading me to the actual solution (see my posted answer). Have a +1, thanks. – Verv Nov 07 '17 at 19:50
1

I ended up going through an endless amount of different solutions with no results, but what seemed to really fix it in the end was the following:

  • Uninstall Chrome
  • Go through Windows Registry and delete every keys named {8A69D345-D564-463C-AFF1-A69D9E530F96}
  • Reinstall Chrome

I ended up getting to this solution after following the solution from DebanjanB's answer and couldn't install Chrome anymore. Searching about this new issue led me to find this post.

Remember to backup your registry before doing this.

After doing this I was able to reinstall Chrome and run the chromedriver.

Verv
  • 2,385
  • 2
  • 23
  • 37