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.
Tag Name | Description |
---|---|
hu-action-point-generator | Action 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-link | Clicks on a link with a given name, id, text or url. |
hu-navigate | Loads the given URL |
hu-get-matching-text | Gets the text matching the provided regular rexpression and stores it in a context variable |
hu-page-validation | Verifies various things (title, form attributes, text, links ... ) in the current page |
hu-session | Keeps state between functional points. All HttpUnit functional points must be nested inside this tag. |
hu-submit-form | Submits a given form with supplied parameters. |
hu-table-validation | Same validations as hu-page-validation as well as table-specific text. |
hu-test-case-generator | Based 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 tag | Documents a example of creating a custom validation point from the hu-table-validation tag. |
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 name | Description | Context Variable (CSV/Properties) | Default |
---|---|---|---|
baseUrl | The 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. | yes | N/A |
beginAt | Sometimes 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. | yes | N/A |
enableSslCertCheck | If 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.conf | true |
enableHttpUnitProxy | If set to true, then all requests and responses will get send through a proxy defined by httpUnitProxyHost and httpUnitProxyPort. | no | false |
httpUnitProxyHost | The 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. | no | N/A |
httpUnitProxyPort | The 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. | no | N/A |
httpUnitProxyUser | 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. | no | N/A |
httpUnitProxyPassword | The 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. | no | N/A |
httpUnitBasicUsername | This 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. | no | N/A |
httpUnitBasicPassword | The 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. | no | N/A |
enableScripting | If set to false, then JavaScript will be ignored. | no | true |
exceptionsThrownOnScriptError | If set to false, then JavaScript errors will not throw exceptions. | no | true |
acceptCookies | If set to false, then cookies will not be accepted | no | true |
autoRefresh | If set to true, then the meta refresh attribute will be followed | no | false |
acceptGzip | If set to false, then gzip streams will not be accepted | no | true |
applicationCodeName | One of the three attributes used to make a client ID | no | httpunit |
applicationName | One of the three attributes used to make a client ID | no | HttpUnit |
applicationVersion | One of the three attributes used to make a client ID | no | 1.5 |
autoRedirect | If set to false, then redirects won't be followed | no | true |
availableScreenWidth | The available screen width | no | 800 |
availHeight | The available screen height | no | 600 |
iframeSupported | If set to false, then iframes will not be supported | no | true |
platform | The platform that will be passed in the header | no | Java |
userAgent | The user agent header value | no | httpunit/1.5 |
cookieDomainMatchingStrict | HttpUnit'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" | no | true |
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:
Attribute | Description | Required |
---|---|---|
nameOfTestCase | The name of the test case and therefore the name of the file to be written to. | False - Defaults to genActionPoint |
formName | The name, id or index number of the form to generate the test case for. | True |
sourcePath | The directory where the generated Jameleon test case will go. It will always be written to | False - NOTE either sourcePath or absolutePath must be set. |
prefix | All 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 |
functionId | Since this is required to be set by all functional points, this is required here too. | True |
className | The class name to be generated. This is for the java source file which will be generated by the action point generator. | False |
functionTagName | The name of the tag to be generated. This is for the java source file which will be generated by the action point generator. | False |
packageName | The 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 |
javaSourcePath | The 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.
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:
Attribute | Description | Required |
---|---|---|
formName | The 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 |
functionName | This is desired macro tag name. Look here learn more about the name attribute for a more in-depth description of what this is. | True |
className | The 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 |
packageName | The 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 |
sourcePath | The base directory name of where the generated Jameleon test case will go. | False - NOTE either sourcePath or absolutePath must be set. |
absolutePath | The exact directory structure where the generated Jameleon test case will go. | False - NOTE either sourcePath or absolutePath must be set. |
functionId | Since this is required to be set by all functional points, this is required here too. | True |
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:
Attribute | Description | Required |
---|---|---|
formName | The 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 |
functionId | Since this is required to be set by all functional points, this is required here too. | True |
onClick | Set this to true to have HttpUnit call the onClick event of the button. | False |
submitButtonName | Submit 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 |
submitButtonValue | Submit 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-type | description |
---|---|
text | A field that represents a free form text (input type=text or textarea). |
checkBox | A 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. |
file | A field that represents a file upload. |
optionIndex | Used for drop-downs where you want to select the nth value from the list. |
optionValue | Used for drop-downs where the value attribute is set in each option tag. |
optionContains | Used 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. |
optionStartsWith | Used 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. |
optionStartsWith | Used 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. |
optionMatches | Used 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. |
optionEquals | Used 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. |
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 Name | Context Name | Description | Required |
---|---|---|---|
link | htmlPageClickLink | The 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 |
linkIsImage | htmlPageClickLinkIsImage | Sets the link to be clicked on as an image. This currently does not work in conjunction with the tablePosition attributes. | No |
tablePosition | htmlPageClickLinkTablePosition | Used 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. |
tableRow | htmlPageClickLinkTableRow | Used 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. |
tableColumn | htmlPageClickLinkTableColumn | Used 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. |
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 Name | Context Name | Description | Required |
---|---|---|---|
url | httpUnitNavigateUrl | The full URL to load. In the case of a file, the url would look like file:/path/to/file. | Yes |
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 Name | Context Name | Description | Required |
---|---|---|---|
varName | huGetMatchinTextVarName | The name by which a context variable will be created and the matching text will be stored to. | Yes |
regex | huGetMatchinTextRegex | The pattern which is to be used to extract the data from the repsonse. | Yes |
regexGroup | huGetMatchinTextRegexGroup | The 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 |
This is a very basic generic page validator. The following attributes are available; none of which are required:
Attribute | Context Name | Description | Multiple Values |
---|---|---|---|
title | htmlPageValidationTitle | The title of the page | No |
titleContains | htmlPageValidationTitleContains | Text to be contained in the title. | No |
trimeWhitespace | htmlPageValidationTitleTrimWhitespace | set to "true" to trim the leading and tailing whitespace from the actual before comparing. | No |
imagesPresent | htmlPageValidationImage | Image(s) that must be present on the page. | Yes |
imagesNotPresent | htmlPageValidationImageNotPresent | Image(s) that should not be on the page. | Yes |
textPresent | htmlPageValidationText | Text that must be in the response | Yes |
textNotPresent | htmlPageValidationTextNotPresent | Text that must not be in the response | Yes |
linksPresent | htmlPageValidationLink | This checks for the id, name or text in the link. If the link is not found, then the test fails. | Yes |
linksNotPresent | htmlPageValidationLinkNotPresent | This checks that a link with a given id, name or text in the link does not exist | Yes |
validateLinkResource | htmlPageValidationLinkValidate | Check that the urls in the list for this validation point are not broken. | |
formNameOrId | htmlPageValidationFormNameOrId | If 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.
name | descriptin | <param-value> |
---|---|---|
text | used for a text box | the value of the text box |
checkbox | used for a checkbox. | value must be either checked or unchecked |
checkbox | used for a checkbox. | value must be either checked or unchecked |
not set | used for a generic parameter type. not set means that the <param-type> tag is not in the <param> tag | value is what the parameter of with the <param-name> tag should be set to |
optionValue | compares against the value attribute of the <option> HTML tag. | value is what the option value attribute should be set to |
optionContains | compares against the text displayed by the select drop-down in the browser. | value should be contained inside in the displayed text |
optionStartsWith | compares against the text displayed by the select drop-down in the browser. | the displayed value should begin with the value set in this tag |
optionEndsWith | compares against the text displayed by the select drop-down in the browser. | the displayed value should end with the value set in this tag |
optionEquals | compares against the text displayed by the select drop-down in the browser. | the displayed value should equal the value set in this tag |
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:
Attribute | Description | Required |
---|---|---|
tableIndex | The 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 |
tableIdentifier | Table name or id Note: Only either table index or table identifier can be set. | False |
row | The row of table that value need to be validated | False |
col | The column of table that value need to be validated | False |
fromVariable | The 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>:
Type | Description |
---|---|
null | This is a default type - parameter type is text |
text | parameter type is text |
textEquals | parameter type is text. Value should equal the given text |
textEqualsIgnoreCase | parameter type is text. Case insensitive value should equal the given text |
textContains | parameter type is text. Value should exist |
textNotContains | parameter type is text. Value should not exist. |
textStartsWith | parameter type is text. Value should start with parameter value |
textEndsWith | parameter type is text. Value should end with parameter value |
textMatches | parameter type is text. Value should match a regular-expression |
link | parameter type is link. |
linkWithID | parameter type is link. Link with Id |
linkWithImageText | parameter type is text. Link with image text |
linkWithName | parameter type is text. Link with name |
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:
Attribute | Description | Required |
---|---|---|
tableIndex | The 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 |
tableIdentifier | Table name or id Note: Only either table index or table identifier can be set. | False |
row | The row of table that value need to be validated | False |
col | The column of table that value need to be validated | False |
fromVariable | The value will be get from variable. Note: Only either fromVariable or value can be set. | False |
The following steps are: