Best practices: Coding JSP pages to use the Storefront Test Automation Engine

The HCL 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 HCL 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">
    <form id="addressForm">
      <input type="text" name="logonId" id="logonId"/>

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 HCL Commerce JSP files do not contain unnecessary white space

  1. Enable the useCDataTrim JSP compiler option:
    1. Edit the workspace_dir\Stores\WebContent\WEB-INF\ibm-web-ext.xml file.
    2. Add the useCDataTrim property and set it to true as shown:
      <jsp-attribute name="useCDataTrim" value="true" />
    3. Delete the compiled JSP files in WC_installdir\wasprofile\temp\localhost\server1\WC\Stores.war
      Note: 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.
  2. Set the Web Container custom property to true.
    1. Open the administrative console.
    2. Select Servers > Application servers > server_name > Web Container Settings > Web containter > Custom Properties > New
    3. Add the following name-value pair:
      Value: true
  3. Ensure that you save your changes to the master configuration file and restart the Application Server.