// Generated by CoffeeScript 1.3.2 (function() { var CoffeeScript, app, async, elementByCss, evalShouldEqual, executeCoffee, express, runTestWith, safeEvalShouldEqual, should, textShouldEqual, valueShouldEqual, wd; wd = require('../../lib/main'); should = require('should'); express = require('express'); CoffeeScript = require('coffee-script'); async = require('async'); evalShouldEqual = function(browser, formula, expected) { return function(done) { return browser["eval"](formula, function(err, res) { should.not.exist(err); res.should.equal(expected); return done(null); }); }; }; safeEvalShouldEqual = function(browser, formula, expected) { return function(done) { return browser.safeEval(formula, 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); return done(null); }); }; }; elementByCss = function(browser, env, css, name) { return function(done) { return browser.elementByCss(css, function(err, res) { should.not.exist(err); env[name] = res; return done(null); }); }; }; textShouldEqual = function(browser, element, expected, done) { return browser.text(element, function(err, res) { should.not.exist(err); res.should.equal(expected); 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); }); }; runTestWith = function(remoteWdConfig, desired) { var browser, elementFunctionTests; browser = null; elementFunctionTests = function() { var funcSuffix, tests, _fn, _i, _len, _ref; tests = {}; tests.element = function(test) { return async.series([ function(done) { return browser.element("name", "elementByName", function(err, res) { should.not.exist(err); should.exist(res); return done(null); }); }, function(done) { return browser.element("name", "elementByName2", function(err, res) { should.exist(err); err.status.should.equal(7); return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }; tests.elementOrNull = function(test) { return async.series([ function(done) { return browser.elementOrNull("name", "elementByName", function(err, res) { should.not.exist(err); should.exist(res); return done(null); }); }, function(done) { return browser.elementOrNull("name", "elementByName2", function(err, res) { should.not.exist(err); (res === null).should.be["true"]; return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }; tests.elementIfExists = function(test) { return async.series([ function(done) { return browser.elementIfExists("name", "elementByName", function(err, res) { should.not.exist(err); should.exist(res); return done(null); }); }, function(done) { return browser.elementIfExists("name", "elementByName2", function(err, res) { should.not.exist(err); (res === void 0).should.be["true"]; return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }; tests.hasElement = function(test) { return async.series([ function(done) { return browser.hasElement("name", "elementByName", function(err, res) { should.not.exist(err); res.should.be["true"]; return done(null); }); }, function(done) { return browser.hasElement("name", "elementByName2", function(err, res) { should.not.exist(err); res.should.be["false"]; return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }; tests.elements = function(test) { return async.series([ function(done) { return browser.elements("name", "elementsByName", function(err, res) { should.not.exist(err); res.should.have.length(3); return done(null); }); }, function(done) { return browser.elements("name", "elementsByName2", function(err, res) { should.not.exist(err); res.should.eql([]); return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }; _ref = ['ByClassName', 'ByCssSelector', 'ById', 'ByName', 'ByLinkText', 'ByPartialLinkText', 'ByTagName', 'ByXPath', 'ByCss']; _fn = function() { var elementFuncName, elementsFuncName, hasElementFuncName, searchSeveralText, searchSeveralText2, searchText, searchText2; elementFuncName = 'element' + funcSuffix; hasElementFuncName = 'hasElement' + funcSuffix; elementsFuncName = 'elements' + funcSuffix; searchText = elementFuncName; if (searchText.match(/ByLinkText/)) { searchText = "click " + searchText; } if (searchText.match(/ByCss/)) { searchText = "#" + searchText; } if (searchText.match(/ByXPath/)) { searchText = "//div[@id='elementByXPath']/input"; } if (searchText.match(/ByTagName/)) { searchText = "span"; } searchText2 = elementFuncName + '2'; if (searchText.match(/ByXPath/)) { searchText2 = "//div[@id='elementByXPath2']/input"; } if (searchText.match(/ByTagName/)) { searchText2 = "span2"; } searchSeveralText = searchText.replace('element', 'elements'); searchSeveralText2 = searchText2.replace('element', 'elements'); tests[elementFuncName] = function(test) { return async.series([ function(done) { return browser[elementFuncName](searchText, function(err, res) { should.not.exist(err); should.exist(res); return done(null); }); }, function(done) { return browser[elementFuncName](searchText2, function(err, res) { should.exist(err); err.status.should.equal(7); return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }; tests[elementFuncName + 'OrNull'] = function(test) { return async.series([ function(done) { return browser[elementFuncName + 'OrNull'](searchText, function(err, res) { should.not.exist(err); should.exist(res); return done(null); }); }, function(done) { return browser[elementFuncName + 'OrNull'](searchText2, function(err, res) { should.not.exist(err); (res === null).should.be["true"]; return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }; tests[elementFuncName + 'IfExists'] = function(test) { return async.series([ function(done) { return browser[elementFuncName + 'IfExists'](searchText, function(err, res) { should.not.exist(err); should.exist(res); return done(null); }); }, function(done) { return browser[elementFuncName + 'IfExists'](searchText2, function(err, res) { should.not.exist(err); (res === void 0).should.be["true"]; return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }; tests[hasElementFuncName] = function(test) { return async.series([ function(done) { return browser[hasElementFuncName](searchText, function(err, res) { should.not.exist(err); res.should.be["true"]; return done(null); }); }, function(done) { return browser[hasElementFuncName](searchText2, function(err, res) { should.not.exist(err); res.should.be["false"]; return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }; return tests[elementsFuncName] = function(test) { return async.series([ function(done) { return browser[elementsFuncName](searchSeveralText, function(err, res) { should.not.exist(err); if (!(elementsFuncName.match(/ByTagName/))) { res.should.have.length(3); } else { (res.length > 1).should.be["true"]; } return done(null); }); }, function(done) { return browser[elementsFuncName](searchSeveralText2, function(err, res) { should.not.exist(err); res.should.eql([]); return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }; }; for (_i = 0, _len = _ref.length; _i < _len; _i++) { funcSuffix = _ref[_i]; _fn(); } return tests; }; return { "wd.remote": function(test) { browser = wd.remote(remoteWdConfig); 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 test.done(); }, "status": function(test) { return browser.status(function(err, status) { should.not.exist(err); should.exist(status); return test.done(); }); }, "sessions": function(test) { return browser.sessions(function(err, sessions) { should.not.exist(err); should.exist(sessions); return test.done(); }); }, "init": function(test) { return browser.init(desired, function(err) { should.not.exist(err); return test.done(); }); }, "sessionCapabilities": function(test) { return browser.sessionCapabilities(function(err, capabilities) { should.not.exist(err); should.exist(capabilities); should.exist(capabilities.browserName); should.exist(capabilities.platform); return test.done(); }); }, "altSessionCapabilities": function(test) { return browser.altSessionCapabilities(function(err, capabilities) { should.not.exist(err); should.exist(capabilities); should.exist(capabilities.browserName); should.exist(capabilities.platform); return test.done(); }); }, "setPageLoadTimeout": function(test) { return browser.setPageLoadTimeout(500, function(err) { should.not.exist(err); return test.done(); }); }, "get": function(test) { return browser.get("http://127.0.0.1:8181/test-page.html", function(err) { should.not.exist(err); return test.done(); }); }, "refresh": function(test) { return browser.refresh(function(err) { should.not.exist(err); return test.done(); }); }, "back / forward": function(test) { return async.series([ function(done) { return browser.get("http://127.0.0.1:8181/test-page.html?p=2", function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.url(function(err, url) { should.not.exist(err); url.should.include("?p=2"); return done(null); }); }, function(done) { return browser.back(function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.url(function(err, url) { should.not.exist(err); url.should.not.include("?p=2"); return done(null); }); }, function(done) { return browser.forward(function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.url(function(err, url) { should.not.exist(err); url.should.include("?p=2"); return done(null); }); }, function(done) { return browser.get("http://127.0.0.1:8181/test-page.html", function(err) { should.not.exist(err); return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }, "eval": function(test) { return async.series([evalShouldEqual(browser, "1+2", 3), evalShouldEqual(browser, "document.title", "TEST PAGE"), evalShouldEqual(browser, "$('#eval').length", 1), evalShouldEqual(browser, "$('#eval li').length", 2)], function(err) { should.not.exist(err); return test.done(); }); }, "safeEval": function(test) { return async.series([ safeEvalShouldEqual(browser, "1+2", 3), safeEvalShouldEqual(browser, "document.title", "TEST PAGE"), safeEvalShouldEqual(browser, "$('#eval').length", 1), safeEvalShouldEqual(browser, "$('#eval li').length", 2), function(done) { return browser.safeEval('wrong formula +', function(err, res) { should.exist(err); (err instanceof Error).should.be["true"]; return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }, "execute (no args)": function(test) { return async.series([ function(done) { return browser.execute("window.wd_sync_execute_test = 'It worked!'", function(err) { should.not.exist(err); return done(null); }); }, evalShouldEqual(browser, "window.wd_sync_execute_test", 'It worked!') ], function(err) { should.not.exist(err); return test.done(); }); }, "execute (with args)": function(test) { var jsScript; jsScript = 'var a = arguments[0], b = arguments[1];\nwindow.wd_sync_execute_test = \'It worked! \' + (a+b)'; return async.series([ function(done) { return browser.execute(jsScript, [6, 4], function(err) { should.not.exist(err); return done(null); }); }, evalShouldEqual(browser, "window.wd_sync_execute_test", 'It worked! 10') ], function(err) { should.not.exist(err); return test.done(); }); }, "safeExecute (no args)": function(test) { return async.series([ function(done) { return browser.safeExecute("window.wd_sync_execute_test = 'It worked!'", function(err) { should.not.exist(err); return done(null); }); }, evalShouldEqual(browser, "window.wd_sync_execute_test", 'It worked!'), function(done) { return browser.safeExecute("invalid-code> here", function(err) { should.exist(err); (err instanceof Error).should.be["true"]; return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }, "safeExecute (with args)": function(test) { var jsScript; jsScript = 'var a = arguments[0], b = arguments[1];\nwindow.wd_sync_execute_test = \'It worked! \' + (a+b)'; return async.series([ function(done) { return browser.safeExecute(jsScript, [6, 4], function(err) { should.not.exist(err); return done(null); }); }, evalShouldEqual(browser, "window.wd_sync_execute_test", 'It worked! 10'), function(done) { return browser.safeExecute("invalid-code> here", [6, 4], function(err) { should.exist(err); (err instanceof Error).should.be["true"]; return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }, "executeAsync (no args)": function(test) { var scriptAsCoffee, scriptAsJs; scriptAsCoffee = "[args...,done] = arguments\ndone \"OK\" "; scriptAsJs = CoffeeScript.compile(scriptAsCoffee, { bare: 'on' }); return browser.executeAsync(scriptAsJs, function(err, res) { should.not.exist(err); res.should.equal("OK"); return test.done(); }); }, "executeAsync (with args)": function(test) { var scriptAsCoffee, scriptAsJs; scriptAsCoffee = "[a,b,done] = arguments\ndone(\"OK \" + (a+b)) "; scriptAsJs = CoffeeScript.compile(scriptAsCoffee, { bare: 'on' }); return browser.executeAsync(scriptAsJs, [10, 5], function(err, res) { should.not.exist(err); res.should.equal("OK 15"); return test.done(); }); }, "safeExecuteAsync (no args)": function(test) { return async.series([ function(done) { var scriptAsCoffee, scriptAsJs; scriptAsCoffee = "[args...,done] = arguments\ndone \"OK\" "; scriptAsJs = CoffeeScript.compile(scriptAsCoffee, { bare: 'on' }); return browser.safeExecuteAsync(scriptAsJs, function(err, res) { should.not.exist(err); res.should.equal("OK"); return done(null); }); }, function(done) { return browser.safeExecuteAsync("123 invalid\n $('#setWaitTimeout').html '
a child
'\n, 1000"), function(done) { return browser.elementByCss("#setWaitTimeout .child", function(err, res) { should.exist(err); err.status.should.equal(7); return done(null); }); }, function(done) { return browser.setImplicitWaitTimeout(2000, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.elementByCss("#setWaitTimeout .child", function(err, res) { should.not.exist(err); should.exist(res); return done(null); }); }, function(done) { return browser.setImplicitWaitTimeout(0, function(err) { should.not.exist(err); return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }, "setAsyncScriptTimeout": function(test) { return async.series([ function(done) { return browser.setAsyncScriptTimeout(2000, function(err) { should.not.exist(err); return done(null); }); }, function(done) { var scriptAsCoffee, scriptAsJs; scriptAsCoffee = "[args...,done] = arguments\nsetTimeout ->\n done \"OK\"\n, 1000"; scriptAsJs = CoffeeScript.compile(scriptAsCoffee, { bare: 'on' }); return browser.executeAsync(scriptAsJs, function(err, res) { should.not.exist(err); res.should.equal("OK"); return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }, "element function tests": elementFunctionTests(), "getAttribute": function(test) { return browser.elementById("getAttribute", function(err, testDiv) { should.not.exist(err); should.exist(testDiv); return async.series([ function(done) { return browser.getAttribute(testDiv, "weather", function(err, res) { should.not.exist(err); res.should.equal("sunny"); return done(null); }); }, function(done) { return browser.getAttribute(testDiv, "timezone", function(err, res) { should.not.exist(err); should.not.exist(res); return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }); }, "getValue (input)": function(test) { return browser.elementByCss("#getValue input", function(err, inputField) { should.not.exist(err); should.exist(inputField); return browser.getValue(inputField, function(err, res) { should.not.exist(err); res.should.equal("Hello getValueTest!"); return test.done(); }); }); }, "getValue (textarea)": function(test) { return browser.elementByCss("#getValue textarea", function(err, inputField) { should.not.exist(err); should.exist(inputField); return browser.getValue(inputField, function(err, res) { should.not.exist(err); res.should.equal("Hello getValueTest2!"); return test.done(); }); }); }, "clickElement": function(test) { return browser.elementByCss("#clickElement a", function(err, anchor) { should.not.exist(err); should.exist(anchor); return async.series([ executeCoffee(browser, 'jQuery ->\n a = $(\'#clickElement a\')\n a.click ->\n a.html \'clicked\' '), function(done) { return textShouldEqual(browser, anchor, "not clicked", done); }, function(done) { return browser.clickElement(anchor, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return textShouldEqual(browser, anchor, "clicked", done); } ], function(err) { should.not.exist(err); return test.done(); }); }); }, "moveTo": function(test) { var env; env = {}; return async.series([ elementByCss(browser, env, "#moveTo .a1", 'a1'), elementByCss(browser, env, "#moveTo .a2", 'a2'), elementByCss(browser, env, "#moveTo .current", 'current'), function(done) { return textShouldEqual(browser, env.current, '', done); }, executeCoffee(browser, 'jQuery ->\n a1 = $(\'#moveTo .a1\')\n a2 = $(\'#moveTo .a2\')\n current = $(\'#moveTo .current\')\n a1.hover ->\n current.html \'a1\'\n a2.hover ->\n current.html \'a2\''), function(done) { return textShouldEqual(browser, env.current, '', done); }, function(done) { return browser.moveTo(env.a1, 5, 5, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return textShouldEqual(browser, env.current, 'a1', done); }, function(done) { return browser.moveTo(env.a2, void 0, void 0, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return textShouldEqual(browser, env.current, 'a2', done); }, function(done) { return browser.moveTo(env.a1, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return textShouldEqual(browser, env.current, 'a1', done); } ], function(err) { should.not.exist(err); return test.done(); }); }, "buttonDown / buttonUp": function(test) { var env; env = {}; return async.series([ elementByCss(browser, env, "#mouseButton a", 'a'), elementByCss(browser, env, "#mouseButton div", 'resDiv'), executeCoffee(browser, 'jQuery ->\n a = $(\'#mouseButton a\')\n resDiv = $(\'#mouseButton div\')\n a.mousedown ->\n resDiv.html \'button down\'\n a.mouseup ->\n resDiv.html \'button up\''), function(done) { return textShouldEqual(browser, env.resDiv, '', done); }, function(done) { return browser.moveTo(env.a, void 0, void 0, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.buttonDown(function(err) { should.not.exist(err); return done(null); }); }, function(done) { return textShouldEqual(browser, env.resDiv, 'button down', done); }, function(done) { return browser.buttonUp(function(err) { should.not.exist(err); return done(null); }); }, function(done) { return textShouldEqual(browser, env.resDiv, 'button up', done); } ], function(err) { should.not.exist(err); return test.done(); }); }, "click": function(test) { return browser.elementByCss("#click a", function(err, anchor) { should.not.exist(err); should.exist(anchor); return async.series([ executeCoffee(browser, 'jQuery ->\n window.numOfClick = 0\n a = $(\'#click a\')\n a.click ->\n window.numOfClick = window.numOfClick + 1\n a.html "clicked #{window.numOfClick}" '), function(done) { return textShouldEqual(browser, anchor, "not clicked", done); }, function(done) { return browser.moveTo(anchor, void 0, void 0, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.click(0, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return textShouldEqual(browser, anchor, "clicked 1", done); }, function(done) { return browser.moveTo(anchor, void 0, void 0, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.click(function(err) { should.not.exist(err); return done(null); }); }, function(done) { return textShouldEqual(browser, anchor, "clicked 2", done); } ], function(err) { should.not.exist(err); return test.done(); }); }); }, "doubleclick": function(test) { return browser.elementByCss("#doubleclick a", function(err, anchor) { should.not.exist(err); should.exist(anchor); return async.series([ executeCoffee(browser, 'jQuery ->\n a = $(\'#doubleclick a\')\n a.click ->\n a.html \'doubleclicked\' '), function(done) { return textShouldEqual(browser, anchor, "not clicked", done); }, function(done) { return browser.moveTo(anchor, void 0, void 0, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.doubleclick(0, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return textShouldEqual(browser, anchor, "doubleclicked", done); } ], function(err) { should.not.exist(err); return test.done(); }); }); }, "type": function(test) { var altKey, nullKey; altKey = wd.SPECIAL_KEYS['Alt']; nullKey = wd.SPECIAL_KEYS['NULL']; return browser.elementByCss("#type input", function(err, inputField) { should.not.exist(err); should.exist(inputField); return async.series([ function(done) { return valueShouldEqual(browser, inputField, "", done); }, function(done) { return browser.type(inputField, "Hello", function(err) { should.not.exist(err); return done(null); }); }, function(done) { return valueShouldEqual(browser, inputField, "Hello", done); }, function(done) { return browser.type(inputField, [altKey, nullKey, " World"], function(err) { should.not.exist(err); return done(null); }); }, function(done) { return valueShouldEqual(browser, inputField, "Hello World", done); }, function(done) { return browser.type(inputField, "\n", function(err) { should.not.exist(err); return done(null); }); }, function(done) { return valueShouldEqual(browser, inputField, "Hello World", done); } ], function(err) { should.not.exist(err); return test.done(); }); }); }, "keys": function(test) { var altKey, nullKey; altKey = wd.SPECIAL_KEYS['Alt']; nullKey = wd.SPECIAL_KEYS['NULL']; return browser.elementByCss("#keys input", function(err, inputField) { should.not.exist(err); should.exist(inputField); return async.series([ function(done) { return valueShouldEqual(browser, inputField, "", done); }, function(done) { return browser.clickElement(inputField, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.keys("Hello", function(err) { should.not.exist(err); return done(null); }); }, function(done) { return valueShouldEqual(browser, inputField, "Hello", done); }, function(done) { return browser.keys([altKey, nullKey, " World"], function(err) { should.not.exist(err); return done(null); }); }, function(done) { return valueShouldEqual(browser, inputField, "Hello World", done); }, function(done) { return browser.keys("\n", function(err) { should.not.exist(err); return done(null); }); }, function(done) { return valueShouldEqual(browser, inputField, "Hello World", done); } ], function(err) { should.not.exist(err); return test.done(); }); }); }, "clear": function(test) { return browser.elementByCss("#clear input", function(err, inputField) { should.not.exist(err); should.exist(inputField); return async.series([ function(done) { return valueShouldEqual(browser, inputField, "not cleared", done); }, 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 test.done(); }); }); }, "title": function(test) { return browser.title(function(err, title) { should.not.exist(err); title.should.equal("TEST PAGE"); return test.done(); }); }, "text (passing element)": function(test) { return browser.elementByCss("#text", function(err, textDiv) { should.not.exist(err); should.exist(textDiv); return browser.text(textDiv, function(err, res) { should.not.exist(err); res.should.include("text content"); res.should.not.include("div"); return test.done(); }); }); }, "text (passing undefined)": function(test) { return browser.text(void 0, function(err, res) { should.not.exist(err); res.should.include("text content"); res.should.include("sunny"); res.should.include("click elementsByLinkText"); res.should.not.include("div"); return test.done(); }); }, "text (passing body)": function(test) { return browser.text('body', function(err, res) { should.not.exist(err); res.should.include("text content"); res.should.include("sunny"); res.should.include("click elementsByLinkText"); res.should.not.include("div"); return test.done(); }); }, "text (passing null)": function(test) { return browser.text(null, function(err, res) { should.not.exist(err); res.should.include("text content"); res.should.include("sunny"); res.should.include("click elementsByLinkText"); res.should.not.include("div"); return test.done(); }); }, "textPresent": function(test) { return browser.elementByCss("#textPresent", function(err, textDiv) { should.not.exist(err); should.exist(textDiv); return async.series([ function(done) { return browser.textPresent('sunny', textDiv, function(err, res) { should.not.exist(err); res.should.be["true"]; return done(null); }); }, function(done) { return browser.textPresent('raining', textDiv, function(err, res) { should.not.exist(err); res.should.be["false"]; return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }); }, "acceptAlert": function(test) { return browser.elementByCss("#acceptAlert a", function(err, a) { should.not.exist(err); should.exist(a); return async.series([ executeCoffee(browser, "jQuery -> \n a = $('#acceptAlert a')\n a.click ->\n alert \"coffee is running out\""), function(done) { return browser.clickElement(a, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.acceptAlert(function(err) { should.not.exist(err); return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }); }, "dismissAlert": function(test) { return browser.elementByCss("#dismissAlert a", function(err, a) { var capabilities; should.not.exist(err); should.exist(a); capabilities = null; return async.series([ function(done) { return browser.sessionCapabilities(function(err, res) { should.not.exist(err); capabilities = res; return done(null); }); }, executeCoffee(browser, "jQuery -> \n a = $('#dismissAlert a')\n a.click ->\n alert \"coffee is running out\""), function(done) { return browser.clickElement(a, function(err) { should.not.exist(err); return done(null); }); }, function(done) { if (!(capabilities.platform === 'MAC' && capabilities.browserName === 'chrome')) { return browser.dismissAlert(function(err) { should.not.exist(err); return done(null); }); } else { return browser.acceptAlert(function(err) { should.not.exist(err); return done(null); }); } } ], function(err) { should.not.exist(err); return test.done(); }); }); }, "active": function(test) { var env; env = {}; return async.series([ elementByCss(browser, env, "#active .i1", 'i1'), elementByCss(browser, env, "#active .i2", 'i2'), function(done) { return browser.clickElement(env.i1, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.active(function(err, res) { should.not.exist(err); res.should.equal(env.i1); return done(null); }); }, function(done) { return browser.clickElement(env.i2, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.active(function(err, res) { should.not.exist(err); res.should.equal(env.i2); return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }, "url": function(test) { return browser.url(function(err, res) { res.should.include("test-page.html"); res.should.include("http://"); return test.done(); }); }, "allCookies / setCookies / deleteAllCookies / deleteCookie": function(test) { return async.series([ function(done) { return browser.deleteAllCookies(function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.allCookies(function(err, res) { should.not.exist(err); res.should.eql([]); return done(null); }); }, function(done) { return browser.setCookie({ name: 'fruit1', value: 'apple' }, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.allCookies(function(err, res) { should.not.exist(err); res.should.have.length(1); (res.filter(function(c) { return c.name === 'fruit1' && c.value === 'apple'; })).should.have.length(1); return done(null); }); }, function(done) { return browser.setCookie({ name: 'fruit2', value: 'pear' }, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.allCookies(function(err, res) { should.not.exist(err); res.should.have.length(2); (res.filter(function(c) { return c.name === 'fruit2' && c.value === 'pear'; })).should.have.length(1); return done(null); }); }, function(done) { return browser.setCookie({ name: 'fruit3', value: 'orange' }, function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.allCookies(function(err, res) { should.not.exist(err); res.should.have.length(3); return done(null); }); }, function(done) { return browser.deleteCookie('fruit2', function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.allCookies(function(err, res) { should.not.exist(err); res.should.have.length(2); (res.filter(function(c) { return c.name === 'fruit2' && c.value === 'pear'; })).should.have.length(0); return done(null); }); }, function(done) { return browser.deleteAllCookies(function(err) { should.not.exist(err); return done(null); }); }, function(done) { return browser.allCookies(function(err, res) { should.not.exist(err); res.should.eql([]); return done(null); }); }, function(done) { return browser.setCookie({ name: 'fruit3', value: 'orange', secure: true }, function(err) { should.not.exist(err); return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }, "waitForCondition": function(test) { var exprCond; exprCond = "$('#waitForCondition .child').length > 0"; return async.series([ executeCoffee(browser, "setTimeout ->\n $('#waitForCondition').html '
a waitForCondition child
'\n, 1500"), function(done) { return browser.elementByCss("#waitForCondition .child", function(err, res) { should.exist(err); err.status.should.equal(7); return done(null); }); }, function(done) { return browser.waitForCondition(exprCond, 2000, 200, function(err, res) { should.not.exist(err); res.should.be["true"]; return done(err); }); }, function(done) { return browser.waitForCondition(exprCond, 2000, function(err, res) { should.not.exist(err); res.should.be["true"]; return done(err); }); }, function(done) { return browser.waitForCondition(exprCond, function(err, res) { should.not.exist(err); res.should.be["true"]; return done(err); }); } ], function(err) { should.not.exist(err); return test.done(); }); }, "waitForConditionInBrowser": function(test) { var exprCond; exprCond = "$('#waitForConditionInBrowser .child').length > 0"; return async.series([ executeCoffee(browser, "setTimeout ->\n $('#waitForConditionInBrowser').html '
a waitForCondition child
'\n, 1500"), function(done) { return browser.elementByCss("#waitForConditionInBrowser .child", function(err, res) { should.exist(err); err.status.should.equal(7); return done(null); }); }, function(done) { return browser.setAsyncScriptTimeout(5000, function(err, res) { should.not.exist(err); return done(null); }); }, function(done) { return browser.waitForConditionInBrowser(exprCond, 2000, 200, function(err, res) { should.not.exist(err); res.should.be["true"]; return done(err); }); }, function(done) { return browser.waitForConditionInBrowser(exprCond, 2000, function(err, res) { should.not.exist(err); res.should.be["true"]; return done(err); }); }, function(done) { return browser.waitForConditionInBrowser(exprCond, function(err, res) { should.not.exist(err); res.should.be["true"]; return done(err); }); }, function(done) { return browser.setAsyncScriptTimeout(0, function(err, res) { should.not.exist(err); return done(null); }); } ], function(err) { should.not.exist(err); return test.done(); }); }, "err.inspect": function(test) { return browser.safeExecute("invalid-code> here", function(err) { should.exist(err); (err instanceof Error).should.be["true"]; err.inspect().should.include('"screen": "[hidden]"'); return test.done(); }); }, "close": function(test) { return browser.close(function(err) { should.not.exist(err); return test.done(); }); }, "quit": function(test) { return browser.quit(function(err) { should.not.exist(err); return test.done(); }); } }; }; app = null; exports.wd = { "per method test": { 'starting express': function(test) { app = express.createServer(); app.use(express["static"](__dirname + '/assets')); app.listen(8181); return test.done(); }, chrome: runTestWith({}, { browserName: 'chrome' }), firefox: runTestWith({}, { browserName: 'firefox' }), 'stopping express': function(test) { app.close(); return test.done(); } } }; }).call(this);