com.atlassian.pageobjects.elements
Class WebDriverElement

java.lang.Object
  extended by com.atlassian.pageobjects.elements.WebDriverElement
All Implemented Interfaces:
PageElement, PageElementFinder
Direct Known Subclasses:
WebDriverCheckboxElement, WebDriverMultiSelectElement, WebDriverSelectElement

public class WebDriverElement
extends Object
implements PageElement

Implementation of PageElement that waits for element to be present before executing each actions.


Field Summary
protected  TimeoutType defaultTimeout
           
protected  AtlassianWebDriver driver
           
protected  WebDriverLocatable locatable
           
protected  PageBinder pageBinder
           
protected  Timeouts timeouts
           
 
Constructor Summary
WebDriverElement(org.openqa.selenium.By locator)
          Creates a WebDriverElement within the driver's search context and default timeout
WebDriverElement(org.openqa.selenium.By locator, TimeoutType timeoutType)
          Creates a WebDriverElement within the driver's search context and given timeout type.
WebDriverElement(org.openqa.selenium.By locator, WebDriverLocatable parent)
          Creates a WebDriverElement within a given parent and default timeout.
WebDriverElement(org.openqa.selenium.By locator, WebDriverLocatable parent, TimeoutType timeoutType)
          Creates a WebDriverElement within a given parent and given timeout type.
WebDriverElement(WebDriverLocatable locatable, TimeoutType timeoutType)
          Creates a WebDriverElement with the given locatable and timeout type.
 
Method Summary
 org.openqa.selenium.WebElement asWebElement()
          This allows retrieving the webelement from the page element.
 PageElement clear()
          Clear the value of the text entry element.
 PageElement click()
          Click this element
protected  WebDriverLocatable.LocateTimeout createTimout()
           
 PageElement find(org.openqa.selenium.By locator)
          

Returns an element that will match the given locator within this element.

<T extends PageElement>
T
find(org.openqa.selenium.By locator, Class<T> elementClass)
          Creates PageElement extension of type T using the specified locator and default timeout.
<T extends PageElement>
T
find(org.openqa.selenium.By locator, Class<T> elementClass, TimeoutType timeoutType)
          Creates PageElement extension of type T using the specified locator and given timeoutType
 PageElement find(org.openqa.selenium.By locator, TimeoutType timeoutType)
          Creates PageElement implementation using the specified locator and given timeoutType.
 List<PageElement> findAll(org.openqa.selenium.By locator)
          Returns a list of element's that match the given locator within this element
<T extends PageElement>
List<T>
findAll(org.openqa.selenium.By locator, Class<T> elementClass)
          Creates (@Link PageElement) extension of type T for each element that matches the given locator with default timeout
<T extends PageElement>
List<T>
findAll(org.openqa.selenium.By locator, Class<T> elementClass, TimeoutType timeoutType)
          Creates (@Link PageElement) extension of type T for each element that matches the given locator with timeoutType
 List<PageElement> findAll(org.openqa.selenium.By locator, TimeoutType timeoutType)
          Creates a PageElement for each element that matches the given locator using timeoutType.
 String getAttribute(String name)
          Get the value of the given attribute of this element.
 org.openqa.selenium.Point getLocation()
          Location of this element on the page (top-left corner)
 org.openqa.selenium.Dimension getSize()
          Dimension of this element on the page
 String getTagName()
          Get the tag name of this element
 String getText()
          Get the visible innerText of this element, including sub-elements, without any leading or trailing whitespaces.
 String getValue()
          Get the value of this element's "value" attribute.
 boolean hasAttribute(String name, String value)
          Whether this element has an attribute set to a specific value
 boolean hasClass(String className)
          Whether this element has the given class set
 boolean isEnabled()
          Whether this element is enabled on the page
 boolean isPresent()
          Whether this element is currently on the DOM of the page
 boolean isSelected()
          Whether this element is selected on the page.
 boolean isVisible()
          Whether this element is visible on the page
 PageElementJavascript javascript()
          Gets a PageElementJavascript for this element
 PageElement select()
          Select an element.
 TimedElement timed()
          Creates a timed element based on this element's locator.
protected  long timeout()
           
 PageElement toggle()
          If the element is a checkbox this will toggle the elements state from selected to not selected, or from not selected to selected.
 String toString()
           
 PageElement type(CharSequence... keysToSend)
          Simulate typing into this element.
protected  org.openqa.selenium.WebElement waitForWebElement()
           
 PageElement withTimeout(TimeoutType timeoutType)
          Returns an instance equivalent to this element, with a changed timeoutType.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

driver

@Inject
protected AtlassianWebDriver driver

pageBinder

@Inject
protected PageBinder pageBinder

timeouts

@Inject
protected Timeouts timeouts

locatable

protected final WebDriverLocatable locatable

defaultTimeout

protected final TimeoutType defaultTimeout
Constructor Detail

