casper.start('http://google.fr/', function() { this.fill('form[action="/search"]', { q: 'casperjs' }, true); }); casper.then(function() { links = this.evaluate(getLinks); this.fill('form[action="/search"]', { q: 'phantomjs' }, true); }); casper.then(function() { links = links.concat(this.evaluate(getLinks)); });
kflow.knysa_open('http://google.fr/'); kflow.knysa_fill('form[action="/search"]', { q: 'casperjs' }); links = kflow.evaluate(getLinks); kflow.knysa_fill('form[action="/search"]', { q: 'phantomjs' }); links = links.concat(kflow.evaluate(getLinks));
Typical PhantomJS test frameworks suffer from callback hell and other tricks that reduce the clarity of how the program flows. Bo Zou created knysa which uses async-await style programming to eliminate these callbacks. Additionally, there's no need to resort to currying and common try-catch-fail constructs are used to maintain a sane path through the code.