In this test I'm working on, I'm using executeAsync()
to catch some events of the page being tested. I don't know the number of events that are going to happen and for each one that it's catched I want to take a screenshot with .takeScreenshot()
. Currently, I'm using this code:
return this.parent
.setExecuteAsyncTimeout(5000)
.executeAsync(function(done) {
window.events = function(event){
if(event.message == 'takeScreenshot'){
return done(event);
} else if(event.message == 'endTest'){
return done(event);
}
};
}, [])
.then(function(event){
return this.parent
.takeScreenshot()
.then(function(data) {
//previously defined array to save the screenshots
bufferArray.push(data);
})
.end();
})
This code is working but the problem is that it only takes one screenshot since it only catches the first event and then finishes the test instead of waiting for the other events. Can anyone tell me if it's possible to call the .takeScreenshot()
inside the .executeAsync()
instead of returning the callback done(event)?