Created
June 15, 2014 15:20
-
-
Save anonymous/61ecd381b211ef5c4775 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
var casper = require('casper').create(); | |
casper.on("remote.message", function(msg){ | |
this.echo("remote.msg: " + msg); | |
}); | |
casper.on("resource.error", function(resourceError){ | |
this.echo("res.err: " + JSON.stringify(resourceError)); | |
}); | |
casper | |
.start() | |
.thenEvaluate(function(){ | |
window.that = function(el, num){ | |
console.log("num received: "+num); | |
}; | |
document.write('<a title="Show 100 items per page" onclick="that(this, 100)" href="javascript:void(0);">100</a>'); | |
}) | |
.then(function() { | |
this.echo('finished'); | |
this.capture('test31_Step1.png'); | |
}) | |
.thenClick("a") | |
.thenEvaluate(function(num){ | |
num = ""+num; | |
var a = document.querySelector('a[title="Show 100 items per page"]'); | |
a.innerHTML = num; | |
a.title = a.title.replace("100", num); | |
a.setAttribute("onclick", a.getAttribute("onclick").replace("100", num)); | |
console.log(a.title); | |
}, 200) | |
.thenClick("a") | |
.then(function() { | |
this.echo('finished'); | |
this.capture('test31_Step2.png'); | |
}) | |
.run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment