Storefront Test Automation Engine

Using Storefront Test Automation Engine of WCS v7 FEP6

The Storefront Test Automation Engine (STAE) facilitates the process of writing, maintaining, and running test scripts to test the store functionally

Below are the components of STAE

Test Suite

Test Suites are built based on JUnit and are used to select the test case that must be run.

Test

A Test performs a few tasks from different page objects to test a storefront flow. Since all tests are built using JUnit version 4, all methods must match the following criteria to be identified as a test:

· Be annotated with @test annotation

· Be public

· Have no arguments

Methods that are annotated with @Before are called before each test case. They are used to prepare the data that is required by the test.

Methods that are annotated with @After are called after each test case. They are used to release resources after a test is complete or complete a cleanup.

Store Page Objects

Store page objects are Java classes that act as a high-level abstraction of the web page. They include relevant tasks and the element identifiers found on the web page that is used by the tasks. Example: AuroraFrontPage class is a SPO

Web test engine

This layer offers functionality to the tests to interact with a web browser. We have option to use HTMLUnit or test via browsers like Firefox, IE and chrome using the Selenium server

Setting up and running tests

Installing the Storefront Test Automation Assets

We need to download the WC_V7.0_-_FEP6STSTORECOMPASSETSMPEN.zip file from IBM Partnerworld site. Once downloaded, extract the zip to a temp folder.

Step 1: Open IBM Installation Manager

Step 2: Add the downloaded test asset store repository using File->Repositories link and click Install. You will be provided with the below page.Select the Companion Asset for FEP 6 and click NEXT

Step 3: Accept the License Agreement and click Next

Step 4: Provide path and click next

Step 5: Select all options and click Next

Step 6: Click Install

Step 7: Verify if the installation is a success and click Finish

Step 8: After installation, go to the installation directory and unzip all zip files available there

Setting up the Storefront Test Automation Engine

Pre-requisites

We need to download the below items to setup the STAE

JUnit

Latest JUnit version can be downloaded from http://sourceforge.net/projects/junit/files/junit/

Selenium Server

Latest version can be downloaded from http://docs.seleniumhq.org/download/

HttpClient, HttpCore and HttpMime

Latest version can be downloaded from http://hc.apache.org/downloads.cgi and http://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime

Some test scripts require setup steps that access WebSphere Commerce Accelerator or IBM Management Center for WebSphere Commerce. To do so, the Storefront Test Automation Engine makes HTTP calls to the WebSphere Commerce back-end tooling using HttpClient.

Google Guice

Latest version can be downloaded from http://code.google.com/p/google-guice/downloads/list

To use Chrome as a test browser, we must install separate ChromeDrive for use with Selenium. Get the latest from http://code.google.com/p/selenium/wiki/ChromeDriver

After downloading all the above required files, extract them to their respective temp folder. We need the JARs to setup the test project later

Setting up STAE:

- In RAD select File > Import.

- In the Import window, select General > Existing Projects into Workspace; then click Next.

- Select archive file option and then click Browse.

- Browse to the location where we installed Storefront assets and then select the zip file StorefrontTestAssetsWteFEP6.zip for Web testing or select MobileTestAssetsFEP6.zip for Mobile testing.

- Select the all projects shown and then click Finish.

Example: Wte, WCHTTPClient, WCWebTestEngine, and Aurora-Tests-Wte, Mobile-Wte

The Storefront Test Automation Engine projects are now in RAD. Since the library dependencies are not installed yet, the Problems view displays multiple compilation errors. We will resolve these errors in the next step.

Install the dependencies of the STAE

a. In both the WCHTTPClient, Aurora-Tests-Wte, WCWebTestEngine and Wte projects, create the lib directory at the root of the project.

b. Copy all of the JAR files related to HttpClient, HttpCore, HttpMime to the lib directory of the WCHTTPClient project.

c. Add the above JAR files to the project build path.

d. Browse to the directory on the file system that contains the extracted JUnit files. Copy thejunit-(version_number).jar file to the lib directory of the Wte project.

e. Copy the following files to the lib directory of the Wte project:

selenium-server-(version_number).jar

f. Browse to the directory on the file system that contains the extracted Google Guice files. Copy the following files to the lib directory of the Wte project:

Guice-(version_number).jar.

g. Add the JARS to project build path

h. In the Aurora-Tests-Wte project, browse to src\com\ibm\commerce, delete the url directory, and then refresh the project in RAD.

i. Right-click the Aurora-Tests-Wte project and click Build Path > Configure Build Path. In the Projects directory remove any projects that are marked as missing.

j. In the WCWebTestEngine lib folder add guice-(verison_number).jar and guice-assitedinject-(verison)number).jar.

k. Add the same to the project build path

Running Tests

In the config.properties file present in Aurora-Tests-Wte project, change the following properties to reflect our environment:

# The host name of their server you are testing.
HOSTNAME=localhost
# The path part of the URL of the store to open (exluding the host).
STOREURL=/webapp/wcs/stores/servlet/en/aurora
# The browser type.
# Possible values: FIREFOX, INTERNET_EXPLORER
BROWSER_TYPE=FIREFOX
#Path to where screenshots are stored for failed test cases
SCREENSHOTPATH=c:/screenshots/
#Site administrator userid and password
ADMIN_USER_NAME=wcsadmin
ADMIN_PASSWORD=wcsadm1n
#URL of the esite store
ESITE_URL=/webapp/wcs/stores/servlet/StoreView?storeId=11001

Use one of the following scenarios to run your tests:

Below is the screen shot of AllTests.java Junit Run. Firefox browsers will be automatically opened and closed during the course of the test. We should not interrupt the browser during the test. The tests will take long time to complete

Future Work:

We can use Selemiun Grid which is part of Selenium 2 to run tests on multiple machines using multiple browsers to speed up the test case execution time or is we want to test multiple browsers simultaneously.

More info at:

http://docs.seleniumhq.org/docs/07_selenium_grid.jsp