com.thoughtworks.selenium
Class GroovySelenium

java.lang.Object
  extended by com.thoughtworks.selenium.GroovySelenium

public class GroovySelenium
extends java.lang.Object

Decorates a real Selenium object to add some convenient behaviors. Additional behaviors can be added by extending this class and extending or overriding postSuccess() and postFailure().


Constructor Summary
GroovySelenium(Selenium selenium)
           
 
Method Summary
 void captureScreenshot(java.lang.String label)
          Captures a screenshot using the wrapped Selenium instance.
protected  java.lang.String generate(java.io.File screenshotDir, java.lang.String label)
           
 java.lang.Object getAlwaysCaptureScreenshots()
           
 java.lang.Object getCaptureScreenshotOnFailure()
           
 java.lang.Object getDefaultTimeout()
           
 java.lang.Object getGenerator()
           
 groovy.lang.MetaClass getMetaClass()
           
static java.lang.Object getPATTERN_AND_WAIT()
           
 java.lang.Object getProperty(java.lang.String name)
           
 java.lang.Object getScreenshotCounter()
           
 java.lang.Object getScreenshotDir()
           
 java.lang.Object getSelenium()
           
 java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args)
           
 java.lang.Object methodMissing(java.lang.String name, java.lang.Object args)
          Delegates missing method calls to the wrapped Selenium object where possible.
protected  void postFailure(java.lang.Object selenium, java.lang.String command)
          Called when a Selenium command fails.
protected  void postSuccess(java.lang.Object selenium, java.lang.String command)
          Called when a Selenium command succeeds.
 void setAlwaysCaptureScreenshots(boolean capture)
          If true is passed in, we will attempt to capture a screenshot of the application whenever a Selenium command finishes, whether it failed or not.
 void setAlwaysCaptureScreenshots(java.lang.Object value)
           
 void setCaptureScreenshotOnFailure(boolean capture)
          If true is passed in, we will attempt to capture a screenshot of the application whenever a Selenium command fails.
 void setCaptureScreenshotOnFailure(java.lang.Object value)
           
 void setDefaultTimeout(int timeout)
          Sets the timeout used when waiting for pages to load.
 void setDefaultTimeout(java.lang.Object value)
           
 void setGenerator(java.lang.Object value)
           
 void setMetaClass(groovy.lang.MetaClass metaClass)
           
 void setProperty(java.lang.String name, java.lang.Object value)
           
 void setScreenshotCounter(java.lang.Object value)
           
 void setScreenshotDir(java.io.File dir)
          Sets the directory in which screenshots will be generated.
 void setScreenshotDir(java.lang.Object value)
           
 void setScreenshotFileNameGenerator(java.lang.Object generator)
          Sets the logic used to generate screenshot filenames.
 void setSelenium(java.lang.Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroovySelenium

public GroovySelenium(Selenium selenium)
Method Detail

getPATTERN_AND_WAIT

public static final java.lang.Object getPATTERN_AND_WAIT()

getSelenium

public java.lang.Object getSelenium()

setSelenium

public void setSelenium(java.lang.Object value)

getDefaultTimeout

public java.lang.Object getDefaultTimeout()

setDefaultTimeout

public void setDefaultTimeout(java.lang.Object value)

getAlwaysCaptureScreenshots

public java.lang.Object getAlwaysCaptureScreenshots()

setAlwaysCaptureScreenshots

public void setAlwaysCaptureScreenshots(java.lang.Object value)

getCaptureScreenshotOnFailure

public java.lang.Object getCaptureScreenshotOnFailure()

setCaptureScreenshotOnFailure

public void setCaptureScreenshotOnFailure(java.lang.Object value)

getScreenshotDir

public java.lang.Object getScreenshotDir()

setScreenshotDir

public void setScreenshotDir(java.lang.Object value)

getGenerator

public java.lang.Object getGenerator()

setGenerator

public void setGenerator(java.lang.Object value)

getScreenshotCounter

public java.lang.Object getScreenshotCounter()

setScreenshotCounter

public void setScreenshotCounter(java.lang.Object value)

setDefaultTimeout

public void setDefaultTimeout(int timeout)
Sets the timeout used when waiting for pages to load.

Parameters:
timeout - in milliseconds

setAlwaysCaptureScreenshots

public void setAlwaysCaptureScreenshots(boolean capture)
If true is passed in, we will attempt to capture a screenshot of the application whenever a Selenium command finishes, whether it failed or not.

Parameters:
capture -

setCaptureScreenshotOnFailure

public void setCaptureScreenshotOnFailure(boolean capture)
If true is passed in, we will attempt to capture a screenshot of the application whenever a Selenium command fails.

Parameters:
capture -

setScreenshotDir

public void setScreenshotDir(java.io.File dir)
Sets the directory in which screenshots will be generated.

Parameters:
dir -

setScreenshotFileNameGenerator

public void setScreenshotFileNameGenerator(java.lang.Object generator)
Sets the logic used to generate screenshot filenames. The name of the failed command is passed into the generator.

Parameters:
generator - an object with a generate() method, which returns a String representing a file name. See the generate method for this class as an example.

generate

protected java.lang.String generate(java.io.File screenshotDir,
                                    java.lang.String label)

postSuccess

protected void postSuccess(java.lang.Object selenium,
                           java.lang.String command)
Called when a Selenium command succeeds. The Selenium object is passed in.

Parameters:
selenium - the selenium instance
command - the name of the command that succeeded

postFailure

protected void postFailure(java.lang.Object selenium,
                           java.lang.String command)
Called when a Selenium command fails. The Selenium object is passed in.

Parameters:
selenium - the selenium instance
command - the name of the command that failed

captureScreenshot

public void captureScreenshot(java.lang.String label)
Captures a screenshot using the wrapped Selenium instance.

Parameters:
label - an identifying label to include in the name of the created screenshot

methodMissing

public java.lang.Object methodMissing(java.lang.String name,
                                      java.lang.Object args)
Delegates missing method calls to the wrapped Selenium object where possible.

Parameters:
name -
args -

getMetaClass

public groovy.lang.MetaClass getMetaClass()

setMetaClass

public void setMetaClass(groovy.lang.MetaClass metaClass)

invokeMethod

public java.lang.Object invokeMethod(java.lang.String name,
                                     java.lang.Object args)

getProperty

public java.lang.Object getProperty(java.lang.String name)

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)


Copyright © 2009. All Rights Reserved.