org.kuali.rice.testtools.selenium
Class WebDriverITBase

java.lang.Object
  extended by org.kuali.rice.testtools.selenium.WebDriverITBase
All Implemented Interfaces:
Failable

public abstract class WebDriverITBase
extends Object
implements Failable

Base class for Selenium Webdriver integration tests

Author:
Kuali Rice Team (rice.collab@kuali.org)

Field Summary
 org.openqa.selenium.WebDriver driver
           
 
Constructor Summary
WebDriverITBase()
           
 
Method Summary
protected  void acceptAlert()
          Accept the javascript alert (clicking OK)
 void assertPopUpWindowUrl(org.openqa.selenium.By by, String windowName, String url)
          Assert that clicking an element causes a popup window with a specific URL
protected  void checkForIncidentReport(Failable failable)
           
protected  void checkForIncidentReport(String locator, Failable failable)
           
protected  void checkForIncidentReport(String locator, Failable failable, String message)
           
protected  void clearText(org.openqa.selenium.By by)
          Clear the text written in an input field by xpath of an element
protected  void clearTextByName(String name)
          Clear the text written in an input field by name of an element
protected  void clearTextByXpath(String locator)
          Clear the text written in an input field by xpath of an element
static void createAndStartService()
           
protected  void dismissAlert()
          Dismiss the javascript alert (clicking Cancel)
 void fail(String message)
          Fail in a framework appropriate way.
protected  String getAttribute(org.openqa.selenium.By by, String attribute)
          Get value of any attribute of an element
protected  String getAttributeByName(String name, String attribute)
          Get value of any attribute by using element name
protected  String getAttributeByXpath(String locator, String attribute)
          Get value of any attribute by using element xpath
protected  String getEval(String script)
           
abstract  String getTestUrl()
          Returns the URL to be used with this test
 String getUserName()
          Override in test to define a user other than admin
 boolean isElementPresent(org.openqa.selenium.By by)
          Check if an element is present
 boolean isElementPresentQuick(org.openqa.selenium.By by)
          Quickly check if an element is present
 void setUp()
          Setup the WebDriver test, login and load the tested web page
static void stopService()
          Tear down the WebDriver test
protected  void switchWindow()
          Switch to new window
 void tearDown()
          Tear down the WebDriver test
protected  void waitAndClick(org.openqa.selenium.By by)
           
protected  void waitAndClick(org.openqa.selenium.By by, String message)
           
protected  void waitAndClick(String locator)
           
protected  void waitAndClick(String locator, String message)
           
protected  void waitAndClickByLinkText(String text)
           
protected  void waitAndClickByLinkText(String text, String message)
           
protected  void waitAndType(org.openqa.selenium.By by, String text)
           
protected  void waitAndType(org.openqa.selenium.By by, String text, String message)
           
protected  void waitAndTypeByName(String name, String text)
           
protected  void waitAndTypeByXpath(String locator, String text)
           
protected  void waitAndTypeByXpath(String locator, String text, String message)
           
protected  void waitFor(org.openqa.selenium.By by)
           
protected  void waitFor(org.openqa.selenium.By by, String message)
          TODO Investigate using WebDriverUtil.waitFor
protected  void waitForElementPresent(String locator)
           
protected  void waitForElementPresentByName(String name)
           
protected  void waitForElementPresentByXpath(String locator)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

driver

public org.openqa.selenium.WebDriver driver
Constructor Detail

WebDriverITBase

public WebDriverITBase()
Method Detail

getTestUrl

public abstract String getTestUrl()
Returns the URL to be used with this test

Returns:
URL of the test

getUserName

public String getUserName()
Override in test to define a user other than admin

Returns:

createAndStartService

public static void createAndStartService()
                                  throws Exception
Throws:
Exception

fail

public void fail(String message)
Description copied from interface: Failable
Fail in a framework appropriate way.

Specified by:
fail in interface Failable
Parameters:
message - to display for the failure.

setUp

public void setUp()
           throws Exception
Setup the WebDriver test, login and load the tested web page

Throws:
Exception

tearDown

public void tearDown()
              throws Exception
Tear down the WebDriver test

Throws:
Exception

stopService

public static void stopService()
                        throws Exception
Tear down the WebDriver test

Throws:
Exception

isElementPresent

public boolean isElementPresent(org.openqa.selenium.By by)
Check if an element is present

This test takes a while due to the 'implicit wait' time.

Parameters:
by - The locating mechanism of the element
Returns:
true if the element is present, false otherwise

isElementPresentQuick

public boolean isElementPresentQuick(org.openqa.selenium.By by)
Quickly check if an element is present

Just like isElementPresent(org.openqa.selenium.By) but with a short 'implicit wait' time. Use this only if it is guaranteed that all elements are rendered.

Parameters:
by - The locating mechanism of the element
Returns:
true if the element is present, false otherwise

assertPopUpWindowUrl

public void assertPopUpWindowUrl(org.openqa.selenium.By by,
                                 String windowName,
                                 String url)
Assert that clicking an element causes a popup window with a specific URL

Parameters:
by - The locating mechanism of the element to be clicked
windowName - The name of the popup window
url - The URL of the popup window

waitFor

protected void waitFor(org.openqa.selenium.By by)
                throws InterruptedException
