Most up-to-date Tag Documentation

There are several tags that are listed here. For the most up-to-date listing of tags and their attributes, please use the Functional Points tab in the GUI. All tags, except the ie-session tag, are in the tags folder.

Syntax Reference of HttpUnit Plug-in Tags

Tag NameDescription
hu-action-point-generatorAction points are quite simple to write. Most of the work is in writing the set methods. This tag attempts to solve that problem by generating the Java code for custom action points.
hu-click-linkClicks on a link with a given name, id, text or url.
hu-navigateLoads the given URL
hu-get-matching-textGets the text matching the provided regular rexpression and stores it in a context variable
hu-page-validationVerifies various things (title, form attributes, text, links ... ) in the current page
hu-sessionKeeps state between functional points. All HttpUnit functional points must be nested inside this tag.
hu-submit-formSubmits a given form with supplied parameters.
hu-table-validationSame validations as hu-page-validation as well as table-specific text.
hu-test-case-generatorBased on the given form, this generates a Jameleon test case that can then be edited to generate custom action points.
A custom hu-table-validation tagDocuments a example of creating a custom validation point from the hu-table-validation tag.

hu-session

This is mostly to keep state between requests for a particlar application. However, there are a few extra features that are specific to the HttpUnit plug-in.

Attribute nameDescriptionContext Variable (CSV/Properties)Default
baseUrlThe full url, including http://, that represents the starting point of the application. This attribute is used in the beginSession() method or when beginSession is set to true in the session tag. If used without the beginAt attribute, this should be the entire URL. yesN/A
beginAtSometimes the complete URL is too long and it can make the data and or script harder to read. This attribute is meant only as a helper to the baseUrl. yesN/A
enableSslCertCheckIf set to false, then host nor the expiration date will be validated. Basically, this should let any SSL key through. This is helpful when required to test against an environment where a cert is not valid. If it is desired to turn this on and off on the fly, then it might be a good idea to define in jameleon.conf instead of in the test script itself. However, if set in jameleon.conf, then certs will not be validate for ANY tests. can be set in jameleon.conftrue
enableHttpUnitProxyIf set to true, then all requests and responses will get send through a proxy defined by httpUnitProxyHost and httpUnitProxyPort. nofalse
httpUnitProxyHostThe host or IP of the proxy server. This variable may be set via the context or as an attributes of the tag. In other words, it may be read in from a CSV file, an Applications.properties or a testEnv-Applications.properties file or it can just simply be set in the hu-session tag as an attribute. noN/A
httpUnitProxyPortThe port of the proxy server. This variable may be set via the context or as an attributes of the tag. In other words, it may be read in from a CSV file, an Applications.properties or a testEnv-Applications.properties file or it can just simply be set in the hu-session tag as an attribute. noN/A
httpUnitProxyUserThe user that has privileges to the proxy server. This is only for authenticating proxy servers. This variable may be set via the context or as an attributes of the tag. In other words, it may be read in from a CSV file, an Applications.properties or a testEnv-Applications.properties file or it can just simply be set in the hu-session tag as an attribute. noN/A
httpUnitProxyPasswordThe password of the user that has privileges to the proxy server. This is only for authenticating proxy servers. This variable may be set via the context or as an attributes of the tag. In other words, it may be read in from a CSV file, an Applications.properties or a testEnv-Applications.properties file or it can just simply be set in the hu-session tag as an attribute. noN/A
httpUnitBasicUsernameThis setting is for those applications that use basic authenication in their web applications. This is the user that has privileges to the HTTP resource being requested. This variable may be set via the context or as an attributes of the tag. In other words, it may be read in from a CSV file, an Applications.properties or a testEnv-Applications.properties file or it can just simply be set in the hu-session tag as an attribute. noN/A
httpUnitBasicPasswordThe password of the user that has privileges to the HTTP resource and matches with httpUnitBasicUsername. This variable may be set via the context or as an attributes of the tag. In other words, it may be read in from a CSV file, an Applications.properties or a testEnv-Applications.properties file or it can just simply be set in the hu-session tag as an attribute. noN/A
enableScriptingIf set to false, then JavaScript will be ignored. notrue
exceptionsThrownOnScriptErrorIf set to false, then JavaScript errors will not throw exceptions.notrue
acceptCookiesIf set to false, then cookies will not be acceptednotrue
autoRefreshIf set to true, then the meta refresh attribute will be followednofalse
acceptGzipIf set to false, then gzip streams will not be acceptednotrue
applicationCodeNameOne of the three attributes used to make a client IDnohttpunit
applicationNameOne of the three attributes used to make a client IDnoHttpUnit
applicationVersionOne of the three attributes used to make a client IDno1.5
autoRedirectIf set to false, then redirects won't be followednotrue
availableScreenWidthThe available screen widthno800
availHeightThe available screen heightno600
iframeSupportedIf set to false, then iframes will not be supportednotrue
platformThe platform that will be passed in the headernoJava
userAgentThe user agent header valuenohttpunit/1.5
cookieDomainMatchingStrictHttpUnit's default behavior is to ignore cookies that are written to a domain which different than the current domain. To disable this behavior, set option to "false"notrue

