Casper Automation Script Stopped Working, Can't Login, Can't Submit Form

432 views
Skip to first unread message

Timothy Michael

unread,
Oct 17, 2014, 8:47:04 AM10/17/14
to casp...@googlegroups.com
I've had a stable process working for the last month to check the status of my orders every day on samsclub.com. It stopped working on the 15th around noon.

The problem is the <Sign In> button can't be clicked after filling in the form. I've tried filling the form, using sendkeys, and about every other way imaginable to populate my email address and password, but then the button seems to be disabled and I can't click it or otherwise submit the form.

The interesting thing is, that if I don't fill out the form, the button clicks normally, and the form highlights the missing required fields. I can fill out one or the other (email or password) and attempt to submit, but when I fill out both, I doesn't submit.

Please take a look at the script and give me some feedback about how to get it working again. When you run the script, if you can actually submit the completed form, the page should indicate that your email address is not recognized.

var casper = require("casper").create ({
   logLevel: "error",
   userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5)",
   pageSettings: {
      loadImages:  false,        // do not load images
      loadPlugins: false         // do not load NPAPI plugins (Flash, Silverlight, ...)
   }
});

casper.start();
collectTracking();
casper.run();

function collectTracking(){
   casper.then(function() {
      logIn();
   });
}

//LogIn
var email           = 'm...@email.com';
var password        = 'password';
var urlBasePage     = 'http://www.samsclub.com';
var Css3loginLink   = 'div.loggedOff';
var Css3loginForm   = 'form[name="loginForm"]';
var Css3loginButton = 'button[class*="ValidateLogin"]';
var Css3loginID     = '#txtLoginEmailID';
var Css3loginPwd    = '#txtLoginPwd';

function logIn() {
   console.log("Beginning Login Function");
   casper.thenOpen(urlBasePage , function then() {
      if(this.exists(Css3loginLink)) {
         this.thenClick(Css3loginLink);
         this.then(function() {
            this.waitForSelector(Css3loginButton, function then() {
               this.then(function() {
                  this.wait(5000, function() {
                     this.capture("./CasperError/1LoginFormReady.png");
                  });
               });
               this.then(function() {
                  this.fill(Css3loginForm, {
                     '/atg/userprofiling/ProfileFormHandler.value.login': email,
                     '/atg/userprofiling/ProfileFormHandler.value.password': password
                  });
               });
               this.then(function() {
                  this.capture("./CasperError/2LoginFormCompleted.png");
               });
               this.then(function() {
                  this.thenClick(Css3loginButton);
               });
               this.then(function() {
                  this.wait(5000, function() {
                     if(this.exists(Css3loginButton)) {
                        console.log('Login Form Failed');
                        this.capture("./CasperError/3LoginFormFailed.png");
                     }
                  });
               });
            });
         });
      }
      this.then(function() {
         this.exit;
      });
   });
}



Hasan Naqvi

unread,
Oct 17, 2014, 10:00:21 AM10/17/14
to casp...@googlegroups.com
Hi!

I am also having the same issue. I never had this issue from past couple of months but it started with me yesturday. No clue how to resolve the issue.

Nicolas Perriault

unread,
Oct 17, 2014, 10:04:36 AM10/17/14
to casp...@googlegroups.com
On 17 Oct 2014, at 16:00, Hasan Naqvi <has...@gmail.com> wrote:

> I am also having the same issue. I never had this issue from past couple of months but it started with me yesturday. No clue how to resolve the issue.

Lots of servers have deprecated their support for SSL v3 lately, because of POODLE. You should pass this option to casperjs: --ssl-protocol=tlsv1

++

--
Nicolas Perriault

Timothy Michael Babb

unread,
Oct 17, 2014, 10:40:50 AM10/17/14
to casp...@googlegroups.com
That did it!

Many thanks.


--
CasperJS homepage & documentation: http://casperjs.org/
CasperJS @github: https://github.com/n1k0/casperjs

You received this message because you are subscribed to the Google Groups "casperjs" group.
Visit this group at http://groups.google.com/group/casperjs?hl=en.
---
You received this message because you are subscribed to a topic in the Google Groups "CasperJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/casperjs/aFb_7rZvZY8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to casperjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jonatan Polak

unread,
Oct 17, 2014, 10:59:26 AM10/17/14
to casp...@googlegroups.com
You can use a universal version too:

--ssl-protocol=any

Regards,
Jonatha

Tim Scott

unread,
Oct 17, 2014, 3:59:47 PM10/17/14
to casp...@googlegroups.com
I'm having the same problem with some different sites. I have tried ssl-protocol=tlsv1 and ssl-protocol=any, but it's not working. My app is running on Heroku, and here is the exact command (with some redactions):

vendor/casperjs/bin/casperjs /app/lib/services/redacted/website/js/redacted/redacted.coffee /app/lib/services/redacted/website/js/ --login_url="https://signin.redacted.com/redacted/redacted" --redacted="https://www.redacted.com/redacted/redacted/members/redacted.aspx" --redacted="508" --start="2014-10-19T20:20:00" --username="redacted" --password="redacted" --log_level=debug --user_agent="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36" --ignore-ssl-errors=true --ssl-protocol=tlsv1

I guess that casperjs passes ssl-protocol and ignore-ssl-errors on to phantomjs without me doing anything else, but I would live to prove that. Is there any way to see the exact command line calls to phantomjs?

My app is falling apart because of this. I've got that sick-to-my-stomache feeling of helplessness.  Any suggestions are much appreciated.

I am using casperjs version 1.0.2.

Tim Scott

unread,
Oct 17, 2014, 6:41:41 PM10/17/14
to casp...@googlegroups.com
I guess my problem is here:

It turns out that v1.0 does not support setting ssl-protocol.

So the obvious answer is to upgrade, right?  But I’m stuck there. When I change my executable to 1.1-beta3, I get this error:

Error: Cannot find module 'casper'
  phantomjs://bootstrap.js:289
  phantomjs://bootstrap.js:254 in require

I made a detailed post about it here earlier today:

I am very grateful of any suggestions to troubleshoot this.

-- 
Tim Scott

Tim Scott

unread,
Oct 19, 2014, 8:38:49 AM10/19/14
to casp...@googlegroups.com
I solved my problem by forking 1.0.2 and patching it, here:

It's deployed in production and working.

I'm still stuck upgrading to 1.1, but relieved for now that the bleeding has stopped.

Regards,
Tim Scott

Hasan Naqvi

unread,
Oct 20, 2014, 4:11:00 AM10/20/14
to casp...@googlegroups.com
Thanks --ssl-protocol=any solved my issue.


On Friday, 17 October 2014 14:47:04 UTC+2, Timothy Michael wrote:
Reply all
Reply to author
Forward
0 new messages