Skip to content

Instantly share code, notes, and snippets.

@charandas
Created August 26, 2014 19:28
Show Gist options
  • Select an option

  • Save charandas/9033998660c9e27fa83f to your computer and use it in GitHub Desktop.

Select an option

Save charandas/9033998660c9e27fa83f to your computer and use it in GitHub Desktop.
fetchText returning the casper object through mocha-casperjs
if (typeof chai === 'undefined') {
console.log('This example requires chai to be installed adjacent to mocha-casperjs')
casper.exit(-1)
}
describe('Google searching', function() {
before(function() {
casper.start('http://www.google.fr/')
})
it('should retrieve 10 or more results', function() {
casper.then(function() {
casper.getTitle().should.contain('Google')
casper.exists('form[action="/search"]').should.be.true
this.fill('form[action="/search"]', {
q: 'casperjs'
}, true)
})
casper.waitForUrl(/q=casperjs/, function() {
this.echo(this.fetchText('#addlang > a'))
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment