I am working on a script for DraftKings. The first thing I need to do is login.
As you can see there is a login button in the top right. When you click it a modal overlay displays with the login box.
I have a CasperJS script that looks like this:
var casper = require('casper').create({
clientScripts: ["./jquery-2.1.4.min.js"],
loadImages:false,
verbose: true,
logLevel: 'debug'
});
//set browser user agent
casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X)');
//Open URL
casper.start('https://draftkings.com');
casper.thenEvaluate(function() {
this.clickLabel('Sign-in', 'a');
//.click('a[data-lp-signin-nav="1"]');
this.capture('login.png');
});
casper.thenEvaluate(function() {
//fill form
//casper.evaluate(function(){
casper.sendKeys('#Username', "xxxxx");
casper.sendKeys('#Password', "xxxxx");
this.click('a[data-signin-submit="1"]');
this.capture('screen.png');
//});
});
casper.run(function() {
//finish execution script
this.exit();
});
I start the page, then I try to click on the sign-in button to have the modal overlay appear, but when login.png does not show it displayed.
On another note I should be able to login without that displaying, but when I do it does not redirect me to the home page, and when I manually open the main page I am not logged in.
The console logs show no errors, and I can see that the forms items are being filled in and the button is being clicked.
Am I missing something here?