Comparing version 0.0.26 to 0.0.27
@@ -1,2 +0,3 @@ | ||
var code = arguments[0], args = arguments[1], done = arguments[2]; | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
var code = args[0], fargs = args[1], done = args[2]; | ||
var wrap = function() { | ||
@@ -6,3 +7,3 @@ return eval(code); | ||
args.push(done); | ||
return wrap.apply(this, args); | ||
fargs.push(done); | ||
wrap.apply(this, fargs); |
@@ -1,7 +0,8 @@ | ||
var code = arguments[0], args = arguments[1]; | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
var code = args[0], fargs = args[1]; | ||
var wrap = function() { | ||
return eval(code); | ||
} | ||
}; | ||
return wrap.apply(this, args); | ||
return wrap.apply(this, fargs); |
@@ -1,7 +0,5 @@ | ||
// run in the browser | ||
var args = Array.prototype.slice.call(arguments, 0); | ||
var condExpr = args[0], timeout = args[1], | ||
poll = args[2], cb = args[3]; | ||
//parse arguments | ||
var condExpr = arguments[0], timeout = arguments[1], | ||
poll = arguments[2], cb = arguments[3]; | ||
// recursive implementation | ||
@@ -14,5 +12,5 @@ var waitForConditionImpl = function(conditionExpr, limit, poll, cb) { | ||
var res = eval(conditionExpr); | ||
if (res == true ) { | ||
if (res === true ) { | ||
// condition ok | ||
return cb(res); | ||
cb(res); | ||
} else { | ||
@@ -19,0 +17,0 @@ // wait for poll and try again |
@@ -1105,2 +1105,42 @@ <table class="wikitable"> | ||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/alert_text">/session/:sessionId/alert_text</a><br> | ||
Gets the text of the currently displayed JavaScript alert(), confirm(), or prompt() dialog. | ||
</td> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
alertText(cb) -> cb(err, text)<br> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/alert_text">/session/:sessionId/alert_text</a><br> | ||
Sends keystrokes to a JavaScript prompt() dialog. | ||
</td> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
alertKeys(keys, cb) -> cb(err)<br> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/accept_alert">/session/:sessionId/accept_alert</a><br> | ||
@@ -1261,2 +1301,21 @@ Accepts the currently displayed alert dialog. | ||
esired, cb<br> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
EXTRA | ||
</td> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
Opens a new window (using Javascript window.open):<br> | ||
@@ -1291,2 +1350,21 @@ | ||
rl, name, cb<br> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
EXTRA | ||
</td> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
windowName(cb) -> cb(err, name)<br> | ||
@@ -1421,3 +1499,3 @@ | ||
deprecated: isVisible(queryType, querySelector, cb) -> cb(err, boolean)<br> | ||
isVisible(queryType, querySelector, cb) -> cb(err, boolean)<br> | ||
@@ -1424,0 +1502,0 @@ |
@@ -1,5 +0,10 @@ | ||
var webdriver = require('wd'); | ||
var wd; | ||
try { | ||
wd = require('wd'); | ||
} catch( err ) { | ||
wd = require('../lib/main'); | ||
} | ||
var assert = require('assert'); | ||
var browser = webdriver.remote(); | ||
var browser = wd.remote(); | ||
@@ -10,4 +15,4 @@ browser.on('status', function(info){ | ||
browser.on('command', function(meth, path){ | ||
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path); | ||
browser.on('command', function(meth, path, data){ | ||
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path, data || ''); | ||
}); | ||
@@ -22,15 +27,15 @@ | ||
}) | ||
.get("http://saucelabs.com/test/guinea-pig") | ||
.get("http://admc.io/wd/test-pages/guinea-pig.html") | ||
.title(function(err, title) { | ||
assert.ok(~title.indexOf('I am a page title - Sauce Labs'), 'Wrong title!'); | ||
}) | ||
.elementById('submit', function(err, el) { | ||
.elementById('i am a link', function(err, el) { | ||
//we should make clickElement not require a callback | ||
browser.clickElement(el, function() { | ||
console.log("did the click!") | ||
}) | ||
console.log("did the click!"); | ||
}); | ||
}) | ||
.eval("window.location.href", function(err, href) { | ||
assert.ok(~href.indexOf('#'), 'Wrong url!'); | ||
assert.ok(~href.indexOf('guinea-pig2'), 'Wrong url!'); | ||
}) | ||
.quit(); |
@@ -1,9 +0,9 @@ | ||
var webdriver; | ||
var wd; | ||
try { | ||
webdriver = require('wd'); | ||
wd = require('wd'); | ||
} catch( err ) { | ||
webdriver = require('../lib/main'); | ||
wd = require('../lib/main'); | ||
} | ||
var assert = require('assert'); | ||
var browser = webdriver.remote(); | ||
var browser = wd.remote(); | ||
@@ -14,4 +14,4 @@ browser.on('status', function(info){ | ||
browser.on('command', function(meth, path){ | ||
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path); | ||
browser.on('command', function(meth, path, data){ | ||
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path, data || ''); | ||
}); | ||
@@ -25,15 +25,15 @@ | ||
browser.get("http://saucelabs.com/test/guinea-pig", function() { | ||
browser.get("http://admc.io/wd/test-pages/guinea-pig.html", function() { | ||
browser.title(function(err, title) { | ||
assert.ok(~title.indexOf('I am a page title - Sauce Labs'), 'Wrong title!'); | ||
browser.elementById('submit', function(err, el) { | ||
browser.elementById('i am a link', function(err, el) { | ||
browser.clickElement(el, function() { | ||
browser.eval("window.location.href", function(err, title) { | ||
assert.ok(~title.indexOf('#'), 'Wrong title!'); | ||
browser.quit() | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
browser.eval("window.location.href", function(err, href) { | ||
assert.ok(~href.indexOf('guinea-pig2')); | ||
browser.quit(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -1,5 +0,9 @@ | ||
var webdriver = require('wd'); | ||
var wd; | ||
try { | ||
wd = require('wd'); | ||
} catch( err ) { | ||
wd = require('../lib/main'); | ||
} | ||
var assert = require('assert'); | ||
var browser = webdriver.remote(); | ||
var browser = wd.remote(); | ||
@@ -10,4 +14,4 @@ browser.on('status', function(info){ | ||
browser.on('command', function(meth, path){ | ||
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path); | ||
browser.on('command', function(meth, path, data){ | ||
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path, data || ''); | ||
}); | ||
@@ -21,27 +25,15 @@ | ||
browser.get("http://saucelabs.com/test/guinea-pig", function() { | ||
browser.title(function(err, title) { | ||
browser.get("http://admc.io/wd/test-pages/guinea-pig.html", function() { | ||
browser.title(function(err, title) { | ||
assert.ok(~title.indexOf('I am a page title - Sauce Labs'), 'Wrong title!'); | ||
browser.elementById('comments', function(err, el) { | ||
el.sendKeys("this is not a comment", function(err) { | ||
browser.elementById('submit', function(err, el) { | ||
el.click(function() { | ||
browser.eval("window.location.href", function(err, title) { | ||
assert.ok(~title.indexOf('#'), 'Wrong title!'); | ||
browser.elementById("your_comments", function(err, el) { | ||
el.textPresent("this is not a comment", function(err, present) { | ||
assert.ok(present, "Comments not correct"); | ||
el.text(function(err, text) { | ||
console.log(text); | ||
browser.quit(); | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
browser.elementById('i am a link', function(err, el) { | ||
browser.clickElement(el, function() { | ||
browser.eval("window.location.href", function(err, href) { | ||
assert.ok(~href.indexOf('guinea-pig2')); | ||
browser.quit(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -5,10 +5,10 @@ // CONFIGURE SAUCE CREDENTIALS HERE | ||
var webdriver; | ||
var wd; | ||
try { | ||
webdriver = require('wd'); | ||
wd = require('wd'); | ||
} catch( err ) { | ||
webdriver = require('../lib/main'); | ||
wd = require('../lib/main'); | ||
} | ||
var assert = require('assert'); | ||
var browser = webdriver.remote("ondemand.saucelabs.com", 80, username, accessKey); | ||
var browser = wd.remote("ondemand.saucelabs.com", 80, username, accessKey); | ||
@@ -19,4 +19,4 @@ browser.on('status', function(info){ | ||
browser.on('command', function(meth, path){ | ||
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path); | ||
browser.on('command', function(meth, path, data){ | ||
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path, data || ''); | ||
}); | ||
@@ -30,18 +30,18 @@ | ||
, name: "This is an example test" | ||
} | ||
}; | ||
browser.init( desired, function() { | ||
browser.get("http://saucelabs.com/test/guinea-pig", function() { | ||
browser.init(desired, function() { | ||
browser.get("http://admc.io/wd/test-pages/guinea-pig.html", function() { | ||
browser.title(function(err, title) { | ||
assert.ok(~title.indexOf('I am a page title - Sauce Labs'), 'Wrong title!'); | ||
browser.elementById('submit', function(err, el) { | ||
browser.elementById('i am a link', function(err, el) { | ||
browser.clickElement(el, function() { | ||
browser.eval("window.location.href", function(err, title) { | ||
assert.ok(~title.indexOf('#'), 'Wrong title!'); | ||
browser.quit() | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
browser.eval("window.location.href", function(err, href) { | ||
assert.ok(~href.indexOf('guinea-pig2')); | ||
browser.quit(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
// CONFIGURE SAUCE CREDENTIALS HERE | ||
var username = "<USERNAME>", | ||
accessKey = "<ACCESS_KEY>"; | ||
var webdriver; | ||
var wd; | ||
try { | ||
webdriver = require('wd'); | ||
wd = require('wd'); | ||
} catch( err ) { | ||
webdriver = require('../lib/main'); | ||
wd = require('../lib/main'); | ||
} | ||
var assert = require('assert'); | ||
var browser = webdriver.remote("ondemand.saucelabs.com", 80, username, accessKey); | ||
var browser = wd.remote("ondemand.saucelabs.com", 80, username, accessKey); | ||
@@ -19,4 +19,4 @@ browser.on('status', function(info){ | ||
browser.on('command', function(meth, path){ | ||
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path); | ||
browser.on('command', function(meth, path, data){ | ||
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path, data || ''); | ||
}); | ||
@@ -27,18 +27,18 @@ | ||
, name: "This is an example test" | ||
} | ||
}; | ||
browser.init(desired, function() { | ||
browser.get("http://saucelabs.com/test/guinea-pig", function() { | ||
browser.get("http://admc.io/wd/test-pages/guinea-pig.html", function() { | ||
browser.title(function(err, title) { | ||
assert.ok(~title.indexOf('I am a page title - Sauce Labs'), 'Wrong title!'); | ||
browser.elementById('submit', function(err, el) { | ||
browser.elementById('i am a link', function(err, el) { | ||
browser.clickElement(el, function() { | ||
browser.eval("window.location.href", function(err, title) { | ||
assert.ok(~title.indexOf('#'), 'Wrong title!'); | ||
browser.quit() | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
browser.eval("window.location.href", function(err, href) { | ||
assert.ok(~href.indexOf('guinea-pig2')); | ||
browser.quit(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -7,2 +7,3 @@ #!/usr/bin/env node | ||
, wd = require('./main') | ||
, underscore = require('underscore') | ||
; | ||
@@ -19,10 +20,20 @@ | ||
net.createServer(function (socket) { | ||
var server = net.createServer(function (socket) { | ||
connections += 1; | ||
socket.setTimeout(5*60*1000, function() { | ||
socket.destroy(); | ||
}); | ||
repl.start("(wd): ", socket); | ||
}).listen(process.platform === "win32" ? "\\\\.\\pipe\\node-repl-sock" : "/tmp/node-repl-sock"); | ||
}).listen(process.platform === "win32" ? | ||
"\\\\.\\pipe\\node-repl-sock-" + process.pid : | ||
"/tmp/node-repl-sock-" + process.pid); | ||
r.on('exit', function () { | ||
server.close(); | ||
process.exit(); | ||
}); | ||
}; | ||
if (process.argv[2] == "shell") { | ||
startRepl() | ||
} | ||
if (process.argv[2] === "shell") { | ||
startRepl(); | ||
} |
@@ -30,3 +30,3 @@ //Element object | ||
element.prototype.sendKeys = element.prototype.type | ||
element.prototype.sendKeys = element.prototype.type; | ||
@@ -91,3 +91,3 @@ | ||
element.prototype.displayed = element.prototype.isDisplayed | ||
element.prototype.displayed = element.prototype.isDisplayed; | ||
@@ -120,3 +120,3 @@ /** | ||
element.prototype.getComputedCSS = element.prototype.getComputedCss | ||
element.prototype.getComputedCSS = element.prototype.getComputedCss; | ||
@@ -132,2 +132,2 @@ /** | ||
exports.element = element | ||
exports.element = element; |
@@ -90,4 +90,4 @@ var JSONWIRE_ERRORS = [ | ||
detail:'Argument was an invalid selector (e.g. XPath/CSS).'} | ||
] | ||
]; | ||
module.exports = JSONWIRE_ERRORS; |
@@ -7,15 +7,14 @@ var __slice = Array.prototype.slice; | ||
var parseRemoteWdConfig = function(args) { | ||
var accessKey, host, path, port, username, _ref; | ||
if (typeof (args != null ? args[0] : void 0) === 'object') { | ||
return args[0]; | ||
var config; | ||
if (typeof (args[0]) === 'object') { | ||
config = args[0]; | ||
} else { | ||
host = args[0], port = args[1], username = args[2], accessKey = args[3]; | ||
return { | ||
host: host, | ||
port: port, | ||
username: username, | ||
accessKey: accessKey | ||
config = { | ||
host: args[0], | ||
port: args[1], | ||
username: args[2], | ||
accessKey: args[3] | ||
}; | ||
} | ||
return config; | ||
}; | ||
@@ -22,0 +21,0 @@ |
1042
lib/webdriver.js
var EventEmitter = require('events').EventEmitter; | ||
var async = require("async"); | ||
var _ = require("underscore"); | ||
var fs = require("fs"); | ||
var element = require('./element').element; | ||
var http = require("http"); | ||
var https = require("https"); | ||
var request = require('request'); | ||
var __slice = Array.prototype.slice; | ||
var utils = require("./utils"); | ||
var JSONWIRE_ERRORS = require('./jsonwire-errors.js'); | ||
var MAX_ERROR_LENGTH = 500; | ||
@@ -32,3 +35,3 @@ // webdriver client main class | ||
// saucelabs default | ||
if ((this.username != null) && (this.accessKey != null)) { | ||
if ((this.username) && (this.accessKey)) { | ||
this.defaultCapabilities.platform = 'VISTA'; | ||
@@ -43,3 +46,3 @@ } | ||
var jsonwireError = JSONWIRE_ERRORS.filter(function(err) { | ||
return err.status = status; | ||
return err.status === status; | ||
}); | ||
@@ -52,50 +55,10 @@ return ((jsonwireError.length>0) ? jsonwireError[0] : null); | ||
var err = new Error(); | ||
for (var k in opts) { | ||
err[k] = opts[k] | ||
} | ||
_.each(opts, function(opt, k) { | ||
err[k] = opt; | ||
}); | ||
// nicer error output | ||
err.inspect = function() { | ||
var res = ""; | ||
var browserError = null; | ||
for (var k in this) { | ||
var _this = this; | ||
(function() { | ||
var v = _this[k]; | ||
if (typeof v === 'object') { | ||
if ((v["class"] != null) && v["class"].match(/org.openqa.selenium.remote.Response/)) { | ||
// for selenium classes, hidding long fields or field with | ||
// duplicate information | ||
var vAsStr = JSON.stringify(v, function(key, value) { | ||
if (key === 'screen' || key === 'stackTrace' || key === 'buildInformation' || key === 'localizedMessage') { | ||
return '[hidden]'; | ||
} else if (key === 'message') { | ||
// trying to extract browser error message | ||
var messageMatch = value.match(/([^\n]+)\nCommand duration/); | ||
if((messageMatch!=null) && (messageMatch.length >= 1)) { browserError = messageMatch[1].trim(); } | ||
return value; | ||
} else { | ||
return value; | ||
} | ||
}, " "); | ||
res += k + ": " + vAsStr + "\n"; | ||
} else { | ||
// for other objects making sure output is not too long | ||
var vAsStr = JSON.stringify(v, undefined, " "); | ||
var maxLength = 1000; | ||
if (vAsStr.length > maxLength) { | ||
vAsStr = vAsStr.substr(0, maxLength) + "\n..."; | ||
} | ||
res += k + ": " + vAsStr + "\n"; | ||
} | ||
} else if (typeof v != 'function') | ||
{ | ||
// printing non object types without modif | ||
res += k + ": " + v + "\n"; | ||
} | ||
})(); | ||
}; | ||
if(browserError != null){ | ||
res += "browser-error: " + browserError + "\n"; | ||
} | ||
return res; | ||
var jsonStr = JSON.stringify(err); | ||
return (jsonStr.length > MAX_ERROR_LENGTH)? | ||
jsonStr.substring(0,MAX_ERROR_LENGTH) + '...' : jsonStr; | ||
}; | ||
@@ -106,47 +69,40 @@ return err; | ||
webdriver.prototype._isWebDriverException = function(res) { | ||
var _ref; | ||
if ((typeof res !== "undefined" && res !== null ? | ||
(_ref = res["class"]) != null ? _ref.indexOf('WebDriverException') : | ||
void 0 : void 0) > 0) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
return res && | ||
res.class && | ||
(res.class.indexOf('WebDriverException') > 0); | ||
}; | ||
var cbStub = function() {}; | ||
// just calls the callback when there is no result | ||
webdriver.prototype._simpleCallback = function(cb) { | ||
cb = cb || cbStub; | ||
var _this = this; | ||
return function(res) { | ||
if(res==null) { | ||
// expected behaviour for quit | ||
if(cb!=null){ return cb(null);} | ||
}else{ | ||
res.setEncoding('utf8'); | ||
var data = ''; | ||
res.on('data', function(chunk) { data += chunk.toString(); }); | ||
res.on('end', function() { | ||
if((data == '') || (data == 'OK')) { | ||
// expected behaviour when not returning JsonWire response | ||
return cb(null) | ||
return function(err, data) { | ||
if(err) { return cb(err); } | ||
if((data === '') || (data === 'OK')) { | ||
// expected behaviour when not returning JsonWire response | ||
cb(null); | ||
} else { | ||
// looking for JsonWire response | ||
var jsonWireRes; | ||
try{jsonWireRes = JSON.parse(data);}catch(ign){} | ||
if (jsonWireRes && (jsonWireRes.sessionId) && (jsonWireRes.status !== undefined)) { | ||
// valid JsonWire response | ||
if(jsonWireRes.status === 0) { | ||
cb(null); | ||
} else { | ||
// looking for JsonWire response | ||
var jsonWireRes = null; | ||
try{jsonWireRes = JSON.parse(data);}catch(err){} | ||
if ((jsonWireRes !== null) && (jsonWireRes.sessionId != null) && (jsonWireRes.status != null)) { | ||
// valid JsonWire response | ||
if(jsonWireRes.status === 0) { | ||
return cb(null) | ||
} else { | ||
return cb(_this._newError( | ||
{message:'Error response status.',status:jsonWireRes.status,cause:jsonWireRes} ) ); | ||
} | ||
} else { | ||
// something wrong | ||
if(cb!=null){ | ||
return cb(_this._newError( | ||
{message:'Unexpected data in simpleCallback.', data:data}) ); | ||
} | ||
} | ||
var error = _this._newError( | ||
{ message:'Error response status: ' + jsonWireRes.status + '.' | ||
, status:jsonWireRes.status | ||
, cause:jsonWireRes }); | ||
var jsonwireError = _this._getJsonwireError(jsonWireRes.status); | ||
if(jsonwireError){ error['jsonwire-error'] = jsonwireError; } | ||
cb(error); | ||
} | ||
}); | ||
} else { | ||
// something wrong | ||
cb(_this._newError( | ||
{message:'Unexpected data in simpleCallback.', data: jsonWireRes || data}) ); | ||
} | ||
} | ||
@@ -158,35 +114,25 @@ }; | ||
webdriver.prototype._callbackWithDataBase = function(cb) { | ||
var strip = function strip(str) { | ||
var x = []; | ||
for (var i = 0; i < str.length; i++) { | ||
if (str.charCodeAt(i)) { | ||
x.push(str.charAt(i)); | ||
} | ||
cb = cb || cbStub; | ||
var _this = this; | ||
return function(err, data) { | ||
if(err) { cb(err); } | ||
var obj; | ||
try { | ||
obj = JSON.parse(data); | ||
} catch (e) { | ||
return cb(_this._newError({message:'Not JSON response', data:data})); | ||
} | ||
return x.join(''); | ||
if (obj.status > 0) { | ||
var error = _this._newError( | ||
{ message:'Error response status: ' + obj.status + '.' | ||
, status:obj.status | ||
, cause:obj }); | ||
var jsonwireError = _this._getJsonwireError(obj.status); | ||
if(jsonwireError){ error['jsonwire-error'] = jsonwireError; } | ||
cb(error); | ||
} else { | ||
cb(null, obj); | ||
} | ||
}; | ||
var _this = this; | ||
return function(res) { | ||
res.setEncoding('utf8'); | ||
var data = ''; | ||
res.on('data', function(chunk) { data += chunk.toString(); }); | ||
res.on('end', function() { | ||
var obj; | ||
try { | ||
obj = JSON.parse(strip(data)); | ||
} catch (e) { | ||
return cb(_this._newError({message:'Not JSON response', data:data})); | ||
} | ||
if (obj.status > 0) { | ||
var err = _this._newError( | ||
{message:'Error response status.',status:obj.status,cause:obj}); | ||
var jsonwireError = _this._getJsonwireError(obj.status); | ||
if(jsonwireError != null){ err['jsonwire-error'] = jsonwireError; } | ||
cb(err); | ||
} else { | ||
cb(null, obj); | ||
} | ||
}); | ||
} | ||
}; | ||
@@ -196,5 +142,6 @@ | ||
webdriver.prototype._callbackWithData = function(cb) { | ||
cb = cb || cbStub; | ||
var _this = this; | ||
return _this._callbackWithDataBase(function(err,obj) { | ||
if(err != null) {return cb(err);} | ||
if(err) {return cb(err);} | ||
if(_this._isWebDriverException(obj.value)) {return cb(_this._newError( | ||
@@ -208,5 +155,6 @@ {message:obj.value.message,cause:obj.value}));} | ||
webdriver.prototype._elementCallback = function(cb) { | ||
cb = cb || cbStub; | ||
var _this = this; | ||
return _this._callbackWithDataBase(function(err, obj) { | ||
if(err != null) {return cb(err);} | ||
if(err) {return cb(err);} | ||
if(_this._isWebDriverException(obj.value)) {return cb(_this._newError( | ||
@@ -226,6 +174,7 @@ {message:obj.value.message,cause:obj.value}));} | ||
webdriver.prototype._elementsCallback = function(cb) { | ||
cb = cb || cbStub; | ||
var _this = this; | ||
return _this._callbackWithDataBase(function(err, obj) { | ||
//_this = this; TODO: not sure about this | ||
if(err != null) {return cb(err);} | ||
if(err) {return cb(err);} | ||
if(_this._isWebDriverException(obj.value)) {return cb(_this._newError( | ||
@@ -245,13 +194,18 @@ {message:obj.value.message,cause:obj.value}));} | ||
webdriver.prototype._newHttpOpts = function(method) { | ||
var opts = new Object(); | ||
opts.method = method; | ||
for (var o in this.options) { | ||
opts[o] = this.options[o]; | ||
} | ||
var opts = _.extend({}, this.options); | ||
opts.method = method; | ||
opts.headers = {}; | ||
opts.headers['Connection'] = 'keep-alive'; | ||
if (opts.method === 'POST' || opts.method === 'GET') | ||
opts.headers['Accept'] = 'application/json'; | ||
if (opts.method == 'POST') | ||
opts.headers['Content-Type'] = 'application/json; charset=UTF-8'; | ||
opts.https = this.https; | ||
opts.headers.Connection = 'keep-alive'; | ||
if (opts.method === 'POST' || opts.method === 'GET') { | ||
opts.headers.Accept = 'application/json'; } | ||
if (opts.method === 'POST') { | ||
opts.headers['Content-Type'] = 'application/json; charset=UTF-8'; } | ||
opts.prepareToSend = function(data) { | ||
this.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); | ||
this.url = (this.https? 'https' : 'http' ) + "://" + this.host + ":" + this.port + this.path; | ||
this.body = data; | ||
}; | ||
return opts; | ||
@@ -261,2 +215,13 @@ }; | ||
var strip = function strip(str) { | ||
if(typeof(str) !== 'string') { return str; } | ||
var x = []; | ||
_(str.length).times(function(i) { | ||
if (str.charCodeAt(i)) { | ||
x.push(str.charAt(i)); | ||
} | ||
}); | ||
return x.join(''); | ||
}; | ||
/** | ||
@@ -268,32 +233,20 @@ * init(desired, cb) -> cb(err, sessionID) | ||
*/ | ||
webdriver.prototype.init = function(desired, cb) { | ||
webdriver.prototype.init = function(/*desired, cb*/) { | ||
var _this = this; | ||
var fargs = utils.varargs(arguments); | ||
var cb = fargs.callback, | ||
desired = fargs.all[0] || {}; | ||
// copy containing defaults | ||
var _desired = _.clone(desired); | ||
_.defaults(_desired, this.defaultCapabilities); | ||
//allow desired ovveride to be left out | ||
if (typeof desired == 'function') { | ||
cb = desired; | ||
desired = {}; | ||
} | ||
// making copy | ||
var _desired = {}; | ||
for (var k in desired) { | ||
_desired[k] = desired[k]; | ||
} | ||
// defaulting capabilities when necessary | ||
for (var k in this.defaultCapabilities) { | ||
_desired[k] = _desired[k] || this.defaultCapabilities[k]; | ||
} | ||
// http options | ||
var httpOpts = _this._newHttpOpts.apply(this, ['POST']); | ||
var httpOpts = _this._newHttpOpts('POST'); | ||
// authentication (for saucelabs) | ||
if ((_this.username != null) && (_this.accessKey != null)) { | ||
if ((_this.username) && (_this.accessKey)) { | ||
var authString = _this.username + ':' + _this.accessKey; | ||
var buf = new Buffer(authString); | ||
httpOpts['headers'] = { | ||
'Authorization': 'Basic ' + buf.toString('base64') | ||
}; | ||
httpOpts.headers.Authorization = 'Basic ' + buf.toString('base64'); | ||
} | ||
@@ -303,33 +256,24 @@ | ||
var data = JSON.stringify({desiredCapabilities: _desired}); | ||
httpOpts.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); | ||
var req = (this.https ? https : http).request(httpOpts, function(res) { | ||
var data = ''; | ||
res.on('data', function(chunk) { | ||
data += chunk; | ||
}); | ||
res.on('end', function() { | ||
if (res.headers.location == undefined) { | ||
console.log('\x1b[31mError\x1b[0m: The environment you requested was unavailable.\n'); | ||
console.log('\x1b[33mReason\x1b[0m:\n'); | ||
console.log(data); | ||
console.log('\nFor the available values please consult the WebDriver JSONWireProtocol,'); | ||
console.log('located at: \x1b[33mhttp://code.google.com/p/selenium/wiki/JsonWireProtocol#/session\x1b[0m'); | ||
if (cb) | ||
cb({ message: 'The environment you requested was unavailable.' }); | ||
return; | ||
} | ||
var locationArr = res.headers.location.split('/'); | ||
_this.sessionID = locationArr[locationArr.length - 1]; | ||
_this.emit('status', '\nDriving the web on session: ' + _this.sessionID + '\n'); | ||
httpOpts.timeout = this._httpInactivityTimeout; | ||
httpOpts.prepareToSend(data); | ||
request(httpOpts, function(err, res, data) { | ||
if(err) { return cb(err); } | ||
data = strip(data); | ||
if (!res.headers.location) { | ||
console.log('\x1b[31mError\x1b[0m: The environment you requested was unavailable.\n'); | ||
console.log('\x1b[33mReason\x1b[0m:\n'); | ||
console.log(data); | ||
console.log('\nFor the available values please consult the WebDriver JSONWireProtocol,'); | ||
console.log('located at: \x1b[33mhttp://code.google.com/p/selenium/wiki/JsonWireProtocol#/session\x1b[0m'); | ||
if (cb) { | ||
cb({ message: 'The environment you requested was unavailable.' }); } | ||
return; | ||
} | ||
var locationArr = res.headers.location.split('/'); | ||
_this.sessionID = locationArr[locationArr.length - 1]; | ||
_this.emit('status', '\nDriving the web on session: ' + _this.sessionID + '\n'); | ||
if (cb) { cb(null, _this.sessionID) } | ||
}); | ||
if (cb) { cb(null, _this.sessionID); } | ||
}); | ||
req.on('error', function(e) { cb(e); }); | ||
// writting data | ||
req.write(data); | ||
// sending | ||
req.end(); | ||
}; | ||
@@ -349,16 +293,15 @@ | ||
// setting path in http options | ||
if (this.sessionID != null) { httpOpts['path'] += '/' + this.sessionID; } | ||
if (relPath) { httpOpts['path'] += relPath; } | ||
if (absPath) { httpOpts['path'] = absPath;} | ||
if (this.sessionID) { httpOpts.path += '/' + this.sessionID; } | ||
if (relPath) { httpOpts.path += relPath; } | ||
if (absPath) { httpOpts.path = absPath;} | ||
// building callback | ||
var cb = opts.cb | ||
if (opts.emit != null) { | ||
var cb = opts.cb; | ||
if (opts.emit) { | ||
// wrapping cb if we need to emit a message | ||
var _cb = cb; | ||
cb = function(res) { | ||
if (opts.emit != null) { | ||
_this.emit(opts.emit.event, opts.emit.message); | ||
} | ||
if (_cb) { _cb(null); } | ||
cb = function() { | ||
var args = __slice.call(arguments, 0); | ||
_this.emit(opts.emit.event, opts.emit.message); | ||
if (_cb) { _cb.apply(_this,args); } | ||
}; | ||
@@ -368,24 +311,20 @@ } | ||
// logging | ||
_this.emit('command', httpOpts['method'], | ||
httpOpts['path'].replace(this.sessionID, ':sessionID') | ||
.replace(this.basePath, '') | ||
_this.emit('command', httpOpts.method, | ||
httpOpts.path.replace(this.sessionID, ':sessionID') | ||
.replace(this.basePath, ''), opts.data | ||
); | ||
// writting data | ||
var data = ''; | ||
if (opts.data != null) { | ||
data = opts.data; | ||
} | ||
var data = opts.data || ''; | ||
if (typeof data === 'object') { | ||
data = JSON.stringify(data); | ||
} | ||
httpOpts.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); | ||
httpOpts.timeout = this._httpInactivityTimeout; | ||
httpOpts.prepareToSend(data); | ||
// building request | ||
var req = (this.https ? https : http).request(httpOpts, cb); | ||
req.on('error', function(e) { cb(e); }); | ||
req.write(data); | ||
//sending | ||
req.end(); | ||
request(httpOpts, function(err, res, data) { | ||
if(err) { return cb(err); } | ||
data = strip(data); | ||
cb(null, data || ""); | ||
}); | ||
}; | ||
@@ -417,8 +356,25 @@ | ||
}); | ||
} | ||
}; | ||
webdriver.prototype.chain = function(){ | ||
// manually stop processing of queued chained functions | ||
webdriver.prototype.haltChain = function(obj){ | ||
this._chainHalted = true; | ||
this._queue = null; | ||
}; | ||
webdriver.prototype.chain = function(obj){ | ||
var _this = this; | ||
if (!obj) { obj = {}; } | ||
//add queue if not already here | ||
// Update the onError callback if supplied. The most recent .chain() | ||
// invocation overrides previous onError handlers. | ||
if (obj.onError) { | ||
this._chainOnErrorCallback = obj.onError; | ||
} else if (!this._chainOnErrorCallback) { | ||
this._chainOnErrorCallback = function(err) { | ||
if (err) { console.error("a function in your .chain() failed:", err); } | ||
}; | ||
} | ||
// Add queue if not already here | ||
if(!_this._queue){ | ||
@@ -429,9 +385,19 @@ _this._queue = async.queue(function (task, callback) { | ||
var func = task.args[task.args.length-1]; | ||
task.args[task.args.length-1] = function(){ | ||
task.args[task.args.length-1] = function(err) { | ||
// if the chain user has their own callback, we will not invoke | ||
// the onError handler, supplying your own callback suggests you | ||
// handle the error on your own. | ||
func.apply(null, arguments); | ||
callback(); | ||
} | ||
if (!_this._chainHalted) { callback(); } | ||
}; | ||
} else { | ||
//add a callback | ||
task.args.push(callback); | ||
// if the .chain() does not supply a callback, we assume they | ||
// expect us to catch errors. | ||
task.args.push(function(err) { | ||
// if there is an error, call the onError callback, | ||
// and do not invoke callback() which would make the | ||
// task queue continue processing | ||
if (err) { _this._chainOnErrorCallback(err); } | ||
else { callback(); } | ||
}); | ||
} | ||
@@ -449,16 +415,16 @@ | ||
return function(){ | ||
_this._queue.push({name: name, args: Array.prototype.slice.apply(arguments)}); | ||
_this._queue.push({name: name, args: Array.prototype.slice.call(arguments, 0)}); | ||
return chain; | ||
} | ||
} | ||
}; | ||
}; | ||
//fill the chain with placeholders | ||
for(var name in _this){ | ||
if(typeof _this[name] === "function" && name !== "chain"){ | ||
chain[name] = buildPlaceholder(name); | ||
_.each(_.functions(_this), function(k) { | ||
if(k !== "chain"){ | ||
chain[k] = buildPlaceholder(k); | ||
} | ||
} | ||
}); | ||
return chain; | ||
} | ||
}; | ||
@@ -475,11 +441,10 @@ /** | ||
_this.sessions.apply(this, [function(err, sessions) { | ||
if (err == null) { | ||
if(err) { | ||
cb(err, sessions); | ||
} else { | ||
sessions = sessions.filter(function(session) { | ||
return session.id === _this.sessionID; | ||
}); | ||
var _ref; | ||
return cb(null, (_ref = sessions[0]) != null ? _ref.capabilities : void 0); | ||
} else { | ||
return cb(err, sessions); | ||
} | ||
cb(null, sessions[0]? sessions[0].capabilities : 0); | ||
} | ||
}]); | ||
@@ -499,3 +464,3 @@ }; | ||
}); | ||
} | ||
}; | ||
@@ -510,9 +475,9 @@ /** | ||
*/ | ||
webdriver.prototype.newWindow = function(url, name, cb) { | ||
if ((cb == undefined) && (typeof(name) == 'function')) { | ||
cb = name; | ||
name = undefined; | ||
}; | ||
webdriver.prototype.newWindow = function(/*url, name, cb*/) { | ||
var fargs = utils.varargs(arguments); | ||
var cb = fargs.callback, | ||
url = fargs.all[0], | ||
name = fargs.all[1]; | ||
this.execute("var url=arguments[0], name=arguments[1]; window.open(url, name);", [url,name] , cb); | ||
} | ||
}; | ||
@@ -530,3 +495,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -545,3 +510,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -556,3 +521,3 @@ /** | ||
// doesn't work at all with chromedriver | ||
if(typeof(frameRef)=='function'){ | ||
if(typeof(frameRef) === 'function'){ | ||
cb = frameRef; | ||
@@ -567,3 +532,3 @@ frameRef = null; | ||
}); | ||
} | ||
}; | ||
@@ -616,3 +581,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -626,5 +591,5 @@ /** | ||
webdriver.prototype.eval = function(code, cb) { | ||
code = "return " + code + ";" | ||
code = "return " + code + ";"; | ||
this.execute.apply( this, [code, function(err, res) { | ||
if(err!=null) {return cb(err);} | ||
if(err) {return cb(err);} | ||
cb(null, res); | ||
@@ -642,3 +607,3 @@ }]); | ||
this.safeExecute.apply( this, [code, function(err, res) { | ||
if(err!=null) {return cb(err);} | ||
if(err) {return cb(err);} | ||
cb(null, res); | ||
@@ -656,14 +621,8 @@ }]); | ||
*/ | ||
webdriver.prototype.execute = function(code,args,cb) { | ||
// parsing arguments (code,args,cb) with optional args | ||
var _args, _i; | ||
_args = 2 <= arguments.length ? __slice.call(arguments, 0, | ||
_i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++]; | ||
code = _args[0], args = _args[1]; | ||
webdriver.prototype.execute = function() { | ||
var fargs = utils.varargs(arguments); | ||
var cb = fargs.callback, | ||
code = fargs.all[0], | ||
args = fargs.all[1] || []; | ||
//args default | ||
if (typeof args === "undefined" || args === null) { | ||
args = []; | ||
} | ||
this._jsonWireCall({ | ||
@@ -675,3 +634,3 @@ method: 'POST' | ||
}); | ||
} | ||
}; | ||
@@ -690,14 +649,8 @@ // script to be executed in browser | ||
*/ | ||
webdriver.prototype.safeExecute = function(code,args,cb) { | ||
// parsing arguments (code,args,cb) with optional args | ||
var _args, _i; | ||
_args = 2 <= arguments.length ? __slice.call(arguments, 0, | ||
_i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++]; | ||
code = _args[0], args = _args[1]; | ||
webdriver.prototype.safeExecute = function() { | ||
var fargs = utils.varargs(arguments); | ||
var cb = fargs.callback, | ||
code = fargs.all[0], | ||
args = fargs.all[1] || []; | ||
//args default | ||
if (typeof args === "undefined" || args === null) { | ||
args = []; | ||
} | ||
this._jsonWireCall({ | ||
@@ -709,3 +662,3 @@ method: 'POST' | ||
}); | ||
} | ||
}; | ||
@@ -719,14 +672,8 @@ /** | ||
*/ | ||
webdriver.prototype.executeAsync = function(code,args,cb) { | ||
// parsing arguments (code,args,cb) with optional args | ||
var _args, _i; | ||
_args = 2 <= arguments.length ? __slice.call(arguments, 0, | ||
_i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++]; | ||
code = _args[0], args = _args[1]; | ||
webdriver.prototype.executeAsync = function() { | ||
var fargs = utils.varargs(arguments); | ||
var cb = fargs.callback, | ||
code = fargs.all[0], | ||
args = fargs.all[1] || []; | ||
//args default | ||
if (typeof args === "undefined" || args === null) { | ||
args = []; | ||
} | ||
this._jsonWireCall({ | ||
@@ -738,3 +685,3 @@ method: 'POST' | ||
}); | ||
} | ||
}; | ||
@@ -752,14 +699,8 @@ // script to be executed in browser | ||
*/ | ||
webdriver.prototype.safeExecuteAsync = function(code,args,cb) { | ||
// parsing arguments (code,args,cb) with optional args | ||
var _args, _i; | ||
_args = 2 <= arguments.length ? __slice.call(arguments, 0, | ||
_i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++]; | ||
code = _args[0], args = _args[1]; | ||
webdriver.prototype.safeExecuteAsync = function() { | ||
var fargs = utils.varargs(arguments); | ||
var cb = fargs.callback, | ||
code = fargs.all[0], | ||
args = fargs.all[1] || []; | ||
//args default | ||
if (typeof args === "undefined" || args === null) { | ||
args = []; | ||
} | ||
this._jsonWireCall({ | ||
@@ -771,3 +712,3 @@ method: 'POST' | ||
}); | ||
} | ||
}; | ||
@@ -787,3 +728,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -801,3 +742,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -815,3 +756,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -829,4 +770,7 @@ /** | ||
}); | ||
} | ||
}; | ||
webdriver.prototype.setHTTPInactivityTimeout = function(ms) { | ||
this._httpInactivityTimeout = ms; | ||
}; | ||
@@ -845,3 +789,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -863,3 +807,3 @@ // for backward compatibility | ||
}); | ||
} | ||
}; | ||
@@ -879,3 +823,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -894,3 +838,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -907,6 +851,6 @@ /** | ||
function(err, elements) { | ||
if(err == null) | ||
if(!err) { | ||
if(elements.length>0) {cb(null,elements[0]);} else {cb(null,null);} | ||
else | ||
cb(err); | ||
} else { | ||
cb(err); } | ||
} | ||
@@ -926,6 +870,6 @@ ]); | ||
function(err, elements) { | ||
if(err == null) | ||
if(elements.length>0) {cb(null,elements[0]);} else {cb(null,undefined);} | ||
else | ||
cb(err); | ||
if(!err) { | ||
if(elements.length>0) {cb(null,elements[0]);} else {cb(null);} | ||
} else { | ||
cb(err); } | ||
} | ||
@@ -948,3 +892,3 @@ ]); | ||
}); | ||
} | ||
}; | ||
@@ -960,8 +904,8 @@ /** | ||
this.elements.apply( this, [using, value, function(err, elements){ | ||
if(err==null) | ||
cb(null, elements.length > 0 ) | ||
else | ||
cb(err); | ||
if(!err) { | ||
cb(null, elements.length > 0 ); | ||
} else { | ||
cb(err); } | ||
}]); | ||
} | ||
}; | ||
@@ -991,6 +935,6 @@ /** | ||
}); | ||
} | ||
}; | ||
poll(); | ||
} | ||
}; | ||
@@ -1020,5 +964,5 @@ /** | ||
}); | ||
} | ||
}; | ||
poll(); | ||
} | ||
}; | ||
@@ -1036,3 +980,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -1048,3 +992,3 @@ // convert to type to something like ById, ByCssSelector, etc... | ||
var elFuncFullType = function(type){ | ||
if(type == 'css') {return 'css selector'} // shortcut for css | ||
if(type === 'css') {return 'css selector'; } // shortcut for css | ||
return type; | ||
@@ -1059,143 +1003,139 @@ }; | ||
for (var i = 0; i < elementFuncTypes.length; i++) { | ||
_.each(elementFuncTypes, function(type) { | ||
(function() { | ||
var type = elementFuncTypes[i]; | ||
/** | ||
* elementByClassName(value, cb) -> cb(err, element) | ||
* elementByCssSelector(value, cb) -> cb(err, element) | ||
* elementById(value, cb) -> cb(err, element) | ||
* elementByName(value, cb) -> cb(err, element) | ||
* elementByLinkText(value, cb) -> cb(err, element) | ||
* elementByPartialLinkText(value, cb) -> cb(err, element) | ||
* elementByTagName(value, cb) -> cb(err, element) | ||
* elementByXPath(value, cb) -> cb(err, element) | ||
* elementByCss(value, cb) -> cb(err, element) | ||
* | ||
* @jsonWire POST /session/:sessionId/element | ||
*/ | ||
webdriver.prototype['element' + elFuncSuffix(type)] = function(value, cb) { | ||
webdriver.prototype.element.apply(this, [elFuncFullType(type), value, cb]); | ||
}; | ||
/** | ||
* elementByClassName(value, cb) -> cb(err, element) | ||
* elementByCssSelector(value, cb) -> cb(err, element) | ||
* elementById(value, cb) -> cb(err, element) | ||
* elementByName(value, cb) -> cb(err, element) | ||
* elementByLinkText(value, cb) -> cb(err, element) | ||
* elementByPartialLinkText(value, cb) -> cb(err, element) | ||
* elementByTagName(value, cb) -> cb(err, element) | ||
* elementByXPath(value, cb) -> cb(err, element) | ||
* elementByCss(value, cb) -> cb(err, element) | ||
* | ||
* @jsonWire POST /session/:sessionId/element | ||
*/ | ||
webdriver.prototype['element' + elFuncSuffix(type)] = function(value, cb) { | ||
webdriver.prototype.element.apply(this, [elFuncFullType(type), value, cb]); | ||
}; | ||
/** | ||
* elementByClassNameOrNull(value, cb) -> cb(err, element) | ||
* elementByCssSelectorOrNull(value, cb) -> cb(err, element) | ||
* elementByIdOrNull(value, cb) -> cb(err, element) | ||
* elementByNameOrNull(value, cb) -> cb(err, element) | ||
* elementByLinkTextOrNull(value, cb) -> cb(err, element) | ||
* elementByPartialLinkTextOrNull(value, cb) -> cb(err, element) | ||
* elementByTagNameOrNull(value, cb) -> cb(err, element) | ||
* elementByXPathOrNull(value, cb) -> cb(err, element) | ||
* elementByCssOrNull(value, cb) -> cb(err, element) | ||
* | ||
* @jsonWire POST /session/:sessionId/elements | ||
* @docOrder 4 | ||
*/ | ||
webdriver.prototype['element' + elFuncSuffix(type)+ 'OrNull'] = function(value, cb) { | ||
webdriver.prototype.elements.apply(this, [elFuncFullType(type), value, | ||
function(err, elements) { | ||
if(err == null) | ||
if(elements.length>0) {cb(null,elements[0]);} else {cb(null,null);} | ||
else | ||
cb(err); | ||
} | ||
]); | ||
}; | ||
/** | ||
* elementByClassNameOrNull(value, cb) -> cb(err, element) | ||
* elementByCssSelectorOrNull(value, cb) -> cb(err, element) | ||
* elementByIdOrNull(value, cb) -> cb(err, element) | ||
* elementByNameOrNull(value, cb) -> cb(err, element) | ||
* elementByLinkTextOrNull(value, cb) -> cb(err, element) | ||
* elementByPartialLinkTextOrNull(value, cb) -> cb(err, element) | ||
* elementByTagNameOrNull(value, cb) -> cb(err, element) | ||
* elementByXPathOrNull(value, cb) -> cb(err, element) | ||
* elementByCssOrNull(value, cb) -> cb(err, element) | ||
* | ||
* @jsonWire POST /session/:sessionId/elements | ||
* @docOrder 4 | ||
*/ | ||
webdriver.prototype['element' + elFuncSuffix(type)+ 'OrNull'] = function(value, cb) { | ||
webdriver.prototype.elements.apply(this, [elFuncFullType(type), value, | ||
function(err, elements) { | ||
if(!err) { | ||
if(elements.length>0) {cb(null,elements[0]);} else {cb(null,null);} | ||
} else { | ||
cb(err); } | ||
} | ||
]); | ||
}; | ||
/** | ||
* elementByClassNameIfExists(value, cb) -> cb(err, element) | ||
* elementByCssSelectorIfExists(value, cb) -> cb(err, element) | ||
* elementByIdIfExists(value, cb) -> cb(err, element) | ||
* elementByNameIfExists(value, cb) -> cb(err, element) | ||
* elementByLinkTextIfExists(value, cb) -> cb(err, element) | ||
* elementByPartialLinkTextIfExists(value, cb) -> cb(err, element) | ||
* elementByTagNameIfExists(value, cb) -> cb(err, element) | ||
* elementByXPathIfExists(value, cb) -> cb(err, element) | ||
* elementByCssIfExists(value, cb) -> cb(err, element) | ||
* | ||
* @jsonWire POST /session/:sessionId/elements | ||
* @docOrder 6 | ||
*/ | ||
webdriver.prototype['element' + elFuncSuffix(type)+ 'IfExists'] = function(value, cb) { | ||
webdriver.prototype.elements.apply(this, [elFuncFullType(type), value, | ||
function(err, elements) { | ||
if(err == null) | ||
if(elements.length>0) {cb(null,elements[0]);} else {cb(null,undefined);} | ||
else | ||
cb(err); | ||
} | ||
]); | ||
}; | ||
/** | ||
* elementByClassNameIfExists(value, cb) -> cb(err, element) | ||
* elementByCssSelectorIfExists(value, cb) -> cb(err, element) | ||
* elementByIdIfExists(value, cb) -> cb(err, element) | ||
* elementByNameIfExists(value, cb) -> cb(err, element) | ||
* elementByLinkTextIfExists(value, cb) -> cb(err, element) | ||
* elementByPartialLinkTextIfExists(value, cb) -> cb(err, element) | ||
* elementByTagNameIfExists(value, cb) -> cb(err, element) | ||
* elementByXPathIfExists(value, cb) -> cb(err, element) | ||
* elementByCssIfExists(value, cb) -> cb(err, element) | ||
* | ||
* @jsonWire POST /session/:sessionId/elements | ||
* @docOrder 6 | ||
*/ | ||
webdriver.prototype['element' + elFuncSuffix(type)+ 'IfExists'] = function(value, cb) { | ||
webdriver.prototype.elements.apply(this, [elFuncFullType(type), value, | ||
function(err, elements) { | ||
if(!err) { | ||
if(elements.length>0) {cb(null,elements[0]);} else {cb(null);} | ||
} else { | ||
cb(err); } | ||
} | ||
]); | ||
}; | ||
/** | ||
* hasElementByClassName(value, cb) -> cb(err, boolean) | ||
* hasElementByCssSelector(value, cb) -> cb(err, boolean) | ||
* hasElementById(value, cb) -> cb(err, boolean) | ||
* hasElementByName(value, cb) -> cb(err, boolean) | ||
* hasElementByLinkText(value, cb) -> cb(err, boolean) | ||
* hasElementByPartialLinkText(value, cb) -> cb(err, boolean) | ||
* hasElementByTagName(value, cb) -> cb(err, boolean) | ||
* hasElementByXPath(value, cb) -> cb(err, boolean) | ||
* hasElementByCss(value, cb) -> cb(err, boolean) | ||
* | ||
* @jsonWire POST /session/:sessionId/elements | ||
* @docOrder 8 | ||
*/ | ||
webdriver.prototype['hasElement' + elFuncSuffix(type)] = function(value, cb) { | ||
webdriver.prototype.hasElement.apply(this, [elFuncFullType(type), value, cb]); | ||
}; | ||
/** | ||
* hasElementByClassName(value, cb) -> cb(err, boolean) | ||
* hasElementByCssSelector(value, cb) -> cb(err, boolean) | ||
* hasElementById(value, cb) -> cb(err, boolean) | ||
* hasElementByName(value, cb) -> cb(err, boolean) | ||
* hasElementByLinkText(value, cb) -> cb(err, boolean) | ||
* hasElementByPartialLinkText(value, cb) -> cb(err, boolean) | ||
* hasElementByTagName(value, cb) -> cb(err, boolean) | ||
* hasElementByXPath(value, cb) -> cb(err, boolean) | ||
* hasElementByCss(value, cb) -> cb(err, boolean) | ||
* | ||
* @jsonWire POST /session/:sessionId/elements | ||
* @docOrder 8 | ||
*/ | ||
webdriver.prototype['hasElement' + elFuncSuffix(type)] = function(value, cb) { | ||
webdriver.prototype.hasElement.apply(this, [elFuncFullType(type), value, cb]); | ||
}; | ||
/** | ||
* waitForElementByClassName(value, timeout, cb) -> cb(err) | ||
* waitForElementByCssSelector(value, timeout, cb) -> cb(err) | ||
* waitForElementById(value, timeout, cb) -> cb(err) | ||
* waitForElementByName(value, timeout, cb) -> cb(err) | ||
* waitForElementByLinkText(value, timeout, cb) -> cb(err) | ||
* waitForElementByPartialLinkText(value, timeout, cb) -> cb(err) | ||
* waitForElementByTagName(value, timeout, cb) -> cb(err) | ||
* waitForElementByXPath(value, timeout, cb) -> cb(err) | ||
* waitForElementByCss(value, timeout, cb) -> cb(err) | ||
*/ | ||
webdriver.prototype['waitForElement' + elFuncSuffix(type)] = function(value, timeout, cb) { | ||
webdriver.prototype.waitForElement.apply(this, [elFuncFullType(type), value, timeout, cb]); | ||
}; | ||
/** | ||
* waitForElementByClassName(value, timeout, cb) -> cb(err) | ||
* waitForElementByCssSelector(value, timeout, cb) -> cb(err) | ||
* waitForElementById(value, timeout, cb) -> cb(err) | ||
* waitForElementByName(value, timeout, cb) -> cb(err) | ||
* waitForElementByLinkText(value, timeout, cb) -> cb(err) | ||
* waitForElementByPartialLinkText(value, timeout, cb) -> cb(err) | ||
* waitForElementByTagName(value, timeout, cb) -> cb(err) | ||
* waitForElementByXPath(value, timeout, cb) -> cb(err) | ||
* waitForElementByCss(value, timeout, cb) -> cb(err) | ||
*/ | ||
webdriver.prototype['waitForElement' + elFuncSuffix(type)] = function(value, timeout, cb) { | ||
webdriver.prototype.waitForElement.apply(this, [elFuncFullType(type), value, timeout, cb]); | ||
}; | ||
/** | ||
* waitForVisibleByClassName(value, timeout, cb) -> cb(err) | ||
* waitForVisibleByCssSelector(value, timeout, cb) -> cb(err) | ||
* waitForVisibleById(value, timeout, cb) -> cb(err) | ||
* waitForVisibleByName(value, timeout, cb) -> cb(err) | ||
* waitForVisibleByLinkText(value, timeout, cb) -> cb(err) | ||
* waitForVisibleByPartialLinkText(value, timeout, cb) -> cb(err) | ||
* waitForVisibleByTagName(value, timeout, cb) -> cb(err) | ||
* waitForVisibleByXPath(value, timeout, cb) -> cb(err) | ||
* waitForVisibleByCss(value, timeout, cb) -> cb(err) | ||
*/ | ||
webdriver.prototype['waitForVisible' + elFuncSuffix(type)] = function(value, timeout, cb) { | ||
webdriver.prototype.waitForVisible.apply(this, [elFuncFullType(type), value, timeout, cb]); | ||
}; | ||
/** | ||
* waitForVisibleByClassName(value, timeout, cb) -> cb(err) | ||
* waitForVisibleByCssSelector(value, timeout, cb) -> cb(err) | ||
* waitForVisibleById(value, timeout, cb) -> cb(err) | ||
* waitForVisibleByName(value, timeout, cb) -> cb(err) | ||
* waitForVisibleByLinkText(value, timeout, cb) -> cb(err) | ||
* waitForVisibleByPartialLinkText(value, timeout, cb) -> cb(err) | ||
* waitForVisibleByTagName(value, timeout, cb) -> cb(err) | ||
* waitForVisibleByXPath(value, timeout, cb) -> cb(err) | ||
* waitForVisibleByCss(value, timeout, cb) -> cb(err) | ||
*/ | ||
webdriver.prototype['waitForVisible' + elFuncSuffix(type)] = function(value, timeout, cb) { | ||
webdriver.prototype.waitForVisible.apply(this, [elFuncFullType(type), value, timeout, cb]); | ||
}; | ||
/** | ||
* elementsByClassName(value, cb) -> cb(err, elements) | ||
* elementsByCssSelector(value, cb) -> cb(err, elements) | ||
* elementsById(value, cb) -> cb(err, elements) | ||
* elementsByName(value, cb) -> cb(err, elements) | ||
* elementsByLinkText(value, cb) -> cb(err, elements) | ||
* elementsByPartialLinkText(value, cb) -> cb(err, elements) | ||
* elementsByTagName(value, cb) -> cb(err, elements) | ||
* elementsByXPath(value, cb) -> cb(err, elements) | ||
* elementsByCss(value, cb) -> cb(err, elements) | ||
* | ||
* @jsonWire POST /session/:sessionId/elements | ||
* @docOrder 2 | ||
*/ | ||
webdriver.prototype['elements' + elFuncSuffix(type)] = function(value, cb) { | ||
webdriver.prototype.elements.apply(this, [elFuncFullType(type), value, cb]); | ||
}; | ||
/** | ||
* elementsByClassName(value, cb) -> cb(err, elements) | ||
* elementsByCssSelector(value, cb) -> cb(err, elements) | ||
* elementsById(value, cb) -> cb(err, elements) | ||
* elementsByName(value, cb) -> cb(err, elements) | ||
* elementsByLinkText(value, cb) -> cb(err, elements) | ||
* elementsByPartialLinkText(value, cb) -> cb(err, elements) | ||
* elementsByTagName(value, cb) -> cb(err, elements) | ||
* elementsByXPath(value, cb) -> cb(err, elements) | ||
* elementsByCss(value, cb) -> cb(err, elements) | ||
* | ||
* @jsonWire POST /session/:sessionId/elements | ||
* @docOrder 2 | ||
*/ | ||
webdriver.prototype['elements' + elFuncSuffix(type)] = function(value, cb) { | ||
webdriver.prototype.elements.apply(this, [elFuncFullType(type), value, cb]); | ||
}; | ||
})(); | ||
}); | ||
} | ||
/** | ||
@@ -1212,3 +1152,3 @@ * getTagName(element, cb) -> cb(err, name) | ||
}); | ||
} | ||
}; | ||
@@ -1227,3 +1167,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -1241,5 +1181,5 @@ /** | ||
}); | ||
} | ||
}; | ||
webdriver.prototype.displayed = webdriver.prototype.isDisplayed | ||
webdriver.prototype.displayed = webdriver.prototype.isDisplayed; | ||
@@ -1268,3 +1208,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -1282,5 +1222,5 @@ /** | ||
}); | ||
} | ||
}; | ||
webdriver.prototype.getComputedCSS = webdriver.prototype.getComputedCss | ||
webdriver.prototype.getComputedCSS = webdriver.prototype.getComputedCss; | ||
@@ -1293,9 +1233,8 @@ /** | ||
*/ | ||
webdriver.prototype.moveTo = function(element, xoffset, yoffset, cb) { | ||
// parsing arguments, xoffset and y offset are optional | ||
var args, _i; | ||
element = arguments[0], args = 3 <= arguments.length ? | ||
__slice.call(arguments, 1, _i = arguments.length - 1) : | ||
(_i = 1, []), cb = arguments[_i++]; | ||
xoffset = args[0], yoffset = args[1], args; | ||
webdriver.prototype.moveTo = function() { | ||
var fargs = utils.varargs(arguments); | ||
var cb = fargs.callback, | ||
element = fargs.all[0], | ||
xoffset = fargs.all[1], | ||
yoffset = fargs.all[2]; | ||
@@ -1308,3 +1247,3 @@ this._jsonWireCall({ | ||
}); | ||
} | ||
}; | ||
@@ -1322,3 +1261,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -1336,3 +1275,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -1346,7 +1285,7 @@ /** | ||
*/ | ||
webdriver.prototype.click = function(button, cb) { | ||
webdriver.prototype.click = function() { | ||
// parsing args, button optional | ||
var args, _i; | ||
args = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++]; | ||
button = args[0], args; | ||
var fargs = utils.varargs(arguments); | ||
var cb = fargs.callback, | ||
button = fargs.all[0]; | ||
@@ -1359,3 +1298,3 @@ this._jsonWireCall({ | ||
}); | ||
} | ||
}; | ||
@@ -1373,3 +1312,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -1391,3 +1330,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -1409,3 +1348,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -1423,3 +1362,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -1437,2 +1376,15 @@ /** | ||
}); | ||
}; | ||
/** | ||
* source(cb) -> cb(err, source) | ||
* | ||
* @jsonWire GET /session/:sessionId/source | ||
*/ | ||
webdriver.prototype.source = function(cb) { | ||
this._jsonWireCall({ | ||
method: 'GET' | ||
, relPath: '/source' | ||
, cb: this._callbackWithData(cb) | ||
}); | ||
} | ||
@@ -1447,3 +1399,3 @@ | ||
}); | ||
} | ||
}; | ||
@@ -1459,5 +1411,5 @@ /** | ||
var _this = this; | ||
if (typeof element === 'undefined' || element == 'body' || element === null) { | ||
if (!element || element === 'body') { | ||
_this.element.apply(this, ['tag name', 'body', function(err, bodyEl) { | ||
if (err == null) {_this._rawText.apply(_this, [bodyEl, cb]);} else {cb(err);} | ||
if (!err) {_this._rawText.apply(_this, [bodyEl, cb]);} else {cb(err);} | ||
}]); | ||
@@ -1488,2 +1440,29 @@ }else { | ||
/** | ||
* alertText(cb) -> cb(err, text) | ||
* | ||
* @jsonWire GET /session/:sessionId/alert_text | ||
*/ | ||
webdriver.prototype.alertText = function(cb) { | ||
this._jsonWireCall({ | ||
method: 'GET' | ||
, relPath: '/alert_text' | ||
, cb: this._callbackWithData(cb) | ||
}); | ||
} | ||
/** | ||
* alertKeys(keys, cb) -> cb(err) | ||
* | ||
* @jsonWire POST /session/:sessionId/alert_text | ||
*/ | ||
webdriver.prototype.alertKeys = function(keys, cb) { | ||
this._jsonWireCall({ | ||
method: 'POST' | ||
, relPath: '/alert_text' | ||
, data: {text: keys} | ||
, cb: this._simpleCallback(cb) | ||
}); | ||
} | ||
/** | ||
* acceptAlert(cb) -> cb(err) | ||
@@ -1499,3 +1478,3 @@ * | ||
}); | ||
} | ||
}; | ||
@@ -1513,3 +1492,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -1524,4 +1503,4 @@ /** | ||
var cbWrap = function(e, o) { | ||
var el = new element(o['ELEMENT'], _this); | ||
cb(null, el) | ||
var el = new element(o.ELEMENT, _this); | ||
cb(null, el); | ||
}; | ||
@@ -1533,3 +1512,3 @@ this._jsonWireCall({ | ||
}); | ||
} | ||
}; | ||
@@ -1547,3 +1526,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -1561,3 +1540,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -1575,7 +1554,4 @@ /** | ||
// setting secure otherwise selenium server throws | ||
if ((typeof cookie !== 'undefined' && cookie !== null) && | ||
!((typeof cookie !== 'undefined' && | ||
cookie !== null ? cookie.secure : void 0) != null)) { | ||
cookie.secure = false; | ||
} | ||
if(cookie){ cookie.secure = cookie.secure || false; } | ||
this._jsonWireCall({ | ||
@@ -1587,3 +1563,3 @@ method: 'POST' | ||
}); | ||
} | ||
}; | ||
@@ -1601,3 +1577,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -1615,3 +1591,3 @@ /** | ||
}); | ||
} | ||
}; | ||
@@ -1626,5 +1602,4 @@ var _isVisible1 = function(element , cb){ | ||
}); | ||
} | ||
}; | ||
// deprecated | ||
var _isVisible2 = function(queryType, querySelector, cb){ | ||
@@ -1636,20 +1611,19 @@ this.elementIfExists(queryType, querySelector, function(err, element){ | ||
if(element == null){ | ||
return cb(null, false); | ||
} | ||
element.isVisible(cb); | ||
if(element){ | ||
element.isVisible(cb); | ||
} else { | ||
cb(null, false); } | ||
}); | ||
} | ||
}; | ||
/** | ||
* isVisible(element , cb) -> cb(err, boolean) | ||
* deprecated: isVisible(queryType, querySelector, cb) -> cb(err, boolean) | ||
* isVisible(queryType, querySelector, cb) -> cb(err, boolean) | ||
*/ | ||
webdriver.prototype.isVisible = function() { | ||
var args; | ||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
var args = __slice.call(arguments, 0); | ||
if (args.length <= 2) { | ||
return _isVisible1.apply(this, args); | ||
_isVisible1.apply(this, args); | ||
} else { | ||
return _isVisible2.apply(this, args); | ||
_isVisible2.apply(this, args); | ||
} | ||
@@ -1666,6 +1640,6 @@ }; | ||
_this.safeEval.apply( _this , [conditionExpr, function(err, res) { | ||
if(err != null) {return cb(err);} | ||
if (res == true) { | ||
if(err) {return cb(err);} | ||
if (res === true) { | ||
// condition ok | ||
return cb(null, true); | ||
cb(null, true); | ||
} else { | ||
@@ -1681,8 +1655,8 @@ // wait for poll and try again | ||
_this.safeEval.apply( _this, [conditionExpr, function(err, res) { | ||
if(err != null) {return cb(err);} | ||
if (res == true) { | ||
return cb(null, true); | ||
if(err) {return cb(err);} | ||
if (res === true) { | ||
cb(null, true); | ||
} else { | ||
// condition nok within timeout | ||
return cb("waitForCondition failure for: " + conditionExpr); | ||
cb("waitForCondition failure for: " + conditionExpr); | ||
} | ||
@@ -1707,14 +1681,10 @@ }]); | ||
// parsing args | ||
var args, cb, conditionExpr, limit, poll, timeout, _i; | ||
args = 2 <= arguments.length ? __slice.call(arguments, 0, | ||
_i = arguments.length - 1) : (_i = 0, []), | ||
cb = arguments[_i++]; | ||
conditionExpr = args[0], timeout = args[1], poll = args[2]; | ||
var fargs = utils.varargs(arguments); | ||
var cb = fargs.callback, | ||
conditionExpr = fargs.all[0], | ||
timeout = fargs.all[1] || 1000, | ||
poll = fargs.all[2] || 100; | ||
//defaults | ||
timeout = timeout || 1000; | ||
poll = poll || 100; | ||
// calling implementation | ||
limit = Date.now() + timeout; | ||
var limit = Date.now() + timeout; | ||
_this._waitForConditionImpl.apply(this, [conditionExpr, limit, poll, cb]); | ||
@@ -1739,17 +1709,13 @@ }; | ||
// parsing args | ||
var args, cb, conditionExpr, limit, poll, timeout, _i; | ||
args = 2 <= arguments.length ? __slice.call(arguments, 0, | ||
_i = arguments.length - 1) : (_i = 0, []), | ||
cb = arguments[_i++]; | ||
conditionExpr = args[0], timeout = args[1], poll = args[2]; | ||
var fargs = utils.varargs(arguments); | ||
var cb = fargs.callback, | ||
conditionExpr = fargs.all[0], | ||
timeout = fargs.all[1] || 1000, | ||
poll = fargs.all[2] || 100; | ||
//defaults | ||
timeout = timeout || 1000; | ||
poll = poll || 100; | ||
// calling script | ||
_this.safeExecuteAsync.apply( _this, [_this._waitForConditionInBrowserJsScript, | ||
[conditionExpr,timeout,poll], function(err,res) { | ||
if(err != null) {return cb(err);} | ||
if(res != true) {return cb("waitForConditionInBrowser failure for: " + conditionExpr);} | ||
if(err) {return cb(err);} | ||
if(res !== true) {return cb("waitForConditionInBrowser failure for: " + conditionExpr);} | ||
cb(null, res); | ||
@@ -1756,0 +1722,0 @@ } |
{ | ||
"name" : "wd" | ||
, "description" : "WebDriver/Selenium 2 node.js client" | ||
, "tags" : ["web", "automation", "browser", "javascript"] | ||
, "version" : "0.0.26" | ||
, "author" : "Adam Christian <adam.christian@gmail.com>" | ||
, "repository" : | ||
{ "type" : "git" | ||
, "url" : "https://github.com/admc/wd.git" | ||
} | ||
, "bugs" : | ||
{ "url" : "https://github.com/admc/wd/issues" } | ||
, "engines" : ["node"] | ||
, "main" : "./lib/main" | ||
, "bin" : { "wd" : "./lib/bin.js" } | ||
, "directories" : { "lib" : "./lib" } | ||
, "dependencies" : { | ||
"async" : "0.1.x" | ||
} | ||
, "devDependencies" : { | ||
"mocha" : "1.6.x" | ||
,"should": "1.2.x" | ||
,"coffee-script": "1.3.x" | ||
,"express": "3.x" | ||
,"imageinfo": "1.0.x" | ||
,"covershot": "0.1.x" | ||
,"nock": "0.13.x" | ||
,"dox": "0.3.x" | ||
,"mu2": "0.5.x" | ||
,"underscore": "1.4.x" | ||
} | ||
, "scripts" : { | ||
"name": "wd", | ||
"description": "WebDriver/Selenium 2 node.js client", | ||
"tags": [ | ||
"web", | ||
"automation", | ||
"browser", | ||
"javascript" | ||
], | ||
"version": "0.0.27", | ||
"author": "Adam Christian <adam.christian@gmail.com>", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/admc/wd.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/admc/wd/issues" | ||
}, | ||
"engines": [ | ||
"node" | ||
], | ||
"main": "./lib/main", | ||
"bin": { | ||
"wd": "./lib/bin.js" | ||
}, | ||
"directories": { | ||
"lib": "./lib" | ||
}, | ||
"dependencies": { | ||
"async": "0.1.x", | ||
"underscore": "1.4.x", | ||
"vargs": "~0.1.0", | ||
"request": "~2.12.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "1.6.x", | ||
"should": "1.2.x", | ||
"coffee-script": "1.3.x", | ||
"express": "3.x", | ||
"imageinfo": "1.0.x", | ||
"covershot": "0.1.x", | ||
"nock": "0.13.x", | ||
"dox": "0.3.x", | ||
"mu2": "0.5.x", | ||
"sv-selenium": "0.1.x" | ||
}, | ||
"scripts": { | ||
"test": "make test_saucelabs" | ||
} | ||
} |
107
README.md
@@ -1,4 +0,5 @@ | ||
# WD.js -- A light weight WebDriver/Se2 client for node.js | ||
# WD.js -- WebDriver/Selenium 2 for node.js | ||
[![Build Status](https://secure.travis-ci.org/admc/wd.png?branch=master)](http://travis-ci.org/admc/wd) | ||
[![Selenium Test Status](https://saucelabs.com/buildstatus/wdjs)](https://saucelabs.com) | ||
@@ -63,19 +64,19 @@ ## Update node to latest | ||
, name: "This is an example test" | ||
} | ||
}; | ||
browser.init(desired, function() { | ||
browser.get("http://saucelabs.com/test/guinea-pig", function() { | ||
browser.get("http://admc.io/wd/test-pages/guinea-pig.html", function() { | ||
browser.title(function(err, title) { | ||
assert.ok(~title.indexOf('I am a page title - Sauce Labs'), 'Wrong title!'); | ||
browser.elementById('submit', function(err, el) { | ||
browser.elementById('i am a link', function(err, el) { | ||
browser.clickElement(el, function() { | ||
browser.eval("window.location.href", function(err, title) { | ||
assert.ok(~title.indexOf('#'), 'Wrong title!'); | ||
browser.quit() | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
browser.eval("window.location.href", function(err, location) { | ||
assert.ok(~location.indexOf('guinea-pig2')); | ||
browser.quit(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
</pre> | ||
@@ -1189,2 +1190,42 @@ | ||
GET <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/alert_text">/session/:sessionId/alert_text</a><br> | ||
Gets the text of the currently displayed JavaScript alert(), confirm(), or prompt() dialog. | ||
</td> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
alertText(cb) -> cb(err, text)<br> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/alert_text">/session/:sessionId/alert_text</a><br> | ||
Sends keystrokes to a JavaScript prompt() dialog. | ||
</td> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
alertKeys(keys, cb) -> cb(err)<br> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
POST <a href="http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/accept_alert">/session/:sessionId/accept_alert</a><br> | ||
@@ -1345,2 +1386,21 @@ Accepts the currently displayed alert dialog. | ||
esired, cb<br> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
EXTRA | ||
</td> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
Opens a new window (using Javascript window.open):<br> | ||
@@ -1375,2 +1435,21 @@ | ||
rl, name, cb<br> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
EXTRA | ||
</td> | ||
<td style="border: 1px solid #ccc; padding: 5px;"> | ||
windowName(cb) -> cb(err, name)<br> | ||
@@ -1505,3 +1584,3 @@ | ||
deprecated: isVisible(queryType, querySelector, cb) -> cb(err, boolean)<br> | ||
isVisible(queryType, querySelector, cb) -> cb(err, boolean)<br> | ||
@@ -1508,0 +1587,0 @@ |
@@ -1,48 +0,71 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var TIMEOUT, assert, should, test; | ||
var TIMEOUT, assert, should, test; | ||
should = require('should'); | ||
should = require('should'); | ||
assert = require('assert'); | ||
assert = require('assert'); | ||
TIMEOUT = 60000; | ||
TIMEOUT = 60000; | ||
test = function(remoteWdConfig, desired) { | ||
var browser, wd; | ||
wd = require('./wd-with-cov'); | ||
if (typeof remoteWdConfig === 'function') { | ||
remoteWdConfig = remoteWdConfig(); | ||
test = function(remoteWdConfig, desired, markAsPassed) { | ||
var sessionID; | ||
var browser, wd; | ||
wd = require('./wd-with-cov'); | ||
if (typeof remoteWdConfig === 'function') { | ||
remoteWdConfig = remoteWdConfig(); | ||
} | ||
browser = null; | ||
after(function(done) { | ||
if(markAsPassed) { | ||
markAsPassed(sessionID, done); | ||
} else { | ||
done(null); | ||
} | ||
browser = null; | ||
describe("remote", function() { | ||
return it("should create browser", function(done) { | ||
browser = wd.remote(remoteWdConfig); | ||
should.exist(browser); | ||
if (process.env.WD_COV == null) { | ||
browser.on("status", function(info) { | ||
return console.log("\u001b[36m%s\u001b[0m", info); | ||
}); | ||
browser.on("command", function(meth, path) { | ||
return console.log(" > \u001b[33m%s\u001b[0m: %s", meth, path); | ||
}); | ||
} | ||
}); | ||
describe("remote", function() { | ||
return it("should create browser", function(done) { | ||
browser = wd.remote(remoteWdConfig); | ||
should.exist(browser); | ||
if (!process.env.WD_COV) { | ||
browser.on("status", function(info) { | ||
return console.log("\u001b[36m%s\u001b[0m", info); | ||
}); | ||
browser.on("command", function(meth, path) { | ||
return console.log(" > \u001b[33m%s\u001b[0m: %s", meth, path); | ||
}); | ||
} | ||
return done(null); | ||
}); | ||
}); | ||
describe("init", function() { | ||
return it("should initialize browser", function(done) { | ||
this.timeout(TIMEOUT); | ||
return browser.init(desired, function() { | ||
sessionID = browser.sessionID; | ||
return done(null); | ||
}); | ||
}); | ||
describe("init", function() { | ||
return it("should initialize browser", function(done) { | ||
}); | ||
describe("browsing", function() { | ||
describe("getting page", function() { | ||
return it("should navigate to test page and check title", function(done) { | ||
this.timeout(TIMEOUT); | ||
return browser.init(desired, function() { | ||
return done(null); | ||
return browser.get("http://admc.io/wd/test-pages/guinea-pig.html", function(err) { | ||
if(err) { console.log(err); return done(err); } | ||
return browser.title(function(err, title) { | ||
if(err) { console.log(err); return done(err); } | ||
assert.ok(~title.indexOf("I am a page title - Sauce Labs"), "Wrong title!"); | ||
done(null); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe("browsing", function() { | ||
describe("getting page", function() { | ||
return it("should navigate to test page and check title", function(done) { | ||
this.timeout(TIMEOUT); | ||
return browser.get("http://saucelabs.com/test/guinea-pig", function() { | ||
return browser.title(function(err, title) { | ||
assert.ok(~title.indexOf("I am a page title - Sauce Labs"), "Wrong title!"); | ||
return describe("clicking submit", function() { | ||
return it("submit element should be clicked", function(done) { | ||
this.timeout(TIMEOUT); | ||
return browser.elementById("submit", function(err, el) { | ||
return browser.clickElement(el, function() { | ||
return browser["eval"]("window.location.href", function(err, location) { | ||
assert.ok(~location.indexOf("http://"), "Wrong location!"); | ||
return done(null); | ||
@@ -53,28 +76,14 @@ }); | ||
}); | ||
return describe("clicking submit", function() { | ||
return it("submit element should be clicked", function(done) { | ||
this.timeout(TIMEOUT); | ||
return browser.elementById("submit", function(err, el) { | ||
return browser.clickElement(el, function() { | ||
return browser["eval"]("window.location.href", function(err, location) { | ||
assert.ok(~location.indexOf("http://"), "Wrong location!"); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
return describe("leaving", function() { | ||
return it("closing browser", function(done) { | ||
this.timeout(TIMEOUT); | ||
return browser.quit(function() { | ||
return done(null); | ||
}); | ||
}); | ||
return describe("leaving", function() { | ||
return it("closing browser", function(done) { | ||
this.timeout(TIMEOUT); | ||
return browser.quit(function() { | ||
done(null); | ||
}); | ||
}); | ||
}; | ||
}); | ||
}; | ||
exports.test = test; | ||
}).call(this); | ||
exports.test = test; |
@@ -1,50 +0,52 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var async, should, test, wd; | ||
var async, should, test, wd; | ||
should = require('should'); | ||
should = require('should'); | ||
async = require('async'); | ||
async = require('async'); | ||
wd = require('./wd-with-cov'); | ||
wd = require('./wd-with-cov'); | ||
test = function(browserName) { | ||
var browser; | ||
browser = null; | ||
describe("wd.remote", function() { | ||
return it("should create browser", function(done) { | ||
browser = wd.remote({}); | ||
if (process.env.WD_COV == null) { | ||
browser.on("status", function(info) { | ||
return console.log("\u001b[36m%s\u001b[0m", info); | ||
}); | ||
browser.on("command", function(meth, path) { | ||
return console.log(" > \u001b[33m%s\u001b[0m: %s", meth, path); | ||
}); | ||
} | ||
test = function(browserName) { | ||
var browser; | ||
browser = null; | ||
describe("wd.remote", function() { | ||
return it("should create browser", function(done) { | ||
browser = wd.remote({}); | ||
if (!process.env.WD_COV) { | ||
browser.on("status", function(info) { | ||
return console.log("\u001b[36m%s\u001b[0m", info); | ||
}); | ||
browser.on("command", function(meth, path) { | ||
return console.log(" > \u001b[33m%s\u001b[0m: %s", meth, path); | ||
}); | ||
} | ||
return done(null); | ||
}); | ||
}); | ||
return describe("chaining", function() { | ||
return it("should work", function(done) { | ||
return browser.chain().init({ | ||
browserName: 'chrome', | ||
tags: ["examples"], | ||
name: "This is an example test" | ||
}).get("http://admc.io/wd/test-pages/guinea-pig.html").title(function(err, title) { | ||
return title.should.include('I am a page title - Sauce Labs'); | ||
}).elementById('submit', function(err, el) { | ||
should.not.exist(err); | ||
should.exist(el); | ||
// Commenting this test, nothing preventing quit to be called first | ||
// we should make clickElement not require a callback | ||
// return browser.clickElement(el, function(err) { | ||
// return should.not.exist.err; | ||
//}); | ||
})["eval"]("window.location.href", function(err, href) { | ||
return href.should.include('http'); | ||
}).quit(function(err) { | ||
return done(null); | ||
}); | ||
}); | ||
return describe("chaining", function() { | ||
return it("should work", function(done) { | ||
return browser.chain().init({ | ||
browserName: 'chrome', | ||
tags: ["examples"], | ||
name: "This is an example test" | ||
}).get("http://saucelabs.com/test/guinea-pig").title(function(err, title) { | ||
return title.should.include('I am a page title - Sauce Labs'); | ||
}).elementById('submit', function(err, el) { | ||
should.not.exist(err); | ||
return should.exist(el); | ||
})["eval"]("window.location.href", function(err, href) { | ||
return href.should.include('http'); | ||
}).quit(function(err) { | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
}; | ||
}); | ||
}; | ||
exports.test = test; | ||
}).call(this); | ||
exports.test = test; |
@@ -1,67 +0,85 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var CoffeeScript, Express, async, executeCoffee, should, test, textShouldEqual, wd; | ||
var CoffeeScript, Express, async, executeCoffee, should, test, textShouldEqual, wd; | ||
CoffeeScript = require('coffee-script'); | ||
CoffeeScript = require('coffee-script'); | ||
should = require('should'); | ||
should = require('should'); | ||
async = require('async'); | ||
async = require('async'); | ||
Express = require('./express').Express; | ||
Express = require('./express').Express; | ||
wd = require('./wd-with-cov'); | ||
wd = require('./wd-with-cov'); | ||
textShouldEqual = function(browser, element, expected, done) { | ||
return browser.text(element, function(err, res) { | ||
textShouldEqual = function(browser, element, expected, done) { | ||
return browser.text(element, function(err, res) { | ||
should.not.exist(err); | ||
res.should.equal(expected); | ||
return done(null); | ||
}); | ||
}; | ||
executeCoffee = function(browser, script) { | ||
var scriptAsJs; | ||
scriptAsJs = CoffeeScript.compile(script, { | ||
bare: 'on' | ||
}); | ||
return function(done) { | ||
return browser.execute(scriptAsJs, function(err) { | ||
should.not.exist(err); | ||
res.should.equal(expected); | ||
return done(null); | ||
}); | ||
}; | ||
}; | ||
executeCoffee = function(browser, script) { | ||
var scriptAsJs; | ||
scriptAsJs = CoffeeScript.compile(script, { | ||
bare: 'on' | ||
test = function(remoteWdConfig, desired) { | ||
var browser, express; | ||
browser = null; | ||
express = new Express(); | ||
before(function(done) { | ||
express.start(); | ||
return done(null); | ||
}); | ||
after(function(done) { | ||
express.stop(); | ||
return done(null); | ||
}); | ||
describe("wd.remote", function() { | ||
return it("should create browser", function(done) { | ||
browser = wd.remote(remoteWdConfig); | ||
if (!process.env.WD_COV) { | ||
browser.on("status", function(info) { | ||
return console.log("\u001b[36m%s\u001b[0m", info); | ||
}); | ||
browser.on("command", function(meth, path) { | ||
return console.log(" > \u001b[33m%s\u001b[0m: %s", meth, path); | ||
}); | ||
} | ||
return done(null); | ||
}); | ||
return function(done) { | ||
return browser.execute(scriptAsJs, function(err) { | ||
}); | ||
describe("init", function() { | ||
return it("should initialize browserinit", function(done) { | ||
this.timeout(45000); | ||
return browser.init(desired, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}; | ||
}; | ||
test = function(remoteWdConfig, desired) { | ||
var browser, express; | ||
browser = null; | ||
express = new Express; | ||
before(function(done) { | ||
express.start(); | ||
return done(null); | ||
}); | ||
after(function(done) { | ||
express.stop(); | ||
return done(null); | ||
}); | ||
describe("wd.remote", function() { | ||
return it("should create browser", function(done) { | ||
browser = wd.remote(remoteWdConfig); | ||
if (process.env.WD_COV == null) { | ||
browser.on("status", function(info) { | ||
return console.log("\u001b[36m%s\u001b[0m", info); | ||
}); | ||
browser.on("command", function(meth, path) { | ||
return console.log(" > \u001b[33m%s\u001b[0m: %s", meth, path); | ||
}); | ||
} | ||
}); | ||
describe("get", function() { | ||
return it("should navigate to test page", function(done) { | ||
this.timeout(15000); | ||
return browser.get("http://127.0.0.1:8181/element-test-page.html", function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("init", function() { | ||
return it("should initialize browserinit", function(done) { | ||
this.timeout(45000); | ||
return browser.init(desired, function(err) { | ||
should.not.exist(err); | ||
}); | ||
describe("element.text", function() { | ||
return it("should retrieve the text", function(done) { | ||
return browser.element("id", "text", function(err, el) { | ||
should.not.exist(err); | ||
el.should.have.property("text"); | ||
return el.text(function(err, res) { | ||
res.should.include("I am some text"); | ||
return done(null); | ||
@@ -71,7 +89,11 @@ }); | ||
}); | ||
describe("get", function() { | ||
return it("should navigate to test page", function(done) { | ||
this.timeout(15000); | ||
return browser.get("http://127.0.0.1:8181/element-test-page.html", function(err) { | ||
}); | ||
describe("element.textPresent", function() { | ||
return it("should check if text is present", function(done) { | ||
return browser.element("id", "text", function(err, el) { | ||
should.not.exist(err); | ||
el.should.have.property("textPresent"); | ||
return el.textPresent("some text", function(err, present) { | ||
should.not.exist(err); | ||
present.should.be.true; | ||
return done(null); | ||
@@ -81,73 +103,18 @@ }); | ||
}); | ||
describe("element.text", function() { | ||
return it("should retrieve the text", function(done) { | ||
return browser.element("id", "text", function(err, el) { | ||
should.not.exist(err); | ||
el.should.have.property("text"); | ||
return el.text(function(err, res) { | ||
res.should.include("I am some text"); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe("element.textPresent", function() { | ||
return it("should check if text is present", function(done) { | ||
return browser.element("id", "text", function(err, el) { | ||
should.not.exist(err); | ||
el.should.have.property("textPresent"); | ||
return el.textPresent("some text", function(err, present) { | ||
should.not.exist(err); | ||
present.should.be["true"]; | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe("element.click", function() { | ||
return it("element should be clicked", function(done) { | ||
return browser.elementByCss("#click a", function(err, anchor) { | ||
should.not.exist(err); | ||
should.exist(anchor); | ||
return async.series([ | ||
executeCoffee(browser, 'jQuery ->\n a = $(\'#click a\')\n a.click ->\n a.html \'clicked\'\n false '), function(done) { | ||
return textShouldEqual(browser, anchor, "not clicked", done); | ||
}, function(done) { | ||
return anchor.click(function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}, function(done) { | ||
return textShouldEqual(browser, anchor, "clicked", done); | ||
} | ||
], function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe("element.getTagName", function() { | ||
return it("should get correct tag name", function(done) { | ||
}); | ||
describe("element.click", function() { | ||
return it("element should be clicked", function(done) { | ||
return browser.elementByCss("#click a", function(err, anchor) { | ||
should.not.exist(err); | ||
should.exist(anchor); | ||
return async.series([ | ||
function(done) { | ||
return browser.elementByCss("#getTagName input", function(err, field) { | ||
executeCoffee(browser, 'jQuery ->\n a = $(\'#click a\')\n a.click ->\n a.html \'clicked\'\n false '), function(done) { | ||
return textShouldEqual(browser, anchor, "not clicked", done); | ||
}, function(done) { | ||
return anchor.click(function(err) { | ||
should.not.exist(err); | ||
should.exist(field); | ||
return field.getTagName(function(err, res) { | ||
should.not.exist(err); | ||
res.should.equal("input"); | ||
return done(null); | ||
}); | ||
return done(null); | ||
}); | ||
}, function(done) { | ||
return browser.elementByCss("#getTagName a", function(err, field) { | ||
should.not.exist(err); | ||
should.exist(field); | ||
return field.getTagName(function(err, res) { | ||
should.not.exist(err); | ||
res.should.equal("a"); | ||
return done(null); | ||
}); | ||
}); | ||
return textShouldEqual(browser, anchor, "clicked", done); | ||
} | ||
@@ -160,138 +127,113 @@ ], function(err) { | ||
}); | ||
describe("element.isDisplayed", function() { | ||
return it("should check if elemnt is displayed", function(done) { | ||
return async.series([ | ||
function(done) { | ||
return browser.elementByCss("#isDisplayed .displayed", function(err, field) { | ||
}); | ||
describe("element.getTagName", function() { | ||
return it("should get correct tag name", function(done) { | ||
return async.series([ | ||
function(done) { | ||
return browser.elementByCss("#getTagName input", function(err, field) { | ||
should.not.exist(err); | ||
should.exist(field); | ||
return field.getTagName(function(err, res) { | ||
should.not.exist(err); | ||
should.exist(field); | ||
return field.isDisplayed(function(err, res) { | ||
should.not.exist(err); | ||
res.should.be["true"]; | ||
return done(null); | ||
}); | ||
res.should.equal("input"); | ||
return done(null); | ||
}); | ||
}, function(done) { | ||
return browser.elementByCss("#isDisplayed .hidden", function(err, field) { | ||
}); | ||
}, function(done) { | ||
return browser.elementByCss("#getTagName a", function(err, field) { | ||
should.not.exist(err); | ||
should.exist(field); | ||
return field.getTagName(function(err, res) { | ||
should.not.exist(err); | ||
should.exist(field); | ||
return field.isDisplayed(function(err, res) { | ||
should.not.exist(err); | ||
res.should.be["false"]; | ||
return done(null); | ||
}); | ||
res.should.equal("a"); | ||
return done(null); | ||
}); | ||
}, function(done) { | ||
return browser.elementByCss("#isDisplayed .displayed", function(err, field) { | ||
should.not.exist(err); | ||
should.exist(field); | ||
return field.displayed(function(err, res) { | ||
should.not.exist(err); | ||
res.should.be["true"]; | ||
return done(null); | ||
}); | ||
}); | ||
} | ||
], function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
} | ||
], function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("element.getComputedCss", function() { | ||
return it("should retrieve the element computed css", function(done) { | ||
return async.series([ | ||
function(done) { | ||
return browser.elementByCss("#getComputedCss a", function(err, field) { | ||
}); | ||
describe("element.isDisplayed", function() { | ||
return it("should check if elemnt is displayed", function(done) { | ||
return async.series([ | ||
function(done) { | ||
return browser.elementByCss("#isDisplayed .displayed", function(err, field) { | ||
should.not.exist(err); | ||
should.exist(field); | ||
return field.isDisplayed(function(err, res) { | ||
should.not.exist(err); | ||
should.exist(field); | ||
return field.getComputedCss('color', function(err, res) { | ||
should.not.exist(err); | ||
should.exist(res); | ||
res.length.should.be.above(0); | ||
return done(null); | ||
}); | ||
res.should.be.true; | ||
return done(null); | ||
}); | ||
}, function(done) { | ||
return browser.elementByCss("#getComputedCss a", function(err, field) { | ||
}); | ||
}, function(done) { | ||
return browser.elementByCss("#isDisplayed .hidden", function(err, field) { | ||
should.not.exist(err); | ||
should.exist(field); | ||
return field.isDisplayed(function(err, res) { | ||
should.not.exist(err); | ||
should.exist(field); | ||
return field.getComputedCSS('color', function(err, res) { | ||
should.not.exist(err); | ||
should.exist(res); | ||
res.length.should.be.above(0); | ||
return done(null); | ||
}); | ||
res.should.be.false; | ||
return done(null); | ||
}); | ||
} | ||
], function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
describe("element.getAttribute", function() { | ||
return it("should retrieve attribute value", function(done) { | ||
return browser.element("id", "getAttribute", function(err, el) { | ||
should.not.exist(err); | ||
el.should.have.property("getAttribute"); | ||
return el.getAttribute("att", function(err, value) { | ||
should.not.exist(err); | ||
value.should.equal("42"); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe("element.getValue", function() { | ||
return it("should retrieve value", function(done) { | ||
return browser.element("id", "getValue", function(err, el) { | ||
should.not.exist(err); | ||
el.should.have.property("getValue"); | ||
return el.getValue(function(err, value) { | ||
}, function(done) { | ||
return browser.elementByCss("#isDisplayed .displayed", function(err, field) { | ||
should.not.exist(err); | ||
value.should.equal("value"); | ||
return done(null); | ||
should.exist(field); | ||
return field.displayed(function(err, res) { | ||
should.not.exist(err); | ||
res.should.be.true; | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
} | ||
], function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("element.sendKeys", function() { | ||
return it("should send keys", function(done) { | ||
var text; | ||
text = "keys"; | ||
return browser.element("id", "sendKeys", function(err, el) { | ||
should.not.exist(err); | ||
el.should.have.property("sendKeys"); | ||
return el.sendKeys(text, function(err) { | ||
}); | ||
describe("element.getComputedCss", function() { | ||
return it("should retrieve the element computed css", function(done) { | ||
return async.series([ | ||
function(done) { | ||
return browser.elementByCss("#getComputedCss a", function(err, field) { | ||
should.not.exist(err); | ||
return el.getValue(function(err, textReceived) { | ||
should.exist(field); | ||
return field.getComputedCss('color', function(err, res) { | ||
should.not.exist(err); | ||
textReceived.should.equal(text); | ||
should.exist(res); | ||
res.length.should.be.above(0); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe("element.clear", function() { | ||
return it("should clear input field", function(done) { | ||
return browser.element("id", "clear", function(err, el) { | ||
should.not.exist(err); | ||
el.should.have.property("clear"); | ||
return el.clear(function(err) { | ||
}, function(done) { | ||
return browser.elementByCss("#getComputedCss a", function(err, field) { | ||
should.not.exist(err); | ||
return el.getValue(function(err, textReceived) { | ||
should.exist(field); | ||
return field.getComputedCSS('color', function(err, res) { | ||
should.not.exist(err); | ||
textReceived.should.equal(""); | ||
should.exist(res); | ||
res.length.should.be.above(0); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
} | ||
], function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("close", function() { | ||
return it("should close current window", function(done) { | ||
return browser.close(function(err) { | ||
}); | ||
describe("element.getAttribute", function() { | ||
return it("should retrieve attribute value", function(done) { | ||
return browser.element("id", "getAttribute", function(err, el) { | ||
should.not.exist(err); | ||
el.should.have.property("getAttribute"); | ||
return el.getAttribute("att", function(err, value) { | ||
should.not.exist(err); | ||
value.should.equal("42"); | ||
return done(null); | ||
@@ -301,6 +243,11 @@ }); | ||
}); | ||
return describe("quit", function() { | ||
return it("should destroy browser", function(done) { | ||
return browser.quit(function(err) { | ||
}); | ||
describe("element.getValue", function() { | ||
return it("should retrieve value", function(done) { | ||
return browser.element("id", "getValue", function(err, el) { | ||
should.not.exist(err); | ||
el.should.have.property("getValue"); | ||
return el.getValue(function(err, value) { | ||
should.not.exist(err); | ||
value.should.equal("value"); | ||
return done(null); | ||
@@ -310,6 +257,47 @@ }); | ||
}); | ||
}; | ||
}); | ||
describe("element.sendKeys", function() { | ||
return it("should send keys", function(done) { | ||
var text; | ||
text = "keys"; | ||
return browser.element("id", "sendKeys", function(err, el) { | ||
should.not.exist(err); | ||
el.should.have.property("sendKeys"); | ||
return el.sendKeys(text, function(err) { | ||
should.not.exist(err); | ||
return el.getValue(function(err, textReceived) { | ||
should.not.exist(err); | ||
textReceived.should.equal(text); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe("element.clear", function() { | ||
return it("should clear input field", function(done) { | ||
return browser.element("id", "clear", function(err, el) { | ||
should.not.exist(err); | ||
el.should.have.property("clear"); | ||
return el.clear(function(err) { | ||
should.not.exist(err); | ||
return el.getValue(function(err, textReceived) { | ||
should.not.exist(err); | ||
textReceived.should.equal(""); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
return describe("quit", function() { | ||
return it("should destroy browser", function(done) { | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
}; | ||
exports.test = test; | ||
}).call(this); | ||
exports.test = test; |
@@ -1,27 +0,23 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var Express, express; | ||
var Express, express; | ||
express = require('express'); | ||
express = require('express'); | ||
Express = (function() { | ||
Express = (function() { | ||
function Express() {} | ||
function Express() {} | ||
Express.prototype.start = function() { | ||
this.app = express(); | ||
this.app.use(express["static"](__dirname + '/assets')); | ||
return this.server = this.app.listen(8181); | ||
}; | ||
Express.prototype.start = function() { | ||
this.app = express(); | ||
this.app.use(express["static"](__dirname + '/assets')); | ||
this.server = this.app.listen(8181); | ||
}; | ||
Express.prototype.stop = function() { | ||
return this.server.close(); | ||
}; | ||
Express.prototype.stop = function() { | ||
return this.server.close(); | ||
}; | ||
return Express; | ||
return Express; | ||
})(); | ||
})(); | ||
exports.Express = Express; | ||
}).call(this); | ||
exports.Express = Express; |
@@ -1,425 +0,423 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var CoffeeScript, Express, altKey, altKeyTracking, async, clearAndCheck, click, enterKey, executeCoffee, inputAndCheck, keysAndCheck, nullKey, preventDefault, returnKey, should, test, typeAndCheck, unbind, valueShouldEqual, wd; | ||
var CoffeeScript, Express, altKey, altKeyTracking, async, clearAndCheck, click, enterKey, executeCoffee, inputAndCheck, keysAndCheck, nullKey, preventDefault, returnKey, should, test, typeAndCheck, unbind, valueShouldEqual, wd; | ||
CoffeeScript = require('coffee-script'); | ||
CoffeeScript = require('coffee-script'); | ||
should = require('should'); | ||
should = require('should'); | ||
async = require('async'); | ||
async = require('async'); | ||
Express = require('./express').Express; | ||
Express = require('./express').Express; | ||
wd = require('./wd-with-cov'); | ||
wd = require('./wd-with-cov'); | ||
altKey = wd.SPECIAL_KEYS['Alt']; | ||
altKey = wd.SPECIAL_KEYS.Alt; | ||
nullKey = wd.SPECIAL_KEYS['NULL']; | ||
nullKey = wd.SPECIAL_KEYS.NULL; | ||
returnKey = wd.SPECIAL_KEYS['Return']; | ||
returnKey = wd.SPECIAL_KEYS.Return; | ||
enterKey = wd.SPECIAL_KEYS['Enter']; | ||
enterKey = wd.SPECIAL_KEYS.Enter; | ||
executeCoffee = function(browser, script, done) { | ||
var scriptAsJs; | ||
scriptAsJs = CoffeeScript.compile(script, { | ||
bare: 'on' | ||
}); | ||
return browser.execute(scriptAsJs, function(err) { | ||
executeCoffee = function(browser, script, done) { | ||
var scriptAsJs; | ||
scriptAsJs = CoffeeScript.compile(script, { | ||
bare: 'on' | ||
}); | ||
return browser.execute(scriptAsJs, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}; | ||
valueShouldEqual = function(browser, element, expected, done) { | ||
return browser.getValue(element, function(err, res) { | ||
should.not.exist(err); | ||
res.should.equal(expected); | ||
return done(null); | ||
}); | ||
}; | ||
click = function(browser, _sel, done) { | ||
return browser.elementByCss(_sel, function(err, inputField) { | ||
should.not.exist(err); | ||
should.exist(inputField); | ||
return browser.clickElement(inputField, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}; | ||
}); | ||
}; | ||
valueShouldEqual = function(browser, element, expected, done) { | ||
return browser.getValue(element, function(err, res) { | ||
typeAndCheck = function(browser, _sel, chars, expected, done) { | ||
return browser.elementByCss(_sel, function(err, inputField) { | ||
should.not.exist(err); | ||
should.exist(inputField); | ||
return async.series([ | ||
function(done) { | ||
return browser.type(inputField, chars, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}, function(done) { | ||
return valueShouldEqual(browser, inputField, expected, done); | ||
} | ||
], function(err) { | ||
should.not.exist(err); | ||
res.should.equal(expected); | ||
return done(null); | ||
}); | ||
}; | ||
}); | ||
}; | ||
click = function(browser, _sel, done) { | ||
return browser.elementByCss(_sel, function(err, inputField) { | ||
keysAndCheck = function(browser, _sel, chars, expected, done) { | ||
return browser.elementByCss(_sel, function(err, inputField) { | ||
should.not.exist(err); | ||
should.exist(inputField); | ||
return async.series([ | ||
function(done) { | ||
return browser.moveTo(inputField, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}, function(done) { | ||
return browser.keys(chars, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}, function(done) { | ||
return valueShouldEqual(browser, inputField, expected, done); | ||
} | ||
], function(err) { | ||
should.not.exist(err); | ||
should.exist(inputField); | ||
return browser.clickElement(inputField, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
return done(null); | ||
}); | ||
}; | ||
}); | ||
}; | ||
typeAndCheck = function(browser, _sel, chars, expected, done) { | ||
return browser.elementByCss(_sel, function(err, inputField) { | ||
should.not.exist(err); | ||
should.exist(inputField); | ||
return async.series([ | ||
function(done) { | ||
return browser.type(inputField, chars, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}, function(done) { | ||
return valueShouldEqual(browser, inputField, expected, done); | ||
} | ||
], function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
}; | ||
inputAndCheck = function(browser, method, _sel, chars, expected, done) { | ||
switch (method) { | ||
case 'type': | ||
return typeAndCheck(browser, _sel, chars, expected, done); | ||
case 'keys': | ||
return keysAndCheck(browser, _sel, chars, expected, done); | ||
} | ||
}; | ||
keysAndCheck = function(browser, _sel, chars, expected, done) { | ||
return browser.elementByCss(_sel, function(err, inputField) { | ||
clearAndCheck = function(browser, _sel, done) { | ||
return browser.elementByCss(_sel, function(err, inputField) { | ||
should.not.exist(err); | ||
should.exist(inputField); | ||
return async.series([ | ||
function(done) { | ||
return browser.clear(inputField, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}, function(done) { | ||
return valueShouldEqual(browser, inputField, "", done); | ||
} | ||
], function(err) { | ||
should.not.exist(err); | ||
should.exist(inputField); | ||
return async.series([ | ||
function(done) { | ||
return browser.moveTo(inputField, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}, function(done) { | ||
return browser.keys(chars, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}, function(done) { | ||
return valueShouldEqual(browser, inputField, expected, done); | ||
} | ||
], function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
return done(null); | ||
}); | ||
}; | ||
}); | ||
}; | ||
inputAndCheck = function(browser, method, _sel, chars, expected, done) { | ||
switch (method) { | ||
case 'type': | ||
return typeAndCheck(browser, _sel, chars, expected, done); | ||
case 'keys': | ||
return keysAndCheck(browser, _sel, chars, expected, done); | ||
} | ||
}; | ||
preventDefault = function(browser, _sel, eventType, done) { | ||
var script; | ||
script = "$('" + _sel + "')." + eventType + " (e) ->\n e.preventDefault()"; | ||
return executeCoffee(browser, script, done); | ||
}; | ||
clearAndCheck = function(browser, _sel, done) { | ||
return browser.elementByCss(_sel, function(err, inputField) { | ||
should.not.exist(err); | ||
should.exist(inputField); | ||
return async.series([ | ||
function(done) { | ||
return browser.clear(inputField, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}, function(done) { | ||
return valueShouldEqual(browser, inputField, "", done); | ||
} | ||
], function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
}; | ||
unbind = function(browser, _sel, eventType, done) { | ||
var script; | ||
script = "$('" + _sel + "').unbind '" + eventType + "' "; | ||
return executeCoffee(browser, script, done); | ||
}; | ||
preventDefault = function(browser, _sel, eventType, done) { | ||
var script; | ||
script = "$('" + _sel + "')." + eventType + " (e) ->\n e.preventDefault()"; | ||
return executeCoffee(browser, script, done); | ||
}; | ||
altKeyTracking = function(browser, _sel, done) { | ||
var script; | ||
script = "f = $('" + _sel + "')\nf.keydown (e) ->\n if e.altKey\n f.val 'altKey on'\n else\n f.val 'altKey off'\n e.preventDefault()"; | ||
return executeCoffee(browser, script, done); | ||
}; | ||
unbind = function(browser, _sel, eventType, done) { | ||
var script; | ||
script = "$('" + _sel + "').unbind '" + eventType + "' "; | ||
return executeCoffee(browser, script, done); | ||
}; | ||
altKeyTracking = function(browser, _sel, done) { | ||
var script; | ||
script = "f = $('" + _sel + "')\nf.keydown (e) ->\n if e.altKey\n f.val 'altKey on'\n else\n f.val 'altKey off'\n e.preventDefault()"; | ||
return executeCoffee(browser, script, done); | ||
}; | ||
test = function(remoteWdConfig, desired) { | ||
var browser, browserName, express, testMethod; | ||
browser = null; | ||
browserName = desired != null ? desired.browserName : void 0; | ||
express = new Express; | ||
before(function(done) { | ||
express.start(); | ||
return done(null); | ||
}); | ||
after(function(done) { | ||
express.stop(); | ||
return done(null); | ||
}); | ||
testMethod = function(method, sel) { | ||
return describe("method:" + method, function() { | ||
return describe("sel:" + sel, function() { | ||
describe("1/ click", function() { | ||
return it("should work", function(done) { | ||
return click(browser, sel, done); | ||
}); | ||
test = function(remoteWdConfig, desired) { | ||
var browser, browserName, express, testMethod; | ||
browser = null; | ||
browserName = desired !== null ? desired.browserName : 0; | ||
express = new Express(); | ||
before(function(done) { | ||
express.start(); | ||
return done(null); | ||
}); | ||
after(function(done) { | ||
express.stop(); | ||
return done(null); | ||
}); | ||
testMethod = function(method, sel) { | ||
return describe("method:" + method, function() { | ||
return describe("sel:" + sel, function() { | ||
describe("1/ click", function() { | ||
return it("should work", function(done) { | ||
return click(browser, sel, done); | ||
}); | ||
if (!(method === 'keys' && (browserName === 'chrome'))) { | ||
describe("1/ typing nothing", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, "", "", done); | ||
}); | ||
}); | ||
} | ||
if (method !== 'keys') { | ||
describe("2/ typing []", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, [], "", done); | ||
}); | ||
}); | ||
} | ||
describe("3/ typing 'Hello'", function() { | ||
}); | ||
if (!(method === 'keys' && (browserName === 'chrome'))) { | ||
describe("1/ typing nothing", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, 'Hello', 'Hello', done); | ||
return inputAndCheck(browser, method, sel, "", "", done); | ||
}); | ||
}); | ||
describe("4/ clear", function() { | ||
} | ||
if (method !== 'keys') { | ||
describe("2/ typing []", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
return inputAndCheck(browser, method, sel, [], "", done); | ||
}); | ||
}); | ||
describe("5/ typing ['Hello']", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, ['Hello'], 'Hello', done); | ||
}); | ||
} | ||
describe("3/ typing 'Hello'", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, 'Hello', 'Hello', done); | ||
}); | ||
describe("6/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
}); | ||
describe("4/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
describe("7/ typing ['Hello',' ','World','!']", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, ['Hello', ' ', 'World', '!'], 'Hello World!', done); | ||
}); | ||
}); | ||
describe("5/ typing ['Hello']", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, ['Hello'], 'Hello', done); | ||
}); | ||
describe("8/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
}); | ||
describe("6/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
describe("9/ typing 'Hello\\n'", function() { | ||
return it("should work", function(done) { | ||
var expected; | ||
expected = (sel.match(/input/) ? 'Hello' : 'Hello\n'); | ||
return inputAndCheck(browser, method, sel, 'Hello\n', expected, done); | ||
}); | ||
}); | ||
describe("7/ typing ['Hello',' ','World','!']", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, ['Hello', ' ', 'World', '!'], 'Hello World!', done); | ||
}); | ||
describe("10/ typing '\\r'", function() { | ||
return it("should work", function(done) { | ||
if (browserName = 'chrome' || (process.env.GHOSTDRIVER_TEST != null)) { | ||
return inputAndCheck(browser, method, sel, [returnKey], (sel.match(/input/) ? 'Hello' : 'Hello\n\n'), done); | ||
} else { | ||
return inputAndCheck(browser, method, sel, '\r', (sel.match(/input/) ? 'Hello' : 'Hello\n\n'), done); | ||
} | ||
}); | ||
}); | ||
describe("8/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
describe("11/ typing [returnKey]", function() { | ||
return it("should work", function(done) { | ||
var expected; | ||
expected = (sel.match(/input/) ? 'Hello' : 'Hello\n\n\n'); | ||
return inputAndCheck(browser, method, sel, [returnKey], expected, done); | ||
}); | ||
}); | ||
describe("9/ typing 'Hello\\n'", function() { | ||
return it("should work", function(done) { | ||
var expected; | ||
expected = (sel.match(/input/) ? 'Hello' : 'Hello\n'); | ||
return inputAndCheck(browser, method, sel, 'Hello\n', expected, done); | ||
}); | ||
describe("12/ typing [enterKey]", function() { | ||
return it("should work", function(done) { | ||
var expected; | ||
expected = (sel.match(/input/) ? 'Hello' : 'Hello\n\n\n\n'); | ||
return inputAndCheck(browser, method, sel, [enterKey], expected, done); | ||
}); | ||
}); | ||
describe("10/ typing '\\r'", function() { | ||
return it("should work", function(done) { | ||
if (browserName === 'chrome' || (process.env.GHOSTDRIVER_TEST)) { | ||
// chrome chrashes when sent '\r', ghostdriver does not | ||
// seem to like it | ||
inputAndCheck(browser, method, sel, [returnKey], (sel.match(/input/) ? 'Hello' : 'Hello\n\n'), done); | ||
} else { | ||
inputAndCheck(browser, method, sel, '\r', (sel.match(/input/) ? 'Hello' : 'Hello\n\n'), done); | ||
} | ||
}); | ||
describe("13/ typing ' World!'", function() { | ||
return it("should work", function(done) { | ||
var expected; | ||
expected = (sel.match(/input/) ? 'Hello World!' : 'Hello\n\n\n\n World!'); | ||
return inputAndCheck(browser, method, sel, ' World!', expected, done); | ||
}); | ||
}); | ||
describe("11/ typing [returnKey]", function() { | ||
return it("should work", function(done) { | ||
var expected; | ||
expected = (sel.match(/input/) ? 'Hello' : 'Hello\n\n\n'); | ||
return inputAndCheck(browser, method, sel, [returnKey], expected, done); | ||
}); | ||
describe("14/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
}); | ||
describe("12/ typing [enterKey]", function() { | ||
return it("should work", function(done) { | ||
var expected; | ||
expected = (sel.match(/input/) ? 'Hello' : 'Hello\n\n\n\n'); | ||
return inputAndCheck(browser, method, sel, [enterKey], expected, done); | ||
}); | ||
describe("15/ preventing default on keydown", function() { | ||
return it("should work", function(done) { | ||
return preventDefault(browser, sel, 'keydown', done); | ||
}); | ||
}); | ||
describe("13/ typing ' World!'", function() { | ||
return it("should work", function(done) { | ||
var expected; | ||
expected = (sel.match(/input/) ? 'Hello World!' : 'Hello\n\n\n\n World!'); | ||
return inputAndCheck(browser, method, sel, ' World!', expected, done); | ||
}); | ||
describe("16/ typing 'Hello'", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, 'Hello', '', done); | ||
}); | ||
}); | ||
describe("14/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
describe("17/ unbinding keydown", function() { | ||
return it("should work", function(done) { | ||
return unbind(browser, sel, 'keydown', done); | ||
}); | ||
}); | ||
describe("15/ preventing default on keydown", function() { | ||
return it("should work", function(done) { | ||
return preventDefault(browser, sel, 'keydown', done); | ||
}); | ||
describe("18/ typing 'Hello'", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, 'Hello', 'Hello', done); | ||
}); | ||
}); | ||
describe("16/ typing 'Hello'", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, 'Hello', '', done); | ||
}); | ||
describe("19/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
}); | ||
describe("17/ unbinding keydown", function() { | ||
return it("should work", function(done) { | ||
return unbind(browser, sel, 'keydown', done); | ||
}); | ||
describe("20/ preventing default on keypress", function() { | ||
return it("should work", function(done) { | ||
return preventDefault(browser, sel, 'keypress', done); | ||
}); | ||
}); | ||
describe("18/ typing 'Hello'", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, 'Hello', 'Hello', done); | ||
}); | ||
describe("21/ typing 'Hello'", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, 'Hello', '', done); | ||
}); | ||
}); | ||
describe("19/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
describe("22/ unbinding keypress", function() { | ||
return it("should work", function(done) { | ||
return unbind(browser, sel, 'keypress', done); | ||
}); | ||
}); | ||
describe("20/ preventing default on keypress", function() { | ||
return it("should work", function(done) { | ||
return preventDefault(browser, sel, 'keypress', done); | ||
}); | ||
describe("23/ typing 'Hello'", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, 'Hello', 'Hello', done); | ||
}); | ||
}); | ||
describe("21/ typing 'Hello'", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, 'Hello', '', done); | ||
}); | ||
describe("24/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
}); | ||
describe("22/ unbinding keypress", function() { | ||
return it("should work", function(done) { | ||
return unbind(browser, sel, 'keypress', done); | ||
}); | ||
describe("25/ preventing default on keyup", function() { | ||
return it("should work", function(done) { | ||
return preventDefault(browser, sel, 'keyup', done); | ||
}); | ||
}); | ||
describe("23/ typing 'Hello'", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, 'Hello', 'Hello', done); | ||
}); | ||
describe("26/ typing 'Hello'", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, 'Hello', 'Hello', done); | ||
}); | ||
}); | ||
describe("24/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
describe("27/ unbinding keypress", function() { | ||
return it("should work", function(done) { | ||
return unbind(browser, sel, 'keyup', done); | ||
}); | ||
}); | ||
describe("25/ preventing default on keyup", function() { | ||
return it("should work", function(done) { | ||
return preventDefault(browser, sel, 'keyup', done); | ||
}); | ||
describe("28/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
}); | ||
describe("26/ typing 'Hello'", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, 'Hello', 'Hello', done); | ||
}); | ||
describe("29/ adding alt key tracking", function() { | ||
return it("should work", function(done) { | ||
return altKeyTracking(browser, sel, done); | ||
}); | ||
}); | ||
describe("27/ unbinding keypress", function() { | ||
return it("should work", function(done) { | ||
return unbind(browser, sel, 'keyup', done); | ||
}); | ||
describe("30/ typing ['a']", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, ['a'], 'altKey off', done); | ||
}); | ||
}); | ||
describe("28/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
describe("31/ typing [altKey,nullKey,'a']", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, [altKey, nullKey, 'a'], 'altKey off', done); | ||
}); | ||
}); | ||
describe("29/ adding alt key tracking", function() { | ||
return it("should work", function(done) { | ||
return altKeyTracking(browser, sel, done); | ||
}); | ||
describe("32/ typing [altKey,'a']", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, [altKey, 'a'], 'altKey on', done); | ||
}); | ||
}); | ||
describe("30/ typing ['a']", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, ['a'], 'altKey off', done); | ||
}); | ||
if (process.env.GHOSTDRIVER_TEST == null) { | ||
describe("33/ typing ['a']", function() { | ||
return it("should work", function(done) { | ||
var expected; | ||
expected = (method === 'type' ? 'altKey off' : 'altKey on'); | ||
return inputAndCheck(browser, method, sel, ['a'], expected, done); | ||
}); | ||
}); | ||
} | ||
describe("34/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
}); | ||
describe("31/ typing [altKey,nullKey,'a']", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, [altKey, nullKey, 'a'], 'altKey off', done); | ||
}); | ||
describe("35/ typing [nullKey]", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, [nullKey], '', done); | ||
}); | ||
}); | ||
describe("32/ typing [altKey,'a']", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, [altKey, 'a'], 'altKey on', done); | ||
}); | ||
describe("36/ typing ['a']", function() { | ||
}); | ||
if (!process.env.GHOSTDRIVER_TEST) { | ||
describe("33/ typing ['a']", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, ['a'], 'altKey off', done); | ||
var expected; | ||
expected = (method === 'type' ? 'altKey off' : 'altKey on'); | ||
return inputAndCheck(browser, method, sel, ['a'], expected, done); | ||
}); | ||
}); | ||
describe("37/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
} | ||
describe("34/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
return describe("38/ unbinding keydown", function() { | ||
return it("should work", function(done) { | ||
return unbind(browser, sel, 'keydown', done); | ||
}); | ||
}); | ||
describe("35/ typing [nullKey]", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, [nullKey], '', done); | ||
}); | ||
}); | ||
}); | ||
}; | ||
describe("wd.remote", function() { | ||
return it("should work", function(done) { | ||
browser = wd.remote(remoteWdConfig); | ||
if (process.env.WD_COV == null) { | ||
browser.on("status", function(info) { | ||
return console.log("\u001b[36m%s\u001b[0m", info); | ||
describe("36/ typing ['a']", function() { | ||
return it("should work", function(done) { | ||
return inputAndCheck(browser, method, sel, ['a'], 'altKey off', done); | ||
}); | ||
browser.on("command", function(meth, path) { | ||
return console.log(" > \u001b[33m%s\u001b[0m: %s", meth, path); | ||
}); | ||
describe("37/ clear", function() { | ||
return it("should work", function(done) { | ||
return clearAndCheck(browser, sel, done); | ||
}); | ||
} | ||
return done(null); | ||
}); | ||
return describe("38/ unbinding keydown", function() { | ||
return it("should work", function(done) { | ||
return unbind(browser, sel, 'keydown', done); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe("init", function() { | ||
return it("should work", function(done) { | ||
return browser.init(desired, function(err) { | ||
should.not.exist(err); | ||
return done(err); | ||
}; | ||
describe("wd.remote", function() { | ||
return it("should work", function(done) { | ||
browser = wd.remote(remoteWdConfig); | ||
if (!process.env.WD_COV) { | ||
browser.on("status", function(info) { | ||
return console.log("\u001b[36m%s\u001b[0m", info); | ||
}); | ||
browser.on("command", function(meth, path) { | ||
return console.log(" > \u001b[33m%s\u001b[0m: %s", meth, path); | ||
}); | ||
} | ||
return done(null); | ||
}); | ||
}); | ||
describe("init", function() { | ||
return it("should work", function(done) { | ||
return browser.init(desired, function(err) { | ||
should.not.exist(err); | ||
return done(err); | ||
}); | ||
}); | ||
describe("get", function() { | ||
return it("should work", function(done) { | ||
return browser.get("http://127.0.0.1:8181/type-test-page.html", function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("get", function() { | ||
return it("should work", function(done) { | ||
return browser.get("http://127.0.0.1:8181/type-test-page.html", function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
testMethod("type", "#type input"); | ||
testMethod("keys", "#type input"); | ||
testMethod("type", "#type textarea"); | ||
testMethod("keys", "#type textarea"); | ||
return describe("quit", function() { | ||
return it("should work", function(done) { | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
return done(err); | ||
}); | ||
}); | ||
testMethod("type", "#type input"); | ||
testMethod("keys", "#type input"); | ||
testMethod("type", "#type textarea"); | ||
testMethod("keys", "#type textarea"); | ||
return describe("quit", function() { | ||
return it("should work", function(done) { | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
return done(err); | ||
}); | ||
}); | ||
}; | ||
}); | ||
}; | ||
exports.test = test; | ||
}).call(this); | ||
exports.test = test; |
@@ -1,6 +0,1 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
module.exports = process.env.WD_COV != null ? require('../../lib-cov/main') : require('../../lib/main'); | ||
}).call(this); | ||
module.exports = process.env.WD_COV? require('../../lib-cov/main') : require('../../lib/main'); |
@@ -1,83 +0,101 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var Express, async, should, test, wd; | ||
var Express, async, should, test, wd; | ||
should = require('should'); | ||
should = require('should'); | ||
async = require('async'); | ||
async = require('async'); | ||
Express = require('./express').Express; | ||
Express = require('./express').Express; | ||
wd = require('./wd-with-cov'); | ||
wd = require('./wd-with-cov'); | ||
test = function(remoteWdConfig, desired) { | ||
var browser, browserName, express, frames, handles, refreshPage; | ||
browser = null; | ||
handles = {}; | ||
browserName = desired != null ? desired.browserName : void 0; | ||
express = new Express; | ||
before(function(done) { | ||
express.start(); | ||
test = function(remoteWdConfig, desired) { | ||
var browser, browserName, express, frames, handles, refreshPage; | ||
browser = null; | ||
handles = {}; | ||
browserName = desired? desired.browserName : undefined; | ||
express = new Express(); | ||
before(function(done) { | ||
express.start(); | ||
return done(null); | ||
}); | ||
after(function(done) { | ||
express.stop(); | ||
return done(null); | ||
}); | ||
describe("wd.remote", function() { | ||
return it("should create browser", function(done) { | ||
browser = wd.remote(remoteWdConfig); | ||
if (!process.env.WD_COV) { | ||
browser.on("status", function(info) { | ||
return console.log("\u001b[36m%s\u001b[0m", info); | ||
}); | ||
browser.on("command", function(meth, path) { | ||
return console.log(" > \u001b[33m%s\u001b[0m: %s", meth, path); | ||
}); | ||
} | ||
return done(null); | ||
}); | ||
after(function(done) { | ||
express.stop(); | ||
return done(null); | ||
}); | ||
describe("init", function() { | ||
return it("should initialize browserinit", function(done) { | ||
this.timeout(30000); | ||
return browser.init(desired, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("wd.remote", function() { | ||
return it("should create browser", function(done) { | ||
browser = wd.remote(remoteWdConfig); | ||
if (process.env.WD_COV == null) { | ||
browser.on("status", function(info) { | ||
return console.log("\u001b[36m%s\u001b[0m", info); | ||
}); | ||
browser.on("command", function(meth, path) { | ||
return console.log(" > \u001b[33m%s\u001b[0m: %s", meth, path); | ||
}); | ||
} | ||
}); | ||
describe("opening first window", function() { | ||
return it("should open the first window", function(done) { | ||
this.timeout(10000); | ||
return browser.get("http://127.0.0.1:8181/window-test-page.html?window_num=1", function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("init", function() { | ||
return it("should initialize browserinit", function(done) { | ||
this.timeout(30000); | ||
return browser.init(desired, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("setting first window name", function() { | ||
return it("should set the window name", function(done) { | ||
return browser.execute("window.name='window-1'", function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("opening first window", function() { | ||
return it("should open the first window", function(done) { | ||
this.timeout(10000); | ||
return browser.get("http://127.0.0.1:8181/window-test-page.html?window_num=1", function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("retrieving first window name", function() { | ||
return it("should be window-1", function(done) { | ||
return browser.windowName(function(err, name) { | ||
should.not.exist(err); | ||
name.should.equal('window-1'); | ||
return done(null); | ||
}); | ||
}); | ||
describe("setting first window name", function() { | ||
return it("should set the window name", function(done) { | ||
return browser.execute("window.name='window-1'", function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("retrieving first window handle", function() { | ||
return it("should retrieve handle", function(done) { | ||
return browser.windowHandle(function(err, handle) { | ||
should.not.exist(err); | ||
should.exist(handle); | ||
handle.length.should.be.above(0); | ||
handles['window-1'] = handle; | ||
return done(null); | ||
}); | ||
}); | ||
describe("retrieving first window name", function() { | ||
return it("should be window-1", function(done) { | ||
return browser.windowName(function(err, name) { | ||
should.not.exist(err); | ||
name.should.equal('window-1'); | ||
return done(null); | ||
}); | ||
}); | ||
describe("opening second window", function() { | ||
return it("should open the second window", function(done) { | ||
this.timeout(10000); | ||
return browser.newWindow('http://127.0.0.1:8181/window-test-page.html?window_num=2', 'window-2', function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("retrieving first window handle", function() { | ||
return it("should retrieve handle", function(done) { | ||
return browser.windowHandle(function(err, handle) { | ||
}); | ||
describe("change focus to second window", function() { | ||
return it("should focus on second window", function(done) { | ||
return browser.window('window-2', function(err) { | ||
should.not.exist(err); | ||
return browser.windowName(function(err, name) { | ||
should.not.exist(err); | ||
should.exist(handle); | ||
handle.length.should.be.above(0); | ||
handles['window-1'] = handle; | ||
name.should.equal('window-2'); | ||
return done(null); | ||
@@ -87,31 +105,31 @@ }); | ||
}); | ||
describe("opening second window", function() { | ||
return it("should open the second window", function(done) { | ||
this.timeout(10000); | ||
return browser.newWindow('http://127.0.0.1:8181/window-test-page.html?window_num=2', 'window-2', function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("retrieving second window handle", function() { | ||
return it("should retrieve handle", function(done) { | ||
return browser.windowHandle(function(err, handle) { | ||
should.not.exist(err); | ||
should.exist(handle); | ||
handle.length.should.be.above(0); | ||
handle.should.not.equal(handles['window-1']); | ||
handles['window-2'] = handle; | ||
return done(null); | ||
}); | ||
}); | ||
describe("change focus to second window", function() { | ||
return it("should focus on second window", function(done) { | ||
return browser.window('window-2', function(err) { | ||
should.not.exist(err); | ||
return browser.windowName(function(err, name) { | ||
should.not.exist(err); | ||
name.should.equal('window-2'); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
describe("opening third window", function() { | ||
return it("should open the third window", function(done) { | ||
this.timeout(10000); | ||
return browser.newWindow('http://127.0.0.1:8181/window-test-page.html?window_num=3', 'window-3', function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("retrieving second window handle", function() { | ||
return it("should retrieve handle", function(done) { | ||
return browser.windowHandle(function(err, handle) { | ||
}); | ||
describe("change focus to third window", function() { | ||
return it("should focus on third window", function(done) { | ||
return browser.window('window-3', function(err) { | ||
should.not.exist(err); | ||
return browser.windowName(function(err, name) { | ||
should.not.exist(err); | ||
should.exist(handle); | ||
handle.length.should.be.above(0); | ||
handle.should.not.equal(handles['window-1']); | ||
handles['window-2'] = handle; | ||
name.should.equal('window-3'); | ||
return done(null); | ||
@@ -121,32 +139,37 @@ }); | ||
}); | ||
describe("opening third window", function() { | ||
return it("should open the third window", function(done) { | ||
this.timeout(10000); | ||
return browser.newWindow('http://127.0.0.1:8181/window-test-page.html?window_num=3', 'window-3', function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("retrieving third window handle", function() { | ||
return it("should retrieve handle", function(done) { | ||
return browser.windowHandle(function(err, handle) { | ||
should.not.exist(err); | ||
should.exist(handle); | ||
handle.length.should.be.above(0); | ||
handle.should.not.equal(handles['window-1']); | ||
handle.should.not.equal(handles['window-2']); | ||
handles['window-3'] = handle; | ||
return done(null); | ||
}); | ||
}); | ||
describe("change focus to third window", function() { | ||
return it("should focus on third window", function(done) { | ||
return browser.window('window-3', function(err) { | ||
should.not.exist(err); | ||
return browser.windowName(function(err, name) { | ||
should.not.exist(err); | ||
name.should.equal('window-3'); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
describe("windowHandles", function() { | ||
return it("should retrieve 2 window handles", function(done) { | ||
return browser.windowHandles(function(err, _handles) { | ||
var k, v, _i, _len; | ||
should.not.exist(err); | ||
_handles.should.have.length(3); | ||
for (v = _i = 0, _len = handles.length; _i < _len; v = ++_i) { | ||
k = handles[v]; | ||
_handles.should.include(v); | ||
} | ||
return done(null); | ||
}); | ||
}); | ||
describe("retrieving third window handle", function() { | ||
return it("should retrieve handle", function(done) { | ||
return browser.windowHandle(function(err, handle) { | ||
}); | ||
describe("change focus to second window using window handle", function() { | ||
return it("should focus on second window", function(done) { | ||
return browser.window(handles['window-2'], function(err) { | ||
should.not.exist(err); | ||
return browser.windowName(function(err, name) { | ||
should.not.exist(err); | ||
should.exist(handle); | ||
handle.length.should.be.above(0); | ||
handle.should.not.equal(handles['window-1']); | ||
handle.should.not.equal(handles['window-2']); | ||
handles['window-3'] = handle; | ||
name.should.equal('window-2'); | ||
return done(null); | ||
@@ -156,12 +179,10 @@ }); | ||
}); | ||
describe("windowHandles", function() { | ||
return it("should retrieve 2 window handles", function(done) { | ||
}); | ||
describe("closing second window", function() { | ||
return it("should close the second window", function(done) { | ||
return browser.close(function(err) { | ||
should.not.exist(err); | ||
return browser.windowHandles(function(err, _handles) { | ||
var k, v, _i, _len; | ||
should.not.exist(err); | ||
_handles.should.have.length(3); | ||
for (v = _i = 0, _len = handles.length; _i < _len; v = ++_i) { | ||
k = handles[v]; | ||
_handles.should.include(v); | ||
} | ||
_handles.should.have.length(2); | ||
return done(null); | ||
@@ -171,57 +192,57 @@ }); | ||
}); | ||
describe("change focus to second window using window handle", function() { | ||
return it("should focus on second window", function(done) { | ||
return browser.window(handles['window-2'], function(err) { | ||
}); | ||
describe("change focus to third window", function() { | ||
return it("should focus on third window", function(done) { | ||
return browser.window('window-3', function(err) { | ||
should.not.exist(err); | ||
return browser.windowName(function(err, name) { | ||
should.not.exist(err); | ||
return browser.windowName(function(err, name) { | ||
should.not.exist(err); | ||
name.should.equal('window-2'); | ||
return done(null); | ||
}); | ||
name.should.equal('window-3'); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
describe("closing second window", function() { | ||
return it("should close the second window", function(done) { | ||
return browser.close(function(err) { | ||
}); | ||
describe("closing third window", function() { | ||
return it("should close the third window", function(done) { | ||
return browser.close(function(err) { | ||
should.not.exist(err); | ||
return browser.windowHandles(function(err, _handles) { | ||
should.not.exist(err); | ||
return browser.windowHandles(function(err, _handles) { | ||
should.not.exist(err); | ||
_handles.should.have.length(2); | ||
return done(null); | ||
}); | ||
_handles.should.have.length(1); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
describe("change focus to third window", function() { | ||
return it("should focus on third window", function(done) { | ||
return browser.window('window-3', function(err) { | ||
}); | ||
describe("change focus to first window", function() { | ||
return it("should focus on first window", function(done) { | ||
return browser.window('window-1', function(err) { | ||
should.not.exist(err); | ||
return browser.windowName(function(err, name) { | ||
should.not.exist(err); | ||
return browser.windowName(function(err, name) { | ||
should.not.exist(err); | ||
name.should.equal('window-3'); | ||
return done(null); | ||
}); | ||
name.should.equal('window-1'); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
describe("closing third window", function() { | ||
return it("should close the third window", function(done) { | ||
return browser.close(function(err) { | ||
should.not.exist(err); | ||
return browser.windowHandles(function(err, _handles) { | ||
should.not.exist(err); | ||
_handles.should.have.length(1); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
describe("opening window with no name", function() { | ||
return it("should open the third window", function(done) { | ||
this.timeout(10000); | ||
return browser.newWindow('http://127.0.0.1:8181/window-test-page.html?window_num=4', function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("change focus to first window", function() { | ||
return it("should focus on first window", function(done) { | ||
return browser.window('window-1', function(err) { | ||
}); | ||
describe("focusing on window with no name handle", function() { | ||
return it("last handle should correspond to latest opened window", function(done) { | ||
return browser.windowHandles(function(err, _handles) { | ||
should.not.exist(err); | ||
_handles.should.have.length(2); | ||
return browser.window(_handles[1], function(err) { | ||
should.not.exist(err); | ||
return browser.windowName(function(err, name) { | ||
should.not.exist(err); | ||
name.should.equal('window-1'); | ||
return browser.url(function(err, url) { | ||
url.should.include("num=4"); | ||
return done(null); | ||
@@ -232,7 +253,10 @@ }); | ||
}); | ||
describe("opening window with no name", function() { | ||
return it("should open the third window", function(done) { | ||
this.timeout(10000); | ||
return browser.newWindow('http://127.0.0.1:8181/window-test-page.html?window_num=4', function(err) { | ||
}); | ||
describe("closing window with no name", function() { | ||
return it("should close the window with no name", function(done) { | ||
return browser.close(function(err) { | ||
should.not.exist(err); | ||
return browser.windowHandles(function(err, _handles) { | ||
should.not.exist(err); | ||
_handles.should.have.length(1); | ||
return done(null); | ||
@@ -242,45 +266,78 @@ }); | ||
}); | ||
describe("focusing on window with no name handle", function() { | ||
return it("last handle should correspond to latest opened window", function(done) { | ||
return browser.windowHandles(function(err, _handles) { | ||
}); | ||
describe("change focus to first window", function() { | ||
return it("should focus on first window", function(done) { | ||
return browser.window('window-1', function(err) { | ||
should.not.exist(err); | ||
return browser.windowName(function(err, name) { | ||
should.not.exist(err); | ||
_handles.should.have.length(2); | ||
return browser.window(_handles[1], function(err) { | ||
should.not.exist(err); | ||
return browser.url(function(err, url) { | ||
url.should.include("num=4"); | ||
return done(null); | ||
}); | ||
}); | ||
name.should.equal('window-1'); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
describe("closing window with no name", function() { | ||
return it("should close the window with no name", function(done) { | ||
return browser.close(function(err) { | ||
should.not.exist(err); | ||
return browser.windowHandles(function(err, _handles) { | ||
should.not.exist(err); | ||
_handles.should.have.length(1); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
describe("opening frame test page", function() { | ||
return it("should open the first window", function(done) { | ||
this.timeout(10000); | ||
return browser.get("http://127.0.0.1:8181/frames/index.html", function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("change focus to first window", function() { | ||
return it("should focus on first window", function(done) { | ||
return browser.window('window-1', function(err) { | ||
should.not.exist(err); | ||
return browser.windowName(function(err, name) { | ||
}); | ||
frames = []; | ||
describe("looking for frame elements", function() { | ||
return it("should find frame elements", function(done) { | ||
return browser.elementsByTagName('frame', function(err, _frames) { | ||
should.not.exist(err); | ||
_frames.should.have.length(3); | ||
return async.forEachSeries(_frames, function(frame, done) { | ||
var frameInfo; | ||
frameInfo = { | ||
el: frame.toString() | ||
}; | ||
return async.series([ | ||
function(done) { | ||
return frame.getAttribute('name', function(err, name) { | ||
should.not.exist(err); | ||
frameInfo.name = name; | ||
return done(null); | ||
}); | ||
}, function(done) { | ||
return frame.getAttribute('id', function(err, id) { | ||
should.not.exist(err); | ||
frameInfo.id = id; | ||
return done(null); | ||
}); | ||
} | ||
], function(err) { | ||
should.not.exist(err); | ||
name.should.equal('window-1'); | ||
frames.push(frameInfo); | ||
return done(null); | ||
}); | ||
}, function(err) { | ||
var i; | ||
should.not.exist(err); | ||
frames.should.have.length(3); | ||
((function() { | ||
var _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = frames.length; _i < _len; _i++) { | ||
i = frames[_i]; | ||
_results.push(i.name); | ||
} | ||
return _results; | ||
})()).should.eql(['menu', 'main', 'bottom']); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
describe("opening frame test page", function() { | ||
return it("should open the first window", function(done) { | ||
this.timeout(10000); | ||
return browser.get("http://127.0.0.1:8181/frames/index.html", function(err) { | ||
}); | ||
refreshPage = function() { | ||
// selenium is very buggy, so having to refresh between each | ||
// frame switch | ||
return describe("refreshing page", function() { | ||
return it("should refresh the page", function(done) { | ||
return browser.refresh(function(err) { | ||
should.not.exist(err); | ||
@@ -291,63 +348,25 @@ return done(null); | ||
}); | ||
frames = []; | ||
describe("looking for frame elements", function() { | ||
return it("should find frame elements", function(done) { | ||
return browser.elementsByTagName('frame', function(err, _frames) { | ||
should.not.exist(err); | ||
_frames.should.have.length(3); | ||
return async.forEachSeries(_frames, function(frame, done) { | ||
var frameInfo; | ||
frameInfo = { | ||
el: frame.toString() | ||
}; | ||
return async.series([ | ||
function(done) { | ||
return frame.getAttribute('name', function(err, name) { | ||
should.not.exist(err); | ||
frameInfo.name = name; | ||
return done(null); | ||
}); | ||
}, function(done) { | ||
return frame.getAttribute('id', function(err, id) { | ||
should.not.exist(err); | ||
frameInfo.id = id; | ||
return done(null); | ||
}); | ||
} | ||
], function(err) { | ||
should.not.exist(err); | ||
frames.push(frameInfo); | ||
return done(null); | ||
}); | ||
}, function(err) { | ||
var i; | ||
should.not.exist(err); | ||
frames.should.have.length(3); | ||
((function() { | ||
var _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = frames.length; _i < _len; _i++) { | ||
i = frames[_i]; | ||
_results.push(i.name); | ||
} | ||
return _results; | ||
})()).should.eql(['menu', 'main', 'bottom']); | ||
return done(null); | ||
}); | ||
}); | ||
}; | ||
describe("selecting default frame", function() { | ||
return it("should select frame menu", function(done) { | ||
return browser.frame(function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
refreshPage = function() { | ||
return describe("refreshing page", function() { | ||
return it("should refresh the page", function(done) { | ||
return browser.refresh(function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
refreshPage(); | ||
describe("selecting frame by number", function() { | ||
return it("should select frame menu", function(done) { | ||
return browser.frame(0, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}; | ||
describe("selecting default frame", function() { | ||
return it("should select frame menu", function(done) { | ||
return browser.frame(function(err) { | ||
}); | ||
}); | ||
refreshPage(); | ||
if (browserName !== 'chrome') { | ||
describe("selecting frame by id", function() { | ||
return it("should select frame main", function(done) { | ||
return browser.frame(frames[1].id, function(err) { | ||
should.not.exist(err); | ||
@@ -358,6 +377,8 @@ return done(null); | ||
}); | ||
refreshPage(); | ||
describe("selecting frame by number", function() { | ||
return it("should select frame menu", function(done) { | ||
return browser.frame(0, function(err) { | ||
} | ||
refreshPage(); | ||
if (browserName !== 'chrome') { | ||
describe("selecting frame by name", function() { | ||
return it("should select frame main", function(done) { | ||
return browser.frame(frames[2].name, function(err) { | ||
should.not.exist(err); | ||
@@ -368,36 +389,13 @@ return done(null); | ||
}); | ||
refreshPage(); | ||
if (browserName !== 'chrome') { | ||
describe("selecting frame by id", function() { | ||
return it("should select frame main", function(done) { | ||
return browser.frame(frames[1].id, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
} | ||
return describe("quit", function() { | ||
return it("should destroy browser", function(done) { | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
} | ||
refreshPage(); | ||
if (browserName !== 'chrome') { | ||
describe("selecting frame by name", function() { | ||
return it("should select frame main", function(done) { | ||
return browser.frame(frames[2].name, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
} | ||
return describe("quit", function() { | ||
return it("should destroy browser", function(done) { | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
}; | ||
}); | ||
}; | ||
exports.test = test; | ||
}).call(this); | ||
exports.test = test; |
@@ -1,19 +0,17 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var desired, remoteWdConfig, test, _ref; | ||
var desired, remoteWdConfig, test, _ref; | ||
_ref = require('./config'), desired = _ref.desired, remoteWdConfig = _ref.remoteWdConfig; | ||
_ref = require('./config'); | ||
desired = _ref.desired; | ||
remoteWdConfig = _ref.remoteWdConfig; | ||
test = require('../common/basic-test-base').test; | ||
test = require('../common/basic-test-base').test; | ||
describe("wd", function() { | ||
return describe("ghostdriver", function() { | ||
return describe("basic test", function() { | ||
return describe("using ghostdriver", function() { | ||
return test(remoteWdConfig, desired); | ||
}); | ||
describe("wd", function() { | ||
return describe("ghostdriver", function() { | ||
return describe("basic test", function() { | ||
return describe("using ghostdriver", function() { | ||
return test(remoteWdConfig, desired); | ||
}); | ||
}); | ||
}); | ||
}).call(this); | ||
}); |
@@ -1,15 +0,11 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
process.env.GHOSTDRIVER_TEST = 1; | ||
process.env.GHOSTDRIVER_TEST = 1; | ||
exports.remoteWdConfig = { | ||
host: 'localhost', | ||
port: 8080 | ||
}; | ||
exports.remoteWdConfig = { | ||
host: 'localhost', | ||
port: 8080 | ||
}; | ||
exports.desired = { | ||
browserName: 'phantomjs' | ||
}; | ||
}).call(this); | ||
exports.desired = { | ||
browserName: 'phantomjs' | ||
}; |
@@ -1,19 +0,17 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var desired, remoteWdConfig, test, _ref; | ||
var desired, remoteWdConfig, test, _ref; | ||
_ref = require('./config'), desired = _ref.desired, remoteWdConfig = _ref.remoteWdConfig; | ||
_ref = require('./config'); | ||
desired = _ref.desired; | ||
remoteWdConfig = _ref.remoteWdConfig; | ||
test = require('../common/element-test-base').test; | ||
test = require('../common/element-test-base').test; | ||
describe("wd", function() { | ||
return describe("ghostdriver", function() { | ||
return describe("element tests", function() { | ||
return describe("using ghostdriver", function() { | ||
return test(remoteWdConfig, desired); | ||
}); | ||
describe("wd", function() { | ||
return describe("ghostdriver", function() { | ||
return describe("element tests", function() { | ||
return describe("using ghostdriver", function() { | ||
return test(remoteWdConfig, desired); | ||
}); | ||
}); | ||
}); | ||
}).call(this); | ||
}); |
@@ -1,19 +0,17 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var desired, remoteWdConfig, test, _ref; | ||
var desired, remoteWdConfig, test, _ref; | ||
_ref = require('./config'), desired = _ref.desired, remoteWdConfig = _ref.remoteWdConfig; | ||
_ref = require('./config'); | ||
desired = _ref.desired; | ||
remoteWdConfig = _ref.remoteWdConfig; | ||
test = require('../common/per-method-test-base').test; | ||
test = require('../common/per-method-test-base').test; | ||
describe("wd", function() { | ||
return describe("ghostdriver", function() { | ||
return describe("per method tests", function() { | ||
return describe("using ghostdriver", function() { | ||
return test(remoteWdConfig, desired); | ||
}); | ||
describe("wd", function() { | ||
return describe("ghostdriver", function() { | ||
return describe("per method tests", function() { | ||
return describe("using ghostdriver", function() { | ||
return test(remoteWdConfig, desired); | ||
}); | ||
}); | ||
}); | ||
}).call(this); | ||
}); |
@@ -1,19 +0,17 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var desired, remoteWdConfig, test, _ref; | ||
var desired, remoteWdConfig, test, _ref; | ||
_ref = require('./config'), desired = _ref.desired, remoteWdConfig = _ref.remoteWdConfig; | ||
_ref = require('./config'); | ||
desired = _ref.desired; | ||
remoteWdConfig = _ref.remoteWdConfig; | ||
test = require('../common/typing-test-base').test; | ||
test = require('../common/typing-test-base').test; | ||
describe("wd", function() { | ||
return describe("ghostdriver", function() { | ||
return describe("typing test", function() { | ||
return describe("using chrome", function() { | ||
return test(remoteWdConfig, desired); | ||
}); | ||
describe("wd", function() { | ||
return describe("ghostdriver", function() { | ||
return describe("typing test", function() { | ||
return describe("using chrome", function() { | ||
return test(remoteWdConfig, desired); | ||
}); | ||
}); | ||
}); | ||
}).call(this); | ||
}); |
@@ -1,19 +0,17 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var desired, remoteWdConfig, test, _ref; | ||
var desired, remoteWdConfig, test, _ref; | ||
_ref = require('./config'), desired = _ref.desired, remoteWdConfig = _ref.remoteWdConfig; | ||
_ref = require('./config'); | ||
desired = _ref.desired; | ||
remoteWdConfig = _ref.remoteWdConfig; | ||
test = require('../common/window-frame-test-base').test; | ||
test = require('../common/window-frame-test-base').test; | ||
describe("wd", function() { | ||
return describe("ghostdriver", function() { | ||
return describe("window frame test", function() { | ||
return describe("using ghostdriver", function() { | ||
return test(remoteWdConfig, desired); | ||
}); | ||
describe("wd", function() { | ||
return describe("ghostdriver", function() { | ||
return describe("window frame test", function() { | ||
return describe("using ghostdriver", function() { | ||
return test(remoteWdConfig, desired); | ||
}); | ||
}); | ||
}); | ||
}).call(this); | ||
}); |
@@ -1,19 +0,16 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var test; | ||
var test; | ||
test = require('../common/basic-test-base').test; | ||
test = require('../common/basic-test-base').test; | ||
describe("wd", function() { | ||
return describe("local", function() { | ||
return describe("basic test", function() { | ||
describe("using chrome", function() { | ||
return test({}, { | ||
browserName: 'chrome' | ||
}); | ||
describe("wd", function() { | ||
return describe("local", function() { | ||
return describe("basic test", function() { | ||
describe("using chrome", function() { | ||
return test({}, { | ||
browserName: 'chrome' | ||
}); | ||
return describe("using firefox", function() { | ||
return test({}, { | ||
browserName: 'firefox' | ||
}); | ||
}); | ||
return describe("using firefox", function() { | ||
return test({}, { | ||
browserName: 'firefox' | ||
}); | ||
@@ -23,3 +20,2 @@ }); | ||
}); | ||
}).call(this); | ||
}); |
@@ -1,32 +0,29 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var should, wd; | ||
var should, wd; | ||
should = require('should'); | ||
should = require('should'); | ||
wd = require('../common/wd-with-cov'); | ||
wd = require('../common/wd-with-cov'); | ||
describe("wd", function() { | ||
return describe("local", function() { | ||
return describe("browser init tests", function() { | ||
describe("default init", function() { | ||
return it("should open firefox browser", function(done) { | ||
var browser; | ||
this.timeout(15000); | ||
browser = wd.remote(); | ||
browser.defaultCapabilities.should.eql({ | ||
browserName: 'firefox', | ||
version: '', | ||
javascriptEnabled: true, | ||
platform: 'ANY' | ||
}); | ||
return browser.init(function(err) { | ||
describe("wd", function() { | ||
return describe("local", function() { | ||
return describe("browser init tests", function() { | ||
describe("default init", function() { | ||
return it("should open firefox browser", function(done) { | ||
var browser; | ||
this.timeout(15000); | ||
browser = wd.remote(); | ||
browser.defaultCapabilities.should.eql({ | ||
browserName: 'firefox', | ||
version: '', | ||
javascriptEnabled: true, | ||
platform: 'ANY' | ||
}); | ||
return browser.init(function(err) { | ||
should.not.exist(err); | ||
return browser.sessionCapabilities(function(err, capabilities) { | ||
should.not.exist(err); | ||
return browser.sessionCapabilities(function(err, capabilities) { | ||
capabilities.browserName.should.equal('firefox'); | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
capabilities.browserName.should.equal('firefox'); | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
return done(null); | ||
}); | ||
@@ -36,24 +33,24 @@ }); | ||
}); | ||
describe("browser.defaultCapabilities", function() { | ||
return it("should open chrome browser", function(done) { | ||
var browser; | ||
this.timeout(15000); | ||
browser = wd.remote(); | ||
browser.defaultCapabilities.browserName = 'chrome'; | ||
browser.defaultCapabilities.javascriptEnabled = false; | ||
browser.defaultCapabilities.should.eql({ | ||
browserName: 'chrome', | ||
version: '', | ||
javascriptEnabled: false, | ||
platform: 'ANY' | ||
}); | ||
return browser.init(function(err) { | ||
}); | ||
describe("browser.defaultCapabilities", function() { | ||
return it("should open chrome browser", function(done) { | ||
var browser; | ||
this.timeout(15000); | ||
browser = wd.remote(); | ||
browser.defaultCapabilities.browserName = 'chrome'; | ||
browser.defaultCapabilities.javascriptEnabled = false; | ||
browser.defaultCapabilities.should.eql({ | ||
browserName: 'chrome', | ||
version: '', | ||
javascriptEnabled: false, | ||
platform: 'ANY' | ||
}); | ||
return browser.init(function(err) { | ||
should.not.exist(err); | ||
return browser.sessionCapabilities(function(err, capabilities) { | ||
should.not.exist(err); | ||
return browser.sessionCapabilities(function(err, capabilities) { | ||
capabilities.browserName.should.equal('chrome'); | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
capabilities.browserName.should.equal('chrome'); | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
return done(null); | ||
}); | ||
@@ -63,24 +60,24 @@ }); | ||
}); | ||
describe("desired only", function() { | ||
return it("should open chrome browser", function(done) { | ||
var browser; | ||
this.timeout(15000); | ||
browser = wd.remote(); | ||
browser.defaultCapabilities.should.eql({ | ||
browserName: 'firefox', | ||
version: '', | ||
javascriptEnabled: true, | ||
platform: 'ANY' | ||
}); | ||
return browser.init({ | ||
browserName: 'chrome' | ||
}, function(err) { | ||
}); | ||
describe("desired only", function() { | ||
return it("should open chrome browser", function(done) { | ||
var browser; | ||
this.timeout(15000); | ||
browser = wd.remote(); | ||
browser.defaultCapabilities.should.eql({ | ||
browserName: 'firefox', | ||
version: '', | ||
javascriptEnabled: true, | ||
platform: 'ANY' | ||
}); | ||
return browser.init({ | ||
browserName: 'chrome' | ||
}, function(err) { | ||
should.not.exist(err); | ||
return browser.sessionCapabilities(function(err, capabilities) { | ||
should.not.exist(err); | ||
return browser.sessionCapabilities(function(err, capabilities) { | ||
capabilities.browserName.should.equal('chrome'); | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
capabilities.browserName.should.equal('chrome'); | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
return done(null); | ||
}); | ||
@@ -90,25 +87,25 @@ }); | ||
}); | ||
return describe("desired overiding defaultCapabilities", function() { | ||
return it("should open firefox browser", function(done) { | ||
var browser; | ||
this.timeout(15000); | ||
browser = wd.remote(); | ||
browser.defaultCapabilities.browserName = 'chrome'; | ||
browser.defaultCapabilities.should.eql({ | ||
browserName: 'chrome', | ||
version: '', | ||
javascriptEnabled: true, | ||
platform: 'ANY' | ||
}); | ||
return browser.init({ | ||
browserName: 'firefox' | ||
}, function(err) { | ||
}); | ||
return describe("desired overiding defaultCapabilities", function() { | ||
return it("should open firefox browser", function(done) { | ||
var browser; | ||
this.timeout(15000); | ||
browser = wd.remote(); | ||
browser.defaultCapabilities.browserName = 'chrome'; | ||
browser.defaultCapabilities.should.eql({ | ||
browserName: 'chrome', | ||
version: '', | ||
javascriptEnabled: true, | ||
platform: 'ANY' | ||
}); | ||
return browser.init({ | ||
browserName: 'firefox' | ||
}, function(err) { | ||
should.not.exist(err); | ||
return browser.sessionCapabilities(function(err, capabilities) { | ||
should.not.exist(err); | ||
return browser.sessionCapabilities(function(err, capabilities) { | ||
capabilities.browserName.should.equal('firefox'); | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
capabilities.browserName.should.equal('firefox'); | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
return done(null); | ||
}); | ||
@@ -121,3 +118,2 @@ }); | ||
}); | ||
}).call(this); | ||
}); |
@@ -1,20 +0,16 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var test; | ||
var test; | ||
test = require('../common/chain-test-base').test; | ||
test = require('../common/chain-test-base').test; | ||
describe("wd", function() { | ||
return describe("local", function() { | ||
return describe("chain tests", function() { | ||
describe("using chrome", function() { | ||
return test('chrome'); | ||
}); | ||
return describe("using firefox", function() { | ||
return test('firefox'); | ||
}); | ||
describe("wd", function() { | ||
return describe("local", function() { | ||
return describe("chain tests", function() { | ||
describe("using chrome", function() { | ||
return test('chrome'); | ||
}); | ||
return describe("using firefox", function() { | ||
return test('firefox'); | ||
}); | ||
}); | ||
}); | ||
}).call(this); | ||
}); |
@@ -1,19 +0,16 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var test; | ||
var test; | ||
test = require('../common/element-test-base').test; | ||
test = require('../common/element-test-base').test; | ||
describe("wd", function() { | ||
return describe("local", function() { | ||
return describe("element tests", function() { | ||
describe("using chrome", function() { | ||
return test({}, { | ||
browserName: 'chrome' | ||
}); | ||
describe("wd", function() { | ||
return describe("local", function() { | ||
return describe("element tests", function() { | ||
describe("using chrome", function() { | ||
return test({}, { | ||
browserName: 'chrome' | ||
}); | ||
return describe("using firefox", function() { | ||
return test({}, { | ||
browserName: 'firefox' | ||
}); | ||
}); | ||
return describe("using firefox", function() { | ||
return test({}, { | ||
browserName: 'firefox' | ||
}); | ||
@@ -23,3 +20,2 @@ }); | ||
}); | ||
}).call(this); | ||
}); |
@@ -1,19 +0,16 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var test; | ||
var test; | ||
test = require('../common/per-method-test-base').test; | ||
test = require('../common/per-method-test-base').test; | ||
describe("wd", function() { | ||
return describe("local", function() { | ||
return describe("per method tests", function() { | ||
describe("using chrome", function() { | ||
return test({}, { | ||
browserName: 'chrome' | ||
}); | ||
describe("wd", function() { | ||
return describe("local", function() { | ||
return describe("per method tests", function() { | ||
describe("using chrome", function() { | ||
return test({}, { | ||
browserName: 'chrome' | ||
}); | ||
return describe("using firefox", function() { | ||
return test({}, { | ||
browserName: 'firefox' | ||
}); | ||
}); | ||
return describe("using firefox", function() { | ||
return test({}, { | ||
browserName: 'firefox' | ||
}); | ||
@@ -23,3 +20,2 @@ }); | ||
}); | ||
}).call(this); | ||
}); |
@@ -1,19 +0,16 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var test; | ||
var test; | ||
test = require('../common/typing-test-base').test; | ||
test = require('../common/typing-test-base').test; | ||
describe("wd", function() { | ||
return describe("local", function() { | ||
return describe("typing test", function() { | ||
describe("using chrome", function() { | ||
return test({}, { | ||
browserName: 'chrome' | ||
}); | ||
describe("wd", function() { | ||
return describe("local", function() { | ||
return describe("typing test", function() { | ||
describe("using chrome", function() { | ||
return test({}, { | ||
browserName: 'chrome' | ||
}); | ||
return describe("using firefox", function() { | ||
return test({}, { | ||
browserName: 'firefox' | ||
}); | ||
}); | ||
return describe("using firefox", function() { | ||
return test({}, { | ||
browserName: 'firefox' | ||
}); | ||
@@ -23,3 +20,2 @@ }); | ||
}); | ||
}).call(this); | ||
}); |
@@ -1,75 +0,28 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var should, wd; | ||
var should = require('should'), | ||
wd = require('../common/wd-with-cov'), | ||
_ = require('underscore'); | ||
should = require('should'); | ||
process.env = _(process.env).omit('SAUCE_USERNAME', 'SAUCE_ACCESS_KEY'); | ||
wd = require('../common/wd-with-cov'); | ||
describe("wd", function() { | ||
return describe("local", function() { | ||
describe("wd remote tests", function() { | ||
describe("default", function() { | ||
return it("browser should be initialized with default parameters", function(done) { | ||
var browser; | ||
browser = wd.remote(); | ||
browser.options.host.should.equal('127.0.0.1'); | ||
browser.options.port.should.equal(4444); | ||
browser.options.path.should.equal('/wd/hub/session'); | ||
browser.basePath.should.equal('/wd/hub'); | ||
should.not.exist(browser.username); | ||
should.not.exist(browser.accessKey); | ||
return done(); | ||
}); | ||
describe("wd", function() { | ||
return describe("local", function() { | ||
describe("wd remote tests", function() { | ||
describe("default", function() { | ||
return it("browser should be initialized with default parameters", function(done) { | ||
var browser; | ||
browser = wd.remote(); | ||
browser.options.host.should.equal('127.0.0.1'); | ||
browser.options.port.should.equal(4444); | ||
browser.options.path.should.equal('/wd/hub/session'); | ||
browser.basePath.should.equal('/wd/hub'); | ||
should.not.exist(browser.username); | ||
should.not.exist(browser.accessKey); | ||
return done(); | ||
}); | ||
return describe("params", function() { | ||
describe("host, port", function() { | ||
return it("browser should be initialized with given parameters", function(done) { | ||
var browser; | ||
browser = wd.remote('localhost', 8888); | ||
browser.options.host.should.equal('localhost'); | ||
browser.options.port.should.equal(8888); | ||
browser.options.path.should.equal('/wd/hub/session'); | ||
browser.basePath.should.equal('/wd/hub'); | ||
should.not.exist(browser.username); | ||
should.not.exist(browser.accessKey); | ||
return done(null); | ||
}); | ||
}); | ||
return describe("host, port, username, accesskey", function() { | ||
return it("browser should be initialized with given parameters", function(done) { | ||
var browser; | ||
browser = wd.remote('localhost', 8888, 'mickey', 'mouse'); | ||
browser.options.host.should.equal('localhost'); | ||
browser.options.port.should.equal(8888); | ||
browser.options.path.should.equal('/wd/hub/session'); | ||
browser.basePath.should.equal('/wd/hub'); | ||
browser.username.should.equal('mickey'); | ||
browser.accessKey.should.equal('mouse'); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
}); | ||
return describe("options", function() { | ||
describe("empty options", function() { | ||
return it("browser should be initialized with default", function(done) { | ||
var browser; | ||
browser = wd.remote({}); | ||
browser.options.host.should.equal('127.0.0.1'); | ||
browser.options.port.should.equal(4444); | ||
browser.options.path.should.equal('/wd/hub/session'); | ||
browser.basePath.should.equal('/wd/hub'); | ||
should.not.exist(browser.username); | ||
should.not.exist(browser.accessKey); | ||
return done(null); | ||
}); | ||
}); | ||
return describe("params", function() { | ||
describe("host, port", function() { | ||
return it("browser should be initialized with given options", function(done) { | ||
return it("browser should be initialized with given parameters", function(done) { | ||
var browser; | ||
browser = wd.remote({ | ||
host: 'localhost', | ||
port: 8888 | ||
}); | ||
browser = wd.remote('localhost', 8888); | ||
browser.options.host.should.equal('localhost'); | ||
@@ -84,11 +37,6 @@ browser.options.port.should.equal(8888); | ||
}); | ||
describe("host, port, username, accesskey", function() { | ||
return it("browser should be initialized with given options", function(done) { | ||
return describe("host, port, username, accesskey", function() { | ||
return it("browser should be initialized with given parameters", function(done) { | ||
var browser; | ||
browser = wd.remote({ | ||
host: 'localhost', | ||
port: 8888, | ||
username: 'mickey', | ||
accessKey: 'mouse' | ||
}); | ||
browser = wd.remote('localhost', 8888, 'mickey', 'mouse'); | ||
browser.options.host.should.equal('localhost'); | ||
@@ -103,57 +51,105 @@ browser.options.port.should.equal(8888); | ||
}); | ||
describe("path", function() { | ||
return it("browser should be initialized with given options", function(done) { | ||
var browser; | ||
browser = wd.remote({ | ||
path: '/taiwan' | ||
}); | ||
browser.options.host.should.equal('127.0.0.1'); | ||
browser.options.port.should.equal(4444); | ||
browser.options.path.should.equal('/taiwan/session'); | ||
browser.basePath.should.equal('/taiwan'); | ||
should.not.exist(browser.username); | ||
should.not.exist(browser.accessKey); | ||
return done(null); | ||
}); | ||
}); | ||
return describe("options", function() { | ||
describe("empty options", function() { | ||
return it("browser should be initialized with default", function(done) { | ||
var browser; | ||
browser = wd.remote({}); | ||
browser.options.host.should.equal('127.0.0.1'); | ||
browser.options.port.should.equal(4444); | ||
browser.options.path.should.equal('/wd/hub/session'); | ||
browser.basePath.should.equal('/wd/hub'); | ||
should.not.exist(browser.username); | ||
should.not.exist(browser.accessKey); | ||
return done(null); | ||
}); | ||
}); | ||
describe("host, port", function() { | ||
return it("browser should be initialized with given options", function(done) { | ||
var browser; | ||
browser = wd.remote({ | ||
host: 'localhost', | ||
port: 8888 | ||
}); | ||
browser.options.host.should.equal('localhost'); | ||
browser.options.port.should.equal(8888); | ||
browser.options.path.should.equal('/wd/hub/session'); | ||
browser.basePath.should.equal('/wd/hub'); | ||
should.not.exist(browser.username); | ||
should.not.exist(browser.accessKey); | ||
return done(null); | ||
}); | ||
describe("host, port, path", function() { | ||
return it("browser should be initialized with given options", function(done) { | ||
var browser; | ||
browser = wd.remote({ | ||
host: 'localhost', | ||
port: 8888, | ||
path: '/' | ||
}); | ||
browser.options.host.should.equal('localhost'); | ||
browser.options.port.should.equal(8888); | ||
browser.options.path.should.equal('/session'); | ||
browser.basePath.should.equal('/'); | ||
should.not.exist(browser.username); | ||
should.not.exist(browser.accessKey); | ||
return done(null); | ||
}); | ||
describe("host, port, username, accesskey", function() { | ||
return it("browser should be initialized with given options", function(done) { | ||
var browser; | ||
browser = wd.remote({ | ||
host: 'localhost', | ||
port: 8888, | ||
username: 'mickey', | ||
accessKey: 'mouse' | ||
}); | ||
browser.options.host.should.equal('localhost'); | ||
browser.options.port.should.equal(8888); | ||
browser.options.path.should.equal('/wd/hub/session'); | ||
browser.basePath.should.equal('/wd/hub'); | ||
browser.username.should.equal('mickey'); | ||
browser.accessKey.should.equal('mouse'); | ||
return done(null); | ||
}); | ||
return describe("host, port, username, accesskey, path", function() { | ||
return it("browser should be initialized with given options", function(done) { | ||
var browser; | ||
browser = wd.remote({ | ||
host: 'localhost', | ||
port: 8888, | ||
username: 'mickey', | ||
accessKey: 'mouse', | ||
path: '/asia/taiwan' | ||
}); | ||
browser.options.host.should.equal('localhost'); | ||
browser.options.port.should.equal(8888); | ||
browser.options.path.should.equal('/asia/taiwan/session'); | ||
browser.basePath.should.equal('/asia/taiwan'); | ||
browser.username.should.equal('mickey'); | ||
browser.accessKey.should.equal('mouse'); | ||
return done(null); | ||
}); | ||
describe("path", function() { | ||
return it("browser should be initialized with given options", function(done) { | ||
var browser; | ||
browser = wd.remote({ | ||
path: '/taiwan' | ||
}); | ||
browser.options.host.should.equal('127.0.0.1'); | ||
browser.options.port.should.equal(4444); | ||
browser.options.path.should.equal('/taiwan/session'); | ||
browser.basePath.should.equal('/taiwan'); | ||
should.not.exist(browser.username); | ||
should.not.exist(browser.accessKey); | ||
return done(null); | ||
}); | ||
}); | ||
describe("host, port, path", function() { | ||
return it("browser should be initialized with given options", function(done) { | ||
var browser; | ||
browser = wd.remote({ | ||
host: 'localhost', | ||
port: 8888, | ||
path: '/' | ||
}); | ||
browser.options.host.should.equal('localhost'); | ||
browser.options.port.should.equal(8888); | ||
browser.options.path.should.equal('/session'); | ||
browser.basePath.should.equal('/'); | ||
should.not.exist(browser.username); | ||
should.not.exist(browser.accessKey); | ||
return done(null); | ||
}); | ||
}); | ||
return describe("host, port, username, accesskey, path", function() { | ||
return it("browser should be initialized with given options", function(done) { | ||
var browser; | ||
browser = wd.remote({ | ||
host: 'localhost', | ||
port: 8888, | ||
username: 'mickey', | ||
accessKey: 'mouse', | ||
path: '/asia/taiwan' | ||
}); | ||
browser.options.host.should.equal('localhost'); | ||
browser.options.port.should.equal(8888); | ||
browser.options.path.should.equal('/asia/taiwan/session'); | ||
browser.basePath.should.equal('/asia/taiwan'); | ||
browser.username.should.equal('mickey'); | ||
browser.accessKey.should.equal('mouse'); | ||
return done(null); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}).call(this); | ||
}); |
@@ -1,19 +0,16 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var test; | ||
var test; | ||
test = require('../common/window-frame-test-base').test; | ||
test = require('../common/window-frame-test-base').test; | ||
describe("wd", function() { | ||
return describe("local", function() { | ||
return describe("window frame test", function() { | ||
describe("using chrome", function() { | ||
return test({}, { | ||
browserName: 'chrome' | ||
}); | ||
describe("wd", function() { | ||
return describe("local", function() { | ||
return describe("window frame test", function() { | ||
describe("using chrome", function() { | ||
return test({}, { | ||
browserName: 'chrome' | ||
}); | ||
return describe("using firefox", function() { | ||
return test({}, { | ||
browserName: 'firefox' | ||
}); | ||
}); | ||
return describe("using firefox", function() { | ||
return test({}, { | ||
browserName: 'firefox' | ||
}); | ||
@@ -23,3 +20,2 @@ }); | ||
}); | ||
}).call(this); | ||
}); |
@@ -1,46 +0,42 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var chromeDesired, configHelper, explorerDesired, firefoxDesired, nameBase, remoteWdConfig, test; | ||
var chromeDesired, configHelper, explorerDesired, firefoxDesired, nameBase, remoteWdConfig, test; | ||
test = require('../common/basic-test-base').test; | ||
test = require('../common/basic-test-base').test; | ||
configHelper = require('./config-helper'); | ||
configHelper = require('./config-helper'); | ||
remoteWdConfig = configHelper.getRemoteWdConfig(); | ||
remoteWdConfig = configHelper.getRemoteWdConfig(); | ||
nameBase = "saucelabs basic test - "; | ||
nameBase = "saucelabs basic test - "; | ||
chromeDesired = { | ||
name: nameBase + 'chrome', | ||
browserName: 'chrome' | ||
}; | ||
chromeDesired = { | ||
name: nameBase + 'chrome', | ||
browserName: 'chrome' | ||
}; | ||
firefoxDesired = { | ||
name: nameBase + 'firefox', | ||
browserName: 'firefox' | ||
}; | ||
firefoxDesired = { | ||
name: nameBase + 'firefox', | ||
browserName: 'firefox' | ||
}; | ||
explorerDesired = { | ||
name: nameBase + 'explorer', | ||
browserName: 'iexplore', | ||
version: '9', | ||
platform: 'Windows 2008' | ||
}; | ||
explorerDesired = { | ||
name: nameBase + 'explorer', | ||
browserName: 'iexplore', | ||
version: '9', | ||
platform: 'Windows 2008' | ||
}; | ||
describe("wd", function() { | ||
return describe("saucelabs", function() { | ||
return describe("basic tests", function() { | ||
describe("using chrome", function() { | ||
return test(remoteWdConfig, chromeDesired); | ||
}); | ||
describe("using firefox", function() { | ||
return test(remoteWdConfig, firefoxDesired); | ||
}); | ||
return describe("using explorer", function() { | ||
return test(remoteWdConfig, explorerDesired); | ||
}); | ||
describe("wd", function() { | ||
return describe("saucelabs", function() { | ||
return describe("basic tests", function() { | ||
describe("using chrome", function() { | ||
test(remoteWdConfig, chromeDesired, configHelper.jobPassed ); | ||
}); | ||
describe("using firefox", function() { | ||
test(remoteWdConfig, firefoxDesired, configHelper.jobPassed); | ||
}); | ||
return describe("using explorer", function() { | ||
test(remoteWdConfig, explorerDesired, configHelper.jobPassed); | ||
}); | ||
}); | ||
}); | ||
}).call(this); | ||
}); |
@@ -1,37 +0,39 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var configHelper, remoteWdConfig, should, wd; | ||
var configHelper, remoteWdConfig, should, wd; | ||
wd = require('../common/wd-with-cov'); | ||
wd = require('../common/wd-with-cov'); | ||
should = require('should'); | ||
should = require('should'); | ||
configHelper = require('./config-helper'); | ||
configHelper = require('./config-helper'); | ||
remoteWdConfig = configHelper.getRemoteWdConfig(); | ||
var TIMEOUT = 30000; | ||
describe("wd", function() { | ||
return describe("saucelabs", function() { | ||
return describe("browser init tests", function() { | ||
describe("default init", function() { | ||
return it("should open a XP firefox browser", function(done) { | ||
var browser; | ||
this.timeout(15000); | ||
browser = wd.remote(remoteWdConfig); | ||
browser.defaultCapabilities.should.eql({ | ||
browserName: 'firefox', | ||
version: '', | ||
javascriptEnabled: true, | ||
platform: 'VISTA' | ||
}); | ||
return browser.init(function(err) { | ||
remoteWdConfig = configHelper.getRemoteWdConfig(); | ||
describe("wd", function() { | ||
return describe("saucelabs", function() { | ||
return describe("browser init tests", function() { | ||
describe("default init", function() { | ||
var browser; | ||
after(function(done) { | ||
configHelper.jobPassed(browser.sessionID, done); | ||
}); | ||
return it("should open a XP firefox browser", function(done) { | ||
this.timeout(TIMEOUT); | ||
browser = wd.remote(remoteWdConfig); | ||
browser.defaultCapabilities.should.eql({ | ||
browserName: 'firefox', | ||
version: '', | ||
javascriptEnabled: true, | ||
platform: 'VISTA' | ||
}); | ||
return browser.init(function(err) { | ||
should.not.exist(err); | ||
return browser.sessionCapabilities(function(err, capabilities) { | ||
should.not.exist(err); | ||
return browser.sessionCapabilities(function(err, capabilities) { | ||
capabilities.browserName.should.equal('firefox'); | ||
capabilities.platform.should.equal('XP'); | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
capabilities.browserName.should.equal('firefox'); | ||
capabilities.platform.should.equal('XP'); | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
return done(null); | ||
}); | ||
@@ -41,30 +43,33 @@ }); | ||
}); | ||
describe("browser.defaultCapabilities", function() { | ||
return it("should open a LINUX chrome browser", function(done) { | ||
var browser; | ||
this.timeout(15000); | ||
browser = wd.remote(remoteWdConfig); | ||
browser.defaultCapabilities.browserName = 'chrome'; | ||
browser.defaultCapabilities.platform = 'LINUX'; | ||
browser.defaultCapabilities.javascriptEnabled = false; | ||
browser.defaultCapabilities.name = 'browser init using defaultCapabilities'; | ||
browser.defaultCapabilities.tags = ['wd', 'test']; | ||
browser.defaultCapabilities.should.eql({ | ||
browserName: 'chrome', | ||
version: '', | ||
javascriptEnabled: false, | ||
platform: 'LINUX', | ||
name: 'browser init using defaultCapabilities', | ||
tags: ['wd', 'test'] | ||
}); | ||
return browser.init(function(err) { | ||
}); | ||
describe("browser.defaultCapabilities", function() { | ||
var browser; | ||
after(function(done) { | ||
configHelper.jobPassed(browser.sessionID, done); | ||
}); | ||
return it("should open a LINUX chrome browser", function(done) { | ||
this.timeout(TIMEOUT); | ||
browser = wd.remote(remoteWdConfig); | ||
browser.defaultCapabilities.browserName = 'chrome'; | ||
browser.defaultCapabilities.platform = 'LINUX'; | ||
browser.defaultCapabilities.javascriptEnabled = false; | ||
browser.defaultCapabilities.name = 'browser init using defaultCapabilities'; | ||
browser.defaultCapabilities.tags = ['wd', 'test']; | ||
browser.defaultCapabilities.should.eql({ | ||
browserName: 'chrome', | ||
version: '', | ||
javascriptEnabled: false, | ||
platform: 'LINUX', | ||
name: 'browser init using defaultCapabilities', | ||
tags: ['wd', 'test'] | ||
}); | ||
return browser.init(function(err) { | ||
should.not.exist(err); | ||
return browser.sessionCapabilities(function(err, capabilities) { | ||
should.not.exist(err); | ||
return browser.sessionCapabilities(function(err, capabilities) { | ||
capabilities.browserName.should.equal('chrome'); | ||
capabilities.platform.should.equal('LINUX'); | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
capabilities.browserName.should.equal('chrome'); | ||
capabilities.platform.should.equal('LINUX'); | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
return done(null); | ||
}); | ||
@@ -74,29 +79,32 @@ }); | ||
}); | ||
describe("desired only", function() { | ||
return it("should open a WINDOWS explorer browser", function(done) { | ||
var browser, desired; | ||
this.timeout(15000); | ||
browser = wd.remote(remoteWdConfig); | ||
browser.defaultCapabilities.should.eql({ | ||
browserName: 'firefox', | ||
version: '', | ||
javascriptEnabled: true, | ||
platform: 'VISTA' | ||
}); | ||
desired = { | ||
browserName: 'iexplore', | ||
platform: 'Windows 2008', | ||
name: 'browser init using desired', | ||
tags: ['wd', 'test'] | ||
}; | ||
return browser.init(desired, function(err) { | ||
}); | ||
describe("desired only", function() { | ||
var browser; | ||
after(function(done) { | ||
configHelper.jobPassed(browser.sessionID, done); | ||
}); | ||
return it("should open a WINDOWS explorer browser", function(done) { | ||
this.timeout(TIMEOUT); | ||
browser = wd.remote(remoteWdConfig); | ||
browser.defaultCapabilities.should.eql({ | ||
browserName: 'firefox', | ||
version: '', | ||
javascriptEnabled: true, | ||
platform: 'VISTA' | ||
}); | ||
var desired = { | ||
browserName: 'iexplore', | ||
platform: 'Windows 2008', | ||
name: 'browser init using desired', | ||
tags: ['wd', 'test'] | ||
}; | ||
return browser.init(desired, function(err) { | ||
should.not.exist(err); | ||
return browser.sessionCapabilities(function(err, capabilities) { | ||
should.not.exist(err); | ||
return browser.sessionCapabilities(function(err, capabilities) { | ||
capabilities.browserName.should.include('explorer'); | ||
capabilities.platform.should.equal('WINDOWS'); | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
capabilities.browserName.should.include('explorer'); | ||
capabilities.platform.should.equal('WINDOWS'); | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
return done(null); | ||
}); | ||
@@ -106,29 +114,32 @@ }); | ||
}); | ||
return describe("desired overiding defaultCapabilities", function() { | ||
return it("should open a firefox browser", function(done) { | ||
var browser; | ||
this.timeout(15000); | ||
browser = wd.remote(remoteWdConfig); | ||
browser.defaultCapabilities.browserName = 'chrome'; | ||
browser.defaultCapabilities.name = 'browser init overide'; | ||
browser.defaultCapabilities.tags = ['wd', 'test']; | ||
browser.defaultCapabilities.should.eql({ | ||
browserName: 'chrome', | ||
version: '', | ||
javascriptEnabled: true, | ||
platform: 'VISTA', | ||
name: 'browser init overide', | ||
tags: ['wd', 'test'] | ||
}); | ||
return browser.init({ | ||
browserName: 'firefox' | ||
}, function(err) { | ||
}); | ||
return describe("desired overiding defaultCapabilities", function() { | ||
var browser; | ||
after(function(done) { | ||
configHelper.jobPassed(browser.sessionID, done); | ||
}); | ||
return it("should open a firefox browser", function(done) { | ||
this.timeout(TIMEOUT); | ||
browser = wd.remote(remoteWdConfig); | ||
browser.defaultCapabilities.browserName = 'chrome'; | ||
browser.defaultCapabilities.name = 'browser init overide'; | ||
browser.defaultCapabilities.tags = ['wd', 'test']; | ||
browser.defaultCapabilities.should.eql({ | ||
browserName: 'chrome', | ||
version: '', | ||
javascriptEnabled: true, | ||
platform: 'VISTA', | ||
name: 'browser init overide', | ||
tags: ['wd', 'test'] | ||
}); | ||
return browser.init({ | ||
browserName: 'firefox' | ||
}, function(err) { | ||
should.not.exist(err); | ||
return browser.sessionCapabilities(function(err, capabilities) { | ||
should.not.exist(err); | ||
return browser.sessionCapabilities(function(err, capabilities) { | ||
capabilities.browserName.should.equal('firefox'); | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
capabilities.browserName.should.equal('firefox'); | ||
return browser.quit(function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
return done(null); | ||
}); | ||
@@ -141,3 +152,2 @@ }); | ||
}); | ||
}).call(this); | ||
}); |
@@ -1,24 +0,51 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var config, should; | ||
var config, should, request; | ||
should = require('should'); | ||
should = require('should'); | ||
request = require('request'); | ||
try { | ||
config = require('./config'); | ||
} catch (err) { | ||
try { | ||
config = require('./config'); | ||
} catch (err) { | ||
} | ||
} | ||
exports.getRemoteWdConfig = function() { | ||
var _ref, _ref1; | ||
should.exist(config, "Missing config!\nYou need to copy config-sample.coffee to config.coffee,\nand then configure your sauce username and access-key in\nconfig.coffee"); | ||
return { | ||
host: "ondemand.saucelabs.com", | ||
port: 80, | ||
username: (_ref = config.saucelabs) != null ? _ref.username : void 0, | ||
accessKey: (_ref1 = config.saucelabs) != null ? _ref1.accessKey : void 0 | ||
}; | ||
should.exist(config, "Missing config!\nYou need to copy config-sample.js to config.js,\nand then configure your sauce username and access-key in\nconfig.js"); | ||
var username, accessKey; | ||
if(config.saucelabs) { | ||
username = config.saucelabs.username; | ||
accessKey = config.saucelabs.accessKey; | ||
} | ||
exports.getRemoteWdConfig = function() { | ||
return { | ||
host: "ondemand.saucelabs.com", | ||
port: 80, | ||
username: username, | ||
accessKey: accessKey | ||
}; | ||
}; | ||
}).call(this); | ||
exports.jobPassed = function(jobId, done) { | ||
var httpOpts = { | ||
url: 'http://' + username + ':' + accessKey + '@saucelabs.com/rest/v1/' + username + '/jobs/' + jobId, | ||
method: 'PUT', | ||
headers: { | ||
'Content-Type': 'text/json' | ||
}, | ||
body: JSON.stringify({ | ||
passed: true | ||
, public: true | ||
, build: process.env.TRAVIS_JOB_ID || Math.round(new Date().getTime() / (1000*60*60)) | ||
}) | ||
}; | ||
request(httpOpts, function(err, res) { | ||
if(err) | ||
{ console.log(err); } | ||
else | ||
{ console.log("> job:", jobId, "marked as pass." ); } | ||
done(err); | ||
}); | ||
}; | ||
@@ -1,11 +0,7 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
module.exports = { | ||
saucelabs: { | ||
username: '<USERNAME>', | ||
accessKey: '<KEY>' | ||
} | ||
}; | ||
}).call(this); | ||
module.exports = { | ||
saucelabs: { | ||
username: '<USERNAME>', | ||
accessKey: '<KEY>' | ||
} | ||
}; |
@@ -1,65 +0,62 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var nock, should, wd; | ||
var nock, should, wd; | ||
wd = require('../common/wd-with-cov'); | ||
wd = require('../common/wd-with-cov'); | ||
nock = require('nock'); | ||
nock = require('nock'); | ||
should = require('should'); | ||
should = require('should'); | ||
describe("wd", function() { | ||
return describe("unit", function() { | ||
return describe("callback tests", function() { | ||
var server; | ||
server = null; | ||
before(function(done) { | ||
server = nock('http://127.0.0.1:5555').filteringRequestBody(/.*/, '*'); | ||
if (process.env.WD_COV == null) { | ||
server.log(console.log); | ||
} | ||
server.post('/wd/hub/session', '*').reply(303, "OK", { | ||
'Location': '/wd/hub/session/1234' | ||
}); | ||
return done(null); | ||
describe("wd", function() { | ||
return describe("unit", function() { | ||
return describe("callback tests", function() { | ||
var server; | ||
server = null; | ||
before(function(done) { | ||
server = nock('http://127.0.0.1:5555').filteringRequestBody(/.*/, '*'); | ||
if (process.env.WD_COV === null) { | ||
server.log(console.log); | ||
} | ||
server.post('/wd/hub/session', '*').reply(303, "OK", { | ||
'Location': '/wd/hub/session/1234' | ||
}); | ||
return describe("simplecallback empty returns", function() { | ||
var browser; | ||
browser = null; | ||
describe("browser initialization", function() { | ||
return it("should initialize browser", function(done) { | ||
browser = wd.remote({ | ||
port: 5555 | ||
}); | ||
return browser.init({}, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
return done(null); | ||
}); | ||
return describe("simplecallback empty returns", function() { | ||
var browser; | ||
browser = null; | ||
describe("browser initialization", function() { | ||
return it("should initialize browser", function(done) { | ||
browser = wd.remote({ | ||
port: 5555 | ||
}); | ||
return browser.init({}, function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("simplecallback with empty return", function() { | ||
return it("should get url", function(done) { | ||
server.post('/wd/hub/session/1234/url', '*').reply(200, ""); | ||
return browser.get("www.google.com", function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("simplecallback with empty return", function() { | ||
return it("should get url", function(done) { | ||
server.post('/wd/hub/session/1234/url', '*').reply(200, ""); | ||
return browser.get("www.google.com", function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("simplecallback with 200 OK", function() { | ||
return it("should get url", function(done) { | ||
server.post('/wd/hub/session/1234/url', '*').reply(200, "OK"); | ||
return browser.get("www.google.com", function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
describe("simplecallback with 200 OK", function() { | ||
return it("should get url", function(done) { | ||
server.post('/wd/hub/session/1234/url', '*').reply(200, "OK"); | ||
return browser.get("www.google.com", function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
return describe("simplecallback with empty JSON data", function() { | ||
return it("should get url", function(done) { | ||
server.post('/wd/hub/session/1234/url', '*').reply(200, '{"sessionId":"1234","status":0,"value":{}}'); | ||
return browser.get("www.google.com", function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
}); | ||
return describe("simplecallback with empty JSON data", function() { | ||
return it("should get url", function(done) { | ||
server.post('/wd/hub/session/1234/url', '*').reply(200, '{"sessionId":"1234","status":0,"value":{}}'); | ||
return browser.get("www.google.com", function(err) { | ||
should.not.exist(err); | ||
return done(null); | ||
}); | ||
@@ -71,3 +68,2 @@ }); | ||
}); | ||
}).call(this); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
6143
1708
0
1
388381
4
65
23
+ Addedrequest@~2.12.0
+ Addedunderscore@1.4.x
+ Addedvargs@~0.1.0
+ Addedrequest@2.12.0(transitive)
+ Addedunderscore@1.4.4(transitive)
+ Addedvargs@0.1.0(transitive)