2013-07-31 5 views
1

저는 CasperJS를 사용하여 채우기 위해 양식을 가지고 있습니다. 코드 자체에 문제가없는 것 같습니다 (오류가 반환되지 않음). 그러나 양식이 채워 졌는지 '확인'할 수없는 것 같습니다.CasperJS & jQuery로 양식을 작성했는지 확인 할 수 없습니다.

'first_name'을 덤프 할 때 공백으로 표시됩니다. 'Joe'문자열로 채워지도록 설정 했더라도 - 내가 뭘 잘못하고 있는지 아이디어가 있습니까?

casper.start(url); 
casper.then(function() { 
    this.fill('form[name="phones_display"]', { 
     'first_name'   : 'Joe', // Required 
     'last_name'    : 'bloggs', // Required 
     'check_payable'   : '', // name to cheque if different from your name 
     'payment_method'  : 'check', // Required check, paypal 
     'shipping_method'  : '', // envelope, fedex 
     'email_address'   : '[email protected]', // Required 
     'paypal_email_address' : '', 
     'telephone_number'  : '12345678', // Required 
     'street_address_1'  : '', // Required 
     'street_address_2'  : '', 
     'city'     : '', // Required 
     'state'     : '', 
     'zip_code'    : '', // Required 
     'hear'     : '', 
     'otherreason'   : '' 
    }, true); 
}); 

casper.then(function() { 
    var first_name = this.evaluate(function() { 
     return $('input[name="first_name"]').val(); 
    }); 

    require('utils').dump(first_name); 
}); 
casper.run(); 

답변

3

양식을 채운 후에 발생하기 때문에 발생합니다. 그래서 '첫 번째 이름'입력을 얻으려고하면 양식이 정리되었습니다. 이것을 피하려면 casper.fill() 메서드의 세 번째 매개 변수를 false로 변경하십시오.

fill(String selector, Object values[, Boolean submit]) 

예 :

this.fill('form[name="phones_display"]', { 
    'first_name'   : 'Joe', // Required 
    'last_name'    : 'bloggs', // Required 
    .... 
}, false); 
+0

감사 :-(일을하려고하지 않습니다 그래서 양식 태그를 엉망으로하고있다 ... 그것을 알아 냈다 shot :) – Zabs

+0

어떤 이유로 든 작동하지 않는 것 같습니다. jsfiddle의 전체 js 코드입니다. http://jsfiddle.net/SD3VR/ – Zabs

0

페이지 내 코드는 결코 나는 것을주지