16

I am in charge of testing an enterprise web application that makes heavy use of AJAX. I need to build a system that allows continuous running of tests without human intervention. Currently I am mostly interested in load testing but I want the same scripts used to generate load to be used in functional tests.

Currently for loadtesting I am using the grinder. We record scripts and then process the heck out of them to handle among other things the asynchronous requests. This system works for now; however the scripts are delicate and I can't maintain them during our development cycle. I need to be able to 'run a browser' via a programming language that abstracts over the details of html and javascript but it must be headless. In other words if my testing script breaks it must represent an actual breakage of the application. Running firefox in xvfb does not work as firefox still uses too much resources even on a headless linux machine running with xvfb. I tried driving firefox with webdriver under the headless x server.

I have been working on HTMLUnit for days since this is the ideal solution. I have been writing HTMLUnit drivers in Jython and hence I can use them with the grinder. Unfortunately I am running into javascript errors (that are not real errors in firefox/chrome/IE) and I think I am at the end of the road for this. In any case I am well aware of HtmlUnit and I really need an alternative.

I know there are some other solutions (envjs and zombie.js); however I don't know how developed these technologies are and I don't want to waste another week going down a dead end.

How hard would it be to take the source code for either Firefox or Webkit and comment out all the rendering/GUI calls and create a real headless browser? Has this been done? Would one be easier to do this with than another? Honestly I cannot fathom why this has not been done already, so I am guessing it is much harder than I am anticipating.

I am assuming that if I can get a truly headless browser with reasonable performance characteristics (I have a large server fleet to throw at this problem, but its not big enough for real firefox with GUI rendering) then I will be set.

Community
  • 1
  • 1
user573225
  • 209
  • 1
  • 2
  • 6
  • Have you considered using a commercial service like BrowserMob (http://browsermob.com/performance-testing) or Gomez (http://www.gomez.com/products-solutions/products/load-testing/). While not cheap, seems way easier than trying to hack Firefox/Webkit. – Rob Di Marco Jan 18 '11 at 02:45
  • I have really not looked into these services but I have heard of them. I am passionate about putting together an in house system preferably with open source technology. We have lots of testing servers and I really want to utilize them. Thanks for the suggestion though. – user573225 Jan 18 '11 at 03:17

4 Answers4

14

enter image description here

This has been done by the guys over at http://www.phantomjs.org/. In their own words:

PhantomJS is a headless WebKit with JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.

PhantomJS is an optimal solution for headless testing of web-based applications, site scraping, pages capture, SVG renderer, PDF converter and many other use cases.

PhantomJS is created by Ariya Hidayat

Community
  • 1
  • 1
Edward Wilde
  • 25,967
  • 8
  • 55
  • 64
1

Take a look at LoadBooster. It is a cloud-based load testing service which utilizes headless browser PhantomJS to test web sites. Disclaimer: I work for LoadBooster.

QingHai
  • 138
  • 3
1

You might be able to take advantage of some of the available JavaScript unit testing tools to assemble the sort of environment you need.

For example I've found that loading env.js in rhino gives an acceptable fake browser for testing most JavaScript. It falls short on certain DOM attributes, like elements sized relative to their window, but that hasn't been a serious problem in my experience.

See also:

Jonah
  • 17,918
  • 1
  • 43
  • 70
  • Thanks, I might try env.js with rhino next. This should allow me to integrate with the current java based loadtesting framwork as well. Any ideas on how it will compare to HtmlUnit? Any experience with zombie.js? – user573225 Jan 18 '11 at 03:26
  • From what I recall, the last time I looked at HTMLUnit it didn't have the JavaScript support I needed but that may no longer be the case. I have not tried zombie.js but it looks worth investigating, thanks for pointing that out. – Jonah Jan 18 '11 at 03:32
0

Have a look at WebKitDriver. The project includes headless implementation of WebKit.

Michael Spector
  • 36,723
  • 6
  • 60
  • 88