Skip to content

Instantly share code, notes, and snippets.

@nicoladj77
Created June 2, 2015 13:01
Show Gist options
  • Save nicoladj77/0ffc351d5d00712e987f to your computer and use it in GitHub Desktop.
Save nicoladj77/0ffc351d5d00712e987f to your computer and use it in GitHub Desktop.
var configLocal = {
undefeatedUrl: 'http://vip.local/espn',
fteUrl: 'http://vip.local/fivethirtyeight',
grantlandUrl: 'http://vip.local/grantland'
}
casper.test.begin( 'Login to wordpress', 3, function suite( test ) {
var jsErrors = [];
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" );
jsErrors.push( msg );
} );
// go to login
casper.start( "http://vip.local/wp-login.php", function () {
test.assertExists( '#loginform', "main form is found" );
this.fill( '#loginform', {
log: "wordpress",
pwd: "wordpress"
}, true );
} );
// check we are logged in
casper.then( function () {
test.assertEval( function () {
return __utils__.findAll( ".wrap > h2" ).length >= 1;
}, "we are logged in" );
} );
// here we add all the page we want to scrape
casper.thenOpen(
configLocal.undefeatedUrl + "/wp-admin/post-new.php?post_type=tu_video"
);
casper.then( function () {
test.assert( jsErrors.length === 0, "No Javascript errors detected" );
} );
casper.run( function () {
this.echo( 'done' );
test.done();
casper.exit();
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment