I am beginner in CasperJs, i wrote the following code:
'use strict';
var casper = require('casper').create();
var username = "XXXXXXXX";
var password = "XXXXXXXX";
casper.start('https://instagram.com/accounts/login/', function() {
this.echo(this.getTitle());
console.log('Starting location is ' + this.getCurrentUrl());
});
casper.then(function() {
/*this.fill('form[data-reactid=".0.0.1.0.1"]', {
username: username,
password: password
}, true); i tried this*/
/*this.fill('form[data-reactid=".0.0.1.0.1"]', {
'input[id="lfFieldInputUsername"]': username,
'input[id="lfFieldInputPassword"]': password
}, true); i tried this too*/
//i am trying this too because the page have only one form element
this.fill('form', {
username: username,
password: password
}, true);
});
casper.then(function() {
console.log('Authentication ok, new location is ' + this.getCurrentUrl());
});
casper.run(function() {
this.echo('end');
});
I found that it couldn't able to find the form element in the page loaded by CasperJs. In the Instagram form login, it does not have name/id/class/action of the form. while it works with twitter login when i used following snippet
this.fillSelectors('form.signin', {
'input[name="session[username_or_email]"]': email,
'input[name="session[password]"]': auth
}, true);
And when i use this.fillSelectors then it shows the following error:
TypeError: 'undefined' is not a function (evaluating 'this.fillSelectors') for this context.
When i use this.fill then it shows following error:
CasperError: Errors encountered while filling form: form not found
Any suggestions would be appreciated.