hu-test-case-generator

This functional point is used to generate another basic test case that in turn can then be edited or customized and executed to create a custom HttpUnit-specific action point (Java source code) to submit a form. This tag does not generator the actual java file, it generates another Jameleon test case. However, to make the second step a little simplier a few java specific attributes were added. Two steps were created so that those people who knew the form fields and types could skip this step and go right to the action point generator. The following attributes are:

AttributeDescriptionRequired
nameOfTestCaseThe name of the test case and therefore the name of the file to be written to.False - Defaults to genActionPoint
formNameThe name, id or index number of the form to generate the test case for.True
sourcePathThe directory where the generated Jameleon test case will go. It will always be written toFalse - NOTE either sourcePath or absolutePath must be set.
prefixAll variable names will begin with this prefix. For example is form "A" has a text input field with id "firstName", and the prefix is set to "fooBar", then the value "firstName" is to be set to will expected in a variable name "fooBarFirstName".True
functionIdSince this is required to be set by all functional points, this is required here too.True
classNameThe class name to be generated. This is for the java source file which will be generated by the action point generator.False
functionTagNameThe name of the tag to be generated. This is for the java source file which will be generated by the action point generator.False
packageNameThe name of the package of the class to be generated. This is for the java source file which will be generated by the action point generator.False
javaSourcePathThe base directory of the java files, not including the package. This is for the java source file which will be generated by the action point generator.False

This functional point is preceeded by other functional points that get the application to the point where the form for which the action point will be generated is the current page. For example:

<j:jelly xmlns:qa="jelly:jameleon" xmlns:j="jelly:core">
   
    <qa:testcase testEnvironment="test"
                    name="TestCaseGenerate"
                    useCSV="false">
        <!-- Test for invalid data and cancel functions -->
        <qa:httpunit-session application="huTestCaseGen" beginSession="true">
            <qa:hu-test-case-generator
                functionId="Generate a test case"
                formName="stopPaymentForm"
                sourcePath="tst\xml\httpunit"
                prefix="pbStopPayment"
                functionTagName="stop-payment"
                className="PbStopPayment"
                javaSourcePath="tst/_tmp/java"
                />
        </qa:httpunit-session>
    </qa:testcase>
    
</j:jelly>
                

In the above example, the <http-unit-begin-session> functional point is used to get application into the state it needs to be in ( etc/jetty/webapps/root/hu_testcase.html in the source or tutorial distribution ) for the <hu-test-case-generator> to do its magic.

Please see the next section for the file that is generated from this above test case generator example.

hu-action-point-generator

This functional point generates a source file which extends HttpUnitSubmitForm. While the HttpUnitSubmitForm may be used in a test case directly, this can make test cases brittle to changes by requiring repetitive code in all of the test cases that use that particular feature of the application. The following is the outcome of the above test case generator example:

<?xml version="1.0"?>

