diff --git a/lib/dalek/actions.js b/lib/dalek/actions.js index e4413b2..f92aa8f 100644 --- a/lib/dalek/actions.js +++ b/lib/dalek/actions.js @@ -27,6 +27,7 @@ var Q = require('q'); var uuid = require('./uuid'); var cheerio = require('cheerio'); +var urlParser = require('url'); // int. global var reporter = null; @@ -170,10 +171,15 @@ Actions.prototype.mouseEvent = function (type, selector) { * @return {Actions} */ -Actions.prototype.setHttpAuth = function (username, password) { - var hash = uuid(); - var cb = this._generateCallbackAssertion('setHttpAuth', 'setHttpAuth', username, password, hash); - this._addToActionQueue([username, password, hash], 'setHttpAuth', cb); +Actions.prototype.setHttpAuth = function (username, password, location) { + if(username !== '' || password !== ''){ + var tmpUrl = urlParser.parse(location); + tmpUrl.auth = username + ':' + password; + location = urlParser.format(tmpUrl); + var hash = uuid(); + var cb = this._generateCallbackAssertion('open', 'open', location, hash); + this._addToActionQueue([location, hash], 'open', cb); + } return this; };