version 1.0

com.actimind.actiwate.testing.html
Interface Action

All Known Subinterfaces:
ActiwateSession, Frame, IFrame, Page, Window
All Known Implementing Classes:
ActiwateTestCase

public interface Action

Interface contains methods emulating user actions on HTML page. For example, mouse click, text enter and so on.


Method Summary
 void back()
          Emulates browser back function
 void chooseFile(FileField fileField, java.lang.String filePath, InputStreamFactory streamFactory, java.lang.String contentType)
          Emulates result of a file choose dialog when a user clicks "Browse" button in the browser.
 void click(Area area, Image image)
          Emulates single mouse click on an Area element.
 void click(ClickableElement clickable)
          Emulates single mouse click on an object.
 void click(org.w3c.dom.html.HTMLElement element)
          Emulates single mouse click on an arbitrary HTML element.
 java.lang.Object executeJavaScript(java.lang.String script)
          Executes specified JavaScript statements in the scope of the current page.
 java.lang.Object executeJavaScript(java.lang.String script, org.w3c.dom.html.HTMLElement element)
          Executes specified JavaScript statements in the scope of the current page.
 void forward()
          Emulates browser forward function
 void goTo(HttpRequest request)
          Sends arbitrary HTTP request.
 void goTo(java.lang.String URL)
          Sends GET request to the specified URL.
 void reload()
          Reloads the current page
 void runPageScripts()
          Loads and executes all scripts associated with the current page.
 void selectOption(Option optionToSelect)
          Emulates option selection in drop down or multiple select.
 void setFile(FileField field, java.io.File fileToUpload, java.lang.String contentType)
          Deprecated.  
 void setFileName(FileField fileField, java.lang.String filePath)
          Emulates manual enter of text into a file field.
 void setFileName(FileField fileField, java.lang.String filePath, InputStreamFactory streamFactory, java.lang.String contentType)
          Emulates manual enter of text into a file field.
 void setText(PasswordField passwordField, java.lang.String text)
          Emulates text insert operation in a password field object.
 void setText(Textarea textarea, java.lang.String text)
          Emulates text insert operation in a textarea object.
 void setText(TextField textField, java.lang.String text)
          Emulates text insert operation in a text field object.
 void toggleOption(Option optionToToggle)
          Emulates option toggling in multiple select (Ctrl + mouse click).
 

Method Detail

click

public void click(ClickableElement clickable)
           throws java.lang.IllegalArgumentException
Emulates single mouse click on an object.

Parameters:
clickable - - element user is able to click
Throws:
java.lang.IllegalArgumentException - if clickable is null

click

public void click(org.w3c.dom.html.HTMLElement element)
           throws java.lang.IllegalArgumentException
Emulates single mouse click on an arbitrary HTML element.

Parameters:
element - - element user is able to click
Throws:
java.lang.IllegalArgumentException - if element is null

click

public void click(Area area,
                  Image image)
           throws java.lang.IllegalArgumentException
Emulates single mouse click on an Area element. If the area's map is referenced by exactly one image then it's possible to use methods click(com.actimind.actiwate.testing.html.objects.ClickableElement) and click(org.w3c.dom.html.HTMLElement). But in case there are several images that use the same map then the mentioned methods will generate error, so you need to use this method to specify which image should be actually clicked.

Parameters:
area - - area element
image - - image element specifying an exact image to click on.
Throws:
java.lang.IllegalArgumentException

setText

public void setText(PasswordField passwordField,
                    java.lang.String text)
             throws java.lang.IllegalArgumentException
Emulates text insert operation in a password field object. Generates 'change' event if text is changed.

Parameters:
passwordField - - PasswordField object where user inserts text
text - - text to insert
Throws:
java.lang.IllegalArgumentException - if passwordField or text is null

setText

public void setText(TextField textField,
                    java.lang.String text)
             throws java.lang.IllegalArgumentException
Emulates text insert operation in a text field object. Generates 'change' event if text is changed.

Parameters:
textField - - TextField object where user inserts text
text - - text to insert
Throws:
java.lang.IllegalArgumentException - if textField or text is null

setText

public void setText(Textarea textarea,
                    java.lang.String text)
             throws java.lang.IllegalArgumentException
Emulates text insert operation in a textarea object. Generates 'change' event if text is changed.

Parameters:
textarea - - textarea object where user inserts text
text - - text to insert
Throws:
java.lang.IllegalArgumentException - if textarea or text is null

setFile

public void setFile(FileField field,
                    java.io.File fileToUpload,
                    java.lang.String contentType)
             throws java.lang.IllegalArgumentException
Deprecated.  

Emulates file setting to the file upload field.

Parameters:
field - - file upload field
fileToUpload - - file for upload
contentType - - content type of a file to upload (for example, "image/gif"), if null "application/octet-stream" will be used.
Throws:
java.lang.IllegalArgumentException - if field or fileToUpload is null

setFileName

public void setFileName(FileField fileField,
                        java.lang.String filePath)
Emulates manual enter of text into a file field. The entered file name is treated as name of non-existing file.

Parameters:
fileField - - file upload field
filePath - - absolute path to file for upload
Throws:
java.lang.IllegalArgumentException - if fileField or filePath is null

setFileName

public void setFileName(FileField fileField,
                        java.lang.String filePath,
                        InputStreamFactory streamFactory,
                        java.lang.String contentType)
Emulates manual enter of text into a file field. The entered file name is treated as name of existing file containing the specified data.

Parameters:
fileField - - file upload field
filePath - - absolute path to file for upload
streamFactory - - factory to create stream containing file for upload
contentType - - content type of a file to upload (for example, "image/gif")
Throws:
java.lang.IllegalArgumentException - if fileField or streamFactory is null or filePath or contentType is null or empty string
See Also:
com.actimind.actiwate.testing.util.FileStreamFactory, ByteArrayStreamFactory

chooseFile

public void chooseFile(FileField fileField,
                       java.lang.String filePath,
                       InputStreamFactory streamFactory,
                       java.lang.String contentType)
Emulates result of a file choose dialog when a user clicks "Browse" button in the browser.

Parameters:
fileField - - file upload field
filePath - - absolute path to file for upload
streamFactory - - factory to create stream containing file for upload
contentType - - content type of a file to upload (for example, "image/gif"),
Throws:
java.lang.IllegalArgumentException - if fileField or streamFactory is null or filePath or contentType is null or empty string
See Also:
com.actimind.actiwate.testing.util.FileStreamFactory, ByteArrayStreamFactory

selectOption

public void selectOption(Option optionToSelect)
                  throws java.lang.IllegalArgumentException
Emulates option selection in drop down or multiple select. Generates 'change' event if option selection changed.

Parameters:
optionToSelect - option to select
Throws:
java.lang.IllegalArgumentException - if option is null

toggleOption

public void toggleOption(Option optionToToggle)
                  throws java.lang.IllegalArgumentException
Emulates option toggling in multiple select (Ctrl + mouse click). Always generates 'change' event.

Parameters:
optionToToggle - option to toggle
Throws:
java.lang.IllegalArgumentException - if option is null or option from single select is passed

executeJavaScript

public java.lang.Object executeJavaScript(java.lang.String script)
Executes specified JavaScript statements in the scope of the current page.

Parameters:
script - JavaScript code to execute.
Returns:
result of JavaScript execution.

executeJavaScript

public java.lang.Object executeJavaScript(java.lang.String script,
                                          org.w3c.dom.html.HTMLElement element)
Executes specified JavaScript statements in the scope of the current page.

Parameters:
script - JavaScript code to execute.
element - scope of script execution.
Returns:
result of JavaScript execution.

runPageScripts

public void runPageScripts()
Loads and executes all scripts associated with the current page. Does not execute OnLoad handlers.

Throws:
java.lang.IllegalStateException - if scripts were already executed on this page.

back

public void back()
          throws HistoryExhaustedException,
                 PageExpiredException
Emulates browser back function

Throws:
HistoryExhaustedException - if there is no entries for the back operation in the history
PageExpiredException - if a previous request was a POST request

forward

public void forward()
             throws HistoryExhaustedException,
                    PageExpiredException
Emulates browser forward function

Throws:
HistoryExhaustedException - if there is no entries for the forward operation in the history
PageExpiredException - if a previous request was a POST request

reload

public void reload()
            throws PageExpiredException
Reloads the current page

Throws:
PageExpiredException - if the current page is a result of a POST request

goTo

public void goTo(java.lang.String URL)
          throws java.lang.UnsupportedOperationException
Sends GET request to the specified URL. URL can be relative, in this case absolute URL will be created with concatenation of current base URL and specified URL.

Parameters:
URL - relative or absolute URL
Throws:
java.lang.IllegalArgumentException - if URL is null
java.lang.UnsupportedOperationException - if this method is called for frame or iframe.

goTo

public void goTo(HttpRequest request)
          throws java.lang.UnsupportedOperationException
Sends arbitrary HTTP request.

Parameters:
request - request to send
Throws:
java.lang.IllegalArgumentException - if request is null
java.lang.UnsupportedOperationException - if this method is called for frame or iframe.


Copyright © 2007 Actimind, Inc. All Rights Reserved.