Is it possible to capture screenshot on test fail

Get help with testing, discuss unit testing strategies etc.


Post Reply
User avatar
Edgar
Posts: 17
Joined: Wed Jul 29, 2015 9:47 am

Is it possible to capture screenshot on test fail

Post by Edgar »

Hello,
I know that there is method to take screenshots

Code: Select all

{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?

User avatar
Edgar
Posts: 17
Joined: Wed Jul 29, 2015 9:47 am

Re: Is it possible to capture screenshot on test fail

Post by Edgar »

Moreover, is it possible to take screenshot, running tests, via phantomJS?

User avatar
mats
Core Developer
Core Developer
Posts: 16325
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden
Contact:

Re: Is it possible to capture screenshot on test fail

Post by mats »

Yes this is possible and easy. Screenshots are only supported in WebDriver.

Code: Select all

var failCounter = 0;

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

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

        })
    }
})
Tired of debugging javascript errors in web applications? Try our new error logging service RootCause, or read more on the Sencha blog

@bryntum
Facebook
API documentation

User avatar
Edgar
Posts: 17
Joined: Wed Jul 29, 2015 9:47 am

Re: Is it possible to capture screenshot on test fail

Post by Edgar »

Than you very much :)

Post Reply