edu.samplu.common
Class ITUtil

java.lang.Object
  extended by edu.samplu.common.ITUtil

public class ITUtil
extends Object

Common selenium test methods that should be reused rather than recreated for each test.

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

Field Summary
static String DEFAULT_BASE_URL
           
static String DEFAULT_WAIT_FOR_PAGE_TO_LOAD_TIMEOUT
           
static String DIV_ERROR_LOCATOR
           
static String DIV_EXCOL_LOCATOR
           
static String DONT_TEAR_DOWN_PROPERTY
           
static String DTS
           
static String DTS_TWO
           
static String HUB_DRIVER_PROPERTY
           
static String HUB_PROPERTY
           
static String HUB_URL_PROPERTY
           
static String KUALI_PORTAL_TITLE
           
static String PORTAL
           
static String PORTAL_URL
           
static String PORTAL_URL_ENCODED
           
static String REMOTE_AUTOLOGIN_PROPERTY
           
static String REMOTE_PUBLIC_URL_PROPERTY
           
static int WAIT_DEFAULT_SECONDS
           
static String WAIT_TO_END_TEST
           
 
Constructor Summary
ITUtil()
           
 
Method Summary
static void assertDocFinal(com.thoughtworks.selenium.Selenium selenium, String docId)
          "FINAL", selenium.getText("//table[@id='row']/tbody/tr[1]/td[4]"
protected static String blanketApprovalCleanUpErrorText(String errorText)
           
static void blanketApprove(com.thoughtworks.selenium.Selenium selenium)
          Generic blanket approve behavior
static void checkErrorMessageItem(com.thoughtworks.selenium.Selenium selenium, String message)
          "//li[@class='uif-errorMessageItem']"
static void checkForIncidentReport(com.thoughtworks.selenium.Selenium selenium, String linkLocator)
          Check the selenium contents for an Incident Report failure with Incident Report Details
static void checkForIncidentReport(com.thoughtworks.selenium.Selenium selenium, String linkLocator, String message)
          Fails if a Incident Report is detected, extracting and reporting the View Id, Document Id, and StackTrace
protected static void checkForIncidentReport(String contents, String linkLocator, String message)
           
static boolean dontTearDownPropertyNotSet()
          Setting the JVM arg remote.driver.dontTearDown to y or t leaves the browser window open when the test has completed.
static String getBaseUrlString()
          In order to run as a smoke test the ability to set the baseUrl via the JVM arg remote.public.url is required.
static String getHubUrlString()
          In order to run as a smoke test under selenium grid the ability to set the hubUrl via the JVM arg remote.public.hub is required.
static org.openqa.selenium.WebDriver getWebDriver()
          remote.public.driver set to chrome or firefox (null assumes firefox) if remote.public.hub is set a RemoteWebDriver is created (Selenium Grid)
static void login(org.openqa.selenium.WebDriver driver, String userName)
          If the JVM arg remote.autologin is set, auto login as admin will not be done.
static void loginSe(com.thoughtworks.selenium.Selenium selenium)
          If the JVM arg remote.autologin is set, auto login as admin will not be done.
static void loginSe(com.thoughtworks.selenium.Selenium selenium, String user)
          If the JVM arg remote.autologin is set, auto login as admin will not be done.
static String prettyHttp(String baseUrl)
          Append http:// if not present.
static String stackTrace(Throwable throwable)
          Write the given stack trace into a String
static void waitAndClick(com.thoughtworks.selenium.Selenium selenium, String elementLocator)
          Wait 60 seconds for the elementLocator to be present or fail.
static void waitAndClick(com.thoughtworks.selenium.Selenium selenium, String elementLocator, int seconds)
          Wait the given seconds for the elementLocator to be present or fail
static void waitAndClick(com.thoughtworks.selenium.Selenium selenium, String elementLocator, int seconds, String message)
          Wait the given seconds for the elementLocator to be present or fail
static void waitAndClick(com.thoughtworks.selenium.Selenium selenium, String elementLocator, String message)
          Wait 60 seconds for the elementLocator to be present or fail.
static void waitAndType(com.thoughtworks.selenium.Selenium selenium, String elementLocator, int seconds, String text, String message)
          Wait the given seconds for the elementLocator to be present or fail, when present type the text.
static void waitAndType(com.thoughtworks.selenium.Selenium selenium, String elementLocator, String text)
          Wait the 60 seconds for the elementLocator to be present or fail, when present type the text.
static void waitAndType(com.thoughtworks.selenium.Selenium selenium, String elementLocator, String text, String message)
          Wait the 60 seconds for the elementLocator to be present or fail, when present type the text.
static void waitForElement(com.thoughtworks.selenium.Selenium selenium, String elementLocator)
          Wait 60 seconds for the elementLocator to be present or fail
static void waitForElement(com.thoughtworks.selenium.Selenium selenium, String elementLocator, int seconds)
          Wait the given seconds for the elementLocator to be present or fail
static void waitForElement(com.thoughtworks.selenium.Selenium selenium, String elementLocator, int seconds, String message)
          Wait the given seconds for the elementLocator to be present or fail
static void waitForElement(com.thoughtworks.selenium.Selenium selenium, String elementLocator, String message)
          Wait 60 seconds for the elementLocator to be present or fail
static void waitForElementVisible(com.thoughtworks.selenium.Selenium selenium, String elementLocator)
          Wait the given seconds for the elementLocator to be present or fail
static void waitForElementVisible(com.thoughtworks.selenium.Selenium selenium, String elementLocator, int seconds, String message)
          Wait the given seconds for the elementLocator to be present or fail
static void waitForElementVisible(com.thoughtworks.selenium.Selenium selenium, String elementLocator, String message)
          Wait 60 seconds for the elementLocator to be present or fail including the given message
static void waitForTitleToEqual(com.thoughtworks.selenium.Selenium selenium, String title)
          Wait for 60 seconds for the selenium.getTitle to match the given title then fail.
static void waitForTitleToEqual(com.thoughtworks.selenium.Selenium selenium, String title, String message)
          Wait for 60 seconds for the selenium.getTitle to match the given title then fail including the given message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KUALI_PORTAL_TITLE

public static final String KUALI_PORTAL_TITLE
See Also:
Constant Field Values

DEFAULT_BASE_URL

public static final String DEFAULT_BASE_URL
See Also:
Constant Field Values

PORTAL

public static final String PORTAL
See Also:
Constant Field Values

PORTAL_URL

public static final String PORTAL_URL

PORTAL_URL_ENCODED

public static final String PORTAL_URL_ENCODED

DTS

public static final String DTS

DTS_TWO

public static final String DTS_TWO

WAIT_TO_END_TEST

public static String WAIT_TO_END_TEST

DIV_ERROR_LOCATOR

public static final String DIV_ERROR_LOCATOR
See Also:
Constant Field Values

DIV_EXCOL_LOCATOR

public static final String DIV_EXCOL_LOCATOR
See Also:
Constant Field Values

WAIT_DEFAULT_SECONDS

public static final int WAIT_DEFAULT_SECONDS
See Also:
Constant Field Values

DEFAULT_WAIT_FOR_PAGE_TO_LOAD_TIMEOUT

public static final String DEFAULT_WAIT_FOR_PAGE_TO_LOAD_TIMEOUT
See Also:
Constant Field Values

REMOTE_PUBLIC_URL_PROPERTY

public static final String REMOTE_PUBLIC_URL_PROPERTY
See Also:
Constant Field Values

REMOTE_AUTOLOGIN_PROPERTY

public static final String REMOTE_AUTOLOGIN_PROPERTY
See Also:
Constant Field Values

HUB_PROPERTY

public static final String HUB_PROPERTY
See Also:
Constant Field Values

HUB_DRIVER_PROPERTY

public static final String HUB_DRIVER_PROPERTY
See Also:
Constant Field Values

HUB_URL_PROPERTY

public static final String HUB_URL_PROPERTY
See Also:
Constant Field Values

DONT_TEAR_DOWN_PROPERTY

public static final String DONT_TEAR_DOWN_PROPERTY
See Also:
Constant Field Values
Constructor Detail

ITUtil

public ITUtil()
Method Detail

assertDocFinal

public static void assertDocFinal(com.thoughtworks.selenium.Selenium selenium,
                                  String docId)
"FINAL", selenium.getText("//table[@id='row']/tbody/tr[1]/td[4]"

Parameters:
selenium -
docId -

blanketApprovalCleanUpErrorText

protected static String blanketApprovalCleanUpErrorText(String errorText)

blanketApprove

public static void blanketApprove(com.thoughtworks.selenium.Selenium selenium)
                           throws InterruptedException
Generic blanket approve behavior

Parameters:
selenium -
Throws:
InterruptedException

checkErrorMessageItem

public static void checkErrorMessageItem(com.thoughtworks.selenium.Selenium selenium,
                                         String message)
"//li[@class='uif-errorMessageItem']"

Parameters:
selenium -
message -

getBaseUrlString

public static String getBaseUrlString()
In order to run as a smoke test the ability to set the baseUrl via the JVM arg remote.public.url is required. Trailing slashes are trimmed. If the remote.public.url does not start with http:// it will be added.

Returns:
http://localhost:8080/kr-dev by default else the value of remote.public.url

prettyHttp

public static String prettyHttp(String baseUrl)
Append http:// if not present. Remove trailing /

Parameters:
baseUrl -
Returns:

getHubUrlString

public static String getHubUrlString()
In order to run as a smoke test under selenium grid the ability to set the hubUrl via the JVM arg remote.public.hub is required. Trailing slashes are trimmed. If the remote.public.hub does not start with http:// it will be added.

Returns:
http://localhost:4444/wd/hub by default else the value of remote.public.hub

getWebDriver

public static org.openqa.selenium.WebDriver getWebDriver()
remote.public.driver set to chrome or firefox (null assumes firefox) if remote.public.hub is set a RemoteWebDriver is created (Selenium Grid)

Returns:
WebDriver or null if unable to create

loginSe

public static void loginSe(com.thoughtworks.selenium.Selenium selenium)
If the JVM arg remote.autologin is set, auto login as admin will not be done.

Parameters:
selenium - to login with

login

public static void login(org.openqa.selenium.WebDriver driver,
                         String userName)
                  throws InterruptedException
If the JVM arg remote.autologin is set, auto login as admin will not be done.

Parameters:
driver -
userName -
Throws:
InterruptedException

loginSe

public static void loginSe(com.thoughtworks.selenium.Selenium selenium,
                           String user)
If the JVM arg remote.autologin is set, auto login as admin will not be done.

Parameters:
selenium - to login with

stackTrace

public static String stackTrace(Throwable throwable)
Write the given stack trace into a String

Parameters:
throwable - whose stack trace to return
Returns:
String of the given throwable's stack trace.

dontTearDownPropertyNotSet

public static boolean dontTearDownPropertyNotSet()
Setting the JVM arg remote.driver.dontTearDown to y or t leaves the browser window open when the test has completed. Valuable when debugging, updating, or creating new tests. When implementing your own tearDown method rather than an inherited one, it is a common courtesy to include this check and not stop and shutdown the browser window to make it easy debug or update your test.

Returns:
true if the dontTearDownProperty is not set.

waitAndClick

public static void waitAndClick(com.thoughtworks.selenium.Selenium selenium,
                                String elementLocator)
                         throws InterruptedException
Wait 60 seconds for the elementLocator to be present or fail. Click if present

Parameters:
selenium -
elementLocator -
Throws:
InterruptedException

waitAndClick

public static void waitAndClick(com.thoughtworks.selenium.Selenium selenium,
                                String elementLocator,
                                String message)
                         throws InterruptedException
Wait 60 seconds for the elementLocator to be present or fail. Click if present

Parameters:
selenium -
elementLocator -
message -
Throws:
InterruptedException

waitAndClick

public static void waitAndClick(com.thoughtworks.selenium.Selenium selenium,
                                String elementLocator,
                                int seconds)
                         throws InterruptedException
Wait the given seconds for the elementLocator to be present or fail

Parameters:
selenium -
elementLocator -
seconds -
Throws:
InterruptedException

waitAndClick

public static void waitAndClick(com.thoughtworks.selenium.Selenium selenium,
                                String elementLocator,
                                int seconds,
                                String message)
                         throws InterruptedException
Wait the given seconds for the elementLocator to be present or fail

Parameters:
selenium -
elementLocator -
seconds -
message -
Throws:
InterruptedException

waitAndType

public static void waitAndType(com.thoughtworks.selenium.Selenium selenium,
                               String elementLocator,
                               String text)
                        throws InterruptedException
Wait the 60 seconds for the elementLocator to be present or fail, when present type the text.

Parameters:
selenium -
elementLocator -
text -
Throws:
InterruptedException

waitAndType

public static void waitAndType(com.thoughtworks.selenium.Selenium selenium,
                               String elementLocator,
                               String text,
                               String message)
                        throws InterruptedException
Wait the 60 seconds for the elementLocator to be present or fail, when present type the text. Include failure message on fail.

Parameters:
selenium -
elementLocator -
text -
message -
Throws:
InterruptedException

waitAndType

public static void waitAndType(com.thoughtworks.selenium.Selenium selenium,
                               String elementLocator,
                               int seconds,
                               String text,
                               String message)
                        throws InterruptedException
Wait the given seconds for the elementLocator to be present or fail, when present type the text.

Parameters:
selenium -
elementLocator -
seconds -
text -
message -
Throws:
InterruptedException

waitForElement

public static void waitForElement(com.thoughtworks.selenium.Selenium selenium,
                                  String elementLocator)
                           throws InterruptedException
Wait 60 seconds for the elementLocator to be present or fail

Parameters:
selenium -
elementLocator -
Throws:
InterruptedException

waitForElement

public static void waitForElement(com.thoughtworks.selenium.Selenium selenium,
                                  String elementLocator,
                                  String message)
                           throws InterruptedException
Wait 60 seconds for the elementLocator to be present or fail

Parameters:
selenium -
elementLocator -
message -
Throws:
InterruptedException

waitForElement

public static void waitForElement(com.thoughtworks.selenium.Selenium selenium,
                                  String elementLocator,
                                  int seconds)
                           throws InterruptedException
Wait the given seconds for the elementLocator to be present or fail

Parameters:
selenium -
elementLocator -
seconds -
Throws:
InterruptedException

waitForElement

public static void waitForElement(com.thoughtworks.selenium.Selenium selenium,
                                  String elementLocator,
                                  int seconds,
                                  String message)
                           throws InterruptedException
Wait the given seconds for the elementLocator to be present or fail

Parameters:
selenium -
elementLocator -
seconds -
message -
Throws:
InterruptedException

waitForElementVisible

public static void waitForElementVisible(com.thoughtworks.selenium.Selenium selenium,
                                         String elementLocator)
                                  throws InterruptedException
Wait the given seconds for the elementLocator to be present or fail

Parameters:
selenium -
elementLocator -
Throws:
InterruptedException

waitForElementVisible

public static void waitForElementVisible(com.thoughtworks.selenium.Selenium selenium,
                                         String elementLocator,
                                         String message)
                                  throws InterruptedException
Wait 60 seconds for the elementLocator to be present or fail including the given message

Parameters:
selenium -
elementLocator -
message -
Throws:
InterruptedException

waitForElementVisible

public static void waitForElementVisible(com.thoughtworks.selenium.Selenium selenium,
                                         String elementLocator,
                                         int seconds,
                                         String message)
                                  throws InterruptedException
Wait the given seconds for the elementLocator to be present or fail

Parameters:
selenium -
elementLocator -
seconds -
Throws:
InterruptedException

waitForTitleToEqual

public static void waitForTitleToEqual(com.thoughtworks.selenium.Selenium selenium,
                                       String title)
                                throws InterruptedException
Wait for 60 seconds for the selenium.getTitle to match the given title then fail.

Parameters:
selenium -
title -
Throws:
InterruptedException

waitForTitleToEqual

public static void waitForTitleToEqual(com.thoughtworks.selenium.Selenium selenium,
                                       String title,
                                       String message)
                                throws InterruptedException
Wait for 60 seconds for the selenium.getTitle to match the given title then fail including the given message.

Parameters:
selenium -
title -
message -
Throws:
InterruptedException

checkForIncidentReport

public static void checkForIncidentReport(com.thoughtworks.selenium.Selenium selenium,
                                          String linkLocator)
Check the selenium contents for an Incident Report failure with Incident Report Details

Parameters:
selenium -
linkLocator -

checkForIncidentReport

public static void checkForIncidentReport(com.thoughtworks.selenium.Selenium selenium,
                                          String linkLocator,
                                          String message)
Fails if a Incident Report is detected, extracting and reporting the View Id, Document Id, and StackTrace

Parameters:
selenium -
linkLocator - used only in the failure message

checkForIncidentReport

protected static void checkForIncidentReport(String contents,
                                             String linkLocator,
                                             String message)


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