0

我想填写表格并提交。

检查我的脚本的一部分:

casper.then(function(){
    if(this.exists('#msisdn')){
        this.echo('ok found');
        **this.test.assertExists('form[id="internetPlus"]', 'form is found');
        this.fill('form[id="internetPlus"]', {
            'numero': 'xxxxxxxx'  
        },true);**
        this.click('#button');

我得到了这个错误:

**PASS form is found**
[info] [remote] attempting to fetch form element from selector:   
'form[id="internetPlus"]'
**[error] [remote] TypeError: 'undefined' is not an object (evaluating   
'field.getAttribute')
FAIL CasperError: Unable to fill form
#    type: uncaughtError
#    error: "CasperError: Unable to fill form"
CasperError: Unable to fill form                                               
  /home/soufyan/workspace/casperjs:524 in fill
  /home/soufyan/workspace/casperjs/kkostoreHomeTest.js:45
  /home/soufyan/workspace/casperjs:909 in runStep
  /home/soufyan/workspace/casperjs:252 in checkStep**

我不明白为什么我无法填写表格,因为断言结果是好的。

4

1 回答 1

0

The form probably does not contain any inputs or fields with the name 'numero'. Make sure there is an input with that name.

I tried to reproduce your problem by simply adding a junk variable to the object literal that is passed to fill method. I got the exact same error.

于 2012-07-14T01:30:54.943 回答