Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sandeeptalabathula/3acf224c0aed9301ad6124c7bc3e2fac to your computer and use it in GitHub Desktop.
Save sandeeptalabathula/3acf224c0aed9301ad6124c7bc3e2fac to your computer and use it in GitHub Desktop.
CasperJS_E2E_LoginTest
var fs = require('fs');
var require = patchRequire(require);
require('../../Common/utility');
require('../../Common/common');
require('../../Common/authentication');
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var time = currentTime.getHours() + '-' + currentTime.getMinutes() + '-' + currentTime.getSeconds();
var fname = "test-at-"+year + "-" + month + "-" + day + "-" + time + ".log";
var file = fs.pathJoin(fs.workingDirectory, 'testoutput', fname);
var x = require('casper').selectXPath;
casper.options.viewportSize = {width: 1536, height: 734};
casper.on('page.error', function(msg, trace) {
this.echo('Error: ' + msg, 'ERROR');
for(var i=0; i<trace.length; i++) {
var step = trace[i];
this.echo(' ' + step.file + ' (line ' + step.line + ')', 'ERROR');
}
});
$$.testCaseID = "LoginBVT";
casper.test.begin($$.testCaseID, function(test) {
$$.Utility.loadTestInput();
casper.start(testInput.Input.Url);
casper.waitForSelector("form#credentials input[name='login']",
function success() {
test.assertExists("form#credentials input[name='login']");
this.click("form#credentials input[name='login']");
},
function fail() {
test.assertExists("form#credentials input[name='login']");
});
casper.run(function() {test.done();});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment