在我正在进行的这个测试中,我executeAsync()用来捕捉正在测试的页面的一些事件。我不知道将要发生的事件的数量,对于捕获的每一个事件,我都想用.takeScreenshot(). 目前,我正在使用以下代码:
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();
})
此代码正在运行,但问题是它只截取一个屏幕截图,因为它只捕获第一个事件,然后完成测试,而不是等待其他事件。谁能告诉我是否可以调用.takeScreenshot()内部.executeAsync()而不是返回回调完成(事件)?