actiWATE is no longer supported
If you are interested in this product development, please contact email@example.com
actiWATE Framework provides a set of objects used for interacting with web application.
The main object in actiWATE Framework is ActiwateTestCase. This is the base object for all actiWATE tests. All actiWATE tests are inherited from this class. In most cases this will be the only class you will need to write automated tests.
The next object of actiWATE Framework is Window. Window object is an abstraction of a window of real Internet browser.
Several windows that sharing the same HTTP session (same cookies) are joined into ActiwateSession. By default actiWATE test works with one session and one window. But test can create new sessions and windows using methods
Other actiWATE Framework objects represent particular HTML elements and used for reading and changing their state.
For complete list of classes and their methods see API reference.
actiWATE Framework utilizes the principle of context. Most methods of ActiwateTestCase execute in context of particular HTML page, which can be either Window or Frame or IFrame object. For example, when test searches for text field using the method
The test can change the context using methods
In certain cases usage of context reduces size of test code and a number of required local variables, and improves readability of the test code. For example, instead of the code
Window window = session.window(); setText(window.frame("main").textField("username"), "someuser"); setText(window.frame("main").textField("password"), "somepassword"); click(window.frame("main").buttonByText("Login"));one can use
switchTo(session.window().frame("main")) setText(textField("username"), "someuser"); setText(textField("password"), "somepassword"); click(buttonByText("Login"));For detailed information see API reference and samples Frames.java and Popups.java.
HTML pages usually contain redundant space and carriage return characters, which are not displayed by real Internet browsers. If browser encounters sequence of space and/or carriage return characters it displays only one space character.
actiWATE Framework performs similar procedure. Methods that work with text on HTML page such as
actiWATE Framework provides a number of objects representing HTML form controls such as Button, RadioButton, Checkbox, SingleSelect, MultipleSelect, TextField, Textarea, etc. These objects are used for reading and changing state of HTML controls and thus interacting with web application being tested.
Classes ActiwateTestCase, ActiwateSession, Window, Frame, IFrame and TableCell contain a number of methods that can be used to find these objects by various criteria. Classes ActiwateTestCase and ActiwateSession provide a number of methods such as setText, setFileName, selectOption, click, etc, which can be used for interacting with these objects.
The following code demonstrates how to set the value of a text field with name "username". It uses method
setText(textField("username"), "jsmith");For detailed information see API reference and samples Form.java, FileUpload.java, and LiveTestCase.java.
actiWATE Framework provides objects Frame and IFrame which represent FRAME and IFRAME HTML elements correspondingly. These objects are similar to the object Window at large. Frame and IFrame objects can be used as a context of a test (see Test context).
The following code switches the context of the test to the frame with name "main". It uses the method
switchTo(window().frame("main"));For detailed information see API reference and sample Frames.java.
actiWATE Framework provides classes Table, TableRow and TableCell for working with HTML tables. You can get table row by index and cell by row and cell indexes. Row and cell indexes are order numbers of TR and TD (TH) elements inside TABLE and TR elements correspondingly. Indexes do not depend on colspan and rowspan attributes. The following figure shows values of row and cell indexes in case when rowspans and colspans are used.
Picture 3 Table row and cell indexes
For detailed information see API reference and sample Tables.java.
There are several classes and methods in actiWATE Framework, which simplify lookup of image maps and areas.
Image maps are represented by ImageMap class. You can find maps by index or by name / id attribute value. ImageMap class provides you with access to the areas. This class also allows to retrieve all images referencing this map.
Area class represents image areas. Image area properties, such as href, coords, shape, etc. are available via this class.
For detailed information see API reference and sample ImageMaps.java.
The following code verifies that clicking on the button opens a new window. When the window is no longer needed the code closes it.
click(buttonByText("Open Pop-Up")); switchTo(windowWithTitle("This is pop-up window")); click(buttonByText("Close Pop-Up")); switchTo(window(0))For detailed information see API reference and sample Popups.java.
For detailed information see API reference and sample AlertConfirmPrompt.java.
There are number of events that are executed asynchronously in browsers. These events include:
The time-line is represented in actiWATE by the container object that implements the
All event objects implement the
The time flow can be emulated by number of methods of the
Consider the following example that illustrates the time-line concept:
Suppose at some point of time there are three asynchronous events that should be triggered:
If we call
Asynchronous event types
actiWATE supports four asynchronous events that are represented by the interfaces described below.
When this line is executed, the
When this line is executed, the
<META http-equiv="refresh" content="2;url=http://www.actiwate.com">
Normally, after the page containing this tag is parsed by actiWATE, the new
Processing of events
There are two ways of processing asynchronous events: manual and automatic. Manual processing is performed
by calling of
Manual processing of events is intended to check Web Application's state before and after some asynchronous event is triggered. For example you might want to check an HTML page content before an AJAX request is send from this page and then check the page once again after the AJAX response is processed.
Automatic mode can be used in tests that don't verify page behavior in details, i.e. results of every asynchronous event separately. In this mode actiWATE automatically executes events that appear in the time-line during testing. If a tested web application has many asynchronous events, this mode helps to avoid writing of numerous calls to AsyncEvents interface since the events are processed automatically after each action such as clicks or goTo() calls.
Automatic mode is configured in actiWATE configuration file using the following two properties:
There is also one peculiarity of this mode: If a subsequent action didn't lead to new events in the time-line, no events are executed independently on whether the time-line already contains events with time offset less than the specified maximum. This means that the automatic execution happens only if new events with time offset property less or equal to the autoExecAsyncEventsOffset value were added in result of an action. This behavior is intended to prevent numerous automatic executions of events on some page in case many actions are performed on the page but no new events are added.
For additional information see API reference and XmlHttpRequest.java and Timers.java samles.
actiWATE supports the screen object with the above properties and allows one to change the following ones in a test:
For the following read-only properties actiWATE returns constant values that cannot be changed:
You can also override default values for availHeight, availWidth, colorDepth, height, and width properties in actiwate.properties file for all actiWATE sessions.
For detailed information see:
In certain cases it can be useful to perform some non-standard actions, such as changing value of hidden input element. For such cases actiWATE Framework provides access to HTML DOM. You can use HTML DOM to find certain HTML elements, verify DOM state, read or change element attributes etc.
The following methods can be used to access HTML DOM:
actiWATE Framework provides interface for accessing HTTP response data. This can be useful when window or frame contains non-HTML content. In this case you can use the method
The following code verifies that window contains a GIF image.
HttpResponse response = window().response(); assertEquals("image/gif", response.getContentType());For detailed information see API reference and sample NonHTMLContent.java.
Currently actiWATE supports only click action for any HTML element. When the click action is performed the following sequence of event is fired: mousedown, focus, mouseup, click. For example, if you need to emulate click on a <div> HTML element, you can write code like this:
actiWATE doesn't support all the client-side technologies of real Internet browser. If HTML page being tested uses the technology that is not yet supported, such as Dynamic HTML behaviors or Macromedia Flash, then automated test can fail. actiWATE provides work-around so that such HTML pages can be tested.
For example, suppose that tested page contains the following HTML code that uses getExpression method:
Basic authorization is used to restrict access to Web documents or CGI scripts by user name and password. When a user accesses the restricted content through a browser he is presented with a dialog requesting credentials (user name and password) to access the content.
actiWATE provides an ability to specify required credentials before a restricted content is reached. There are two ways to specify credentials:
If you need to reuse test code within one test class simply extract the reusable code to separate method and call it whenever needed. This method can accept parameters if needed. If it is necessary to reuse same method from several test classes then there are two options.
The first option is making a superclass for a number of test classes and placing reusable method in it. Sometimes this approach is not applicable, for example, if test classes are so different that having common superclass is confusing. In this case you can use the second option.
The second option is putting reusable code into a static method, which accepts object ActiwateSession as one of its parameters. You can call this method from any test class. Methods of class ActiwateTestCase, being non-static, will not be available from the reusable code. This code will use methods of session object passed as parameter.
See also sample TestScriptReusing.java.
© Copyright Actimind, Inc. 2000-2007 All rights reserved