Skip to content

Commit

Permalink
feat(PhantomJS): add support for PhantomJS
Browse files Browse the repository at this point in the history
Support for PhantomJS from pull request #2 from erlswtshrt/master
  • Loading branch information
John Earle authored and felixzapata committed Aug 26, 2016
1 parent 7aff463 commit 14986b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ var reporter = require('./lib/reporter');
var PLUGIN_NAME = 'gulp-axe-core';
require('chromedriver');

//setup custom phantomJS capability
const phantomjs_exe = require('phantomjs-prebuilt').path;
var customPhantom = WebDriver.Capabilities.phantomjs();
customPhantom.set("phantomjs.binary.path", phantomjs_exe);

var promise;
var results = [];

Expand All @@ -24,22 +29,23 @@ module.exports = function (customOptions) {
};

var options = customOptions ? Object.assign(defaultOptions, customOptions) : defaultOptions;
var driver = new WebDriver.Builder().forBrowser(options.browser).build();
var driver = options.browser === 'phantomjs' ? new WebDriver.Builder().withCapabilities(customPhantom).build() :
new WebDriver.Builder().forBrowser(options.browser).build();

var createResults = function(cb) {

var dest = '';
if(options.saveOutputIn !== '') {
dest = path.join(options.folderOutputReport, options.saveOutputIn);
fs.writeFileSync(dest, JSON.stringify(results, null, ' '));
}
driver.quit();
cb();

};

var bufferContents = function (file, enc, cb) {

if (file.isNull()) {
cb(null, file);
return;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"file-url": "^1.1.0",
"fs-extra": "^0.30.0",
"fs-path": "0.0.22",
"phantomjs-prebuilt": "^2.1.12",
"promise": "^7.1.1",
"selenium-webdriver": "^2.53.3",
"through2": "^0.6.5"
Expand Down

0 comments on commit 14986b1

Please sign in to comment.