2017-09-22 10 views
1

이 테스트에서 나는 executeAsync()을 사용하여 테스트중인 페이지의 일부 이벤트를 잡아 냈습니다. 나는 일어날 사건의 숫자를 알지 못한다. 그리고 그것들이 붙잡 혔을 때마다 나는 .takeScreenshot()으로 스크린 샷을 찍고 싶다. 현재,이 코드를 사용하고 있습니다 :intern을 사용하여 execute 또는 executeAsync 내에서 스크린 샷을 찍는 방법

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() 대신 콜백 완료 (이벤트)를 반환 할 수 말해 줄래?

답변

0

takeScreenshot 메서드는 executeAsync에서 호출 할 수 없으므로 다른 작업을 수행해야합니다. 비동기/대기가 없으면 재귀가 아마도 가장 간단한 솔루션 일 것이므로 (테스트되지 않음)