我已经使用下面链接中的代码登录..它在 facebook 上运行良好.. 如何使用 CasperJS 登录网站?
但它给我的网站的登录页面错误。用户名字段的名称是 LoginForm[username],密码字段的名称是 LoginForm[password]。
我的代码。
casper.start(url, function() {
// search for 'casperjs' from google form
console.log("page loaded");
this.test.assertExists('form#login-form', 'form is found');
this.fill('form#login-form', {
LoginForm[username]: 'ascd@csc.com',
LoginForm[password]: '******'
}, true);
});
输出
[info] [remote] attempting to fetch form element from selector: 'form#login-form'
remote message caught: attempting to fetch form element from selector: 'form#login-form'
[error] [remote] TypeError: 'undefined' is not an object (evaluating 'field.getAttribute')
remote message caught: TypeError: 'undefined' is not an object (evaluating 'field.getAttribute')
Page Error: 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
//// HTML