Class Graphene

java.lang.Object
org.jboss.arquillian.graphene.Graphene

public class Graphene extends Object

Graphene Utility Class

The Graphene utility is entry point for concise Graphene syntax of operating with browser.

It contains useful methods not only for waiting on certain browser actions.

It is recommended to import the class members statically:

 import static org.jboss.arquillian.graphene.Graphene.*;
 

or let add the class static members to favorites in your IDE.

Request Guards API

Request Guards are coarse-grained and concise way how to declare that given interaction with browser leads to a server request of certain type.

Fluent Waiting API

This API serves as a base for defining explicit conditions for which the execution of browser should wait for.

  • waitGui() - guards fast GUI actions - very fast interactions without need to reach server or do any time-consuming
  • waitAjax() - guards regular AJAX actions - fast interaction with tested server
  • waitModel() - guards heavy computation or network-utilization (typically server-side)

Navigation to Page Objects

  • goTo(Class) - navigates the browser into a page given by provided page object class and returns this page instance

Page Fragments

Author:
Lukas Fryc, Jan Papousek
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    click(org.openqa.selenium.WebElement element)
    Clicks in the middle of the given element.
    static <T> T
    createPageFragment(Class<T> type, org.openqa.selenium.WebElement root)
    Creates page fragment of given type with given element as a root.
    static void
    doubleClick(org.openqa.selenium.WebElement element)
    Performs a double-click at middle of the given element.
    static <T> T
    goTo(Class<T> pageObject)
    Requests navigation to a page represented by given page object.
    static <T> T
    goTo(Class<T> pageObject, Class<?> browserQualifier)
    Requests navigation to a page represented by given page object.
    static <T> T
    guardAjax(T target)
    Returns the guarded object checking whether the Ajax (XHR) request is done during each method invocation.
    static <T> T
    guardHttp(T target)
    Returns the guarded object checking whether the HTTP request is done during each object's method invocation.
    static <T> T
    guardNoRequest(T target)
    Returns the guarded object checking that no request is done during each method invocation.
    waitAjax() is entry point for fluent waiting API specification, e.g.:
    waitAjax(org.openqa.selenium.WebDriver driver)
    waitAjax() is entry point for fluent waiting API specification, e.g.:
    static <T> T
    waitForHttp(T target)
    Returns the guarded object checking that HTTP request has happen after any object's method invocation.
    waitGui() is entry point for fluent waiting API specification, e.g.:
    waitGui(org.openqa.selenium.WebDriver driver)
    waitGui(WebDriver) is entry point for fluent waiting API specification, e.g.:
    waitModel() is entry point for fluent waiting API specification, e.g.:
    waitModel(org.openqa.selenium.WebDriver driver)
    waitModel(WebDriver) is entry point for fluent waiting API specification, e.g.:
    static void
    writeIntoElement(org.openqa.selenium.WebElement element, String text)
    Writes into the given element the given string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Graphene

      public Graphene()
  • Method Details

    • guardHttp

      public static <T> T guardHttp(T target)
      Returns the guarded object checking whether the HTTP request is done during each object's method invocation. If the request is not observed, the RequestGuardException is thrown.
      Type Parameters:
      T - type of the given target
      Parameters:
      target - object to be guarded
      Returns:
      the guarded object
      Throws:
      RequestGuardException - when no HTTP request is observed
    • guardAjax

      public static <T> T guardAjax(T target)
      Returns the guarded object checking whether the Ajax (XHR) request is done during each method invocation. If the request is not observed, the RequestGuardException is thrown.
      Type Parameters:
      T - type of the given target
      Parameters:
      target - object to be guarded
      Returns:
      the guarded object
      Throws:
      RequestGuardException - when no AJAX (XHR) request is observed
    • guardNoRequest

      public static <T> T guardNoRequest(T target)
      Returns the guarded object checking that no request is done during each method invocation. If any request is observed, the RequestGuardException is thrown.
      Type Parameters:
      T - type of the given target
      Parameters:
      target - object to be guarded
      Returns:
      the guarded object
      Throws:
      RequestGuardException - when HTTP or AJAX request is observed
    • waitForHttp

      public static <T> T waitForHttp(T target)
      Returns the guarded object checking that HTTP request has happen after any object's method invocation. If AJAX request is observed, the guarded object will ignore it and will wait for regular HTTP request instead.
      Type Parameters:
      T - type of the given target
      Parameters:
      target - object to be guarded
      Returns:
      the guarded object
      Throws:
      RequestGuardException - when no HTTP request is observed
    • waitAjax

      public static WebDriverWait<Void> waitAjax()
      waitAjax() is entry point for fluent waiting API specification, e.g.:
       waitAjax().until().element(button).isVisible();
       
      waitAjax() guards regular AJAX actions - fast interaction with tested server.
      See Also:
    • waitAjax

      public static WebDriverWait<Void> waitAjax(org.openqa.selenium.WebDriver driver)
      waitAjax() is entry point for fluent waiting API specification, e.g.:
       waitAjax(browser).until().element(button).isVisible();
       
      waitAjax() guards regular AJAX actions - fast interaction with tested server.
      See Also:
    • waitGui

      public static WebDriverWait<Void> waitGui()
      waitGui() is entry point for fluent waiting API specification, e.g.:
       waitGui().until().element(popupPanel).isVisible();
       
      waitGui() guards fast GUI actions - very fast interactions without need to reach server or do any time-consuming computations.
      See Also:
    • waitGui

      public static WebDriverWait<Void> waitGui(org.openqa.selenium.WebDriver driver)
      waitGui(WebDriver) is entry point for fluent waiting API specification, e.g.:
       waitGui(browser).until().element(popupPanel).isVisible();
       
      waitGui(WebDriver) guards fast GUI actions - very fast interactions without need to reach server or do any time-consuming computations.
      See Also:
    • waitModel

      public static WebDriverWait<Void> waitModel()
      waitModel() is entry point for fluent waiting API specification, e.g.:
       waitModel().until().element(button).isVisible();
       
      waitModel() guards heavy computation or network-utilization interactions (typically server-side).
      See Also:
    • waitModel

      public static WebDriverWait<Void> waitModel(org.openqa.selenium.WebDriver driver)
      waitModel(WebDriver) is entry point for fluent waiting API specification, e.g.:
       waitModel(browser).until().element(button).isVisible();
       
      waitModel(WebDriver) guards heavy computation or network-utilization (typically server-side).
      See Also:
    • createPageFragment

      public static <T> T createPageFragment(Class<T> type, org.openqa.selenium.WebElement root)
      Creates page fragment of given type with given element as a root.
      Parameters:
      type - the page fragment class
      root - the root of a page fragment in a current page
      Returns:
      the initialized page fragment
      See Also:
    • goTo

      public static <T> T goTo(Class<T> pageObject)

      Requests navigation to a page represented by given page object.

      The Page object can be annotated with Location annotation in order to support navigation between pages.

      See documentation for Page in order to know how to define Page objects.

      See documentation for InitialPage in order to know how to define a page which should be used as initial page on a start of a test.

      Parameters:
      pageObject - page object class
      Returns:
      page object instance
      See Also:
    • goTo

      public static <T> T goTo(Class<T> pageObject, Class<?> browserQualifier)

      Requests navigation to a page represented by given page object.

      The Page object can be annotated with Location annotation in order to support navigation between pages.

      See documentation for Page in order to know how to define Page objects.

      See documentation for InitialPage in order to know how to define a page which should be used as initial page on a start of a test.

      Parameters:
      pageObject - page object class
      Returns:
      page object instance
      See Also:
    • click

      public static void click(org.openqa.selenium.WebElement element)
      Clicks in the middle of the given element. Equivalent to: Actions.moveToElement(onElement).click().perform()
      Parameters:
      element - Element to click.
    • doubleClick

      public static void doubleClick(org.openqa.selenium.WebElement element)
      Performs a double-click at middle of the given element. Equivalent to: Actions.moveToElement(element).doubleClick().perform()
      Parameters:
      element - Element to move to.
    • writeIntoElement

      public static void writeIntoElement(org.openqa.selenium.WebElement element, String text)
      Writes into the given element the given string. Equivalent to: Actions.moveToElement(element).click().sendKeys(text).perform()
      Parameters:
      element - Element to move to.
      text - Text to write