<j:jelly xmlns:qa="jelly:jameleon" xmlns:j="jelly:core">

    <qa:testcase testEnvironment="test" name="genActionPoint">
        <qa:httpunit-session application="huTestCaseGen">
            <qa:hu-action-point-generator functionId="genActionPoint"
                formName="stopPaymentForm"
                functionName="stop-payment"
                className="PbStopPayment"
                packageName="net.sf.jameleon.test"
                sourcePath="tst/_tmp/java">
                <qa:param>
                    <qa:param-name>test_checked</qa:param-name>
                    <qa:param-value fromVariable="pbStopPaymentTest_checked"></qa:param-value>
                    <qa:param-type>checkBox</qa:param-type>
                </qa:param>

                <qa:param>
                    <qa:param-name>payee</qa:param-name>
                    <qa:param-value fromVariable="pbStopPaymentPayee"></qa:param-value>
                    <qa:param-type>text</qa:param-type>
                </qa:param>

                <qa:param>
                    <qa:param-name>amount</qa:param-name>
                    <qa:param-value fromVariable="pbStopPaymentAmount"></qa:param-value>
                    <qa:param-type>text</qa:param-type>
                </qa:param>

                <qa:param>
                    <qa:param-name>memo</qa:param-name>
                    <qa:param-value fromVariable="pbStopPaymentMemo"></qa:param-value>
                    <qa:param-type>text</qa:param-type>
                </qa:param>

                <qa:param>
                    <qa:param-name>reason</qa:param-name>
                    <qa:param-value fromVariable="pbStopPaymentReason"></qa:param-value>
                    <qa:param-type>text</qa:param-type>
                </qa:param>

                <qa:param>
                    <qa:param-name>test_cb</qa:param-name>
                    <qa:param-value fromVariable="pbStopPaymentTest_cb"></qa:param-value>
                    <qa:param-type>checkBox</qa:param-type>
                </qa:param>

                <qa:param>
                    <qa:param-name>fromNumber</qa:param-name>
                    <qa:param-value fromVariable="pbStopPaymentFromNumber"></qa:param-value>
                    <qa:param-type>text</qa:param-type>
                </qa:param>

                <qa:param>
                    <qa:param-name>accountNumber</qa:param-name>
                    <qa:param-value fromVariable="pbStopPaymentAccountNumber"></qa:param-value>
                    <qa:param-type>optionContains</qa:param-type>
                </qa:param>

                <qa:param>
                    <qa:param-name>inputTextWithValue</qa:param-name>
                    <qa:param-value fromVariable="pbStopPaymentInputTextWithValue"></qa:param-value>
                    <qa:param-type>text</qa:param-type>
                </qa:param>

                <qa:param>
                    <qa:param-name>writtenDate</qa:param-name>
                    <qa:param-value fromVariable="pbStopPaymentWrittenDate"></qa:param-value>
                    <qa:param-type>text</qa:param-type>
                </qa:param>

            </qa:hu-action-point-generator>
        </qa:httpunit-session>
    </qa:testcase>
</j:jelly>
                        

The above test case, basically, explains the form on the page noted above. From this the following areas need to be edited or reviewed for correctness. The test case generator tries guess the param types of each of the form elements contained in the stopPaymentForm. However, it is still best to make sure the param-types are correct. The following attributes need values:

AttributeDescriptionRequired
formNameThe name, id or index number of the form to generate the test case for. This should be the same as what was already set to generate this file.True
functionNameThis is desired macro tag name. Look here learn more about the name attribute for a more in-depth description of what this is.True
classNameThe name of class file to be generated. If this is set to StopPayment, then a java file named StopPayment.java which the class named className will be generated.True
packageNameThe package of the class file to be generated. If the sourcePath is set, then the package directories will be auto-created if they don't already exist. However, if the absolutePath attribute is set, then the package directories will not be created.True
sourcePathThe base directory name of where the generated Jameleon test case will go.False - NOTE either sourcePath or absolutePath must be set.
absolutePathThe exact directory structure where the generated Jameleon test case will go.False - NOTE either sourcePath or absolutePath must be set.
functionIdSince this is required to be set by all functional points, this is required here too.True

hu-submit-form

This is the HttpUnitSubmitForm. We can use this utility directly to submit a form. The following is an example of submitting a form:

<?xml version="1.0"?>

<j:jelly xmlns:qa="jelly:jameleon" xmlns:j="jelly:core">

