Last active
December 29, 2016 06:30
-
-
Save cjoshmartin/c973fe418cddac033392667bca902944 to your computer and use it in GitHub Desktop.
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
{ | |
"paycheck": { | |
"date": "12/30/2016", | |
"pay": 0.0 | |
} | |
} |
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
var casper = require('casper').create(); | |
var xpath = require("casper").selectXPath; | |
var config = require('../config.json'); | |
var data = require('../data.json'); | |
var fs =require('fs'); | |
var current={ | |
"work":{}, | |
}; | |
var hourly =config.money.hourly; | |
casper.start(hourly.url,function () { | |
this.wait(2000,function () { | |
this.echo('filling form...'); | |
this.sendKeys('#username',config.cas.username); | |
this.sendKeys('#password',config.cas.password); | |
// this.capture('username.png'); | |
this.click('input[name="_eventId_submit"]'); | |
this.wait(3000,function () { | |
// this.echo("taking a screenshot"); | |
// this.capture('currentstate.png'); | |
current.work.hours=parseFloat((this.fetchText(xpath("//div[@id='timesheet-table-basic']/table/tbody/tr[4]/td[18]")))); | |
// this.echo("hours worked is: "+current.hours); | |
// this.echo("money earned: $"+ current.hours*hourly.rate); | |
current.work.amount=current.work.hours*hourly.rate; | |
var temp =JSON.parse(JSON.stringify(data)); | |
current.push(temp); | |
console.log("output: " + JSON.stringify(current,null,' ')); | |
fs.write('data.json',JSON.stringify(current,null,' '),'w'); | |
});// end of second wait | |
});// end of first wait function | |
});//end of start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment