com.appfoundation.automation.util
Class TestUtils

java.lang.Object
  extended by com.appfoundation.automation.util.TestUtils

public class TestUtils
extends java.lang.Object

Test Utils

This class contains static utility methods for common testing activities

Author:
john.valentino

Field Summary
private static RuntimeProperties properties
           
 
Constructor Summary
TestUtils()
           
 
Method Summary
static void click(org.openqa.selenium.WebDriver driver, java.lang.String xpath)
          Clicks the web element matching the given xpath
static void clickAt(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By by)
          This is something that was present in Selenium prior to Web Driver, which forces clicking on the element of the matching expression whether that element is clickable or whether that click would be at some other location on the screen.
static void doubleClick(org.openqa.selenium.WebDriver driver, java.lang.String xpath)
          Double-clicks on the element that matches the given xpath
static void dragAndDrop(org.openqa.selenium.WebDriver driver, java.lang.String xpath, int x, int y)
          Performs a drag and drop
static void dragAndDrop(org.openqa.selenium.WebDriver driver, org.openqa.selenium.WebElement element, int x, int y)
          Performs a drag and drop
static void waitForTextToBePresent(org.openqa.selenium.WebDriver driver, java.lang.String text, org.openqa.selenium.By by, int timeoutInSeconds)
          Waits for the text to be present
static void waitForTextValueToBePresent(org.openqa.selenium.WebDriver driver, java.lang.String text, org.openqa.selenium.By by)
          Waits for the text to be present in the specified element
static void waitForTextValueToBePresent(org.openqa.selenium.WebDriver driver, java.lang.String text, org.openqa.selenium.By by, int timeoutInSeconds)
          Waits for the text to be present in the specified element
static void waitForTextValueToBePresent(org.openqa.selenium.WebDriver driver, java.lang.String text, java.lang.String xpath)
          Waits for the text to be present in the specified element
static void waitToBeClickable(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By by)
          Waits for up to 1 second for the given element to be click-able
static void waitToBeClickable(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By by, int timeoutInSeconds)
          Waits up until the specified timeout in seconds for given element to be click-able
static void waitToBeClickable(org.openqa.selenium.WebDriver driver, java.lang.String xpath)
          Waits up to 1 second for the given element by XPath to be click-able
static void waitToBeClickableAndThenClick(org.openqa.selenium.WebDriver driver, java.lang.String xpath)
          Waits for the element matching the given xpath to be clickable and then clicks in
static void waitToBeClickableAndThenClick(org.openqa.selenium.WebDriver driver, java.lang.String xpath, int time)
          Waits for the element matching the given xpath to be clickable and then clicks in
static void waitToBeClickableAndThenDoubleClick(org.openqa.selenium.WebDriver driver, java.lang.String xpath, int time)
          Waits for the element of the given xpath to be clickable, and then double-clicks it
static void waitToBePresent(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By by)
          Waits for the specified element to be present
static void waitToBePresent(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By by, int timeoutInSeconds)
          Waits for the specified element to be present
static void waitUntilElementDoesNotExist(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By by, int waitSeconds, int retries)
          Waits until the given element no longer exists
static void waitUntilElementDoesNotExist(org.openqa.selenium.WebDriver driver, java.lang.String xpath)
          Waits until the given element no longer exists
static void waitUntilElementExists(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By by, int waitSeconds, int retries)
          Waits until the given element exists
static void waitUntilElementExists(org.openqa.selenium.WebDriver driver, java.lang.String xpath)
          Waits until the given element exists
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

properties

private static RuntimeProperties properties
Constructor Detail

TestUtils

public TestUtils()
Method Detail

waitToBeClickable

public static void waitToBeClickable(org.openqa.selenium.WebDriver driver,
                                     java.lang.String xpath)
Waits up to 1 second for the given element by XPath to be click-able

Parameters:
driver -
xpath -

waitToBeClickable

public static void waitToBeClickable(org.openqa.selenium.WebDriver driver,
                                     org.openqa.selenium.By by)
Waits for up to 1 second for the given element to be click-able

Parameters:
driver -
by -

waitToBeClickable

public static void waitToBeClickable(org.openqa.selenium.WebDriver driver,
                                     org.openqa.selenium.By by,
                                     int timeoutInSeconds)
Waits up until the specified timeout in seconds for given element to be click-able

Parameters:
driver -
by -
timeoutInSeconds -

waitToBeClickableAndThenClick

public static void waitToBeClickableAndThenClick(org.openqa.selenium.WebDriver driver,
                                                 java.lang.String xpath,
                                                 int time)
Waits for the element matching the given xpath to be clickable and then clicks in

Parameters:
driver -
xpath -
time -

waitToBeClickableAndThenClick