<qa:testcase testEnvironment="test"
              name="HU_StopPayment"
              useCSV="true">
  <qa:hu-session application="huStopPayment">

      <qa:http-unit-begin-session 
          functionId="Begin session" />        
      <qa:hu-submit-form
          functionId="HU_StopPayment"
          formName="stopPaymentForm">
          <qa:param>
              <qa:param-name>payee</qa:param-name>
              <qa:param-value
                  fromVariable="pbStopPaymentPayee"/>
              <qa:param-type>text</qa:param-type>
          </qa:param>

          <qa:param>
              <qa:param-name>amount</qa:param-name>
              <qa:param-value
                  fromVariable="pbStopPaymentAmount"/>
              <qa:param-type>text</qa:param-type>
          </qa:param>

          <qa:param>
              <qa:param-name>memo</qa:param-name>
              <qa:param-value
                  fromVariable="pbStopPaymentMemo"/>
              <qa:param-type>text</qa:param-type>
          </qa:param>

          <qa:param>
              <qa:param-name>reason</qa:param-name>
              <qa:param-value
                  fromVariable="pbStopPaymentReason"/>
              <qa:param-type>text</qa:param-type>
          </qa:param>

          <qa:param>
              <qa:param-name>test_cb</qa:param-name>
              <qa:param-value
                  fromVariable="pbStopPaymentTest_cb"/>
              <qa:param-type>checkBox</qa:param-type>
          </qa:param>

          <qa:param>
              <qa:param-name>fromNumber</qa:param-name>
              <qa:param-value
                  fromVariable="pbStopPaymentFromNumber"/>
              <qa:param-type>text</qa:param-type>
          </qa:param>

          <qa:param>
              <qa:param-name>accountNumber</qa:param-name>
              <qa:param-value
                  fromVariable="pbStopPaymentAccountNumber"/>
              <qa:param-type>optionContains</qa:param-type>
          </qa:param>

          <qa:param>
              <qa:param-name>writtenDate</qa:param-name>
              <qa:param-value
                  fromVariable="pbStopPaymentWrittenDate"/>
              <qa:param-type>text</qa:param-type>
          </qa:param>

      </qa:hu-submit-form>
  </qa:httpunit-session>
</qa:testcase>
</j:jelly>
                  

The following attributes are:

AttributeDescriptionRequired
formNameThe name, id or index number of the form to generate the test case for. This should be the same as what was already set to generate this file.True
functionIdSince this is required to be set by all functional points, this is required here too.True
onClickSet this to true to have HttpUnit call the onClick event of the button.False
submitButtonNameSubmit button name or id. If more than one button exists in the form, then this is useful. This can be used with or without the submitButtonName attribute. If neither submitButtonName nor submitButtonValue are set, the default button will be clicked.False
submitButtonValueSubmit button value attribute. This can be used with or without the submitButtonName attribute. If neither attribute is is set, the default button will be clicked.False

There are also param tags that are used here. These are basically used to set the elements of the defined form before submitting. Below are currently supported param-types for this tag:

param-typedescription
textA field that represents a free form text (input type=text or textarea).
checkBoxA checkbox. For pages that only have checkboxes with unique names, it's recommended to set the value to yes/no, true/false, or checked/unchecked. In the case where multiple checkboxes all with the same name, but different HTML value attributes, set the value to the HTML value.
fileA field that represents a file upload.
optionIndexUsed for drop-downs where you want to select the nth value from the list.
optionValueUsed for drop-downs where the value attribute is set in each option tag.
optionContainsUsed for drop-downs where the value attribute is not set or it is desired to set the value to the displayed text in the drop-down, but the entire displayed text is dynamic or has strange characters in it.
optionStartsWithUsed for drop-downs where the value attribute is not set or it is desired to set the value to the displayed text in the drop-down by the starting text.
optionStartsWithUsed for drop-downs where the value attribute is not set or it is desired to set the value to the displayed text in the drop-down by the ending text.
optionMatchesUsed for drop-downs where the value attribute is not set or it is desired to set the value to the displayed text in the drop-down by a regular expression.
optionEqualsUsed for drop-downs where the value attribute is not set or it is desired to set the value to the displayed text in the drop-down by the exact text.

hu-click-link

Clicks on a link defined by the id, name, alt text, or the text that is displayed as being the link in the browser. If it is desired to use a more exact method, then feel free to post a request and it will be added, but for now, the power method is used.

The following attributes are available:

