org.richfaces.fragment.common

## Class Utils

- java.lang.Object
- - org.richfaces.fragment.common.Utils

-     public final class Utils
      extends Object

  Author:
    Jiri Stefek

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static org.openqa.selenium.By` | `BY_BODY`
    `static org.openqa.selenium.By` | `BY_HTML`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Utils()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static org.openqa.selenium.WebElement` | `getAncestorOfElement(org.openqa.selenium.WebElement element)` Returns the closest ancestor from the element.
    `static org.openqa.selenium.WebElement` | `getAncestorOfElement(org.openqa.selenium.WebElement element, String tagNameOfAncestorElement)` Returns the closest ancestor with tagName from the element.
    `static <T> com.google.common.base.Optional<T>` | `getComponentOption(org.openqa.selenium.WebElement rootOfComponent, String option)` Returns the given option of the component determined by its root element.
    `static <T> com.google.common.base.Optional<T>` | `getComponentOptionDocumentObjectSafe(org.openqa.selenium.WebElement rootOfComponent, String option)` Returns the given option of the component determined by its root element in a document object safe way.
    `static org.openqa.selenium.JavascriptExecutor` | `getExecutorFromElement(org.openqa.selenium.WebElement element)`
    `static int` | `getIndexOfElement(org.openqa.selenium.WebElement element)` Returns the result of invocation of jQuery function `index()` on given element.
    `static Locations` | `getLocations(org.openqa.selenium.WebElement root)` Returns Locations of input element.
    `static org.openqa.selenium.WebElement` | `getNextSiblingOfElement(org.openqa.selenium.WebElement element)` Returns the closest following sibling from the element.
    `static org.openqa.selenium.WebElement` | `getNextSiblingOfElement(org.openqa.selenium.WebElement element, String tagNameofSibling)` Returns the closest following sibling with tagName from the element.
    `static org.openqa.selenium.WebElement` | `getPreviousSiblingOfElement(org.openqa.selenium.WebElement element)` Returns the closest preceding sibling from the element.
    `static org.openqa.selenium.WebElement` | `getPreviousSiblingOfElement(org.openqa.selenium.WebElement element, String tagNameofSibling)` Returns the closest preceding sibling with tagName from the element.
    `static String` | `getTextFromHiddenElement(org.openqa.selenium.JavascriptExecutor executor, org.openqa.selenium.WebElement element)` Returns text from given hidden element.
    `static String` | `getTextFromHiddenElement(org.openqa.selenium.WebElement element)` Returns text from given hidden element.
    `static long` | `getWaitAjaxDefaultTimeout(org.openqa.selenium.WebDriver browser)` Returns the default timeout for Ajax waiting in milliseconds.
    `static long` | `getWaitGUIDefaultTimeout(org.openqa.selenium.WebDriver browser)` Returns the default timeout for GUI waiting in milliseconds.
    `static <T> T` | `invokeRichFacesJSAPIFunction(org.openqa.selenium.WebElement componentRoot, String functionWithParams)` Invokes RF JS API function on given root of RF component.
    `static boolean` | `isVisible(org.openqa.selenium.SearchContext searchContext, org.openqa.selenium.By by)`
    `static boolean` | `isVisible(org.openqa.selenium.WebElement e)`
    `static void` | `jQ(org.openqa.selenium.JavascriptExecutor executor, String cmd, org.openqa.selenium.WebElement element)` Executes jQuery command on input element.
    `static void` | `jQ(String cmd, org.openqa.selenium.WebElement element)` Executes jQuery command on input element.
    `static void` | `performFirefoxKeyboardWorkaround(org.openqa.selenium.WebDriver browser)` When using Firefox and body element is focused, focus on the page from url/address bar, otherwise nothing happens.
    `static void` | `performUniversalBlur(org.openqa.selenium.WebDriver browser)` Creates and inserts a new button to DOM, clicks on it and removes it.
    `static String` | `returningJQ(org.openqa.selenium.JavascriptExecutor executor, String cmd, org.openqa.selenium.WebElement element)` Executes returning jQuery command on input element.
    `static String` | `returningJQ(String cmd, org.openqa.selenium.WebElement element)` Executes returning jQuery command on input element.
    `static void` | `tolerantAssertLocationsEquals(Locations l1, Locations l2, int xTolerance, int yTolerance, String message)` Asserts that two locations are equal with some allowed tolerance.
    `static void` | `tolerantAssertLocationsEquals(org.openqa.selenium.WebElement element, Locations l2, int xTolerance, int yTolerance, String message)` Asserts that elements locations and some other locations are equal with some allowed tolerance.
    `static void` | `tolerantAssertPointEquals(org.openqa.selenium.Point p1, org.openqa.selenium.Point p2, int xTolerance, int yTolerance, String message)` Asserts that two points are equal with some allowed tolerance.
    `static void` | `triggerJQ(org.openqa.selenium.JavascriptExecutor executor, String event, org.openqa.selenium.WebElement element)` Executes jQuery trigger command on input element.
    `static void` | `triggerJQ(String event, org.openqa.selenium.WebElement element)` Executes jQuery trigger command on input element.
    `static org.openqa.selenium.WebElement` | `unwrap(org.openqa.selenium.WebElement element)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### BY_BODY

          public static final org.openqa.selenium.By BY_BODY

    - #### BY_HTML

          public static final org.openqa.selenium.By BY_HTML

  - ### Constructor Detail

    - #### Utils

          public Utils()

  - ### Method Detail

    - #### getExecutorFromElement

          public static org.openqa.selenium.JavascriptExecutor getExecutorFromElement(org.openqa.selenium.WebElement element)

    - #### getIndexOfElement

          public static int getIndexOfElement(org.openqa.selenium.WebElement element)

      Returns the result of invocation of jQuery function `index()` on given element.
      Parameters:
        `element` - element on which the command will be executed, has to be instance of org.jboss.arquillian.graphene.proxy.GrapheneProxyInstance

    - #### getAncestorOfElement

          public static org.openqa.selenium.WebElement getAncestorOfElement(org.openqa.selenium.WebElement element)

      Returns the closest ancestor from the element.
      Parameters:
        `element` - element from which will be the ancestor found

    - #### getAncestorOfElement

          public static org.openqa.selenium.WebElement getAncestorOfElement(org.openqa.selenium.WebElement element,
                                                            String tagNameOfAncestorElement)

      Returns the closest ancestor with tagName from the element.
      Parameters:
        `element` - element from which will be the ancestor found
        `tagNameOfAncestorElement` - tagName of the ancestor to be found

    - #### getNextSiblingOfElement

          public static org.openqa.selenium.WebElement getNextSiblingOfElement(org.openqa.selenium.WebElement element)

      Returns the closest following sibling from the element.
      Parameters:
        `element` - element from which will be the sibling found

    - #### getNextSiblingOfElement

          public static org.openqa.selenium.WebElement getNextSiblingOfElement(org.openqa.selenium.WebElement element,
                                                               String tagNameofSibling)

      Returns the closest following sibling with tagName from the element.
      Parameters:
        `element` - element from which will be the sibling found
        `tagNameofSibling` - tagName of the sibling to be found

    - #### getPreviousSiblingOfElement

          public static org.openqa.selenium.WebElement getPreviousSiblingOfElement(org.openqa.selenium.WebElement element)

      Returns the closest preceding sibling from the element.
      Parameters:
        `element` - element from which will be the sibling found

    - #### getPreviousSiblingOfElement

          public static org.openqa.selenium.WebElement getPreviousSiblingOfElement(org.openqa.selenium.WebElement element,
                                                                   String tagNameofSibling)

      Returns the closest preceding sibling with tagName from the element.
      Parameters:
        `element` - element from which will be the sibling found
        `tagNameofSibling` - tagName of the sibling to be found

    - #### getComponentOption

          public static <T> com.google.common.base.Optional<T> getComponentOption(org.openqa.selenium.WebElement rootOfComponent,
                                                                  String option)

      Returns the given option of the component determined by its root element. For example `getComponentOption(rootOfHotKey, "key")` will return concrete value of the hotkey's option `key`
      Parameters:
        `rootOfComponent` -
        `option` -
      Returns:

    - #### getComponentOptionDocumentObjectSafe

          public static <T> com.google.common.base.Optional<T> getComponentOptionDocumentObjectSafe(org.openqa.selenium.WebElement rootOfComponent,
                                                                                    String option)

      Returns the given option of the component determined by its root element in a document object safe way. It provides a safe way to retrieve an option if the option value can be equal to the JavaScript object `document`.
      Parameters:
        `rootOfComponent` -
        `option` -
      Returns:
        actual component option value, or null if it is equal to document object

    - #### getLocations

          public static Locations getLocations(org.openqa.selenium.WebElement root)

      Returns Locations of input element.
      See Also:
        `Locations`

    - #### getTextFromHiddenElement

          public static String getTextFromHiddenElement(org.openqa.selenium.JavascriptExecutor executor,
                                        org.openqa.selenium.WebElement element)

      Returns text from given hidden element. WebDriver, in this case, returns empty String.
      Parameters:
        `element` - not visible element

    - #### getTextFromHiddenElement

          public static String getTextFromHiddenElement(org.openqa.selenium.WebElement element)

      Returns text from given hidden element. WebDriver, in this case, returns empty String.
      Parameters:
        `element` - not visible element

    - #### invokeRichFacesJSAPIFunction

          public static <T> T invokeRichFacesJSAPIFunction(org.openqa.selenium.WebElement componentRoot,
                                           String functionWithParams)

      Invokes RF JS API function on given root of RF component. The root must be set correctly.
      Parameters:
        `componentRoot` - root of the RF component
        `functionWithParams` - JS API function with params (e.g. `setValue(new Date('October 10, 2012 12:00:00'))` )

    - #### isVisible

          public static boolean isVisible(org.openqa.selenium.WebElement e)

    - #### isVisible

          public static boolean isVisible(org.openqa.selenium.SearchContext searchContext,
                          org.openqa.selenium.By by)

    - #### jQ

          public static void jQ(org.openqa.selenium.JavascriptExecutor executor,
                String cmd,
                org.openqa.selenium.WebElement element)

      Executes jQuery command on input element. E.g. to trigger click use jQ("click()", element).
      Parameters:
        `cmd` - command to be executed
        `element` - element on which the command will be executed

    - #### jQ

          public static void jQ(String cmd,
                org.openqa.selenium.WebElement element)

      Executes jQuery command on input element. E.g. to trigger click use jQ("click()", element).
      Parameters:
        `cmd` - command to be executed
        `element` - element on which the command will be executed

    - #### performFirefoxKeyboardWorkaround

          public static void performFirefoxKeyboardWorkaround(org.openqa.selenium.WebDriver browser)

      When using Firefox and body element is focused, focus on the page from url/address bar, otherwise nothing happens. Workaround for Selenium issue #7937

    - #### performUniversalBlur

          public static void performUniversalBlur(org.openqa.selenium.WebDriver browser)

      Creates and inserts a new button to DOM, clicks on it and removes it.
      Parameters:
        `browser` -

    - #### returningJQ

          public static String returningJQ(org.openqa.selenium.JavascriptExecutor executor,
                           String cmd,
                           org.openqa.selenium.WebElement element)

      Executes returning jQuery command on input element. E.g. to get a position of element from top of the page use returningjQ("position().top", element).
      Parameters:
        `cmd` - command to be executed
        `element` - element on which the command will be executed

    - #### returningJQ

          public static String returningJQ(String cmd,
                           org.openqa.selenium.WebElement element)

      Executes returning jQuery command on input element. E.g. to get a position of element from top of the page use returningjQ("position().top", element).
      Parameters:
        `cmd` - command to be executed
        `element` - element on which the command will be executed

    - #### tolerantAssertPointEquals

          public static void tolerantAssertPointEquals(org.openqa.selenium.Point p1,
                                       org.openqa.selenium.Point p2,
                                       int xTolerance,
                                       int yTolerance,
                                       String message)

      Asserts that two points are equal with some allowed tolerance.

    - #### tolerantAssertLocationsEquals

          public static void tolerantAssertLocationsEquals(Locations l1,
                                           Locations l2,
                                           int xTolerance,
                                           int yTolerance,
                                           String message)

      Asserts that two locations are equal with some allowed tolerance.

    - #### tolerantAssertLocationsEquals

          public static void tolerantAssertLocationsEquals(org.openqa.selenium.WebElement element,
                                           Locations l2,
                                           int xTolerance,
                                           int yTolerance,
                                           String message)

      Asserts that elements locations and some other locations are equal with some allowed tolerance.

    - #### triggerJQ

          public static void triggerJQ(org.openqa.selenium.JavascriptExecutor executor,
                       String event,
                       org.openqa.selenium.WebElement element)

      Executes jQuery trigger command on input element. Useful for easy triggering of JavaScript events like click, dblclick, mouseout...
      Parameters:
        `executor` - JavascriptExecutor
        `event` - event to be triggered
        `element` - element on which the command will be executed

    - #### triggerJQ

          public static void triggerJQ(String event,
                       org.openqa.selenium.WebElement element)

      Executes jQuery trigger command on input element. Useful for easy triggering of JavaScript events like click, dblclick, mouseout...
      Parameters:
        `event` - event to be triggered
        `element` - element on which the command will be executed, has to be instance of org.jboss.arquillian.graphene.proxy.GrapheneProxyInstance

    - #### unwrap

          public static org.openqa.selenium.WebElement unwrap(org.openqa.selenium.WebElement element)

    - #### getWaitGUIDefaultTimeout

          public static long getWaitGUIDefaultTimeout(org.openqa.selenium.WebDriver browser)

      Returns the default timeout for GUI waiting in milliseconds.
      Parameters:
        `browser` -
      Returns:

    - #### getWaitAjaxDefaultTimeout

          public static long getWaitAjaxDefaultTimeout(org.openqa.selenium.WebDriver browser)

      Returns the default timeout for Ajax waiting in milliseconds.
      Parameters:
        `browser` -
      Returns:

Copyright © 2016 JBoss by Red Hat. All Rights Reserved.