Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.thoughtworks.selenium
Class SeleneseTestBase

    java.lang.Object
      com.thoughtworks.selenium.SeleneseTestBase

    public class SeleneseTestBase

extends java.lang.Object

Provides a base class that implements some handy functionality for Selenium testing (you are not required to extend this class).

This class adds a number of "verify" commands, which are like "assert" commands, but they don't stop the test when they fail. Instead, verification errors are all thrown at once during tearDown.

Author:
  Nelson Sproul (nsproul@bea.com) Mar 13-06

Field Summary
`protected Selenium` | `selenium` Use this object to run all of your selenium tests
`protected java.lang.StringBuffer` | `verificationErrors`

Constructor Summary
`SeleneseTestBase()`

Method Summary
`static void` | `assertEquals(java.lang.Object s1, java.lang.Object s2)` Like JUnit's Assert.assertEquals, but knows how to compare string arrays
`static void` | `assertEquals(java.lang.String[] s1, java.lang.String[] s2)` Asserts that two string arrays have identical string contents
`static void` | `assertEquals(java.lang.String s1, java.lang.String s2)` Like JUnit's Assert.assertEquals, but handles "regexp:" strings like HTML Selenese
`static void` | `assertEquals(java.lang.String s1, java.lang.String[] s2)` Like JUnit's Assert.assertEquals, but joins the string array with commas, and handles "regexp:" strings like HTML Selenese
`static void` | `assertFalse(boolean condition)`
`static void` | `assertFalse(java.lang.String message, boolean condition)`
`static void` | `assertNotEquals(boolean b1, boolean b2)` Asserts that two booleans are not the same
`static void` | `assertNotEquals(java.lang.Object obj1, java.lang.Object obj2)` Asserts that two objects are not the same (compares using .equals())
`static void` | `assertTrue(boolean condition)`
`static void` | `assertTrue(java.lang.String message, boolean condition)`
`void` | `checkForVerificationErrors()` Asserts that there were no verification errors during the current test, failing immediately if any are found
`void` | `clearVerificationErrors()` Clears out the list of verification errors
`static void` | `fail(java.lang.String message)`
`java.lang.String` | `getText()` Returns the body text of the current page
`protected boolean` | `isCaptureScreenShotOnFailure()`
`static java.lang.String` | `join(java.lang.String[] sa, char c)`
`void` | `pause(int millisecs)` Sleeps for the specified number of milliseconds
`protected java.lang.String` | `runtimeBrowserString()`
`static boolean` | `seleniumEquals(java.lang.Object expected, java.lang.Object actual)` Compares two objects, but handles "regexp:" strings like HTML Selenese
`static boolean` | `seleniumEquals(java.lang.String expectedPattern, java.lang.String actual)` Compares two strings, but handles "regexp:" strings like HTML Selenese
`protected void` | `setCaptureScreenShotOnFailure(boolean captureScreetShotOnFailure)`
`void` | `setUp()` Calls this.setUp(null)
`void` | `setUp(java.lang.String url)` Calls this.setUp with the specified url and a default browser.
`void` | `setUp(java.lang.String url, java.lang.String browserString)` Creates a new DefaultSelenium object and starts it using the specified baseUrl and browser string.
`void` | `setUp(java.lang.String url, java.lang.String browserString, int port)`
`void` | `tearDown()` checks for verification errors and stops the browser
`void` | `verifyEquals(boolean s1, boolean s2)` Like assertEquals, but fails at the end of the test (during tearDown)
`void` | `verifyEquals(java.lang.Object s1, java.lang.Object s2)` Like assertEquals, but fails at the end of the test (during tearDown)
`void` | `verifyEquals(java.lang.String[] s1, java.lang.String[] s2)` Asserts that two string arrays have identical string contents (fails at the end of the test, during tearDown)
`void` | `verifyFalse(boolean b)` Like assertFalse, but fails at the end of the test (during tearDown)
`void` | `verifyNotEquals(boolean s1, boolean s2)` Like assertNotEquals, but fails at the end of the test (during tearDown)
`void` | `verifyNotEquals(java.lang.Object s1, java.lang.Object s2)` Like assertNotEquals, but fails at the end of the test (during tearDown)
`void` | `verifyTrue(boolean b)` Like assertTrue, but fails at the end of the test (during tearDown)

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### selenium

    protected Selenium selenium

  Use this object to run all of your selenium tests

### verificationErrors

    protected java.lang.StringBuffer verificationErrors

Constructor Detail

### SeleneseTestBase

    public SeleneseTestBase()

Method Detail

### setUp

    public void setUp()
               throws java.lang.Exception

  Calls this.setUp(null)

  Throws:
    `java.lang.Exception`
  See Also:
    `setUp(String)`

### setUp

    public void setUp(java.lang.String url)
               throws java.lang.Exception

  Calls this.setUp with the specified url and a default browser. On Windows, the default browser is *iexplore; otherwise, the default browser is *firefox.

  Parameters:
    `url` - the baseUrl to use for your Selenium tests
  Throws:
    `java.lang.Exception`
  See Also:
    `setUp(String, String)`

