Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ sahipro.com with your query.

Sahi OS 5.0 and Chrome: --user-data-dir containing spaces not working

Hello,
I am wondering how I can start Chrome with a user data dir which contains spaces. The problem is that padding the path into quotes does not work:

Start FF on the cmd:
C:\Program Files (x86)\Mozilla Firefox>firefox.exe -profile "c:/foo bar/ff/"

Start Chrome on the cmd:
C:\Program Files (x86)\Google\Chrome\Application>chrome.exe --user-data-dir="C:/foo bar/chrome/"

Both URLs about:support and chrome/version proove that the profile path is set as desired. The same definition in browser_types.xml:

<browserType>
<name>firefox</name>
<displayName>Firefox</displayName>
<icon>firefox.png</icon>
<path>$ProgramFiles (x86)\Mozilla Firefox\firefox.exe</path>
<options>-profile "c:/foo bar/ff/" -no-remote</options>
<processName>firefox.exe</processName>
<capacity>5</capacity>
</browserType>

<browserType>
<name>chrome</name>
<displayName>Chrome</displayName>
<icon>chrome.png</icon>
<path>$ProgramFiles (x86)\Google\Chrome\Application\chrome.exe</path>
<options>--user-data-dir="C:/foo bar/chrome/" --no-default-browser-check --no-first-run --disable-infobars --proxy-server=localhost:9999 --disable-popup-blocking</options>
<processName>chrome.exe</processName>
<capacity>5</capacity>
</browserType>

The result is that Firefox starts as expected with "c:/foo bar/ff" as profile folder.
But Chrome open _TWO_ tabs, the second one showing Sahi start page, but the first tab opens "file:///C:/foo%20bar/chrome/".

For testing purppses, I wrote a small bat wrapper which takes all arguments (including the chrome.exe call), prints them into a file and calls afterwards the argument string (= chrome start). Instead of chrome.exe, I am calling the wrapper in browser_types.xml.

Result: The arguments written to file are not the same as logged by Sahi: after "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" the first argument is "C:/foo bar/chrome/", which is interpreted by chrome as the first page to open. The parameter --user-data-dir is missing COMPLETELY.

Can someone confirm this behaviour please?

Thanks & regards,

Simon

Sahi OS 5.0
Windows 7 Pro
Java 1.8
Chrome 48

Answers

  • tschnecktschneck Members
    edited February 2016
  • Due to the fact, the parsing of the sahi method net.sf.sahi.util.Utils#getCommandTokens(String)} won't work correctly, the method remove the prefix '--user-data-dir' and chrome get only the location as argument. Unfortunately the Logger logs the command before this behavior will happen.

    In my opinion it would be better to use the Apache Library 'org.apache.commons.exec' with the class CommandLine#parse(String) to parse and execute native commands. Maybe this hint will help to fix the issue.
Sign In or Register to comment.