Skip to content

Instantly share code, notes, and snippets.

@tredence123
Created April 21, 2015 08:02
Show Gist options
  • Select an option

  • Save tredence123/653f1456dd4d2db7fdd0 to your computer and use it in GitHub Desktop.

Select an option

Save tredence123/653f1456dd4d2db7fdd0 to your computer and use it in GitHub Desktop.
Enter Key
/*
Author: Prateek
Description: This is a casperjs automated test script for showing that, Clicking on the Stop button does not show the results of the cancelled cells
*/
//Test begins
casper.test.begin(" After stopping the execution, for cancelled cells result is not displayed", 6, function suite(test) {
var x = require('casper').selectXPath;
var github_username = casper.cli.options.username;
var github_password = casper.cli.options.password;
var rcloud_url = casper.cli.options.url;
var functions = require(fs.absolute('basicfunctions'));
var input= 'a<-12; print a';
var errors = [];
casper.start(rcloud_url, function () {
casper.page.injectJs('jquery-1.10.2.js');
});
casper.wait(10000);
casper.viewport(1024, 768).then(function () {
functions.login(casper, github_username, github_password, rcloud_url);
});
casper.viewport(1024, 768).then(function () {
this.wait(9000);
console.log("validating that the Main page has got loaded properly by detecting if some of its elements are visible. Here we are checking for Shareable Link and Logout options");
functions.validation(casper);
});
functions.create_notebook(casper);
casper.then(function(){
//this.click({type:'xpath', path:".//*[@id='command-prompt']/div[2]/div"});
this.wait(2000);
this.sendKeys(({type:'xpath', path:".//*[@id='command-prompt']/div[2]/div"}, input, {keepFocus: true}));
this.page.sendEvent("keypress", casper.page.event.key.Enter);
});
casper.wait(3000);
//Registering to the page.errors actually not required but still if there are some errors found on the page it will gives us the details
casper.on("page.error", function(msg, trace) {
this.echo("Error: " + msg, "ERROR");
this.echo("file: " + trace[0].file, "WARNING");
this.echo("line: " + trace[0].line, "WARNING");
this.echo("function: " + trace[0]["function"], "WARNING");
errors.push(msg);
});
casper.run(function() {
if (errors.length > 0) {
this.echo(errors.length + ' Javascript errors found', "WARNING");
} else {
this.echo(errors.length + ' Javascript errors found', "INFO");
}
test.done();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment