edu.samplu.common
Class WebDriverUtil

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

public class WebDriverUtil
extends Object

The goal of the WebDriverUtil class is to invert the dependencies on WebDriver from WebDriverLegacyITBase for reuse without having to extend WebDriverLegacyITBase. For the first example see waitFor

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

Field Summary
static int DEFAULT_IMPLICIT_WAIT_TIME
          TODO apparent dup WebDriverITBase.DEFAULT_WAIT_SEC TODO parametrize for JVM Arg 30 Seconds
static boolean JGROWL_ERROR_FAILURE
          false TODO upgrade to config via JVM param.
static boolean jGrowlEnabled
           
static String JS_HIGHLIGHT_BACKGROUND
          green
static String JS_HIGHLIGHT_BOARDER
          green
static String JS_HIGHLIGHT_INPUT_PROPERTY
          -Dremote.driver.highlight.input=
static int JS_HIGHLIGHT_MS
          400 milliseconds
static String JS_HIGHLIGHT_MS_PROPERTY
          -Dremote.driver.highlight.ms=
static String JS_HIGHLIGHT_PROPERTY
          -Dremote.driver.highlight=true to enable highlighting of elements as selenium runs
static boolean jsHighlightEnabled
           
static String PROXY_HOST_PROPERTY
          local proxy used for running tests thru jmeter.
static String REMOTE_DRIVER_SAUCELABS_PROPERTY
          Set -Dremote.driver.saucelabs for running on saucelabs
static String REMOTE_JGROWL_ENABLED
          Set -Dremote.jgrowl.enabled=
static String REMOTE_LOGIN_UIF
          Set -Dremote.login.uif=KNS to use old login screen.
static String REMOTE_PUBLIC_CHROME
          Set -Dremote.public.chrome= or WEBDRIVER_CHROME_DRIVER
static int SETUP_URL_LOAD_WAIT_SECONDS
          Time to wait for the URL used in setup to load.
static int SHORT_IMPLICIT_WAIT_TIME
          TODO introduce SHORT_IMPLICIT_WAIT_TIME with param in WebDriverITBase TODO parametrize for JVM Arg 1 Second
static String WEBDRIVER_CHROME_DRIVER
          Selenium's webdriver.chrome.driver parameter, you can set -Dwebdriver.chrome.driver= or Rice's REMOTE_PUBLIC_CHROME
 
Constructor Summary
WebDriverUtil()
           
 
Method Summary
static void checkForIncidentReport(org.openqa.selenium.WebDriver driver, String locator, Failable failable, String message)
           
static org.openqa.selenium.chrome.ChromeDriverService chromeDriverCreateCheck()
           
static String deLinespace(String contents)
           
static String determineUser(String testParam)
           
static void failOnMatchedJira(String contents, Failable failable)
           
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) if proxy.host is set, the web driver is setup to use a proxy
static void highlightElement(org.openqa.selenium.WebDriver webDriver, org.openqa.selenium.WebElement webElement)
           
static boolean isKradLogin()
          Use the KRAD Login Screen or the old KNS Login Screen
static void jGrowl(org.openqa.selenium.WebDriver driver, String jGrowlHeader, boolean sticky, String message)
           
static void jGrowl(org.openqa.selenium.WebDriver driver, String jGrowlHeader, boolean sticky, String message, Throwable t)
           
static void jGrowlException(Throwable t)
           
static void kradLogin(org.openqa.selenium.WebDriver driver, String userName, Failable failable)
          Logs in using the KRAD Login Page If the JVM arg remote.autologin is set, auto login as admin will not be done.
static void login(org.openqa.selenium.WebDriver driver, String userName, Failable failable)
          Logs into the Rice portal using the KNS Style Login Page.
static void loginKradOrKns(org.openqa.selenium.WebDriver driver, String user, Failable failable)
           
protected static void selectFrameSafe(org.openqa.selenium.WebDriver driver, String locator)
           
static org.openqa.selenium.WebDriver setUp(String username, String url)
          Setup the WebDriver test, login, and load the given web page
static org.openqa.selenium.WebDriver setUp(String username, String url, String className, String testName)
          Setup the WebDriver test, login, and load the given web page
static void tearDown(boolean passed, String sessionId, String testParam, String userParam)
           
static void waitFor(org.openqa.selenium.WebDriver driver, int waitSeconds, org.openqa.selenium.By by, String message)
          Wait for the given amount of seconds, for the given by, using the given driver.
static void waitFors(org.openqa.selenium.WebDriver driver, int waitSeconds, org.openqa.selenium.By by, String message)
          Wait for the given amount of seconds, for the given by, using the given driver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jGrowlEnabled

public static boolean jGrowlEnabled

jsHighlightEnabled

public static boolean jsHighlightEnabled

DEFAULT_IMPLICIT_WAIT_TIME

public static int DEFAULT_IMPLICIT_WAIT_TIME
TODO apparent dup WebDriverITBase.DEFAULT_WAIT_SEC TODO parametrize for JVM Arg 30 Seconds


JGROWL_ERROR_FAILURE

public static final boolean JGROWL_ERROR_FAILURE
false TODO upgrade to config via JVM param.

See Also:
Constant Field Values

JS_HIGHLIGHT_BACKGROUND

public static final String JS_HIGHLIGHT_BACKGROUND
green

See Also:
Constant Field Values

JS_HIGHLIGHT_BOARDER

public static final String JS_HIGHLIGHT_BOARDER
green

See Also:
Constant Field Values

JS_HIGHLIGHT_MS

public static final int JS_HIGHLIGHT_MS
400 milliseconds

See Also:
Constant Field Values

JS_HIGHLIGHT_MS_PROPERTY

public static final String JS_HIGHLIGHT_MS_PROPERTY
-Dremote.driver.highlight.ms=

See Also:
Constant Field Values

JS_HIGHLIGHT_PROPERTY

public static final String JS_HIGHLIGHT_PROPERTY
-Dremote.driver.highlight=true to enable highlighting of elements as selenium runs

See Also:
Constant Field Values

JS_HIGHLIGHT_INPUT_PROPERTY

public static final String JS_HIGHLIGHT_INPUT_PROPERTY
-Dremote.driver.highlight.input=

See Also:
Constant Field Values

SHORT_IMPLICIT_WAIT_TIME

public static int SHORT_IMPLICIT_WAIT_TIME
TODO introduce SHORT_IMPLICIT_WAIT_TIME with param in WebDriverITBase TODO parametrize for JVM Arg 1 Second


REMOTE_DRIVER_SAUCELABS_PROPERTY

public static final String REMOTE_DRIVER_SAUCELABS_PROPERTY
Set -Dremote.driver.saucelabs for running on saucelabs

See Also:
Constant Field Values

WEBDRIVER_CHROME_DRIVER

public static final String WEBDRIVER_CHROME_DRIVER
Selenium's webdriver.chrome.driver parameter, you can set -Dwebdriver.chrome.driver= or Rice's REMOTE_PUBLIC_CHROME

See Also:
Constant Field Values

REMOTE_JGROWL_ENABLED

public static final String REMOTE_JGROWL_ENABLED
Set -Dremote.jgrowl.enabled=

See Also:
Constant Field Values

REMOTE_LOGIN_UIF

public static final String REMOTE_LOGIN_UIF
Set -Dremote.login.uif=KNS to use old login screen. Default value = KRAD

See Also:
Constant Field Values

REMOTE_PUBLIC_CHROME

public static final String REMOTE_PUBLIC_CHROME
Set -Dremote.public.chrome= or WEBDRIVER_CHROME_DRIVER

See Also:
Constant Field Values

SETUP_URL_LOAD_WAIT_SECONDS

public static final int SETUP_URL_LOAD_WAIT_SECONDS
Time to wait for the URL used in setup to load. Sometimes this is the first hit on the app and it needs a bit longer than any other. 120 Seconds. TODO parametrize for JVM Arg

See Also:
Constant Field Values

PROXY_HOST_PROPERTY

public static final String PROXY_HOST_PROPERTY
local proxy used for running tests thru jmeter. Include host name and port number. Example: localhost:7777

