Home

Advertisement

Previous Entry | Next Entry

webTest -- automated Testing made easier

  • Jan. 8th, 2009 at 9:25 PM
close up

WebTest -- automated testing made easier

The web based Software reduces the distance between the user and developer. With less or no training the users start to use the Software. Every computer user virtually use a browser every time he uses his computer and the browser becomes an integral part of every computer user.

When it comes to developing a web based software, testing the software to make sure it is bug-free is a real challenge. In the presence of tools to automate the testing process, the QA engineer life becomes easier. Even better, if the tool to automate the testing process is easy to learn and produce the quality test suites in a quick time. I'm just referring to the tool -- WebTest, primarily to automate the testing process for any web based application. With this tool, the developer can write XML based test suites to test the user interface. The fun part is to observe how quick you write tests using this tool, I bet you will be surprised!

WebTest is a automated web functional testing tool. It is a open source tool released under Apache 2 License. The project is founded in year 2001 and currently involve 4 full time committers. The tool is written in Java, built using Apache Ant build system and it is platform independent.

How to use ?

In this section, I'll take you through a quick tour on how to download, install and start using this tool.

Prerequisites


  • A platform that is able to run Java.
  • An installed JDK version 5 or higher.
  • A tool to unzip.
  • Ant version 1.7.0 or newer (optional)
WebTest's distribution contains the necessary part from ant 1.7.0 ready to run

Install and configure

You can download the tool from this web page: http://webtest.canoo.com/webtest/manual/Downloads.html . You can download the package build.zip and extract it in any directory of your choice. The directory in which you extract the package is referred to as WebTest home.

The sub-directory lib/ of your WebTest home contains all the java libraries that make up WebTest's runtime. The sub-directory bin/ of your WebTest home contains shell scripts for Unix and Windows that start WebTest from lib/.

Set your path to run WebTest with one of the provided shell scripts:

  • On Windows

Add the bin/ directory of your WebTest home to your path, by opening up the System Properties (WinKey + Pause), selecting the Advanced tab, and the Environment Variables button, then editing the PATH variable in the user variables.
For example:
"C:\Program Files\Webtest\bin";%PATH%

  • Unix-based Operating Systems

Add the bin/ directory of your WebTest home to your PATH. Assuming the WebTest home is /usr/local/webtest directory.
For example:
setenv PATH ${PATH}:/usr/local/webtest/bin in .login (tcsh)
or
export PATH=${PATH}:/usr/local/webtest/bin in .bashrc (bash).

Create a new WebTest project

WebTest contains a utility script able to create a new project with some examples ready to run. Open a new shell and type:

C:\> webtest -f path\to\webtest\home\webtest.xml wt.createProject

(For unix/linux users, the command name is webtest.sh instead of webtest)

You will be asked for the name of the new project to create. If you just hit [enter] the default name myWebTestProject will be used;
C:\> webtest -f WebTest\webtest.xml wt.createProject
Buildfile: WebTest\webtest.xml
wt.init:
wt.createProject:
[input] Enter your WebTest project name: [myWebTestProject]

[echo]
[echo] Your WebTest project >myWebTestProject< has been successfully created with some demo
[echo] tests to get started.
[echo] You can now just go to >c:\myWebTestProject< and run ant.
[echo]

BUILD SUCCESSFUL
Total time: 7 seconds

Run the demo tests

Your newly created project contains some web tests ready to run that you can use as templates. You can run them just by moving to the project directory and calling:

C:\myWebTestProject> webtest
(if you're behind a proxy, edit the build.xml file to configure the proxy connection)
You should see some activity in the shell window and after a few seconds something like:

....
wt.openResultFile:
[echo] Opening result file C:\myWebTestProject\results\webtestResults.html with cmd
wt.full:

BUILD SUCCESSFUL
Total time: 16 seconds

and an html report file like this one should be displayed in your favorite browser:

NOTE: The demo test suite deployed while you created the project includes 6 tests, out of which 2 tests are expected to fail. The sample report you see below denotes the list of tests failed. In such case, you would not see a BUILD SUCCESSFUL message as indicated above.

WebTest Report
graphics2

graphics9







Why WebTest?

Selenium is another best tool for writing automated test suites for web applications. What makes Webtest so special over Selenium? I'm not going to cover every aspect of differences in detail, but the following table would give an overview of merits and demerits of both these tools. Depending on your application and your exposure, you may find it easier to rate them. The green color against the tool signifies it scores higher than the other tool and it does not mean the support for the feature does not exist in the other tool.

Feature

WebTest

Selenium

Browser Fidelity

graphics35

graphics1

Reports

graphics3

graphics67

Speed

graphics4

graphics66

Integration in Development process

graphics5

graphics65

Scalability

graphics6

graphics64

Capture JS Errors

graphics7

graphics63

Testing AJAX

graphics8

graphics24

Beginner Friendly

graphics42

graphics25

Documentation

graphics10

graphics60

Predictable Behavior

graphics11

graphics59

Xpath support

graphics12

graphics58

Support for badly formed HTML code

graphics46

graphics29

Extensibility

graphics14

graphics56

Data driven tests

graphics15

graphics55

Multi Language Support

graphics49

graphics32

Internationalization support

graphics17

graphics53

Support for Non-HTML content

graphics18

graphics52

Courtesy: http://mguillem.wordpress.com/2007/10/29/webtest-vs-selenium-webtest-wins-13-5/

About the Author

By: Bhuvaneswaran A. The author is currently employed at CollabNet in Engineering group working on customizing CollabNet's flagship products, CollabNet Sourceforge Edition and CollabNet Enterprise Edition. During his spare time, he contributes to Ubuntu Linux and Subversion open source projects.