javascript - Cannot submit form with CasperJS - in other words cannot login -
i'm trying login tumblr casperjs using methods start
, fill
, waitforurl
cannot this. it seems me form wasn't submitted, because timeout in waitforur
expired everytime.
terminal response:
code i'm using this:
/*jslint browser: true, regexp: true */ // global casper, require var login_url, login_username, login_password, casper; casper = require('casper').create({ waittimeout: 20000, viewportsize: { width: 1024, height: 768 }, verbose: true, loglevel: 'debug', useragent: 'mozilla/4.0 (compatible; msie 6.0; windows nt 5.1)' }); if (!casper.cli.has('username') && !casper.cli.has('password')) { casper.echo('usage: $ casperjs sfdclogin.casper.js --username=username --password=password').exit(-1); } login_url = 'https://tumblr.com/login'; login_username = casper.cli.get('username'); login_password = casper.cli.get('password'); phantom.cookiesenabled = true; casper .start(login_url, function () { // 'use strict'; this.log('logging in', 'debug'); /* this.fillselectors('#signup_form_form', { '#signup_email': login_username, '#signup_password': login_password }, true); */ this.fill('#signup_form_form', { '#user[email]': login_username, '#user[password]': login_password }, true); }) .waitforurl('http://tumblr.com/dashboard', function () { // 'use strict'; this.echo('we\'re logged in.'); }) .run();
also, i'm using correct username , password script.
try using following instead of current casper.fill()
. because casperjs' fill()
searches name attribute of elements.
this.fill('#signup_form', { 'user[email]': login_username, 'user[password]': login_password }, true);
you use if want continue using ids selectors.
this.fillselectors('#signup_form', { '#signup_email': login_username, '#signup_password': login_password }, true);
Comments
Post a Comment