See Also:
Constant Field Values
Constructor Detail

WebDriverUtil

public WebDriverUtil()
Method Detail

setUp

public static org.openqa.selenium.WebDriver setUp(String username,
                                                  String url)
                                           throws Exception
Setup the WebDriver test, login, and load the given web page

Parameters:
username -
url -
Returns:
driver
Throws:
Exception

setUp

public static org.openqa.selenium.WebDriver setUp(String username,
                                                  String url,
                                                  String className,
                                                  String testName)
                                           throws Exception
Setup the WebDriver test, login, and load the given web page

Parameters:
username -
url -
className -
testName -
Returns:
driver
Throws:
Exception

tearDown

public static void tearDown(boolean passed,
                            String sessionId,
                            String testParam,
                            String userParam)
                     throws Exception
Parameters:
passed -
sessionId -
testParam -
userParam -
Throws:
Exception

determineUser

public static String determineUser(String testParam)
Parameters:
testParam -
Returns:

checkForIncidentReport

public static void checkForIncidentReport(org.openqa.selenium.WebDriver driver,
                                          String locator,
                                          Failable failable,
                                          String message)
Parameters:
driver -
locator -
message -

chromeDriverCreateCheck

public static org.openqa.selenium.chrome.ChromeDriverService chromeDriverCreateCheck()
Returns:
chromeDriverService

jGrowl

public static void jGrowl(org.openqa.selenium.WebDriver driver,
                          String jGrowlHeader,
                          boolean sticky,
                          String message,
                          Throwable t)

jGrowl

public static void jGrowl(org.openqa.selenium.WebDriver driver,
                          String jGrowlHeader,
                          boolean sticky,
                          String message)

jGrowlException

public static void jGrowlException(Throwable t)

highlightElement

public static void highlightElement(org.openqa.selenium.WebDriver webDriver,
                                    org.openqa.selenium.WebElement webElement)

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) if proxy.host is set, the web driver is setup to use a proxy

Returns:
WebDriver or null if unable to create

kradLogin

public static void kradLogin(org.openqa.selenium.WebDriver driver,
                             String userName,
                             Failable failable)
                      throws InterruptedException
Logs in using the KRAD Login Page If the JVM arg remote.autologin is set, auto login as admin will not be done.

Parameters:
driver -
userName -
failable -
Throws:
InterruptedException

login

public static void login(org.openqa.selenium.WebDriver driver,
                         String userName,
                         Failable failable)
                  throws InterruptedException
Logs into the Rice portal using the KNS Style Login Page.

Parameters:
driver -
userName -
failable -
Throws:
InterruptedException

loginKradOrKns

public static void loginKradOrKns(org.openqa.selenium.WebDriver driver,
                                  String user,
                                  Failable failable)
                           throws InterruptedException
Throws:
InterruptedException

isKradLogin

public static boolean isKradLogin()
Use the KRAD Login Screen or the old KNS Login Screen


selectFrameSafe

protected static void selectFrameSafe(org.openqa.selenium.WebDriver driver,
                                      String locator)

waitFor

public static void waitFor(org.openqa.selenium.WebDriver driver,
                           int waitSeconds,
                           org.openqa.selenium.By by,
                           String message)
                    throws InterruptedException
Wait for the given amount of seconds, for the given by, using the given driver. The message is displayed if the by cannot be found. No action is performed on the by, so it is possible that the by found is not visible or enabled.

Parameters:
driver - WebDriver
waitSeconds - int
by - By
message - String
Throws:
InterruptedException

waitFors

public static void waitFors(org.openqa.selenium.WebDriver driver,
                            int waitSeconds,
                            org.openqa.selenium.By by,
                            String message)
                     throws InterruptedException
Wait for the given amount of seconds, for the given by, using the given driver. The message is displayed if the by cannot be found. No action is performed on the by, so it is possible that the by found is not visible or enabled.

Parameters:
driver - WebDriver
waitSeconds - int
by - By
message - String
Throws:
InterruptedException

failOnMatchedJira

public static void failOnMatchedJira(String contents,
                                     Failable failable)

deLinespace

public static String deLinespace(String contents)


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