WebDriverElement

public WebDriverElement(org.openqa.selenium.By locator)
Creates a WebDriverElement within the driver's search context and default timeout

Parameters:
locator - The locator mechanism to use.

WebDriverElement

public WebDriverElement(org.openqa.selenium.By locator,
                        TimeoutType timeoutType)
Creates a WebDriverElement within the driver's search context and given timeout type.

Parameters:
locator - The locator mechanism to use.
timeoutType - default timeout of this element

WebDriverElement

public WebDriverElement(org.openqa.selenium.By locator,
                        WebDriverLocatable parent)
Creates a WebDriverElement within a given parent and default timeout.

Parameters:
locator - The locator mechanism to use.
parent - The locatable parent of this element.

WebDriverElement

public WebDriverElement(org.openqa.selenium.By locator,
                        WebDriverLocatable parent,
                        TimeoutType timeoutType)
Creates a WebDriverElement within a given parent and given timeout type.

Parameters:
locator - The locator mechanism to use.
parent - The locatable parent of this element.
timeoutType - default timeout of this element

WebDriverElement

public WebDriverElement(WebDriverLocatable locatable,
                        TimeoutType timeoutType)
Creates a WebDriverElement with the given locatable and timeout type.

Parameters:
locatable - WebDriverLocatable that that locate this element
timeoutType - default timeout of this element
Method Detail

timeout

protected long timeout()

createTimout

protected WebDriverLocatable.LocateTimeout createTimout()

waitForWebElement

protected org.openqa.selenium.WebElement waitForWebElement()

isPresent

public boolean isPresent()
Description copied from interface: PageElement
Whether this element is currently on the DOM of the page

Specified by:
isPresent in interface PageElement
Returns:
True if this element tag exists in the DOM, false otherwise.

isVisible

public boolean isVisible()
Description copied from interface: PageElement
Whether this element is visible on the page

Specified by:
isVisible in interface PageElement
Returns:
true if this element is visible on the page, false otherwise.

isEnabled

public boolean isEnabled()
Description copied from interface: PageElement
Whether this element is enabled on the page

Specified by:
isEnabled in interface PageElement
Returns:
True if this element is enabled, false otherwise.

isSelected

public boolean isSelected()
Description copied from interface: PageElement
Whether this element is selected on the page. Useful on checkboxes and radio buttons. For checkboxes, returns true if the checkbox is checked. For radio buttons, returns true if the radio button this class represents is selected.

Specified by:
isSelected in interface PageElement
Returns:
True if this element is selected, false otheriwse.

hasClass

public boolean hasClass(String className)
Description copied from interface: PageElement
Whether this element has the given class set

Specified by:
hasClass in interface PageElement
Parameters:
className - The name of the class to check
Returns:
true if this element's class attribute contains the given classname, false otherwise.

getAttribute

public String getAttribute(String name)
Description copied from interface: PageElement
Get the value of the given attribute of this element.

Specified by:
getAttribute in interface PageElement
Parameters:
name - The name of the attribute.
Returns:
The attribute's current value, or null if the value is not set

hasAttribute

public boolean hasAttribute(String name,
                            String value)
Description copied from interface: PageElement
Whether this element has an attribute set to a specific value

Specified by:
hasAttribute in interface PageElement
Parameters:
name - The attribute name
value - The expected value
Returns:
true if attribute is set to the specific value, false otherwise or if attribute is not present

getText

public String getText()
Description copied from interface: PageElement
Get the visible innerText of this element, including sub-elements, without any leading or trailing whitespaces.

Specified by:
getText in interface PageElement
Returns:
The innerText of this element.

getTagName

public String getTagName()
Description copied from interface: PageElement
Get the tag name of this element

Specified by:
getTagName in interface PageElement
Returns:
The tag name

getValue

public String getValue()
Description copied from interface: PageElement
Get the value of this element's "value" attribute.

Specified by:
getValue in interface PageElement
Returns:
The value of this element's "value" attribute, or null if the value is not set.

getLocation

public org.openqa.selenium.Point getLocation()
Description copied from interface: PageElement
Location of this element on the page (top-left corner)

Specified by:
getLocation in interface PageElement
Returns:
location of the element on the page

getSize

public org.openqa.selenium.Dimension getSize()
Description copied from interface: PageElement
Dimension of this element on the page

Specified by:
getSize in interface PageElement
Returns:

click

public PageElement click()
Description copied from interface: PageElement
Click this element

Specified by:
click in interface PageElement
Returns:
The eleemnt that got clicked.

type

public PageElement type(CharSequence... keysToSend)
Description copied from interface: PageElement
Simulate typing into this element. This will append the keystrokes to the end of the text entry element.

Specified by:
type in interface PageElement
Parameters:
keysToSend - keys to type
Returns:
The Element that got typed in.

select