Attribute NameContext NameDescriptionRequired
linkhtmlPageClickLinkThe link in page to be clicked. This is the text, id, name, or alt text of the <a> HTML element or the nested <img> tag if linkIsImage is set to "true".Yes
linkIsImagehtmlPageClickLinkIsImageSets the link to be clicked on as an image. This currently does not work in conjunction with the tablePosition attributes.No
tablePositionhtmlPageClickLinkTablePositionUsed for clicking on a link in a specific table, row and column. The first table is 1. This points to the table the desired link is in. It does not define the location within the table. That is where the tableRow and tableColumn attributes come in. It supports nested tables by using the following format:

table->(column,row)table->(column,row)...

For example, if the third table inside the third row of the fourth column inside the second top-level table on the page is the disired table, 2->(4,3)3 would be used.
Yes if any of the other table related attributes are used.
tableRowhtmlPageClickLinkTableRowUsed for clicking on a link in a specific table, row and column. The first row is 1. This points to the row the desired link is in.Yes if any of the other table related attributes are used.
tableColumnhtmlPageClickLinkTableColumnUsed for clicking on a link in a specific table, row and column. The first column is 1. This points to the column the desired link is in.Yes if any of the other table related attributes are used.

hu-navigate

Loads the given URL to the current page. This is useful when you need to just make a GET request without clicking on a link.

The following attributes are available:

Attribute NameContext NameDescriptionRequired
urlhttpUnitNavigateUrlThe full URL to load. In the case of a file, the url would look like file:/path/to/file.Yes

hu-get-matching-text

Gets the matching text against the currently active browser and sets the matching text in the provided context variable name.

The following attributes are available:

Attribute NameContext NameDescriptionRequired
varNamehuGetMatchinTextVarNameThe name by which a context variable will be created and the matching text will be stored to.Yes
regexhuGetMatchinTextRegexThe pattern which is to be used to extract the data from the repsonse.Yes
regexGrouphuGetMatchinTextRegexGroupThe group number (based on parenthesis) to extract the data from. For example, the following regex has two different groups: (Some text ([\\d]+)) The first group would be the entire expression (Some text 2343). The second group would be only the matching numbers (2343). Yes

hu-page-validation

This is a very basic generic page validator. The following attributes are available; none of which are required:

AttributeContext NameDescriptionMultiple Values
titlehtmlPageValidationTitleThe title of the pageNo
titleContainshtmlPageValidationTitleContainsText to be contained in the title.No
trimeWhitespacehtmlPageValidationTitleTrimWhitespaceset to "true" to trim the leading and tailing whitespace from the actual before comparing.No
imagesPresenthtmlPageValidationImageImage(s) that must be present on the page.Yes
imagesNotPresenthtmlPageValidationImageNotPresentImage(s) that should not be on the page. Yes
textPresenthtmlPageValidationTextText that must be in the responseYes
textNotPresenthtmlPageValidationTextNotPresentText that must not be in the responseYes
linksPresenthtmlPageValidationLinkThis checks for the id, name or text in the link. If the link is not found, then the test fails.Yes
linksNotPresenthtmlPageValidationLinkNotPresentThis checks that a link with a given id, name or text in the link does not existYes
validateLinkResourcehtmlPageValidationLinkValidateCheck that the urls in the list for this validation point are not broken.
formNameOrIdhtmlPageValidationFormNameOrIdIf is desired to validate form fields, the form id or name must be set. This then assumes the <param> tag will be used. <param-type> can be set to the values displayed in the table below: No

Please note that a parameter can have multiple <param-value> tags. In this case, the values are checked against the same order as the form field. Some form fields can not have multiple values. An error will displayed in these cases. Also, as of 2.0.1, if none of the above attributes are set, then an exception will be thrown.

namedescriptin<param-value>
textused for a text boxthe value of the text box
checkboxused for a checkbox.value must be either checked or unchecked
checkboxused for a checkbox.value must be either checked or unchecked
not setused for a generic parameter type. not set means that the <param-type> tag is not in the <param> tagvalue is what the parameter of with the <param-name> tag should be set to
optionValuecompares against the value attribute of the <option> HTML tag.value is what the option value attribute should be set to
optionContainscompares against the text displayed by the select drop-down in the browser.value should be contained inside in the displayed text
optionStartsWithcompares against the text displayed by the select drop-down in the browser.the displayed value should begin with the value set in this tag
optionEndsWithcompares against the text displayed by the select drop-down in the browser.the displayed value should end with the value set in this tag
optionEqualscompares against the text displayed by the select drop-down in the browser.the displayed value should equal the value set in this tag

