Last active
December 15, 2015 02:38
-
-
Save nickboyce/5188171 to your computer and use it in GitHub Desktop.
Initial discovery of Casper/PhantomJS
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
// 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); | |
}); |
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
# 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