0

I use simple uptime monitors like statuscake, uptimerobot, etc. to verify that my sites are up. The problem is that some of the sites are ASP.NET applications with complex __doPostback interactions -- basically, the user fills out a form, clicks submit, and then ASP.NET-generated javascript takes them to the next page.

My idea was to write a CasperJS (basically an easier API for PhantomJS) script to simulate this user interaction and test to make sure it works.

I have the test running in CasperJS and now I'd like to expose the test as its own REST API so I can have my uptime monitor hit it every few minutes. The REST API would return 200 if the test is successful; some error code if not.

I would normally throw restify or express around the logic, but you need to run CasperJS via casperjs file.js instead of via node, which means I can't run restify within it. I've looked at PhantomJS, Nightmare, and Zombie. If you know for sure those would work for this let me know; otherwise I had issues with their API that lead me back to CasperJS.

This feels a bit like exposing a test suite as an API if that gives any ideas.

Any suggestions?

Tobias Fünke
  • 2,034
  • 3
  • 24
  • 38

1 Answers1

1

PhantomJS has a built-in server, you may use with CasperJS like shown in this answer: CasperJS passing data back to PHP

Community
  • 1
  • 1
Vaviloff
  • 16,282
  • 6
  • 48
  • 56
  • Thanks @Vaviloff, that seems to work but the comment below it suggests there is a memory leak, and I think I see why. `casper.run()` will `.exit()` by default afterwards (which kills the server). If you override its functionality by passing a callback function, you're supposed to call `.exit()` yourself, which the example does not. Because of this, casper stays running but the memory accumulates. – Tobias Fünke Nov 23 '15 at 12:12