Example Google Script

The following is an example script that searches for Jameleon on the sourceforge site, clicks on the link with the provided text and validates the arrival at the new page.

<jm:testcase xmlns:jm="jelly:jameleon">
  <jm:test-case-summary>Tests searching on the sourceforege site</jm:test-case-summary>
  <jm:test-case-author>Christian Hargraves</jm:test-case-author>
  <jm:functional-point-tested>HttpUnit Example</jm:functional-point-tested>
  <jm:httpunit-session baseUrl="http://sourceforge.net" enableScripting="false" beginSession="true">

        functionId="Verify that we are on the sourceforge home page"
        title="SourceForge.net: Welcome to SourceForge.net"
        textPresent="Open Source Technology Group"/>
    <jm:http-unit-submit-form functionId="Form submit" formName="searchform">
        functionId="Check that we actually did a search for 'Jameleon' and that we found 'Jameleon'"
        title="SourceForge.net: Software Search"
        functionId="Click on the 'Jameleon' link"
        functionId="Validate that we arrived at the Jameleon SourceForge Page."
        title="SourceForge.net: Jameleon"
        functionId="Navigate to the Jameleon site by clicking on the 'Home Page' link"
        link="Home Page"/>
        functionId="Verify that we arrived at the Jameleon Site."
        title="Jameleon - An Automated Testing Tool - Overview"/>


Script Explained

We will start at the hu-session tag since the other tags are covered in the getting started section of the main Jameleon site.

hu-session The hu-session tag is the first HttpUnit specific tag. This tag is used to start the session of the web application. In the above example, we are telling the hu-session tag to go to http://sourceforge.net and start the session there. The beginSession attribute is what starts the session in the place defined by baseUrl.
hu-page-validation This tag can be used to validate many things at once. In our case, we are validating that the session was opened correctly at the expected SourceForge home page, by checking the title and that some text appears on the page. Please start the GUI and see the tags under net, sf, jameleon, plugin, httpunit for a complete list of supported attributes of this tag.
hu-submit-form This tag is used to submit forms. In our case, we want to enter jameleon in the text box and click on the "Search" button. This tag is more thoroughly documented in the syntax reference page. Basically, from the HTML source of the SourceForge home page, we found a form with the name searchform and since there is only one button in the form, we don't need to define the button's name/value. The name of the text field is words. It's important to note that this tag not only fills out the form, but also submits it.
hu-page-validation This is the same tag as used previously. Here we are validating that the results page is displayed. Due to the dynamic nature of the results page, all I did was check the title and that the link we are going to click on next is present.
hu-click-link This tag is used to click on links with the provided text. This tag can also accept the exact table position of the link to click on. Please use the GUI tool to look up the possible attributes.
hu-page-validation Again we use this tag to check that we arrived at the Jameleon home page.