Parameters:
by - The locating mechanism of the element
Throws:
InterruptedException

waitFor

protected void waitFor(org.openqa.selenium.By by,
                       String message)
                throws InterruptedException
TODO Investigate using WebDriverUtil.waitFor

Parameters:
by - The locating mechanism of the element
message - User defined message to display
Throws:
InterruptedException

waitAndType

protected void waitAndType(org.openqa.selenium.By by,
                           String text)
                    throws InterruptedException
Parameters:
by - The locating mechanism of the element
text - The text to type
Throws:
InterruptedException

waitAndType

protected void waitAndType(org.openqa.selenium.By by,
                           String text,
                           String message)
                    throws InterruptedException
Parameters:
by - The locating mechanism of the element
text - The text to type
message - User defined message to display
Throws:
InterruptedException

waitAndTypeByXpath

protected void waitAndTypeByXpath(String locator,
                                  String text)
                           throws InterruptedException
Parameters:
locator - The locating mechanism of the element
text - The text to type
Throws:
InterruptedException

waitAndTypeByXpath

protected void waitAndTypeByXpath(String locator,
                                  String text,
                                  String message)
                           throws InterruptedException
Parameters:
locator - The locating mechanism of the element
text - The text to type
message - User defined message to display
Throws:
InterruptedException

waitAndTypeByName

protected void waitAndTypeByName(String name,
                                 String text)
                          throws InterruptedException
Parameters:
name - The name of the element
text - The text to type
Throws:
InterruptedException

clearTextByName

protected void clearTextByName(String name)
                        throws InterruptedException
Clear the text written in an input field by name of an element

Parameters:
name - The name of the element
Throws:
InterruptedException

clearTextByXpath

protected void clearTextByXpath(String locator)
                         throws InterruptedException
Clear the text written in an input field by xpath of an element

Parameters:
locator - The locating mechanism of the element
Throws:
InterruptedException

clearText

protected void clearText(org.openqa.selenium.By by)
                  throws InterruptedException
Clear the text written in an input field by xpath of an element

Parameters:
by - method used for finding the element
Throws:
InterruptedException

dismissAlert

protected void dismissAlert()
Dismiss the javascript alert (clicking Cancel)


acceptAlert

protected void acceptAlert()
Accept the javascript alert (clicking OK)


getEval

protected String getEval(String script)

switchWindow

protected void switchWindow()
Switch to new window


getAttributeByName

protected String getAttributeByName(String name,
                                    String attribute)
                             throws InterruptedException
Get value of any attribute by using element name

Parameters:
name - name of an element
attribute - the name of an attribute whose value is to be retrieved
Throws:
InterruptedException

getAttributeByXpath

protected String getAttributeByXpath(String locator,
                                     String attribute)
                              throws InterruptedException
Get value of any attribute by using element xpath

Parameters:
locator - locating mechanism of an element
attribute - the name of an attribute whose value is to be retrieved
Throws:
InterruptedException

getAttribute

protected String getAttribute(org.openqa.selenium.By by,
                              String attribute)
                       throws InterruptedException
Get value of any attribute of an element

Parameters:
by - method used for finding the element
attribute - the name of an attribute whose value is to be retrieved
Throws:
InterruptedException

waitAndClickByLinkText

protected void waitAndClickByLinkText(String text)
                               throws InterruptedException
Parameters:
text - text of the link
Throws:
InterruptedException

waitAndClickByLinkText

protected void waitAndClickByLinkText(String text,
                                      String message)
                               throws InterruptedException
Parameters:
text - text of the link
message - user defined message to display
Throws:
InterruptedException

waitAndClick

protected void waitAndClick(org.openqa.selenium.By by)
                     throws InterruptedException
Parameters:
by - method used for finding the element
Throws:
InterruptedException

waitAndClick

protected void waitAndClick(org.openqa.selenium.By by,
                            String message)
                     throws InterruptedException
Parameters:
by - method used for finding the element
message - user defined message to display
Throws:
InterruptedException

waitAndClick

protected void waitAndClick(String locator)
                     throws InterruptedException
Parameters:
locator - mechanism to locate element by xpath
Throws:
InterruptedException

waitAndClick

protected void waitAndClick(String locator,
                            String message)
                     throws InterruptedException
Parameters:
locator - mechanism to locate element by xpath
message - user defined message to display
Throws:
InterruptedException

waitForElementPresent

protected void waitForElementPresent(String locator)
                              throws InterruptedException
Parameters:
locator - mechanism to locate element by xpath
Throws:
InterruptedException

waitForElementPresentByXpath

protected void waitForElementPresentByXpath(String locator)
                                     throws InterruptedException
Parameters:
locator - mechanism to locate element by xpath
Throws:
InterruptedException

waitForElementPresentByName

protected void waitForElementPresentByName(String name)
                                    throws InterruptedException
Parameters:
name - name of an element
Throws:
InterruptedException

checkForIncidentReport

protected void checkForIncidentReport(Failable failable)

checkForIncidentReport

protected void checkForIncidentReport(String locator,
                                      Failable failable)

checkForIncidentReport

protected void checkForIncidentReport(String locator,
                                      Failable failable,
                                      String message)


Copyright © 2005-2013 The Kuali Foundation. All Rights Reserved.