Skip to content

Instantly share code, notes, and snippets.

@nickboyce
Last active December 15, 2015 02:38
Show Gist options
  • Save nickboyce/5188171 to your computer and use it in GitHub Desktop.
Save nickboyce/5188171 to your computer and use it in GitHub Desktop.
Initial discovery of Casper/PhantomJS
// brew install phantomjs
// brew install casperjs
var casper = require("casper").create();
casper.start("http://www.easyart.com/scripts/pod/pod.pl?pid=213288", function() {});
casper.then(function() {
this.test.assertEval(function() {
return document.querySelectorAll("#pod-size-options input[type=radio]").length == 4
}, "displays 4 size options");
this.test.assertEval(function() {
return document.querySelectorAll("#pod-media-options li").length == 2
}, "displays 2 media options (paper & canvas)");
});
var framingLink;
casper.then(function() {
framingLink = this.getElementAttribute(".framing-link", "href");
this.click(".framing-link");
});
casper.then(function() {
this.click(".cancel-framing-link")
});
casper.then(function() {
console.log('clicked ok, new location is ' + framingLink);
console.log('clicked ok, new location is ' + this.getElementAttribute(".framing-link", "href"));
this.test.assert(function() {
this.getElementAttribute(".framing-link", "href") == framingLink;
}, "framing link mustn't change");
this.test.assertEval(function() {
return document.querySelectorAll("#pod-size-options input")[0].checked == true
}, "small size must be selected");
});
casper.run(function() {
this.test.renderResults(true);
});
# brew install phanstomjs
# brew install casperjs
casper = require("casper").create()
casper.start("http://www.easyart.com/scripts/pod/pod.pl?pid=213288")
casper.then ->
@test.assertEval ->
document.querySelectorAll("#pod-size-options input[type=radio]").length is 4
, "displays 4 size options"
@test.assertEval ->
document.querySelectorAll("#pod-media-options li").length is 2
, "displays 2 media options (paper & canvas)"
casper.run ->
this.test.renderResults(true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment