skyzyx
8/29/2013 - 7:28 PM

Use PhantomJS, with Sahi, with Mink, with Behat, with PHP.

Use PhantomJS, with Sahi, with Mink, with Behat, with PHP.

// http://shaneauckland.co.uk/2012/11/headless-behatmink-testing-with-sahi-and-phantomjs/
if (phantom.args.length === 0) {
    console.log('Usage: sahi.js <Sahi Playback Start URL>');
    phantom.exit();
} else {
    var address = phantom.args[0];
    console.log('Loading ' + address);
    var page = new WebPage();
    page.open(address, function(status) {
        if (status === 'success') {
            var title = page.evaluate(function() {
                return document.title;
            });
            console.log('Page title is ' + title);
        } else {
            console.log('FAIL to load the address');
        }
    });
}