org.zkoss.ztl
Class ZKSeleneseTestBase

java.lang.Object
  extended by org.zkoss.ztl.ZKSeleneseTestBase

public class ZKSeleneseTestBase
extends java.lang.Object

This is a copy of SeleneseTestCaseBase.java and improve the log mechanism.

Author:
jumperchen

Field Summary
protected  java.lang.ThreadLocal<com.thoughtworks.selenium.Selenium> selenium
          Use this object to run all of your selenium tests
 
Constructor Summary
ZKSeleneseTestBase()
           
 
Method Summary
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 message, 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)
          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 assertEquals(java.lang.String message, java.lang.String s1, java.lang.String s2)
          Like JUnit's Assert.assertEquals, but 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 assertNotEquals(java.lang.String message, 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 actual, java.lang.String expectedPattern)
          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 verifyContains(java.lang.String message, java.lang.String s1, java.lang.String s2, com.thoughtworks.selenium.Selenium selenium)
          Like assertEquals, but fails at the end of the test (during tearDown)
 void verifyEquals(boolean s1, boolean s2, com.thoughtworks.selenium.Selenium selenium)
          Like assertEquals, but fails at the end of the test (during tearDown)
 void verifyEquals(java.lang.Object s1, java.lang.Object s2, com.thoughtworks.selenium.Selenium selenium)
          Like assertEquals, but fails at the end of the test (during tearDown)
 void verifyEquals(java.lang.String[] s1, java.lang.String[] s2, com.thoughtworks.selenium.Selenium selenium)
          Asserts that two string arrays have identical string contents (fails at the end of the test, during tearDown)
 void verifyEquals(java.lang.String message, boolean s1, boolean s2, com.thoughtworks.selenium.Selenium selenium)
          Like assertEquals, but fails at the end of the test (during tearDown)
 void verifyEquals(java.lang.String message, java.lang.Object s1, java.lang.Object s2, com.thoughtworks.selenium.Selenium selenium)
          Like assertEquals, but fails at the end of the test (during tearDown)
 void verifyFalse(java.lang.String message, boolean b, com.thoughtworks.selenium.Selenium selenium)
          Like assertFalse, but fails at the end of the test (during tearDown)
 void verifyNotContains(java.lang.String message, java.lang.String s1, java.lang.String s2, com.thoughtworks.selenium.Selenium selenium)
          Like assertNotEquals, but fails at the end of the test (during tearDown)
 void verifyNotEquals(boolean s1, boolean s2, com.thoughtworks.selenium.Selenium selenium)
          Like assertNotEquals, but fails at the end of the test (during tearDown)
 void verifyNotEquals(java.lang.Object s1, java.lang.Object s2, com.thoughtworks.selenium.Selenium selenium)
          Like assertNotEquals, but fails at the end of the test (during tearDown)
 void verifyNotEquals(java.lang.String message, boolean s1, boolean s2, com.thoughtworks.selenium.Selenium selenium)
          Like assertNotEquals, but fails at the end of the test (during tearDown)
 void verifyNotEquals(java.lang.String message, java.lang.Object s1, java.lang.Object s2, com.thoughtworks.selenium.Selenium selenium)
          Like assertNotEquals, but fails at the end of the test (during tearDown)
 void verifyTrue(java.lang.String message, boolean b, com.thoughtworks.selenium.Selenium selenium)
          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 java.lang.ThreadLocal<com.thoughtworks.selenium.Selenium> selenium
Use this object to run all of your selenium tests

Constructor Detail

ZKSeleneseTestBase

public ZKSeleneseTestBase()
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(java.lang.String message,
                       boolean b,
                       com.thoughtworks.selenium.Selenium selenium)
Like assertTrue, but fails at the end of the test (during tearDown)


verifyFalse

public void verifyFalse(java.lang.String message,
                        boolean b,
                        com.thoughtworks.selenium.Selenium selenium)
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,
                         com.thoughtworks.selenium.Selenium selenium)
Like assertEquals, but fails at the end of the test (during tearDown)


verifyEquals

public void verifyEquals(java.lang.String message,
                         java.lang.Object s1,
                         java.lang.Object s2,
                         com.thoughtworks.selenium.Selenium selenium)
Like assertEquals, but fails at the end of the test (during tearDown)


verifyContains

public void verifyContains(java.lang.String message,
                           java.lang.String s1,
                           java.lang.String s2,
                           com.thoughtworks.selenium.Selenium selenium)
Like assertEquals, but fails at the end of the test (during tearDown)


verifyNotContains

public void verifyNotContains(java.lang.String message,
                              java.lang.String s1,
                              java.lang.String s2,
                              com.thoughtworks.selenium.Selenium selenium)
Like assertNotEquals, but fails at the end of the test (during tearDown)


verifyEquals

public void verifyEquals(boolean s1,
                         boolean s2,
                         com.thoughtworks.selenium.Selenium selenium)
Like assertEquals, but fails at the end of the test (during tearDown)


verifyEquals

public void verifyEquals(java.lang.String message,
                         boolean s1,
                         boolean s2,
                         com.thoughtworks.selenium.Selenium selenium)
Like assertEquals, but fails at the end of the test (during tearDown)


assertEquals

public static void assertEquals(java.lang.String message,
                                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 message,
                                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 actual,
                                     java.lang.String expectedPattern)
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,
                         com.thoughtworks.selenium.Selenium selenium)
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,
                            com.thoughtworks.selenium.Selenium selenium)
Like assertNotEquals, but fails at the end of the test (during tearDown)


verifyNotEquals

public void verifyNotEquals(java.lang.String message,
                            java.lang.Object s1,
                            java.lang.Object s2,
                            com.thoughtworks.selenium.Selenium selenium)
Like assertNotEquals, but fails at the end of the test (during tearDown)


verifyNotEquals

public void verifyNotEquals(boolean s1,
                            boolean s2,
                            com.thoughtworks.selenium.Selenium selenium)
Like assertNotEquals, but fails at the end of the test (during tearDown)


verifyNotEquals

public void verifyNotEquals(java.lang.String message,
                            boolean s1,
                            boolean s2,
                            com.thoughtworks.selenium.Selenium selenium)
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())


assertNotEquals

public static void assertNotEquals(java.lang.String message,
                                   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)


Copyright © 2014. All Rights Reserved.