public static void waitToBeClickableAndThenClick(org.openqa.selenium.WebDriver driver,
                                                 java.lang.String xpath)
Waits for the element matching the given xpath to be clickable and then clicks in

Parameters:
driver -
xpath -

click

public static void click(org.openqa.selenium.WebDriver driver,
                         java.lang.String xpath)
Clicks the web element matching the given xpath

Parameters:
driver -
xpath -

doubleClick

public static void doubleClick(org.openqa.selenium.WebDriver driver,
                               java.lang.String xpath)
Double-clicks on the element that matches the given xpath

Parameters:
driver -
xpath -

waitToBeClickableAndThenDoubleClick

public static void waitToBeClickableAndThenDoubleClick(org.openqa.selenium.WebDriver driver,
                                                       java.lang.String xpath,
                                                       int time)
Waits for the element of the given xpath to be clickable, and then double-clicks it

Parameters:
driver -
xpath -
time -

clickAt

public static void clickAt(org.openqa.selenium.WebDriver driver,
                           org.openqa.selenium.By by)
This is something that was present in Selenium prior to Web Driver, which forces clicking on the element of the matching expression whether that element is clickable or whether that click would be at some other location on the screen.

Parameters:
driver -
by -

waitToBePresent

public static void waitToBePresent(org.openqa.selenium.WebDriver driver,
                                   org.openqa.selenium.By by,
                                   int timeoutInSeconds)
Waits for the specified element to be present

Parameters:
driver -
by -
timeoutInSeconds -

waitToBePresent

public static void waitToBePresent(org.openqa.selenium.WebDriver driver,
                                   org.openqa.selenium.By by)
Waits for the specified element to be present

Parameters:
driver -
by -

waitForTextValueToBePresent

public static void waitForTextValueToBePresent(org.openqa.selenium.WebDriver driver,
                                               java.lang.String text,
                                               org.openqa.selenium.By by,
                                               int timeoutInSeconds)
Waits for the text to be present in the specified element

Parameters:
driver -
text -
by -
timeoutInSeconds -

waitForTextToBePresent

public static void waitForTextToBePresent(org.openqa.selenium.WebDriver driver,
                                          java.lang.String text,
                                          org.openqa.selenium.By by,
                                          int timeoutInSeconds)
Waits for the text to be present

Parameters:
driver -
text -
by -
timeoutInSeconds -

waitForTextValueToBePresent

public static void waitForTextValueToBePresent(org.openqa.selenium.WebDriver driver,
                                               java.lang.String text,
                                               org.openqa.selenium.By by)
Waits for the text to be present in the specified element

Parameters:
driver -
text -
by -

waitForTextValueToBePresent

public static void waitForTextValueToBePresent(org.openqa.selenium.WebDriver driver,
                                               java.lang.String text,
                                               java.lang.String xpath)
Waits for the text to be present in the specified element

Parameters:
driver -
text -
xpath -

waitUntilElementDoesNotExist

public static void waitUntilElementDoesNotExist(org.openqa.selenium.WebDriver driver,
                                                org.openqa.selenium.By by,
                                                int waitSeconds,
                                                int retries)
                                         throws java.lang.Exception
Waits until the given element no longer exists

Parameters:
driver -
by -
waitSeconds -
retries -
Throws:
java.lang.Exception

waitUntilElementDoesNotExist

public static void waitUntilElementDoesNotExist(org.openqa.selenium.WebDriver driver,
                                                java.lang.String xpath)
                                         throws java.lang.Exception
Waits until the given element no longer exists

Parameters:
driver -
xpath -
Throws:
java.lang.Exception

waitUntilElementExists

public static void waitUntilElementExists(org.openqa.selenium.WebDriver driver,
                                          org.openqa.selenium.By by,
                                          int waitSeconds,
                                          int retries)
                                   throws java.lang.Exception
Waits until the given element exists

Parameters:
driver -
by -
waitSeconds -
retries -
Throws:
java.lang.Exception

waitUntilElementExists

public static void waitUntilElementExists(org.openqa.selenium.WebDriver driver,
                                          java.lang.String xpath)
                                   throws java.lang.Exception
Waits until the given element exists

Parameters:
driver -
xpath -
Throws:
java.lang.Exception

dragAndDrop

public static void dragAndDrop(org.openqa.selenium.WebDriver driver,
                               java.lang.String xpath,
                               int x,
                               int y)
                        throws java.lang.Exception
Performs a drag and drop

Parameters:
driver -
xpath -
x -
y -
Throws:
java.lang.Exception

dragAndDrop

public static void dragAndDrop(org.openqa.selenium.WebDriver driver,
                               org.openqa.selenium.WebElement element,
                               int x,
                               int y)
                        throws java.lang.Exception
Performs a drag and drop

Parameters:
driver -
element -
x -
y -
Throws:
java.lang.Exception