com.canoo.webtest.engine
Class Context

java.lang.Object
  extended by com.canoo.webtest.engine.Context

public class Context
extends Object

Represents context information for a webtest.

Author:
unknown, Marc Guillemot, Paul King

Field Summary
static String KEY_DEFAULT_WEBCLIENTCONTEXT
          The name identifiying the default WebClientContext that is the current one at test startup.
 
Constructor Summary
Context(WebtestTask webtest)
           
 
Method Summary
 boolean containsKey(String key)
           
 WebClientContext defineCurrentWebClientContext(String name)
          Defines the current WebClientContext creating it if none was previously registered under this name.
 Object get(String key)
           
 com.gargoylesoftware.htmlunit.ScriptException getBackgroundJSError()
          Gets the last background JS exception (if any).
 Configuration getConfig()
          Shortcut method to get the configuration of the
 com.gargoylesoftware.htmlunit.html.HtmlForm getCurrentForm()
          Delegates to current WebClientContext
 com.gargoylesoftware.htmlunit.html.HtmlPage getCurrentHtmlResponse(Step step)
          /** Delegates to current WebClientContext
 com.gargoylesoftware.htmlunit.Page getCurrentResponse()
          Delegates to current WebClientContext
 String getCurrentResponseFile()
          Delegates to current WebClientContext
 int getCurrentStepNumber()
           
 WebClientContext getCurrentWebClientContext()
          Gets the currently active WebClientContext.
 int getNumberOfSteps()
           
 WebClientContext.StoredResponses getResponses()
          Delegates to current WebClientContext
 ResetScriptRunner getRunner()
           
 String getSavedPassword()
          Delegates to current WebClientContext
 String getSavedUserName()
          Delegates to current WebClientContext
 com.gargoylesoftware.htmlunit.WebClient getWebClient()
          Delegates to current WebClientContext
 Map<String,WebClientContext> getWebClientContexts()
          Gets the currently available WebClientContext
 WebtestTask getWebtest()
          Gets the <webtest> for this context.
 XPathHelper getXPathHelper()
          Gets the XPath helper used for this test.
 void increaseStepNumber()
           
 boolean isPrepared()
           
 void put(String key, Object value)
           
 void remove(String key)
           
 void restorePreviousResponse()
          Delegates to current WebClientContext
 void restoreResponses(WebClientContext.StoredResponses savedResponses)
          Delegates to current WebClientContext
 void restoreWindowListener()
          Delegates to current WebClientContext
 void saveResponseAsCurrent(com.gargoylesoftware.htmlunit.Page page)
          Delegates to current WebClientContext
 void setBackgroundJSError(com.gargoylesoftware.htmlunit.ScriptException e)
          Sets the last background JS exception.
 void setCurrentForm(com.gargoylesoftware.htmlunit.html.HtmlForm form)
          Delegates to current WebClientContext
 void setPrepared(boolean prepared)
           
 void setRunner(ResetScriptRunner sr)
           
 void setSavedPassword(String password)
          Delegates to current WebClientContext
 void setSavedUserName(String userName)
          Delegates to current WebClientContext
 void setWebClient(com.gargoylesoftware.htmlunit.WebClient webClient)
          Delegates to current WebClientContext
 void suspendWindowListener()
          Delegates to current WebClientContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_DEFAULT_WEBCLIENTCONTEXT

public static final String KEY_DEFAULT_WEBCLIENTCONTEXT
The name identifiying the default WebClientContext that is the current one at test startup.

See Also:
Constant Field Values
Constructor Detail

Context

public Context(WebtestTask webtest)
Method Detail

containsKey

public boolean containsKey(String key)

get

public Object get(String key)

getConfig

public Configuration getConfig()
Shortcut method to get the configuration of the

Returns:
the configuration
See Also:
WebtestTask

getCurrentForm

public com.gargoylesoftware.htmlunit.html.HtmlForm getCurrentForm()
Delegates to current WebClientContext

See Also:
getCurrentWebClientContext(), WebClientContext.getCurrentForm()

getCurrentHtmlResponse

public com.gargoylesoftware.htmlunit.html.HtmlPage getCurrentHtmlResponse(Step step)
/** Delegates to current WebClientContext

See Also:
getCurrentWebClientContext(), WebClientContext.getCurrentHtmlResponse(Step)

getCurrentResponse

public com.gargoylesoftware.htmlunit.Page getCurrentResponse()
Delegates to current WebClientContext

See Also:
getCurrentWebClientContext(), WebClientContext.getCurrentResponse()

getCurrentResponseFile

public String getCurrentResponseFile()
Delegates to current WebClientContext

See Also:
getCurrentResponseFile(), WebClientContext.getCurrentResponseFile()

getCurrentStepNumber

public int getCurrentStepNumber()

getCurrentWebClientContext

public WebClientContext getCurrentWebClientContext()
Gets the currently active WebClientContext.

Returns:
the web client context

getNumberOfSteps

public int getNumberOfSteps()

getWebClientContexts

public Map<String,WebClientContext> getWebClientContexts()
Gets the currently available WebClientContext

Returns:
an unmodifiable Map of (key, WebClientContext)

defineCurrentWebClientContext

public WebClientContext defineCurrentWebClientContext(String name)
Defines the current WebClientContext creating it if none was previously registered under this name.

Parameters:
name - the name of the WebClientContext to activate. The default WebClientContext is registered under the key KEY_DEFAULT_WEBCLIENTCONTEXT.
Returns:
the new current context

getResponses

public WebClientContext.StoredResponses getResponses()
Delegates to current WebClientContext

See Also:
getCurrentWebClientContext(), WebClientContext.getResponses()

getRunner

public ResetScriptRunner getRunner()

getSavedPassword

public String getSavedPassword()
Delegates to current WebClientContext

See Also:
getCurrentWebClientContext(), WebClientContext.getSavedPassword()

getSavedUserName

public String getSavedUserName()
Delegates to current WebClientContext

See Also:
getCurrentWebClientContext(), WebClientContext.getSavedUserName()

getWebClient

public com.gargoylesoftware.htmlunit.WebClient getWebClient()
Delegates to current WebClientContext

See Also:
getCurrentWebClientContext(), WebClientContext.getWebClient()

getWebtest

public WebtestTask getWebtest()
Gets the <webtest> for this context.

Returns:
the task

getXPathHelper

public XPathHelper getXPathHelper()
Gets the XPath helper used for this test. It will be responsible to create the xpath objects with the right custom functions and variables.

Returns:
the helper

increaseStepNumber

public void increaseStepNumber()

isPrepared

public boolean isPrepared()

put

public void put(String key,
                Object value)

remove

public void remove(String key)

restorePreviousResponse

public void restorePreviousResponse()
Delegates to current WebClientContext

See Also:
getCurrentWebClientContext(), WebClientContext.restorePreviousResponse()

restoreResponses

public void restoreResponses(WebClientContext.StoredResponses savedResponses)
Delegates to current WebClientContext

See Also:
getCurrentWebClientContext(), WebClientContext.restoreResponses(com.canoo.webtest.engine.WebClientContext.StoredResponses)

restoreWindowListener

public void restoreWindowListener()
Delegates to current WebClientContext

See Also:
getCurrentWebClientContext(), WebClientContext.restoreWindowListener()

saveResponseAsCurrent

public void saveResponseAsCurrent(com.gargoylesoftware.htmlunit.Page page)
Delegates to current WebClientContext

See Also:
getCurrentWebClientContext(), WebClientContext.saveResponseAsCurrent(Page)

setCurrentForm

public void setCurrentForm(com.gargoylesoftware.htmlunit.html.HtmlForm form)
Delegates to current WebClientContext

See Also:
getCurrentWebClientContext(), WebClientContext.setCurrentForm(HtmlForm)

setPrepared

public void setPrepared(boolean prepared)

setRunner

public void setRunner(ResetScriptRunner sr)

setSavedPassword

public void setSavedPassword(String password)
Delegates to current WebClientContext

See Also:
getCurrentWebClientContext(), WebClientContext.setSavedPassword(String)

setSavedUserName

public void setSavedUserName(String userName)
Delegates to current WebClientContext

See Also:
getCurrentWebClientContext(), WebClientContext.setSavedUserName(String)

setWebClient

public void setWebClient(com.gargoylesoftware.htmlunit.WebClient webClient)
Delegates to current WebClientContext

See Also:
getCurrentWebClientContext(), WebClientContext.setWebClient(WebClient)

suspendWindowListener

public void suspendWindowListener()
Delegates to current WebClientContext

See Also:
getCurrentWebClientContext(), WebClientContext.suspendWindowListener()

getBackgroundJSError

public com.gargoylesoftware.htmlunit.ScriptException getBackgroundJSError()
Gets the last background JS exception (if any). This method should disappear when HtmlUnit offer better control possibilities for that. This consumes the exception and next call will return null (unless a new error occurs)

Returns:
the JS error

setBackgroundJSError

public void setBackgroundJSError(com.gargoylesoftware.htmlunit.ScriptException e)
Sets the last background JS exception. This method should disappear when HtmlUnit offer better control possibilities for that


Copyright © 2001-2007 Canoo Engineering AG, Basel. All rights reserved.