1 message in com.canoo.lists.webtest[Webtest] Setting checkbox values and...| From | Sent On | Attachments |
|---|---|---|
| Josh Passenger | 07 Oct 2004 22:39 |
| Subject: | [Webtest] Setting checkbox values and <unknown> appears as stepId for groups in report after a failure![]() |
|---|---|
| From: | Josh Passenger (jos...@dstc.edu.au) |
| Date: | 10/07/2004 10:39:28 PM |
| List: | com.canoo.lists.webtest |
Hi,
A bit of a brain dump follows.
I have written a custom report stylesheet for processing webtest result files and have noticed that group nodes receive a stepId of '<unknown>' after a previous failure.
Is this expected behaviour?
I have seen previous postings where in the report viewer, these are ignored and the stepId of the first child is displayed.
I have taken this route as well but thought it might be worth reporting it.
Additionally, I have patched my local webtest with httpunit-1.5.5-d-16Jun.jar and rolled a new version of the form/SetCheckbox.java step that allows an individual checkbox to be selected or deselected using the 'value', 'name' AND the 'checked' attributes when multiple check boxes exist in a page with the same name.
The change is from:
/** * Set / reset the particular checkbox. * @param _context The current test context * @throws StepExecutionException if the checkbox name is not provided */ public void doExecute(final Context _context) throws Exception {
verifyParameters();
final WebForm form = _context.getFormForField("input", "checkbox", getName()); if (form == null) throw new StepFailedException("No form found with checkbox named \"" + getName() + "\"", this);
if (getValue() == null) form.setCheckbox(getName(), isChecked()); else form.setParameter(getName(), new String[] {getValue()}); }
to:
// my set check box /** * Set / reset the particular checkbox. * @param _context The current test context * @throws StepExecutionException if the checkbox name is not provided */ public void doExecute(final Context _context) throws Exception {
verifyParameters();
final WebForm form = _context.getFormForField("input", "checkbox", getName()); if (form == null) throw new StepFailedException("No form found with checkbox named \"" + getName() + "\"", this);
if (getValue() == null) { form.setCheckbox(getName(), isChecked()); } else { form.setCheckbox(getName(), getValue(), isChecked()); } }
The current implementation does not preserve the multiple values for checkboxes with the same name so attempting to check all of them individually results in just the last check box being selected. I have not noticed any issues using this newer version of httpunit but note that 1.6 has just come out with changes that are likelt to break webtest.
I am happy to share my new stylesheet, it provides a one page view of test results using hideable table rows and is very similar to the junit report format with some enhancements.
Lastly, we needed a way to detect failures and call ant <fail message="WebTest failed" unless="some.property"/>
JUnit and HttpUnit allow for a failure property to be set but I could not see how to achieve this in WebTest.
The solution taken was to roll an additional stylesheet that processes the result.xml file into an intermediary XML file suitable for loading with ant <xmlproperty/>
The result of a set of tests is evaluated into a temporary status file, loaded with <xmlproperty/> and the relevant properties investigated using ant <fail/>
The stylesheet is simple and I have inlined it below:
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xalan="http://xml.apache.org/xalan" exclude-result-prefixes="xalan"> <xsl:output method="xml" indent="yes" xalan:indent-amount="2"/> <xsl:strip-space elements="*"/> <xsl:template match="/"> <webtest> <xsl:choose> <xsl:when test="count(/summary/testresult[@successful = 'no']) = 0"> <success>true</success> </xsl:when> <xsl:otherwise> <failure>true</failure> </xsl:otherwise> </xsl:choose> </webtest> </xsl:template> </xsl:stylesheet>
A sample xml result file might look like:
<?xml version="1.0" encoding="UTF-8"?> <webtest> <failure>true</failure> </webtest>
Yielding a property of webtest.failure=true after loading using ant <xmlproperty/>
I hope this helps and would appreciate some feedback on the unknown stepId for failed groups.
Thanks for such a complete product,
Josh




