haejeong87
haejeong87

Reputation: 957

Selenium ChromeDriver, cannot start Google Chrome with Extension loaded

I am working on creating automated tests for my Google Chrome Extension using Selenium 2.0 with:

  1. WebdriverJS + NodeJS
  2. ChromeDriver
  3. MacOSX 10.8.4

First, I wanted to test the installation process as well, but it doesn't seem possible to click the "Add" button when the installation dialog pops up using Selenium. (My other SO question about this).

Now, I changed my plan. Instead of installing the extension as part of the test drive, I want to start Chrome with my extension installed. But I have not been successful.

Please take a look at the code below:

var webdriver = require('selenium-webdriver'),
    chrome = require('selenium-webdriver/chrome');

var o = new chrome.Options();
o.addExtensions(['extensions/chrome/chrome_extension.zip']); // crx file is just a zip file
var s = new chrome.ServiceBuilder('bin/chromedriver').build();
var driver = chrome.createDriver(o, s)

When I run the code above, I get the following error: enter image description here

I've noticed that ChromeDriver loads a Chrome Extension called "Chrome Automation Extension 1" when it opens Chrome, so there must be a way to load another extension, either load it straight from the Webstore with the app ID, or load from local machine - packed or unpacked.

Any help would be greatly appreciated!

Upvotes: 0

Views: 6336

Answers (1)

Rob W
Rob W

Reputation: 348972

Make sure that "manifest.json" is at the root of your zip file. It's a common error to accidentally zip the extension's directory instead of the extension files.

Using zip:

cd path/to/extension
zip -ur ../chrome_extension.zip *

Using 7-zip:

cd path/to/extension
7z u -tzip ../chrome-extension.zip *

Upvotes: 5

Related Questions