0

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!

4

1 回答 1

3

确保“manifest.json”位于 zip 文件的根目录中。意外压缩扩展的目录而不是扩展文件是一个常见错误。

使用zip

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

使用7-zip

cd path/to/extension
7z u -tzip ../chrome-extension.zip *
于 2013-08-31T21:23:26.570 回答