Login to Jotform with Casperjs/Jquery

  • tfn
    Asked on May 13, 2014 at 12:20 PM

    I am having an impossible time just trying to simply login to the website to pull submissions with a script that i made. I have tried using casperjs fill(), sendKeys(), as well as jquery to set val of the selector and then perform a simple login button click. But no matter what i try which all work for logging into different websites it wont let me login to jotform. Is something blocking script logins? Here is my sample code.

     

    var casper = require('casper').create({

    pageSettings: {

            webSecurityEnabled: false

        }

    });

    var x = require('casper').selectXPath;

    var base_url = 'http://www.jotform.com/myforms/';

    var login_url = 'http://www.jotform.com/login'

    var delay = 2000;

    casper.userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11");

     

    casper.start(login_url);

    casper.then(function() { 

    this.sendKeys('#username', 'example');

    this.sendKeys('#password', 'password');

    casper.capture('jotformlogin.png');

    });

    casper.thenClick(x('//*[@id="loginButton"]'), function() {

    this.wait(delay, function() {});

    casper.capture('jotformlogin1.png');

    });

    casper.thenOpen('http://www.jotform.com/submissions/41147560839964', function() {

    this.wait(delay, function() {});

    casper.capture('jotmyforms.png');

    });

     

    casper.thenOpen(base_url + 'logout.php', function() {

        this.log("logging out", 'debug');

    });

     

    casper.run(function() {

        casper.exit();

    });

  • TitusN
    Replied on May 13, 2014 at 2:53 PM

    Yes - you might be experiencing our security safegurards - 

    Please review our api documentation on how you can implement authentication.

    Let us know if that helps.

  • TitusN
    Replied on May 13, 2014 at 2:56 PM

    Hello,

    I have also notified our developers so that they can offer further advice.

    Thanks

  • Aytekin JotForm Founder
    Replied on May 14, 2014 at 7:55 AM

    You should really be using our API for this:

    http://api.jotform.com/docs/#form-id-submissions

     

    If you need to do it on JavaScript we have a JavaScript library to make things easier here:

    http://developers.jotform.com/libraries#jotform-api-javascript