views:

93

answers:

3

I want to test a Ajax based web application. I want to write the test scripts in Java and simulate the web browser.

Simulation of a web browser is very important since Iam using very advanced Ajax library like jQuery in the web Application.

Any ideas on how I should proceed?

+4  A: 

I think you might want to give Selenium a look.

Kindness,

Dan

Daniel Elliott
+4  A: 

Doing "simulation" of a browser will probably not work that well if your application relies on Javascript a lot : there are some crawlers that you can use to test your application, but they don't like JS that much.

The best solution in your case might be to use a real browser to do your testing.

The Selenium tool-suite is quite nice for that : it allows your testing programm to pilot a browser (a real one : firefox, internet explorer, ...) ; which mean having you JS code executed exactly the same way that it would be with a "real" user.

For instance, you can have your testing programm tell a browser to open a page, click on a link, check some content in the page, ... And if there was some JS event plugged onto the link, it will have been executed : there will have been a real "click" on the link.


Using a tool like selenium has some drawbacks, though ; some of them are :

  • you need a machine with a graphic environnement, to launch the browsers (command line is not enough)
  • tests with selenium take time : browsing and using the application means loading all the CSS/JS/Images/ads/whatever, for each page ; like in a real browser -- because you are using a real browser

But these tests are quite nice, and usefull to test the application as a whole -- ie, more "functionnal tests" than "unit-test".

Pascal MARTIN
Selenium is an excellent tool, thanks a lot for your help!
Sumit Ghosh