Using Canoo Web Test

From the Canoo web page, download the latest WebTest release. Current one is 3.0.
Unzip the file, for example to Webtest folder.

Now configure the system path

You will find it in the following location:  Open the System Properties (WinKey + Pause), select the Advanced tab, and click to the Environment Variables button, then edit the PATH variable in the user variables.
Add the bin and the lib folders to the path.
For example:
“C:\Webtest\bin”; “C:\Webtest\lib”;

Now open the console window, go to the Webtest folder and type the following command to create a new project with some examples ready to run.
C:\Webtest> webtest -f webtest.xml wt.createProject

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.

Run the demo tests

Your newly created project contains some web tests ready to run, so that you can use them as templates. You can run them just by moving to the project directory and calling:
C:\Webtest\myWebTestProject > webtest

You should see some activity in the console window after a few seconds and a html report file should be displayed in your favorite browser.

Let’s make our test!

In our project folder open the tests folder. There are a couple of auto generated xml and groovy tests.
The important file is the allTests.xml file. This file contains the xml test files names. Delete the <ant antfile=”someTest.xml”/>  tags and write one with the desired test name. For example:
<ant antfile=”OurFirstTest.xml”/>

Delete (or move to another  folder) the groovy files from the tests folder. The groovy files which are in the tests folder are automatically run.
Now open a text editor and write your first Canoo test! 🙂
Here are the main operations for it:
The test is a simple xml file (in our case the OurFirstTest.xml  file).
After the default declarations there is the webtest tag. We can write the name of our test into the name parameter the following way: <webtest name=”This is our first test”>.
The <webtest></webtest> tags holds the concrete steps of the test.

The following tag is the <invoke/>. To this tag, with the url parameter, we can add the desired web page address. Also to all tags we can write description parameter too where we can add some description about the current step.
Here are the basic operations which we can use for the test:
<verifyTitle text=”The desired title of the page”/>
<clickLink href=”theLinkWhichYouWhantToClick.html ”/>
<clickElement xpath=”//The xpath of the desired element”/>
<setInputField xpath=”//The xpath of the desired element” value=”The text which you want to write”/>
<clickButton id=”The id of the button”/>
<verifyXpath xpath=”//The xpath of the desired element which you want to verify” />
<sleep seconds=”2”/> – sleeps the thread for the desired seconds
<retry maxcount=”3”></retry> – Retry/rerun the operations which are between the <retry> tags.

Here is a sample code:

<?xml version="1.0"?>
<!DOCTYPE project SYSTEM "../dtd/Project.dtd">

<project default="test">
<target name="test">
<webtest name="Test the Canoo website">
<invoke url="" description="Go to Canoo website"/>
<verifyTitle text="Canoo WebTest" description="Verify the tile"/>
<sleep seconds="2" description="Sleep the thread for 2 seconds"/>
<retry maxcount="3" description="Retry the following operation">
<clickLink href="manualOverview.html" description="Click to link with href"/>
<verifyTitle text="Manual Overview" />
<clickElement xpath="//*[@id='searchText']" description="click to searchbox by xpath" />
<setInputField xpath="//*[@id='searchText']" value="verifyXPath" description="Enter text to input field"/>
<clickButton id="searchButton" description="Click to button"/>
<verifyXPath xpath="//html/head/title[contains(text(),'testInfo - Google')]" description="Verify the element is appeard by xpath"/>

To run the test, write the following to the console:
C:\Webtest\myWebTestProject > webtest

This command will run the test(s) which are added to the allTests.xml file – in our case the OurFirstTest.xml  test.
The test is run in the background. In console we can see the current steps and a little process window open with the current steps.
After the test a html test report will open in our default browser with the test(s) results.
On that page we can see the errors (if have any), the time and other interesting things about the test(s).
If there is an error, we can click on it to view the error details.

My opinion is that this is a good tool for testing because it’s simple, but it’s not sophisticated enough, they need time to develop.

For more information visit the page.

Posted By István Lackó

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>