Documente Academic
Documente Profesional
Documente Cultură
Development Guide
EMC Corporation
Corporate Headquarters:
Hopkinton, MA 01748‑9103
1‑508‑435‑1000
www.EMC.com
Copyright © 2007 – 2008 EMC Corporation. All rights reserved.
Published August 2008
EMC believes the information in this publication is accurate as of its publication date. The information is subject to change
without notice.
THE INFORMATION IN THIS PUBLICATION IS PROVIDED AS IS. EMC CORPORATION MAKES NO REPRESENTATIONS
OR WARRANTIES OF ANY KIND WITH RESPECT TO THE INFORMATION IN THIS PUBLICATION, AND SPECIFICALLY
DISCLAIMS IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Use, copying, and distribution of any EMC software described in this publication requires an applicable software license.
For the most up‑to‑date listing of EMC product names, see EMC Corporation Trademarks on EMC.com.
All other trademarks used herein are the property of their respective owners.
Table of Contents
Preface ................................................................................................................................. 7
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 3
Table of Contents
List of Figures
4 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Table of Contents
List of Tables
Table 1. Events that initiate and terminate recording of a test step ........................................ 11
Table 2. Interfaces and abstract classes to implement ........................................................... 37
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 5
Table of Contents
6 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Preface
This document describes how to extend the EMC Documentum Web Development Kit Automated
Test Framework.
Intended Audience
The audience of this manual is intended to be developers who want to extend the WDK Automated
Test Framework and who are familiar with WDK.
Revision History
The following changes have been made to this document.
Revision History
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 7
Preface
8 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Chapter 1
Overview
Introduction
The Web Development Kit (WDK) Automated Test Framework helps automate the generation of and
running reusable test cases for WDK applications. You can use the WDK Automated Test Framework
to perform these kinds of tests on WDK applications:
• Sequence of user actions
• Validate actions
• Validate the states of controls
To ensure reusable test cases, the WDK Automated Test Framework does not depend on nor test the
locations of user interface elements on the browser page.
Architecture
The WDK Automated Test Framework consists of a WDK application to record and execute tests
(also known as test cases), and to view the results of the tests. Because the WDK Automated Test
Framework is a WDK application, you can configure and extend it as you would any other WDK
application. For more information, see the Web Development Kit Development Guide.
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 9
Overview
You configure the WDK Automated Test Framework by extending (including specifying
custom elements and attributes in) the testframeworkconfig id=ʺdefaultʺ definition in the
testframework_config.xml configuration file in one of these paths:
• For Webtop: webtop/config/test
• For a custom WDK application: webcomponent/config/test
10 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Overview
onChangeEvent onFormRenderFinish
onServerEvent onNest
onWebformTagStart onReturn
onReturnJump
onWebformTagStart*
* Only if the body of the webform tag is not processed.
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 11
Overview
Within a test step, user actions are recorded as ClientEvent instances in the array returned by the
getClientEvents method. If the logic to used to create a ClientEvent instance is more than a single line,
then a controlEvent_integer_generate method that returns a ClientEvent instance is created.
If an action to validate is recorded in a test step, the test step class will be created to implement
IActionListener and IActionCompleteListener and skeleton code for these methods are created:
• onPreAction method: Saves the initial state of the action before executing the action.
• onPostAction method: Executes after the action executes.
• onComplete method: Executes after the action completes and calls ITestStepActionValidator,
which calls the default implementation, to validate the action’s initial state with its final state.
The XML configuration code that corresponds to the test case structure is shown in Figure 3, page 14.
Because control state validation is completely controlled through the test case XML configuration file,
no Java code is generated for control state validation.
12 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Overview
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 13
Overview
Figure 3, page 14 shows sample XML that is recorded in a test case configuration file. The testcase
element’s id attribute identifies the test case (the id attribute value corresponds to the string entered in
the testcaseid field when recording the test case). The class element contains the name of the test case
Java class. The variables element specifies global variables that the test case uses. The validationdata
element contains teststep elements that specify the control and action results to validate. The global
variables and variables specific to a test step may be set or retrieved by the test case Java class. Each
teststep element’s name attribute corresponds to an inner class that extends ComponentTestStep.
14 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Overview
For information about using the WDK Automated Test Framework, making reusable test cases, and
creating unit tests, see the Web Development Kit Automated Test Framework User Guide.
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 15
Overview
16 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Chapter 2
Supporting New Controls
Overview
To support (also known as instrumentation) new controls in the WDK Automated Test Framework,
you might want to implement these kinds of functionality:
• Recording inspection page: Modifying the recording inspection page to enable inspection of the
new control’s fields.
• Recording server‑ and client‑side control events: Creating XML and Java source code in the test
case configuration file and Java class for server‑ and client‑side control events.
• Control validation: Validating control states.
• Control inspection: Inspecting and setting control state during test case recording.
When you do not provide support for a new control, test recording outputs comments in the test case
about an unknown control.
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 17
Supporting New Controls
2 <clickeventgenerators>
<class>com.documentum.web.test.controlevent.dmf.MyClickEvent</class>
</clickeventgenerators>
3 <mouseovereventgenerators>
<class>com.documentum.web.test.controlevent.dmf.MyMouseOverEvent</class>
</mouseovereventgenerators>
1 Specify the fully qualified name of your class that implements ISetValueEventGenerator.
2 Specify the fully qualified name of your class that implements IClickEventGenerator.
3 Specify the fully qualified name of your class that implements IMouseOverEventGenerator.
...
18 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Supporting New Controls
1 Return true if the control is an instance of the MyControl class or false if not.
2 Return a MyControlClickEvent instance for the control.
For ClientEvent, override the getJavaScript method. You can either code the JavaScript to be used
in this method or you can call other common classes to build the JavaScript. In this example, the
getJavaScript method calls the ControlById and MyControlClickEvent common classes to build the
JavaScript.
public String getJavaScript()
{
String controlId = m_myControl.getId();
1 IControlVar controlVar = new ControlById(controlId);
2 return new MyControlClickEvent(controlVar).getJavaScript();
}
In the MyControlClickEvent class, the getJavaScript method calls the getDeclareScript method on the
ControlById instance (m_controlVar) to retrieve the JavaScript, and adds browser‑specific JavaScript
(depending on whether the browser is Internet Explorer or not):
public String getJavaScript()
{
StringBuffer buf = new StringBuffer();
1buf.append(m_controlVar.getDeclareScript());
if (ClientInfoService.getInfo().isBrowser(ClientInfo.MSIE))
{
buf.append(m_controlVar.getName() + ".click();\n");
}
else
{
buf.append("var eventClick = document.createEvent(\"MouseEvents\");");
buf.append("eventClick.initEvent(\"click\",true,true);");
buf.append(m_controlVar.getName() + ".dispatchEvent(eventClick);");
}
return buf.toString();
}
1 Calls the getDeclareScript method on the ControlById instance (m_controlVar) to retrieve the
JavaScript.
The ControlById getDeclareScript method returns this JavaScript, which instantiates a variable that
references a control passed to ControlById:
public final String getDeclareScript()
{
StringBuffer buf = new StringBuffer();
1buf.append("var controlId = ’" + m_id + "’;\n");
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 19
Supporting New Controls
return buf.toString();
}
1 Inserts the JavaScript to set a variable; the m_id variable is the control’s ID.
2 Determines whether the frame’s name has been passed into this class. In this case, the frame’s
name is not passed in.
3 Inserts the JavaScript that sets the control name variable to a DOM document object’s element
identified by the control’s ID. The class’s getName() method generates a unique control name.
20 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Supporting New Controls
1 <controleventproducers>
<class>com.documentum.web.test.controlevent.UnnamedControlEvent</class>
</controleventproducers>
2 <clientusereventproducers>
<class>com.documentum.web.test.recorder.ClientSideControlEventProducer</class>
</clientusereventproducers>
3 <clientusereventcreators>
<class>com.documentum.web.test.recorder.TreeNodeUserEvent</class>
</clientusereventcreators>
1 Specify the fully qualified name of your class that implements IControlEventProducer.
2 Specify the fully qualified name of your class that implements IClientUserEventProducer.
3 Specify the fully qualified name of your class that implements IClientUserEventCreator.
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 21
Supporting New Controls
validation XML, and the performance of the validation itself. By default, validation is performed
by the DefaultUIValidator class and the inspector component enables you to specify the control’s
attributes in the inspector_component.xml file’s <commomcontrolvalidation> element for validation.
To display your control’s states on the inspection page of the test recorder:
1. Create a class that extends UIValidationFieldHandler and override the getInputAssistance and
getValue methods. The getInputAssistance method returns a specific InputAssistance instance for
a getterclass field specified in your extended testframework_config.xml file. The getValue method
22 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Supporting New Controls
retrieves the value of a control’s attribute. An InputAssistance instance (for example, an EditBox or
RadioGroup control) indicates that a field is to be inspected.
For example, DropDownListFieldHandler extends UIValidationFieldHandler. The options and
value in the getValue and getInputAssistance methods are mapped to the options and value fields
in the testconfig_component.xml file shown in Step 3.
public String getValue(Control control, String field, ArgumentList parameterList)
{
if (control instanceof DropDownList)
{
DropDownList thisDropDownList = (DropDownList) control;
1if (field.equals("value"))
{
for (Object o : thisDropDownList.getOptions())
{
Option thisOption = (Option)o;
if (thisOption.getValue().equals(thisDropDownList.getValue()))
{
return thisOption.getValue();
}
}
}
2if (field.equals("options"))
{
String options = "";
for (Object o : thisDropDownList.getOptions())
{
options += ((Option)o).getLabel() + ",";
}
return options.substring(0, options.length() 1);
}
}
return null;
}
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 23
Supporting New Controls
1 Checks whether the field is the DropDownList control’s value attribute or not and if it is the value
attribute, then returns the current value of the value attribute of the thisDropDownList.
2 Checks whether the field is the options attribute or not and if it is the options attribute, then
retrieves the labels.
3 Checks whether the field is the value attribute or not and if it is the value attribute, then a dropdown
list instance, thisDropDownList, is populated by a list of values and labels is returned; otherwise,
an editbox is returned.
2. Extend the Inspector component (app\wdk\config\test\inspector_component.xml file) and
add this XML structure to your extended Inspector component’s configuration file in the
config/scope/component/controls element:
1 <control>
2 <class>control_class_name</class>
3<producer>validation_xml_producer_class_name</producer>
4<validation>
<entry>
<reference>element_config</reference>
</entry>
...
<entry>
<field>control_attribute</field>
</entry>
...
<identity>
<entry>
<field>identity_element</field>
</entry>
...
</identity>
...
</control>
1 This element contains the structure that specifies how to inspect a particular control.
2 This element specifies the package name and name of the class that implements the control.
3 This element specifies the name of the class that creates the validation XML.
4 Specify element structures that contain fields that you want to validate. An <entry> element can
contain a <reference> element that refers to an element in this configuration file or a <field> element
that specifies a control attribute to validate.
For example, this XML structure provides inspection for the DropDownList control:
<control>
<class>com.documentum.web.form.control.DropDownList</class>
<validation>
<entry>
<reference>commomcontrolvalidation</reference>
</entry>
<entry>
<reference>valuevalidation</reference>
</entry>
<entry>
<reference>dropdownlistvalidation</reference>
24 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Supporting New Controls
</entry>
</validation>
<identity>
<entry>
<reference>commomcontrolidentity</reference>
</entry>
</identity>
</control>
3. Extend the appropriate testframework_config.xml file and add this XML structure to your
extended testframework_config.xml file in the config/scope/component/controls element, where
the <field> elements in <fieldgetters> correspond to the fields in the <field> elements specified in:
1 <control>
2<class>control_class_name</class>
3<definitioncomponent>component_name</definitioncomponent>
4<fieldgetters>
5<field name="name" getterclass="class_name" />
...
<field name="name" getter="attribute" />
...
</fieldgetters>
6<validator>validator_class_name</validator>
</control>
1 Contains the structure that specifies how to perform user interface validation on a particular control.
2 Specifies the package name and name of the class that implements the control. This value must
be the same as the control_class_name in Step 2.
3 Specifies the name of the component in which to define the validation. The default is the inspector
component, which is usually sufficient.
4 Contains the structure that specifies attributes in the control.
5 Specifies the name (in the name attribute) of a field and either:
• getterclass attribute that specifies the package name and the name of the class that extends
UIValidationFieldHandler
• getter attribute that specifies the name of a method in the control_class_name.
6 Specifies the name of the class that creates the validation XML.
For example, this XML provides validation for the DropDownList control:
<control>
<class>com.documentum.web.form.control.DropDownList</class>
<fieldgetters>
<field name="value" getterclass="com.documentum.web.test.validation.ui.
fieldhandler.DropDownListFieldHandler" />
<field name="size" getter="getSize" />
<field name="width" getter="getWidth" />
<field name="height" getter="getHeight" />
<field name="options" getterclass="com.documentum.web.test.validation.ui.
fieldhandler.DropDownListFieldHandler" />
</fieldgetters>
</control>
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 25
Supporting New Controls
4. (Optional) To change the recording inspection page for new controls, you extend
com.documentum.web.test.validation.ui.inputassistance.InputAssistance and
com.documentum.web.test.validation.ui.inspector.InputAssistanceInspector. When extending
InputAssistanceInspector, initialize the controls that are to be used in the corresponding JSP
layout, and save the information to validate according to the controls’ states. For example, for a
dropdown control, you extend InputAssistance and implement methods to create a name‑value
pair that represents a choice in the dropdown, add a choice, get all the available choices, and
get the label and value of a choice:
package com.documentum.web.test.validation.ui.inputassistance;
import java.util.List;
import java.util.ArrayList;
26 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Supporting New Controls
1 Nested class that represents a name‑value pair for the choice in the dropdown.
2 Adds a choice with a label or both a label and value to the dropdown.
3 Retrieves all of the available choices.
4 An array, m_choices, of all the choices.
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 27
Supporting New Controls
28 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Chapter 3
Enhancing Additional Functionality
Overview
You can enhance additional WDK Automated Test Framework functionality in these areas:
• Responding to WDK Automated Test Framework events, page 29
• Enhancing default preference restoration, page 30
• Enhancing default object and tree node identification, page 30
• Executing code after autologin, page 31
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 29
Enhancing Additional Functionality
30 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Enhancing Additional Functionality
The default implementation uses the object ID of the tree nodes instance as a parameter. An
example of another implementation would be one that identifies nodes in a VDM tree. You
specify your implementation in the treenodeidentifierfunctionproviders element of your extended
testframework_config.xml file.
Where class_name is the complete class name of the class that implements the IPostAutoLoginListener
interface.
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 31
Enhancing Additional Functionality
32 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Appendix A
Implementing Deferred Client Event
Processing in Components
Overview
When you create a component that includes client events that are not fired immediately after the
DOM is ready, you must call WDK ATF JavaScript methods in the component’s JSP to record, as
DeferredClientEvent objects, all events to defer while the component is performing other processing .
During test execution, the DeferredClientEvent objects are not executed until after the corresponding
processing has completed.
For example, even after results are displayed in the search component, the component continues to
poll the content server for additional search results. So, if a client event is executed before the polling
has completed, the client event can fail when it attempts to acquire the posting lock (which is most
likely owned by the polling call).
Procedure
1. Call the window.suspendTestEvents function before starting your deferred events and the
window.resumeTestEvents function after the deferred events have completed as shown in this
example from webcomponent\library\searchresultslist\search60\searchresults.jsp.
The <dmf:webform/> tag, which is specified in all component JSPs, includes the
suspendTestEvents() and resumeTestEvents() functions.
The initInlineCall() function is called from within the body of the searchresults.jsp file and is the
initial starting point for polling for search updates from the content server.
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 33
Implementing Deferred Client Event Processing in Components
<script type="text/javascript">
var updateStatusCall;
function initInlineCall ()
{
1 notifyPollingInitiation()
2 updateStatusCall = setInterval("updateSearchStatus()", 1000);
}
function updateSearchStatus ()
{
var prefs = InlineRequestEngine.getPreferences(InlineRequestType.JSON);
3 prefs.setCallback(renderSearchStatus);
postInlineServerEvent(null, prefs, null, null, "onUpdateSearchStatus",
null, null);
function notifyPollingInitiation()
{
if (window.suspendTestEvents)
{
5 window.suspendTestEvents();
}
}
function notifyPollingComplete()
{
if (window.resumeTestEvents)
{
34 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Implementing Deferred Client Event Processing in Components
6 window.resumeTestEvents();
}
}
function showSearchResults ()
{
clearInterval(updateStatusCall);
unlock();
notifyPollingComplete();
<dmf:postserverevent handlermethod=’onShowResults’/>
}
function onStopSearch ()
{
clearInterval(updateStatusCall);
unlock();
notifyPollingComplete();
<dmf:postserverevent handlermethod=’onStopSearch’/>
}
function onRestartSearch ()
{
clearInterval(updateStatusCall);
unlock();
notifyPollingComplete();
<dmf:postserverevent handlermethod=’onRestartSearch’ />
}
function unlock ()
{
if (isEventPostingLocked())
{
releaseEventPostingLock();
}
}
</script>
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 35
Implementing Deferred Client Event Processing in Components
playback, this function causes the WDK ATF to resume consuming steps and fire the deferred events
for the step.
36 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Appendix B
Interfaces and Abstract Classes
Table 2, page 37 lists the interfaces you can implement and abstract classes you can extend to enhance
the functionality of the WDK Automated Test Framework.
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 37
Interfaces and Abstract Classes
38 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Interfaces and Abstract Classes
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 39
Interfaces and Abstract Classes
40 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Interfaces and Abstract Classes
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 41
Interfaces and Abstract Classes
42 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Appendix C
New Features, Usability Improvements,
and Fixed Bugs
See the WDK Automated Test Framework User Guide for a list of new features, usability improvements,
and fixed bugs that apply to using the WDK Automated Test Framework.
Version 2.5
Support client events that are deferred; that is, client events that are not fired immediately after the
DOM is ready. For example, even after results are displayed in the search component, the component
continues to poll the server for additional search results. So, if a client event is executed before the
polling has completed, the client event can fail when it attempts to acquire the posting lock (which
is most likely owned by the polling call). Therefore, to support deferred client events, JavaScript
in the component JSP instructs the test recorder to record any events that occur during polling as
DeferredClientEvent objects. During test execution, polling is executed and the DeferredClientEvent
objects are not executed until after polling has completed. Deferred client events are part of new
WDK AJAX‑related functionality. (New feature)
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 43
New Features, Usability Improvements, and Fixed Bugs
44 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide
Index
A I
architecture IClientUserEventCreator
component, 10 introduction, 21
introduction, 9 IClientUserEventProducer
introduction, 21
IControlEventProducer
C introduction, 21
click events introduction
example of supporting, 18 WDK Automated Test Framework, 9
ClientEvent
introduction, 21
components J
showtestresult, 10 Java classes
testlauncher, 10 test cases, 11
testrecorderlauncher, 10
testtool, 10
unittest, 10
O
WDK Automated Test Framework, objects
in, 10 identification, 30
configuration
test case files, 11, 14 P
testframework_config.xml, 10 preference restoration
WDK Automated Test Framework, 10 enhancing, 30
controls
click events, 18
events, 18 R
events, server‑, client‑side, 20 recording
inspection, 21 ClientEvent, 21
mouse over events, 18 control events, 20
recording inspection page, 22 IClientUserEventCreator, 21
supporting new, overview, 17 IClientUserEventProducer, 21
validation, 21 IControlEventProducer, 21
value change events, 18 inspection page, modifying, 22
E S
events showtestresult component
controls, 18 description, 10
test step initiation, 11
test step termination, 11
WDK Automated Test Framework, 29
EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide 45
Index
T description, 10
test cases testrecorderlauncher component
configuration files, 14 description, 10
Java classes, 11 to 12 testtool component
test steps description, 10
definiton, 11 tree nodes
description, 11 identification, 30
test suites
definition, 11 U
testframework_config.xml unittest component
description, 10 description, 10
testlauncher component
46 EMC Documentum Web Development Kit Automated Test Framework Version 2.5 Development Guide