Ajax Testing: Doubling Down with Selenium and JMeter

This idea comes from my colleague John McCaffrey, but since he's having a bad case of blogger's block, I get to post about it.

For anyone who has developed tests for web applications with a tool like Selenium (or Watir), you know it is a sysiphean task, rolling the boulder of automated tests up the hill of a constantly changing application. The DOM changes, the text changes, the url's and parameter's change, iframes and onload events don't always play nice with your test recorder. Depending on the framework you are using, id's may change in unpredictable ways, forcing you to hack together brittle xpath expressions. Still, functional testing is important, so you persevere, spending countless hours in making those tests run clean.

If you are doing performance tests on top of that (and you are doing
performance tests in every sprint, aren't you?), then you have a second
set of brittle tests to support. Ugh.

Why not save some time and leverage your functional tests to create performance tests? Enter JMeter. JMeter, like many tools of its type, has the ability to record HTTP requests through a proxy.
So, record your tests in Selenium, get them working to your
satisfaction, then point your browser at the JMeter proxy and record
away.

You'll want to put some assertions in your script in
JMeter, and you will need to do some work if your app has
authentication and you want your script to log in under a different
user name per thread, but at least you don't have to duplicate the
effort of keeping the base interactions up to date.

This
increase in efficiency is especially important if you want to pipeline
requirements, development and testing, as you'll only have 2 weeks
(presuming 2 week iterations) to whip your tests into shape.

It is also possible to generate Selenium and JMeter rests programmatically. More on that later.

Technorati Tags: , , , , ,

Related Services: Ajax Rich Internet Applications, Custom Software Development

Related posts:

  1. Can your Selenium do that? Testing flash/flex and silverlight in web apps with iMacros
  2. Coming in GWT 1.5: Selenium testing support
  3. Again – AJAX and Screen Scraping
  4. Agile Development for Product Managers: Why Agile Testing Rocks
  5. Improving Test Coverage of Ajax Applications

Comments: 4 so far

  1. Selenium is good for ajax based apps. is Jmeter capable of handling AJAX?

    Comment by smith, Thursday, September 11, 2008 @ 6:42 am

  2. @smith

    Absolutely. JMeter just looks at the HTTP requests recorded against it and replays them. Since an Ajax app makes HTTP requests just like a regular Web app, they are the same from JMeter’s point of view.

    There can be some gotcha’s, such as Comet, but if unless your Ajax app is really unusual, you should be good to go.

    Comment by Dietrich Kappe, Friday, September 12, 2008 @ 11:27 pm

  3. JMeter can call Ajax that you e.g. record using the proxy and a browser, but it does not run Javascript code itself. So there are some browser side-effects of calls that can be “lost” when running the test afterwards.

    Comment by Tor I., Tuesday, November 3, 2009 @ 4:19 am

  4. That’s Cool!!! I was wondering if this is possible or not. I will try that out now.

    Comment by Kevin, Thursday, February 4, 2010 @ 8:54 pm

Leave a comment

Powered by WP Hashcash

Launch: Pathfinder Newsletter

    Get a monthly update on best practices for delivering successful software.

    Subscribe via email


    Subscribe via RSS      RSS icon

Topics

Search

WordPress

Comments about this site: info@pathf.com