I'm evaluating phantom.js and zombie.js. I expected the trade-off to be that phantom has wider documents support (since it uses a real renderer) while zombie is faster (since no rendering engine is used). However zombie seems much slower in the test I did. Does this make sense?
I am thinking maybe zombie waits for the full page to load before visit() returns (including running all scripts and loadsing css) while phantom returns immediatelly after start() (I used casperjs) allowing me to continue without waiting for the full page.
Phantom.js
casper.userAgent("Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.98 Safari/534.13");
casper.test.begin('bing search', 2, function(test) {
casper.start('http://www.bing.com/', function() {
this.waitUntilVisible('#sb_form_q', function() {
this.sendKeys('#sb_form_q', "book", true);
this.click('#sb_form_go');
this.waitUntilVisible('#count', function() {
var val = this.evaluate(function() {
return document.getElementById('count').innerText
});
console.log(val)
});
});
}).run(function() {
test.done();
});
});
Zombie.js
var Browser = require("zombie");
var browser = new Browser()
browser.userAgent = "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.98 Safari/534.13"
browser.visit("http://www.bing.com/", function() {
browser.fill("#sb_form_q", "book");
browser.pressButton("#sb_form_go");
function resultArrived(window) {
return window.document.querySelector("#count")
}
browser.wait(resultArrived, function() {
console.log(browser.document.querySelector("#count").innerHTML)
});
});