org.specrunner.webdriver
Class AbstractPluginBrowserAware

java.lang.Object
  extended by org.specrunner.parameters.core.ParameterHolder
      extended by org.specrunner.plugins.core.AbstractPlugin
          extended by org.specrunner.plugins.core.AbstractPluginNamed
              extended by org.specrunner.plugins.core.AbstractPluginScoped
                  extended by org.specrunner.plugins.core.AbstractPluginValue
                      extended by org.specrunner.webdriver.AbstractPluginBrowserAware
All Implemented Interfaces:
IParameterHolder, IActionType, IParalelPlugin, IPlugin, ISleepPlugin, ITestPlugin, ITimedPlugin, IWaitPlugin
Direct Known Subclasses:
AbstractPluginFind, AbstractPluginHasCapabilities, AbstractPluginHasInputDevices, AbstractPluginHasTouchScreen, AbstractPluginNavigation, AbstractPluginOptions, AbstractPluginRotatable, AbstractPluginSwitchTo, AbstractPluginUrlAware, PluginClick, PluginClickHold, PluginDoubleClick, PluginHeader, PluginRelease, PluginView

public abstract class AbstractPluginBrowserAware
extends AbstractPluginValue

A generic plugin that acts over a webdriver.

Author:
Thiago Santos

Field Summary
static String FEATURE_DIR
          Default directory to save downloaded files.
static String FEATURE_INTERVAL
          Feature for interval.
static String FEATURE_MAXWAIT
          Feature to set max interval.
static String FEATURE_TIMEOUT
          Default timeout to finish the action.
static String FEATURE_WAITFOR
          Wait for feature.
 
Fields inherited from class org.specrunner.plugins.core.AbstractPlugin
FEATURE_CONDITION, FEATURE_NORMALIZED, FEATURE_SLEEP, FEATURE_THREADSAFE, FEATURE_WAIT
 
Constructor Summary
AbstractPluginBrowserAware()
           
 
Method Summary
 void doEnd(IContext context, IResultSet result)
           
protected abstract  void doEnd(IContext context, IResultSet result, org.openqa.selenium.WebDriver client)
          Method delegation which receives the browser to be used by subclasses.
 String getBrowserName()
          Gets the browser name.
 String getDir()
          Get current download directory, if any.
 String getDownload()
          The download target.
 Long getInterval()
          The interval between JavaScript finish checks.
 Long getMaxwait()
          The max time to wait for JavaScript return.
protected  org.openqa.selenium.support.ui.ExpectedCondition<?> getWaitCondition(long start, Long timeout)
          Return the condition to wait.
 String getWaitfor()
          XPath expression to wait for.
 void initialize(IContext context)
           
protected  boolean isWaitForClient()
          Sign actions to wait for browser response.
 void setDir(String dir)
          Set current download directory, if any.
 void setDownload(String download)
          Set download name.
 void setInterval(Long interval)
          Change the interval.
 void setMaxwait(Long maxwait)
          Set the max wait interval.
 void setWaitfor(String waitfor)
          Set the XPath condition to wait for.
protected  void waitForClient(org.openqa.selenium.WebDriver client)
          Wait for client.
 
Methods inherited from class org.specrunner.plugins.core.AbstractPluginValue
getValue, getValue, isEval, setEval, setValue
 
Methods inherited from class org.specrunner.plugins.core.AbstractPluginScoped
getScope, saveGlobal, saveLocal, saveStrict, setScope
 
Methods inherited from class org.specrunner.plugins.core.AbstractPluginNamed
getName, setName
 
Methods inherited from class org.specrunner.plugins.core.AbstractPlugin
copy, doStart, getCondition, getConditionModel, getNormalized, getNormalized, getParent, getSleep, getSleepModel, getThreadsafe, getTimeout, getTimeoutModel, getWait, getWaitModel, setCondition, setConditionModel, setNormalized, setParent, setSleep, setSleepModel, setThreadsafe, setTimeout, setTimeoutModel, setWait, setWaitModel, toString
 
Methods inherited from class org.specrunner.parameters.core.ParameterHolder
getParameters, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.specrunner.parameters.IParameterHolder
getParameters, setParameters
 
Methods inherited from interface org.specrunner.plugins.IActionType
getActionType
 

Field Detail

FEATURE_INTERVAL

public static final String FEATURE_INTERVAL
Feature for interval.


FEATURE_MAXWAIT

public static final String FEATURE_MAXWAIT
Feature to set max interval.


FEATURE_WAITFOR

public static final String FEATURE_WAITFOR
Wait for feature. Use it to set generic XPath wait condition.


FEATURE_TIMEOUT

public static final String FEATURE_TIMEOUT
Default timeout to finish the action.


FEATURE_DIR

public static final String FEATURE_DIR
Default directory to save downloaded files.

Constructor Detail

AbstractPluginBrowserAware

public AbstractPluginBrowserAware()
Method Detail

getInterval

public Long getInterval()
The interval between JavaScript finish checks. Default is '100' milliseconds.

Returns:
The interval.

setInterval

public void setInterval(Long interval)
Change the interval.

Parameters:
interval - The interval.

getMaxwait

public Long getMaxwait()
The max time to wait for JavaScript return. Default is '1000' milliseconds.

Returns:
The max time to wait for JavaScript.

setMaxwait

public void setMaxwait(Long maxwait)
Set the max wait interval.

Parameters:
maxwait - The max wait.

getWaitfor

public String getWaitfor()
XPath expression to wait for.

Returns:
The wait expression.

setWaitfor

public void setWaitfor(String waitfor)
Set the XPath condition to wait for.

Parameters:
waitfor - The condition.

getDir

public String getDir()
Get current download directory, if any.

Returns:
The directory.

setDir

public void setDir(String dir)
Set current download directory, if any.

Parameters:
dir - The directory.

getDownload

public String getDownload()
The download target.

Returns:
The file target name.

setDownload

public void setDownload(String download)
Set download name.

Parameters:
download - The download file name.

initialize

public void initialize(IContext context)
                throws PluginException
Specified by:
initialize in interface IPlugin
Overrides:
initialize in class AbstractPlugin
Throws:
PluginException

doEnd

public void doEnd(IContext context,
                  IResultSet result)
           throws PluginException
Specified by:
doEnd in interface IPlugin
Overrides:
doEnd in class AbstractPlugin
Throws:
PluginException

getBrowserName

public String getBrowserName()
Gets the browser name.

Returns:
The name.

doEnd

protected abstract void doEnd(IContext context,
                              IResultSet result,
                              org.openqa.selenium.WebDriver client)
                       throws PluginException
Method delegation which receives the browser to be used by subclasses.

Parameters:
context - The test context.
result - The result set.
client - The browser.
Throws:
PluginException - On execution errors.

isWaitForClient

protected boolean isWaitForClient()
Sign actions to wait for browser response.

Returns:
true, when wait is desired, false, otherwise. Default is true.

waitForClient

protected void waitForClient(org.openqa.selenium.WebDriver client)
Wait for client. If wait is set it already has waited for the period time set.

Parameters:
client - The client.

getWaitCondition

protected org.openqa.selenium.support.ui.ExpectedCondition<?> getWaitCondition(long start,
                                                                               Long timeout)
Return the condition to wait. If waitfor attribute is provided, the condition turn into <xpath>.isDisplayed().

Parameters:
start - The begin time.
timeout - The timeout.
Returns:
The expected condition.


Copyright © 2013. All rights reserved.