Currently using RiotJS and Mocha for unit testing. Was wanting to know if I can use a headless browser webkit like PhantomJS & CasperJS to do additional tests on my RiotJS tags/pages. Up to now all my attempts to load the tags/pages and perform queries on the document have failed. Would appreciate any samples/links.
Thanks
Updated: querySelector fails for '#testId', but succeeds for 'testId2'.
Extract from my unit test:
page.open('http://localhost/src/default.html', function (status) {
var test = document.querySelector("#testId"); // returns undefined
}
<!-- html page -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Riot.js Example</title>
</head>
<body>
<!-- mount points -->
<spinner data-url="./data.json" data-sourceId="instance1" data-model="myModel" id="testId"></spinner>
<imageoutput data-sourceId="instance1" data-model="myModel"></imageoutput>
<div id="testId2">this content</div>
<!-- mount the same way -->
<!--[if lt IE 9]>
<script src="../dist/scripts/es5-shim.js"></script>
<script src="ie-stuff.js"></script>
<![endif]-->
<script src="../dist/scripts/require.js" data-main="./main"></script>
</body>
</html>
Patrick,
It would be nice you better specify which test objectives you want to do, what to do on each page to see if the CasperJS / PhantomJS realize do it!
The CasperJS, working with the PhantomJS can work independently and I confess that today, any automation project pages or testing, I use them only and give the trick!
For a layout test (images, fonts, CSS), you can study the PhantomCSS, but if your goal is to navigate, click, test elements and even download archive (assuming avoid URLs with Silverlight, Java ... the CasperJS will give account to do anything you want ... and the returns you can get at log.xml to treat it in any other tool or system.
I'm finishing my new site and it, post several tutorials and tips regarding the CasperJS and PhantomJS ... and in the future, perhaps a course ... If you want you can find me on facebook, twitter, github ... post there when everything is online.