public PageElement select()
Description copied from interface: PageElement
Select an element. This method will work against radio buttons, "option" elements within a "select" and checkboxes

Specified by:
select in interface PageElement
Returns:
The Element that got selected

toggle

public PageElement toggle()
Description copied from interface: PageElement
If the element is a checkbox this will toggle the elements state from selected to not selected, or from not selected to selected.

Specified by:
toggle in interface PageElement
Returns:
The Element that got toggled

clear

public PageElement clear()
Description copied from interface: PageElement
Clear the value of the text entry element.

Specified by:
clear in interface PageElement
Returns:
The Element that got cleared.

timed

public TimedElement timed()
Description copied from interface: PageElement
Creates a timed element based on this element's locator.

Specified by:
timed in interface PageElement
Returns:
A TimedElement that is based on this element's locator.

javascript

public PageElementJavascript javascript()
Description copied from interface: PageElement
Gets a PageElementJavascript for this element

Specified by:
javascript in interface PageElement
Returns:
API to execute javascript on this element.

find

public PageElement find(org.openqa.selenium.By locator)
Description copied from interface: PageElement

Returns an element that will match the given locator within this element.

This method will always return an element instance. Use PageElement.isPresent() to check whether a corresponding element on the page actually exists.

Specified by:
find in interface PageElement
Specified by:
find in interface PageElementFinder
Parameters:
locator - The locator mechanism
Returns:
An element that will be located within this element.

find

public PageElement find(org.openqa.selenium.By locator,
                        TimeoutType timeoutType)
Description copied from interface: PageElementFinder
Creates PageElement implementation using the specified locator and given timeoutType.

Specified by:
find in interface PageElementFinder
Parameters:
locator - Locator mechanism to use
timeoutType - timeout for the element's timed operations
Returns:
Element that waits until its present in the DOM before executing actions.

find

public <T extends PageElement> T find(org.openqa.selenium.By locator,
                                      Class<T> elementClass)
Description copied from interface: PageElementFinder
Creates PageElement extension of type T using the specified locator and default timeout.

Specified by:
find in interface PageElementFinder
Parameters:
locator - Locator mechanism to use
elementClass - The class of the element to create
Returns:
An instance that implements specified PageElement interface

find

public <T extends PageElement> T find(org.openqa.selenium.By locator,
                                      Class<T> elementClass,
                                      TimeoutType timeoutType)
Description copied from interface: PageElementFinder
Creates PageElement extension of type T using the specified locator and given timeoutType

Specified by:
find in interface PageElementFinder
Parameters:
locator - Locator mechanism to use
elementClass - The class of the element to create
timeoutType - timeout for the element's timed operations
Returns:
An instance that implements specified PageElement interface

findAll

public List<PageElement> findAll(org.openqa.selenium.By locator)
Description copied from interface: PageElement
Returns a list of element's that match the given locator within this element

Specified by:
findAll in interface PageElement
Specified by:
findAll in interface PageElementFinder
Parameters:
locator - The locator mecharnism
Returns:
A list of elements that are located within this element.

findAll

public List<PageElement> findAll(org.openqa.selenium.By locator,
                                 TimeoutType timeoutType)
Description copied from interface: PageElementFinder
Creates a PageElement for each element that matches the given locator using timeoutType.

Specified by:
findAll in interface PageElementFinder
Parameters:
locator - Locator mechanism to use
timeoutType - timeout for the element's timed operations
Returns:
List of PageElements that match the given locator

findAll

public <T extends PageElement> List<T> findAll(org.openqa.selenium.By locator,
                                               Class<T> elementClass)
Description copied from interface: PageElementFinder
Creates (@Link PageElement) extension of type T for each element that matches the given locator with default timeout

Specified by:
findAll in interface PageElementFinder
Parameters:
locator - Locator mechanism to use
elementClass - The class of the element to create
Returns:
A list of objects that implement specified PageElement interface

findAll

public <T extends PageElement> List<T> findAll(org.openqa.selenium.By locator,
                                               Class<T> elementClass,
                                               TimeoutType timeoutType)
Description copied from interface: PageElementFinder
Creates (@Link PageElement) extension of type T for each element that matches the given locator with timeoutType

Specified by:
findAll in interface PageElementFinder
Parameters:
locator - Locator mechanism to use
elementClass - The class of the element to create
timeoutType - timeout for the element's timed operations
Returns:
A list of objects that implement specified PageElement interface

asWebElement

public org.openqa.selenium.WebElement asWebElement()
This allows retrieving the webelement from the page element.

Returns:
the web element that represents the page element.

withTimeout

public PageElement withTimeout(TimeoutType timeoutType)
Description copied from interface: PageElement
Returns an instance equivalent to this element, with a changed timeoutType.

Specified by:
withTimeout in interface PageElement
Parameters:
timeoutType - new timeout
Returns:
new element with given timeoutType

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014 Atlassian. All rights reserved.