hu-table-validation

While the <hu-page-validation> is great for basic use, usually a more precise test is required. This can be accomplished by the HtmlTableValidation. We can use this utility directly to validate text on a page. The following is the example:

<qa:testcase xmlns:qa="jelly:jameleon" >
  <qa:httpunit-session application="multi" beginSession="true">
      <qa:hu-table-validation 
        functionId="Any row in the table with a colum value 'First Name:' followed by 'Kim' in the next column">
          <qa:hu-table-param>
              <qa:hu-table-param-name>First Name:</qa:hu-table-param-name>
              <qa:hu-table-param-value>Kim</qa:hu-table-param-value>
          </qa:hu-table-param>
      </qa:hu-table-validation>

      <qa:hu-table-validation 
        functionId="1st table 2nd column 9th row and the 1st table in there.">
        <!-- Look for any column to have 2+2, followed by any column to have 4, but it must exist in the 2nd row -->
          <qa:hu-table-param tableIndex="1->(2,9)1">
              <qa:hu-table-param-name>2+2</qa:hu-table-param-name> 
              <qa:hu-table-param-value row="2">4</qa:hu-table-param-value>
          </qa:hu-table-param>
      </qa:hu-table-validation>

      <qa:hu-table-validation 
        functionId="1st table 2nd column 9th row and the 1st table in there.">
        <!-- Look for any column to have 2+2, then in the 2nd column there be 4, and they must exist in the 2nd row -->
          <qa:hu-table-param tableIndex="1->(2,9)1">
              <qa:hu-table-param-name>2+2</qa:hu-table-param-name> 
              <qa:hu-table-param-value row="2" col="2">4</qa:hu-table-param-value>
          </qa:hu-table-param>

      </qa:hu-table-validation>

      <qa:hu-table-validation 
        functionId="Find a table with the id or name set to 'test3'">
        <!-- Any column must have 2+2, followd by any column that must have 5 -->
          <qa:hu-table-param tableIdentifier="test3">
              <qa:hu-table-param-name>2+2</qa:hu-table-param-name> 
              <qa:hu-table-param-value>5</qa:hu-table-param-value>
          </qa:hu-table-param>
      </qa:hu-table-validation>

      <qa:hu-table-validation 
        functionId="Find a table with the id or name set to 'test3'">
        <!-- The 2nd column must have 5 and don't worry about whether it's capitol or not -->
          <qa:hu-table-param tableIdentifier="test3">
              <qa:hu-table-param-value col="2">FIVE</qa:hu-table-param-value>
              <qa:hu-table-param-type>textEqualsIgnoreCase</qa:hu-table-param-type>
          </qa:hu-table-param>
      </qa:hu-table-validation>

      <qa:hu-table-validation 
        functionId="Find a table with the id or name set to 'test3'">
        <!-- The 2nd column must have 5-->
          <qa:hu-table-param tableIdentifier="test3">
              <qa:hu-table-param-value row="2">5</qa:hu-table-param-value>
          </qa:hu-table-param>
      </qa:hu-table-validation>

      <qa:hu-table-validation 
        functionId="Find the 1st table in the 10th row, first column of the 1st table on the page">
        <!-- The 2nd column, 2nd row must have the value 5-->
          <qa:hu-table-param  tableIndex="1->(1,10)1">
              <qa:hu-table-param-value row="2" col="2">5</qa:hu-table-param-value>
          </qa:hu-table-param>

      </qa:hu-table-validation>

      <qa:hu-table-validation 
        functionId="Find a link with the text 'This is a link' preceeded by the previous column having 'Link Test:'">
        <!-- The 2nd column, 2nd row must have the value 5-->
          <qa:hu-table-param>
              <qa:param-name>Link test:</qa:param-name>
              <qa:hu-table-param-value>This is a link</qa:hu-table-param-value>
              <qa:hu-table-param-type>link</qa:hu-table-param-type>
          </qa:hu-table-param>

      </qa:hu-table-validation>

  </qa:httpunit-session>
