How to capture screenshot when a particular assertion failed in CasperJS?

Is it possible to take a screenshot if a specific one failed assert

? I see in the docs and forums that it is possible to make a global process when a test catches a failure like this:

casper.test.on("fail", function (failure) {
  // Do something, "casper.capture" for example
});

      

But I want a specific process for everyone assert

. I mean:

test.assertTitle(...) // if it fails, do this
test.assertMatch(...) // if it fails, do that
...

      

Is it possible? How can i do this?

+3


source to share


1 answer


After searching google / forum / code I find it =)



try{
  test.assertxxx(...)
} catch (e) {
  casper.fail("It a fail!");
}

      

+4


source







All Articles