Created
December 7, 2012 18:20
-
-
Save m-allanson/4235225 to your computer and use it in GitHub Desktop.
Broken noise-box casperJS script
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(); | |
var casper2 = require('casper').create(); | |
var roomName = 'caspersroom'; | |
var audiofile = ''; | |
casper.start('http://localhost:7001/', function() { | |
this.test.assertTitle('NoiseBox', 'NoiseBox title is ok'); | |
this.test.assertExists('form[action="/host/"]', 'The form to create a new host exists'); | |
this.fill('form[action="/host/"]', { | |
id: roomName | |
}, true); | |
}); | |
casper.then(function() { | |
this.test.assertUrlMatch('/host/caspersroom', 'Form submitted to new host url'); | |
this.test.assertTextExists('Hosting "'+roomName+'"', 'New host identifies itself as existing'); | |
}); | |
casper.then(function(){ | |
casper2.start('http://localhost:7001/caspersroom', function() { | |
this.test.assertUrlMatch(':7001/caspersroom', 'The client room exists'); | |
this.test.assertTextExists('Viewing "'+roomName+'"', 'The client room identifies itself'); | |
this.test.assertExists('a[href$=".mp3"]', 'An anchor element links to an mp3'); | |
}); | |
casper2.thenClick('a[href$=".mp3"]', function() { | |
this.test.assertUrlMatch(':7001/caspersroom', 'Clicking the anchor does not change the page'); | |
}); | |
casper2.run(function() { | |
this.test.done(4); // checks that all assertions have been executed | |
this.test.renderResults(true); | |
}); | |
}); | |
casper.then(function() { | |
var self = this; | |
casper.waitForSelector('audio[src$=".mp3"]', function() { | |
self.test.assertExists('audio[src$=".mp3"]', 'The host has an audio element pointing to an mp3'); | |
}); | |
}); | |
casper.run(function() { | |
this.test.done(5); // checks that all assertions have been executed | |
this.test.renderResults(true); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment