org.jboss.jsfunit.jsfsession
Class JSFClientSession

java.lang.Object
  extended by org.jboss.jsfunit.jsfsession.JSFClientSession

public class JSFClientSession
extends Object

This class provides a wrapper for HtmlUnit that imitates browser interaction with a JSF application.

Since:
1.0
Author:
Stan Silvert

Method Summary
 void click(String componentID)
          Click a JSF component.
 com.gargoylesoftware.htmlunit.Page getContentPage()
          Get the latest content page returned from the server.
 Element getElement(String componentID)
          Get a DOM Element on the current page that has the given JSF componentID.
 String getPageAsText()
          Get the content page as a text String.
 void setValue(String componentID, String value)
          Set the value attribute of a JSF component.
 void type(String componentID, char c)
          Simulates typing a character while this JSF component has focus.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getContentPage

public com.gargoylesoftware.htmlunit.Page getContentPage()
Get the latest content page returned from the server. This page may have been changed by javascript or direct manipulation of the DOM.

Returns:
The Page.

getPageAsText

public String getPageAsText()
Get the content page as a text String.

Returns:
the text

getElement

public Element getElement(String componentID)
Get a DOM Element on the current page that has the given JSF componentID.

Parameters:
componentID - The JSF component id (or a suffix of the client ID)
Returns:
The Element, or null if not found.
Throws:
DuplicateClientIDException - if more than one client ID matches the suffix
ClassCastException - if the current page is not an HtmlPage.

setValue

public void setValue(String componentID,
                     String value)
Set the value attribute of a JSF component.

Parameters:
componentID - The JSF component id (or a suffix of the client ID) of a component rendered as an HtmlInput component.
Throws:
ComponentIDNotFoundException - if no client ID matches the suffix
DuplicateClientIDException - if more than one client ID matches the suffix
ClassCastException - if the current page is not an HtmlPage or the specified component is not an HtmlInput.

type

public void type(String componentID,
                 char c)
          throws IOException
Simulates typing a character while this JSF component has focus.

Parameters:
componentID - The JSF component id (or a suffix of the client ID) of a component rendered as an HtmlElement.
Throws:
ComponentIDNotFoundException - if no client ID matches the suffix
DuplicateClientIDException - if more than one client ID matches the suffix
ClassCastException - if the current page is not an HtmlPage or the specified component is not an HtmlElement.
IOExceptioin - if typing causes a failed request to the server.
IOException

click

public void click(String componentID)
           throws IOException
Click a JSF component.

Parameters:
componentID - The JSF component id (or a suffix of the client ID) to be clicked.
Throws:
ComponentIDNotFoundException - if no client ID matches the suffix
DuplicateClientIDException - if more than one client ID matches the suffix
ClassCastException - if the current page is not an HtmlPage or the specified component is not an HtmlElement.
IOException - if clicking causes a failed request to the server.


Copyright © 2007-2010 JBoss, a division of Red Hat, Inc.. All Rights Reserved.