</qa:testcase>

The following are <hu-table-param-value> attributes:

AttributeDescriptionRequired
tableIndexThe index of table. If there is a nestly index, it will follow by "->". Example 1->(2,9)2 (First table, then go to cell with col=2, row=9 and get second table. Note: Only either table index or table identifier can be set. False
tableIdentifierTable name or id Note: Only either table index or table identifier can be set.False
rowThe row of table that value need to be validatedFalse
colThe column of table that value need to be validatedFalse
fromVariableThe value will be get from variable. Note: Only either fromVariable or value can be set.False

The following are valid types for <hu-table-param-type>:

TypeDescription
nullThis is a default type - parameter type is text
textparameter type is text
textEqualsparameter type is text. Value should equal the given text
textEqualsIgnoreCaseparameter type is text. Case insensitive value should equal the given text
textContainsparameter type is text. Value should exist
textNotContainsparameter type is text. Value should not exist.
textStartsWithparameter type is text. Value should start with parameter value
textEndsWithparameter type is text. Value should end with parameter value
textMatchesparameter type is text. Value should match a regular-expression
linkparameter type is link.
linkWithIDparameter type is link. Link with Id
linkWithImageTextparameter type is text. Link with image text
linkWithNameparameter type is text. Link with name

A custom hu-table-validation tag

While the generic action and validatin points provided are easy to use, it is recommended to create custom action and validation points to make the test cases more immune to change of the application being tested. This allows for custom javadocs to be entered and for easier use and cleaner test cases.

The following is an example on how to extend the HtmlTableValidation class. The example below is located tst/java/net/sf/jameleon/function/HUTableValidation.java in the source distribution.

import net.sf.jameleon.plugin.httpunit.HtmlTableValidation;

/**
* Submits a form with a first and last name.
* @jameleon.function name="hu-table-test-validate" type="action"
* @jameleon.step Enter first name in first form field.
* @jameleon.step Enter last name in second form field.
* @jameleon.step Click Submit button.
* @author Christian Hargraves
*/
public class HUTableValidation extends HtmlTableValidation{

/**
* The first name to be validated
* @jameleon.attribute required="true" contextName="huFirstName"
*/
protected String firstName;
/**
* The math to be validated.
* @jameleon.attribute required="true" contextName="huMath"
*/
protected String math;
/**
* The link to be validated.
* @jameleon.attribute required="true" contextName="huLink"
*/
protected String link;

public void testBlock(){
  addParameter("First Name:", firstName);
  addParameter("2+2", math, "text", -1, -1, "1->(2,9)1", null );
  addParameter("Link test:", link,"link");
  super.testBlock();
}

}
              
<j:jelly xmlns:qa="jelly:jameleon" xmlns:j="jelly:core">
<qa:testcase testEnvironment="test" name="variableValueUnescapeXML-HU";>
  <qa:httpunit-session application="multi">
      <qa:http-unit-begin-session functionId="Begin session" />
      <qa:hu-table-test-validate 
                    functionId="Test an example of extending the hu-table-validation tag" 
                    firstName="Kim" 
                    math="4" 
                    link="This is a link">
      </qa:hu-table-test-validate>
  </qa:httpunit-session>
</qa:testcase>
</j:jelly>
              

Notice how much cleaner the test case looks now. Now when the application changes, there is no need to change all of the test cases, only the single java file.

The following <hu-table-param-value> attributes are:

AttributeDescriptionRequired
tableIndexThe index of table. If there is a nestly index, it will follow by "->". Example 1->(2,9)2 (First table, then go to cell with col=2, row=9 and get second table. Note: Only either table index or table identifier can be set. False
tableIdentifierTable name or id Note: Only either table index or table identifier can be set.False
rowThe row of table that value need to be validatedFalse
colThe column of table that value need to be validatedFalse
fromVariableThe value will be get from variable. Note: Only either fromVariable or value can be set.False

The following steps are:

  1. Create a java class that extends HtmlTableValidation
  2. Create setter methods.
  3. In the testBlock() method. Call addParameter(...) to register parameters.
  4. Call super.testBlock()
  5. Add new validation point to the test case.