The following is an example of filling out a form, clicking a button and validating the results:
<j:testcase xmlns:j="jelly:jameleon"> <j:test-case-summary> An example test that fills out variable form fields and clicks on the apppriate button to submit the form </j:test-case-summary> <j:test-case-author>Christian Hargraves</j:test-case-author> <j:test-case-level>ACCEPTANCE</j:test-case-level> <j:functional-point-tested>sample form</j:functional-point-tested> <j:application-tested>htmlunit-plugin</j:application-tested> <j:htmlunit-session baseUrl="http://jameleon.sourceforge.net/htmlunit-plugin/forms/sampleForm.html" beginSession="true"> <j:htmlunit-validate functionId="Validate that the page was successfully loaded" title="" xpath="//form[@name='sample']"/> <j:htmlunit-set-text-field functionId="Enter first name using XPath to locate the text field" xpath="//form[1]//input[@name='fname']" value="Mark"/> <j:htmlunit-set-text-field functionId="Enter last name using XPath to locate the text field" xpath="//form[1]//input[@name='lname']" value="Smith"/> <j:htmlunit-set-radio-button functionId="Select gender, using the form, fieldName, value and checked attributes" form="sample" fieldName="gender" value="male" checked="true" /> <j:htmlunit-set-password-field functionId="Enter the password using the form (XPath this time), fieldName and value attributes" form="//form[1]" fieldName="password" value="some password" /> <j:htmlunit-click functionId="Click the purple submit button" xpath="//form[@name='sample']/tr/td[1]/input[@type='button' and @value='Go']"/> <j:htmlunit-validate functionId="Validate that the 'Go Back' button shows up" xpath="//input[@type='button' and @value='Go Back']"/> <j:htmlunit-validate functionId="Validate that the password shows up" xpath="//tr/td[text()='Password:']/following-sibling::td[text()='some password']"/> </j:htmlunit-session> </j:testcase>