2014-01-26 6 views
3

somewith 버튼을 클릭하는 것처럼 자바 스크립트 설정이 포함 된 HTML 양식이 포함 된 페이지가 있습니다. 양식이 제출됩니다. 나는 브라우저 콘솔에서이 발사하여이를 확인 :.casperjs 버튼 클릭으로 다음 페이지로 이동하지 않습니다.

document.getElementById를 ("arcotsubmit")를

은 즉시 해고됩니다 같이 URL 변경 및 양식 제출됩니다()을 클릭합니다.

지금 내가 casper.js와이를 복제하려고 :

var casper = require('casper').create({}); 


casper.start('https://cib.icicibank.com/corp/BANKAWAY?Action.CorpUser.Init1.001=Y&AppSignonBankId=ICI&AppType=corporate', function() { 
    this.echo(this.getTitle()); 
}); 

casper.then(function(){ 

    this.click("#arcotsubmit"); 

}); 

casper.then(function(){ 

    console.log(this.getCurrentUrl()) 
}); 

casper.run(); 

그것은 같은 URL에 남아와 같은 페이지를 다운로드합니다. 캐스퍼가 버튼을 클릭 한 후 나타나는 html을 다운로드하고 싶습니다. URL은 실시간이며 직접 테스트 할 수 있습니다. 내가 브라우저 콘솔

document.getElementById("arcotsubmit").click() 

에서이 명령을 사용하고 난 casperjs에서 this.click ("#의 arcotsubmit")와 함께 할 수없는 나는 이유는 리디렉션 할 수있는 경우

내 요점은 무엇입니까?

+0

동일한 문제가 발생했기 때문에 해결책을 찾았습니까? 그리고, 나는 똑바로 PhantomJS를 사용하고있다. – alphadogg

답변

0

가능한 빠른 수정. 캐스퍼의 클릭이 작동하지 않지만 브라우저의 콘솔에서 코드가 작동하는 경우 캐스퍼의 evaluate 기능을 사용해보십시오.

casper.then(function() { 
    this.evaluate(function() { 
    document.getElementById("arcotsubmit").click(); 
    }); 
}); 
+4

그 것과 똑같은. 작동하지 않습니다. – beNerd

0

가 리디렉션에 대한 대신 클릭를 제출합니다.이 입력 [유형 = 이미지]의 기본 이벤트는 은 그래서이 시도 제출

casper.test.begin('Test page.', 2, function suite(test) { 
    casper.start(
     'https://cib.icicibank.com/corp/BANKAWAY?Action.CorpUser.Init1.001=Y&AppSignonBankId=ICI&AppType=corporate', 
     function() { 
      this.echo(this.getTitle()); 
      test.assertUrlMatch(/BANKAWAY?/, 'Current location is ' + this.getCurrentUrl()); 
     } 
    ); 

    casper.then(function(){ 
     this.fill('#rt', {}, true); 
     this.wait(2000, function() { 
      test.assertUrlMatch(/BANKAWAY;/, 'New location is ' + this.getCurrentUrl()); 
     }); 
    }); 

    casper.run(function() { 
     test.done(); 
    }); 
}); 

그것은 전달됩니다. Test Result Screen Shot

관련 문제