How to open a specific Chrome profile using Webdriver.io?

Viewed 1975

I'm using webdriver.io to open a browser instance using a node script. The browser opens but it's ignoring some of the options defined in the desiredCapabilities object. This is the configuration that I have right now:

const path = require('path');
const webdriver = require('webdriverio');

const INIT_URL = 'http://www.google.ca';

const options = {
  desiredCapabilities: {
    browserName: 'chrome',
    applicationCacheEnabled: false,
    chromeOptions: {
      args: [
        'disable-web-security',
        'allow-running-insecure-content',
        'auto-open-devtools-for-tabs',
        'user-data-dir=/Users/david/Library/Application\ Support/Google/Chrome/Profile\ 2'
      ]
    }
  }
};

const browser = webdriver
  .remote(options)
  .init()
  .url(INIT_URL);

All the options seems to be working except user-data-dir. The browser instance opens but is not using the provided profile.

Is there a way to configure Selenium with Webdriver.io (NodeJS) to select a specific browser profile that actually works?

Update

By @FlorentB. recommendation I've tried double quotes and double backslash with no success like this:

  • 'user-data-dir="/Users/david/Library/Application\ Support/Google/Chrome/Profile\ 2"'
  • 'user-data-dir=/Users/david/Library/Application\\ Support/Google/Chrome/Profile\\ 2'

But I also notice that when I see the available profiles of the Chrome instance open by Selenium the list is empty:

Empty profile list

But when I open a normal instance of Chrome (manually, without Selenium) I do see my both available profiles:

Normal profile list

1 Answers
Related