Created
July 20, 2015 05:57
-
-
Save collegeimprovements/1a019a6a882f263dff7c to your computer and use it in GitHub Desktop.
Casperjs for alarm active admin - play ground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var config = {u:'#txtUsername', p:'#txtPassword'}; | |
var siteCred = {u:'cybagereg', p:'Cybage1'}; | |
var fs = require('fs'); | |
var list_of_files = ['aha.png','pre.png','Finally_new_page.png']; | |
list_of_files.forEach(function(filename) { | |
if (fs.exists(filename)){ fs.remove(filename);} | |
}); | |
var casper = require('casper').create({logLevel: "debug", verbose: true, clientScripts: ['C:/Users/arpitsh/Desktop/Ghost/lib/jquery-2.1.4.js'] }); | |
//var config = {u:'#txtUsername', p:'#txtPassword'}; | |
//var siteCred = {u:'cybagereg', p:'Cybage1'}; | |
casper.start('https://alarmadmin.alarm.com/default.aspx', function() { | |
casper.echo(this.getTitle()); // get the title of the webpage | |
if(this.exists(config.u)) | |
{casper.echo('\n\n#txtUsername found***>>>');}else{casper.echo('\n\n#txtUsername NOT found***>>>');} | |
if(this.exists(config.p)) | |
{casper.echo('\n\n#txtPassword found***>>>');}else{casper.echo('\n\n#txtPassword NOT found***>>>');} | |
// this.sendKeys('#txtUsername', siteCred.u); // workin OK with id selectors | |
this.sendKeys(config.u, siteCred.u); | |
this.sendKeys('input[name=txtPassword]', siteCred.p); // working OK with name selectors | |
// casper.thenEvaluate(function(){ | |
// $("input[name=txtPassword]").val(siteCred.p); | |
// }); | |
casper.capture('pre.png'); | |
this.click('#butLogin'); // working OK with id selectors | |
casper.capture('aha.png'); | |
// | |
//casper.on("url.changed", function(){ | |
// casper.echo("***********************\n\n\n"); | |
// this.then(function(){ | |
// this.echo("AND this is also working but needs wati function so not much useful ------> " + this.getCurrentUrl()); | |
// }); | |
//}); // working but requires some kind of wait function. | |
// Let's wait for a while, so that URL is changed. | |
casper.wait(8000,function(){ | |
casper.echo(this.getCurrentUrl()); | |
casper.wait(10000,function(){casper.capture('Finally_new_page.png');}); | |
}); | |
// casper.then(function(){ | |
// casper.echo(this.getCurrentUrl()); | |
// casper.capture('after_submit.png'); | |
// }); | |
}); | |
//casper.exit(); | |
casper.run(); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment