Class Graphene
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.
guardHttp(Object)) /guardAjax(Object)- guards that given request was donewaitForHttp(Object)- guards that full page reload was doneguardNoRequest(Object)- guards that no request was done
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-consumingwaitAjax()- guards regular AJAX actions - fast interaction with tested serverwaitModel()- 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
createPageFragment(Class, WebElement)- creates a page fragments of given type by specifying a root element where given fragments is located
- Author:
- Lukas Fryc, Jan Papousek
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclick(org.openqa.selenium.WebElement element) Clicks in the middle of the given element.static <T> TcreatePageFragment(Class<T> type, org.openqa.selenium.WebElement root) Creates page fragment of given type with given element as a root.static voiddoubleClick(org.openqa.selenium.WebElement element) Performs a double-click at middle of the given element.static <T> TRequests navigation to a page represented by given page object.static <T> TRequests navigation to a page represented by given page object.static <T> TguardAjax(T target) Returns the guarded object checking whether the Ajax (XHR) request is done during each method invocation.static <T> TguardHttp(T target) Returns the guarded object checking whether the HTTP request is done during each object's method invocation.static <T> TguardNoRequest(T target) Returns the guarded object checking that no request is done during each method invocation.static WebDriverWait<Void>waitAjax()waitAjax()is entry point for fluent waiting API specification, e.g.:static WebDriverWait<Void>waitAjax(org.openqa.selenium.WebDriver driver) waitAjax()is entry point for fluent waiting API specification, e.g.:static <T> TwaitForHttp(T target) Returns the guarded object checking that HTTP request has happen after any object's method invocation.static WebDriverWait<Void>waitGui()waitGui()is entry point for fluent waiting API specification, e.g.:static WebDriverWait<Void>waitGui(org.openqa.selenium.WebDriver driver) waitGui(WebDriver)is entry point for fluent waiting API specification, e.g.:static WebDriverWait<Void>waitModel()is entry point for fluent waiting API specification, e.g.:static WebDriverWait<Void>waitModel(org.openqa.selenium.WebDriver driver) waitModel(WebDriver)is entry point for fluent waiting API specification, e.g.:static voidwriteIntoElement(org.openqa.selenium.WebElement element, String text) Writes into the given element the given string.
-
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, theRequestGuardExceptionis 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, theRequestGuardExceptionis 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, theRequestGuardExceptionis 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
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
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
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
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
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
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
Creates page fragment of given type with given element as a root.- Parameters:
type- the page fragment classroot- the root of a page fragment in a current page- Returns:
- the initialized page fragment
- See Also:
-
goTo
Requests navigation to a page represented by given page object.
The
Pageobject can be annotated withLocationannotation in order to support navigation between pages.See documentation for
Pagein order to know how to definePageobjects.See documentation for
InitialPagein 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
Requests navigation to a page represented by given page object.
The
Pageobject can be annotated withLocationannotation in order to support navigation between pages.See documentation for
Pagein order to know how to definePageobjects.See documentation for
InitialPagein 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
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
-