在casperjs文档中的示例代码中,提交表单是通过以下方式:
var loginFormSelector = 'form[name="loginForm"]';
casper.waitForSelector(loginFormSelector,
function() {
this.echo("Login page loaded. Entering in username and password");
this.fillSelectors(loginFormSelector, {
'input#username': username,
'input#password': password'
}, true);
},
function() {
this.die("Login form not found");
});
我的错误日志
Login page loaded. Entering in username and password
[info] [remote] attempting to fetch form element from selector: 'form[name="loginForm"]'
[debug] [remote] Set "username" field value to usrname
[debug] [remote] Set "password" field value to ***********
[info] [remote] submitting form to unknown, HTTP POST
[info] [phantom] Step anonymous 4/5: done in 14362ms.