• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Automating Web GUI Testing

 
Ranch Hand
Posts: 430
Android VI Editor Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Is there a way to automate the testing of a web based GUI interface? I've looked into opensource tools like httpunit, htmlunit, jwebunit but none of these actually test the web interface. I would like to somehow record/playback the actions of a user on the webpage and replay those actions to run the tests.

Can anyone share some light on this?

Thanks
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Selenium is a very powerful open source tool for this kind of thing.
 
O. Ziggy
Ranch Hand
Posts: 430
Android VI Editor Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
Selenium is a very powerful open source tool for this kind of thing.



Thanks i tried selenium but it didnt seem to work for me due to redirections and https. Is there any other option?

I am also thinking of coding it myself but im not sure how/where to start. Is it better done in javascript or can some other technique be done? can some one please give me some pointer in this?

cheers..
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since, as far as a web application is concerned, all GUI actions just result in requests, servlet testing can be separated from GUI testing.
Here is what I would do:
1. Write a filter to capture all details of requests and responses in some sort of general format. Be sure to capture all headers in a usable form. Choose a format for recording requests that will be easy to hand edit to create new scripts.
2. Have multiple users try the application as it is now, recording as above.
3. Write code to use HttpClient or one of the other client emulators to execute "scripts" based on your recorded sessions and your new scripts.

Bill
 
O. Ziggy
Ranch Hand
Posts: 430
Android VI Editor Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply. A couple of questions

Since, as far as a web application is concerned, all GUI actions just result in requests, servlet testing can be separated from GUI testing.



Yes this is ok because we do have separate unit tests which tests each servlet. The user interface is not involved at unit test level of the servlets.

My problem is i want to test the actual web pages. Forms, textboxes, listboxes text on the screen and so forth. The tools i mentioned earlier emulate the browser so my testing will not really be valid as i need the data to be sent by the browser that the user will use.

Tools like httpUnit, jwebunit dont actually use the forms but they send the requests to the servlets.


1. Write a filter to capture all details of requests and responses in some sort of general format. Be sure to capture all headers in a usable form. Choose a format for recording requests that will be easy to hand edit to create new scripts.
2. Have multiple users try the application as it is now, recording as above.
3. Write code to use HttpClient or one of the other client emulators to execute "scripts" based on your recorded sessions and your new scripts.



Im new to Java so ill need a slightly expanded explanation

- What exactly is a filter and how does it capture requests and responses?
- When you say recording do you mean recording the user's actions or the requests?
- Please explain point 3.

Thanks in advance
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. In the javax.servlet package we find the Filter interface. You can define a custom class implementing this interface and link it into a web application so that it sees all requests before they go to the application and all responses before they are sent to the client. This is typically done by "wrapping" the request and response objects created by the servlet container with extensions of HttpServletRequestWrapper and HttpServletResponseWrapper.

Your custom Filter can capture and record selected material from the request (as caused by the user's actions) and response (which creates the environment for the next action).
You should be able to find plenty of Filter examples by Googling. Hopefully one will be close to what you need.

With HttpClient or similar toolkit you can "Play" the recorded actions and/or actions you create by modifying an existing recorded input.
HttpClient essentially replicates the browser environment under your control as far as creating requests is concerned.

Warning, this will be non-trivial programming so approach carefully.

Bill
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thanks i tried selenium but it didnt seem to work for me due to redirections and https.


It definitely does work with HTTPS; haven't tried it with redirects, but can't really see why it wouldn't support something as simple as that. It's a complex tool, though, so there is a definite learning curve.
 
Fire me boy! Cool, soothing, shameless self promotion:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic