Page 1 of 1

Is it possible to capture screenshot on test fail

Posted: Fri Jul 31, 2015 11:05 am
by Edgar
Hello,
I know that there is method to take screenshots
{screenshot:'myScreen.png'}
Is it possible to subscribe to some event, that on any test event the screenshot will be captured.
Or maybe siesta has some tool to do that?

Re: Is it possible to capture screenshot on test fail

Posted: Fri Jul 31, 2015 3:23 pm
by Edgar
Moreover, is it possible to take screenshot, running tests, via phantomJS?

Re: Is it possible to capture screenshot on test fail

Posted: Fri Jul 31, 2015 4:12 pm
by mats
Yes this is possible and easy. Screenshots are only supported in WebDriver.
var failCounter = 0;

Harness.on('testupdate', function(ev, test) {
    if (test.getFailCount() > failCounter) {
        failCounter = test.getFailCount();

        test.screenshot(test.url, function() {

        })
    }
})

Re: Is it possible to capture screenshot on test fail

Posted: Sat Aug 01, 2015 10:41 pm
by Edgar
Than you very much :)