20040106 Tuesday January 06, 2004

HowTo: Get an input field's value with Canoo's WebTest I should start this by saying that I love Canoo's WebTest. It allows you to test clicking through your webapp as if you're using a browser. You simply write your tests in an XML file (which is really an Ant build file), and then run it with Ant. Usually, in my webapps, I write simple tests for CRUD on entities - i.e. EditUser (tests pulling up the edit screen), SavePosition (edit and save, verifies next screen's title), SearchUsers (verifies list screen's title).

One of the issues I had this morning was testing a wizard with WebTest. This was because I didn't know how to get the id of the new record after it was added. Now I found a way. Let's say you have a Create a Job wizard. On the first screen, you enter the job, and on the second, you add the required skills, on the third, you view a summary. To get the new id of the job, you can use XPath to get the hidden field named "jobId" - to do with what you may (i.e. click on a link to the third screen). Here's how: {{{ }}} This is especially helpful because I tend to use a lot of onclick handler's (with location.href's) on buttons (so I don't have to submit to the same action). I also turn off JavaScript for my tests - by not including js.jar in WebTest's classpath. I can't say enough about this tool - the ability to test your app, with JavaScript turned off, and verify that everything works... that's just cool. Especially when you're a JavaScript junkie like me. Posted in Java at Jan 06 2004, 05:25:15 PM MST 5 Comments

Comments:

Have you tried maxq http://maxq.tigris.org ? How does it compare to Webtest? I love that maxq support HTTP test recording, scripting, and playback, which makes testing so much easier.

Posted by Unknown on January 06, 2004 at 08:38 PM MST #

MaxQ looks nice, but it doesn't look like it would be possible to automate it. I like WebTest because it's just an Ant task and I can run it right next to my JUnit and Cactus tests. For further automation, I use Anthill to schedule my tests.

There are many testing tools like MaxQ that can record mouse clicks, etc. but I'll leave that up to the QA department (now I just have to find one of those ;-).

Posted by Matt Raible on January 06, 2004 at 11:31 PM MST #

"it doesn't look like it would be possible to automate it" It supports playback, which can be integrated in the build.

Posted by Unknown on January 07, 2004 at 12:25 AM MST #

I like that tool very much but AFAIK Canoo Web Test is not Javascript ready. We have forms with more then one Submit button. If a button is pressed, the form's action attribute is exchanged by a little javascript and then the form is submitted by that script. With Canoo Web Test you cannot test such web pages :-(

Posted by Jochen on January 07, 2004 at 04:06 AM MST #

WebTest JavaScript support has improved remarkably in the interim

Posted by Paul King on May 24, 2005 at 06:54 PM MDT #

Post a Comment:
  • HTML Syntax: Allowed
Click me to subscribe
Matt Raible is a Web Architecture Consultant specializing in open source frameworks.
« May 2012
SunMonTueWedThuFriSat
  
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
23
24
25
26
27
28
29
30
31
  
       
Today

Recent Entries

Tag Cloud