2014-07-15 3 views
2

가 나는 clickMore 함수를 호출 한 :SpookyJS에서 함수를 호출하는 방법은 무엇입니까?

function clickMore(max, i){ 
    i = i || 0; 
    if ((max == null || i < max) && this.visible(moreButton)) { // synchronous 
     // asynchronous steps... 
     this.thenClick(moreButton); // sometimes the click is not properly dispatched 
     this.echo('click'); 
     this.waitUntilVisible(loadingButton); 
     this.waitUntilVisible(moreButton, null, function onTimeout(){ 
     // only placeholder so that the script doesn't "die" here if the end is reached 
     }); 
     this.then(function(){ 

     //this.capture("business_"+i+".png"); //captures a screenshot of the page 
     clickMore.call(this, max, i+1); // recursion 
     }); 
    } 
} 

내가 짜증 여기에서 해당 함수를 호출하고 싶습니다 :

spooky.then(function(){ 
       clickMore.call(spooky); 
      }) 

나는 무시 무시한 문서를 검토 한 결과, 그리고 알고 난 아마거야 함수 튜플을 사용해야하지만 구현 방법을 모르는 경우. 어떻게이 일을 할 수 있습니까?

UPDATE : 행운으로 SpookyJS 문서에서 함수 튜플을 사용하여 시도

: 캐스퍼/PhantomJS 자바 스크립트 환경에서 실행됩니다 spooky.then에 전달

spooky.then([{ 
    clickMore: clickMore 
}, function(){ 
    clickMore.call(spooky); 
}]); 

답변

1

기능. 그들은 Spooky의 Node.js JS 환경에 액세스 할 수 없습니다.

spooky.then([{ 
    clickMore: clickMore 
}, function(){ 
    clickMore.call(spooky); // <- spooky is not defined here 
}]); 

소개 위키 페이지에 대한 JavaScript Environmentsthe fact that they are isolated 말씀을 다시 한번를 바랍니다.

+0

실제로 질문에 답변하지 않았습니다. –

+0

물론 그랬습니다. 제공된 코드는 작동하지 않습니다. 이유를 설명하고 관련 문서를 지적했습니다. – lawnsea

+0

글쎄, 질문에 업데이 트에 따르면, 제공된 코드가 작동하지 않았다. 오류가 무엇인지 지적하고 싶지만이 문제에 대한 해결책은 아닙니다. 이것은 오히려 문제의 근본 원인을 보여줍니다. –

관련 문제