Selenium not starting portable chrome but local installation

For anyone else stumbling upon this problem, here is how I managed to get the portable Chrome starting:

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary(binaryPath);
driver = new ChromeDriver(chromeOptions);

  String chromePath = "M:/my/googlechromeporatble.exe path"; 
  String chromedriverpath="M:/my/chromedriver.exe path";
  ChromeOptions options = new ChromeOptions();
  options.setBinary(chromepath);
  System.setProperty("webdriver.chrome.driver",chromedriverpath);              
  driver = new ChromeDriver(options);

This will invoke portable chrome rather than local installation. First set google chrome portable path and then invoke chromeriver.exe


I'm using Python 3.7 on Windows 10 and got Chrome Portable from PortableApps.com.

comments by @mario.schlipf and @SeJaPy were helpful, but I noticed that in the newer Webdriver releases, the setbinary method has been replaced by binary_location

This is how it actually worked for me:

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

chromedriverpath='M:/my/chromedriver.exe'
chromePath = 'M:/my/App/Chrome-bin/chrome.exe'    #  <==  IMPORTANT! See note below.

chromeoptions = Options()
chromeoptions.add_argument('--incognito')
chromeoptions.binary_location = chromePath   

browser = webdriver.Chrome(executable_path=chromedriverpath, options=chromeoptions)

NOTE:

The chromePath variable must point to the Chrome executable in the portabilized environment.

In packages obtained from PortableApps.com, you have two executables: a GoogleChromePortable.exe in the install (actually, unpack) directory and a chrome.exe in [installdirectory]/App/Chrome-bin, the first being "just" a launcher which provides the portabilized app with a consistent environment.

As I could observe, chromedriver needs to directly interact with the "real" Chrome executable, otherwise the script will launch the browser (via the launcher) but will eventually crash with error message:

unknown error: DevTools Active Port file doesn't exist

and no browser session will be returned as a result.

This may seem obvious to many people... but it was not to me, so I decided to put this note in order to make some clarity for the less clever guys (me included) :).