### runtimeBrowserString

    protected java.lang.String runtimeBrowserString()

### setUp

    public void setUp(java.lang.String url,
                      java.lang.String browserString)
               throws java.lang.Exception

  Creates a new DefaultSelenium object and starts it using the specified baseUrl and browser string. The port is selected as follows: if the server package's RemoteControlConfiguration class is on the classpath, that class' default port is used. Otherwise, if the "server.port" system property is specified, that is used - failing that, the default of 4444 is used.

  Parameters:
    `url` - the baseUrl for your tests
    `browserString` - the browser to use, e.g. *firefox
  Throws:
    `java.lang.Exception`
  See Also:
    `setUp(String, String, int)`

### setUp

    public void setUp(java.lang.String url,
                      java.lang.String browserString,
                      int port)

### verifyTrue

    public void verifyTrue(boolean b)

  Like assertTrue, but fails at the end of the test (during tearDown)

### verifyFalse

    public void verifyFalse(boolean b)

  Like assertFalse, but fails at the end of the test (during tearDown)

### getText

    public java.lang.String getText()

  Returns the body text of the current page

### verifyEquals

    public void verifyEquals(java.lang.Object s1,
                             java.lang.Object s2)

  Like assertEquals, but fails at the end of the test (during tearDown)

### verifyEquals

    public void verifyEquals(boolean s1,
                             boolean s2)

  Like assertEquals, but fails at the end of the test (during tearDown)

### assertEquals

    public static void assertEquals(java.lang.Object s1,
                                    java.lang.Object s2)

  Like JUnit's Assert.assertEquals, but knows how to compare string arrays

### assertEquals

    public static void assertEquals(java.lang.String s1,
                                    java.lang.String s2)

  Like JUnit's Assert.assertEquals, but handles "regexp:" strings like HTML Selenese

### assertEquals

    public static void assertEquals(java.lang.String s1,
                                    java.lang.String[] s2)

  Like JUnit's Assert.assertEquals, but joins the string array with commas, and handles "regexp:" strings like HTML Selenese

### seleniumEquals

    public static boolean seleniumEquals(java.lang.String expectedPattern,
                                         java.lang.String actual)

  Compares two strings, but handles "regexp:" strings like HTML Selenese

  Parameters:
    `expectedPattern` -
    `actual` -
  Returns:
    true if actual matches the expectedPattern, or false otherwise

### seleniumEquals

    public static boolean seleniumEquals(java.lang.Object expected,
                                         java.lang.Object actual)

  Compares two objects, but handles "regexp:" strings like HTML Selenese

  Returns:
    true if actual matches the expectedPattern, or false otherwise
  See Also:
    `seleniumEquals(String, String)`

### assertEquals

    public static void assertEquals(java.lang.String[] s1,
                                    java.lang.String[] s2)

  Asserts that two string arrays have identical string contents

### verifyEquals

    public void verifyEquals(java.lang.String[] s1,
                             java.lang.String[] s2)

  Asserts that two string arrays have identical string contents (fails at the end of the test, during tearDown)

### join

    public static java.lang.String join(java.lang.String[] sa,
                                        char c)

### verifyNotEquals

    public void verifyNotEquals(java.lang.Object s1,
                                java.lang.Object s2)

  Like assertNotEquals, but fails at the end of the test (during tearDown)

### verifyNotEquals

    public void verifyNotEquals(boolean s1,
                                boolean s2)

  Like assertNotEquals, but fails at the end of the test (during tearDown)

### assertNotEquals

    public static void assertNotEquals(java.lang.Object obj1,
                                       java.lang.Object obj2)

  Asserts that two objects are not the same (compares using .equals())

### fail

    public static void fail(java.lang.String message)

### assertTrue

    public static void assertTrue(java.lang.String message,
                                  boolean condition)

### assertTrue

    public static void assertTrue(boolean condition)

### assertFalse

    public static void assertFalse(java.lang.String message,
                                   boolean condition)

### assertFalse

    public static void assertFalse(boolean condition)

### assertNotEquals

    public static void assertNotEquals(boolean b1,
                                       boolean b2)

  Asserts that two booleans are not the same

### pause

    public void pause(int millisecs)

  Sleeps for the specified number of milliseconds

### checkForVerificationErrors

    public void checkForVerificationErrors()

  Asserts that there were no verification errors during the current test, failing immediately if any are found

### clearVerificationErrors

    public void clearVerificationErrors()

  Clears out the list of verification errors

### tearDown

    public void tearDown()
                  throws java.lang.Exception

  checks for verification errors and stops the browser

  Throws:
    `java.lang.Exception`

### isCaptureScreenShotOnFailure

    protected boolean isCaptureScreenShotOnFailure()

### setCaptureScreenShotOnFailure

    protected void setCaptureScreenShotOnFailure(boolean captureScreetShotOnFailure)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009. All Rights Reserved.