我已经使用了下面链接中的代码进行登录..它可以与Facebook一起正常使用..如何使用CasperJS登录到网站?
但它给我的网站登录页面错误。用户名字段的名称为LoginForm [用户名],密码字段的名称为LoginForm [密码]。
我的代码。
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]: '[email protected]',
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
this.fill('form#login-form', {
'LoginForm[username]': '[email protected]',
'LoginForm[password]': '******'
}, true);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句