Best practices: Coding JSP pages to use the Storefront Test Automation Engine
The WebSphere Commerce test automation framework is designed to help you effectively and
efficiently test your store before deployment. To fully leverage the test automation
framework, it is recommended that you edit your JavaServer Pages (JSP) to include the
following best practices.
Define HTML element IDs
- Define a unique ID attribute for every HTML element in the web page.
The WebSphere Commerce test automation framework uses HTML element IDs to perform actions such as clicking links, entering data, or selecting objects. As well, information is verified on a page by identifying the HTML elements and their unique ID. Therefore, it is important that the HTML of the store pages have unique IDs for all HTML elements. At the very least, provide proper IDs for all the elements that are important for the test scenarios.
For example:
<div id="headerNav" class="header">
</div>
<form id="addressForm">
<input type="text" name="logonId" id="logonId"/>
</form>
Maintain tags
To ensure that tags are maintained, insert the following code in every JSP file you create:<!-- BEGIN BreadCrumbTrailDisplay.jsp-->
... ...
<!-- END BreadCrumbTrailDisplay.jsp -->
Ensure that the generated HTML pages from your WebSphere Commerce JSP files do not contain unnecessary white space
- Enable the
useCDataTrim
JSP compiler option:- Edit the workspace_dir\Stores\WebContent\WEB-INF\ibm-web-ext.xml file.
- Add the
useCDataTrim
property and set it to true as shown:<jsp-attribute name="useCDataTrim" value="true" />
- Delete the compiled JSP files in
WC_installdir\wasprofile\temp\localhost\server1\WC\Stores.warNote: Since
useCDataTrim
is a JSP compiler option, you need to remove all compiled JSP files for the change to take effect. In addition, when using DCS servlet caching you might need to clear the contents of the cache. You can confirm which JSP compiler options were used by examining the compiled JSP java source in the WebSphere temp directory.
- Set the Web Container custom property to true.
- Open the administrative console.
- Select
- Add the following name-value
pair:
Name: com.ibm.ws.jsp.getWriterOnEmptyBuffer Value: true
- Ensure that you save your changes to the master configuration file and restart the Application Server.