net.thucydides.core.pages
Class WebElementFacadeImpl

Package class diagram package WebElementFacadeImpl
java.lang.Object
  extended by net.thucydides.core.pages.WebElementFacadeImpl
All Implemented Interfaces:
WebElementFacade, WebElementState, org.openqa.selenium.internal.Locatable, org.openqa.selenium.internal.WrapsElement, org.openqa.selenium.SearchContext, org.openqa.selenium.WebElement

public class WebElementFacadeImpl
extends Object
implements WebElementFacade

A proxy class for a web element, providing some more methods.


Constructor Summary
WebElementFacadeImpl(org.openqa.selenium.WebDriver driver, org.openqa.selenium.support.pagefactory.ElementLocator locator, long timeoutInMilliseconds)
           
WebElementFacadeImpl(org.openqa.selenium.WebDriver driver, org.openqa.selenium.WebElement webElement, long timeoutInMilliseconds)
          Deprecated. As of release 0.9.127, replaced by static wrapWebElement(WebDriver driver,WebElement webElement,long timeoutInMilliseconds)
 
Method Summary
 WebElementFacade and()
          Convenience method to chain method calls more fluently.
 void clear()
           
 void click()
          Wait for an element to be visible and enabled, and then click on it.
 boolean containsOnlyText(String value)
          Does this element exactly match given text?
 boolean containsSelectOption(String value)
          Does this dropdown contain the specified value.
 boolean containsText(String value)
          Does this element contain a given text?
 WebElementFacade find(org.openqa.selenium.By bySelector)
           
 WebElementFacade findBy(org.openqa.selenium.By selector)
           
 WebElementFacade findBy(String xpathOrCssSelector)
           
 org.openqa.selenium.WebElement findElement(org.openqa.selenium.By by)
           
 List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.By by)
           
 String getAttribute(String name)
           
protected  InternalSystemClock getClock()
           
 org.openqa.selenium.interactions.internal.Coordinates getCoordinates()
           
 String getCssValue(String propertyName)
           
protected  org.openqa.selenium.WebElement getElement()
           
protected  JavascriptExecutorFacade getJavascriptExecutorFacade()
           
 org.openqa.selenium.Point getLocation()
           
 String getSelectedValue()
           
 String getSelectedVisibleTextValue()
           
 List<String> getSelectOptions()
           
 org.openqa.selenium.Dimension getSize()
           
 String getTagName()
           
 String getText()
           
 String getTextValue()
           
 long getTimeoutInMilliseconds()
           
 String getValue()
           
 org.openqa.selenium.WebElement getWrappedElement()
           
 boolean hasFocus()
          Does this element currently have the focus.
 boolean isCurrentlyEnabled()
           
 boolean isCurrentlyVisible()
          Is this web element present and visible on the screen This method will not throw an exception if the element is not on the screen at all.
 boolean isDisplayed()
           
 boolean isEnabled()
           
 boolean isPresent()
           
 boolean isSelected()
           
 boolean isVisible()
          Is this web element present and visible on the screen This method will not throw an exception if the element is not on the screen at all.
 WebElementFacade selectByIndex(int indexValue)
           
 WebElementFacade selectByValue(String value)
           
 WebElementFacade selectByVisibleText(String label)
           
 void sendKeys(CharSequence... keysToSend)
           
 void setWindowFocus()
           
 void shouldBeCurrentlyVisible()
          Checks whether a web element is visible.
 void shouldBeEnabled()
           
 void shouldBePresent()
           
 void shouldBeVisible()
          Checks whether a web element is visible.
 void shouldContainOnlyText(String textValue)
          Check that an element exactly matches a text value
 void shouldContainSelectedOption(String textValue)
           
 void shouldContainText(String textValue)
          Check that an element contains a text value
 void shouldNotBeCurrentlyVisible()
          Checks whether a web element is not visible straight away.
 void shouldNotBeEnabled()
           
 void shouldNotBePresent()
           
 void shouldNotBeVisible()
          Checks whether a web element is not visible.
 void shouldNotContainText(String textValue)
          Check that an element does not contain a text value
 void submit()
           
 WebElementFacade then()
          Convenience method to chain method calls more fluently.
 WebElementFacade then(org.openqa.selenium.By bySelector)
           
 WebElementFacade then(String xpathOrCssSelector)
           
 List<WebElementFacade> thenFindAll(org.openqa.selenium.By selector)
           
 List<WebElementFacade> thenFindAll(String xpathOrCssSelector)
           
 String toString()
           
 WebElementFacade type(String value)
          Type a value into a field, making sure that the field is empty first.
 WebElementFacade typeAndEnter(String value)
          Type a value into a field and then press Enter, making sure that the field is empty first.
 WebElementFacade typeAndTab(String value)
          Type a value into a field and then press TAB, making sure that the field is empty first.
 org.openqa.selenium.support.ui.Wait<org.openqa.selenium.WebDriver> waitForCondition()
           
 WebElementFacade waitUntilDisabled()
           
 WebElementFacade waitUntilEnabled()
           
 WebElementFacade waitUntilNotVisible()
           
 WebElementFacade waitUntilPresent()
           
 WebElementFacade waitUntilVisible()
           
 WebElementFacade withTimeoutOf(int timeout, TimeUnit unit)
           
static WebElementFacadeImpl wrapWebElement(org.openqa.selenium.WebDriver driver, org.openqa.selenium.WebElement element, long timeoutInMilliseconds)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebElementFacadeImpl

@Deprecated
public WebElementFacadeImpl(org.openqa.selenium.WebDriver driver,
                                       org.openqa.selenium.WebElement webElement,
                                       long timeoutInMilliseconds)
Deprecated. As of release 0.9.127, replaced by static wrapWebElement(WebDriver driver,WebElement webElement,long timeoutInMilliseconds)

Parameters:
driver -
webElement -
timeoutInMilliseconds -

WebElementFacadeImpl

public WebElementFacadeImpl(org.openqa.selenium.WebDriver driver,
                            org.openqa.selenium.support.pagefactory.ElementLocator locator,
                            long timeoutInMilliseconds)
Method Detail

wrapWebElement

public static WebElementFacadeImpl wrapWebElement(org.openqa.selenium.WebDriver driver,
                                                  org.openqa.selenium.WebElement element,
                                                  long timeoutInMilliseconds)

getElement

protected org.openqa.selenium.WebElement getElement()

getJavascriptExecutorFacade

protected JavascriptExecutorFacade getJavascriptExecutorFacade()

getClock

protected InternalSystemClock getClock()

then

public WebElementFacade then(String xpathOrCssSelector)
Specified by:
then in interface WebElementFacade

findBy

public WebElementFacade findBy(String xpathOrCssSelector)
Specified by:
findBy in interface WebElementFacade

thenFindAll

public List<WebElementFacade> thenFindAll(String xpathOrCssSelector)
Specified by:
thenFindAll in interface WebElementFacade

findBy

public WebElementFacade findBy(org.openqa.selenium.By selector)
Specified by:
findBy in interface WebElementFacade

find

public WebElementFacade find(org.openqa.selenium.By bySelector)
Specified by:
find in interface WebElementFacade

then

public WebElementFacade then(org.openqa.selenium.By bySelector)
Specified by:
then in interface WebElementFacade

getAttribute

public String getAttribute(String name)
Specified by:
getAttribute in interface WebElementFacade
Specified by:
getAttribute in interface org.openqa.selenium.WebElement

thenFindAll

public List<WebElementFacade> thenFindAll(org.openqa.selenium.By selector)
Specified by:
thenFindAll in interface WebElementFacade

getTimeoutInMilliseconds

public long getTimeoutInMilliseconds()
Specified by:
getTimeoutInMilliseconds in interface WebElementFacade

withTimeoutOf

public WebElementFacade withTimeoutOf(int timeout,
                                      TimeUnit unit)
Specified by:
withTimeoutOf in interface WebElementFacade

isVisible

public boolean isVisible()
Is this web element present and visible on the screen This method will not throw an exception if the element is not on the screen at all. If the element is not visible, the method will wait a bit to see if it appears later on.

Specified by:
isVisible in interface WebElementState

and

public WebElementFacade and()
Convenience method to chain method calls more fluently.

Specified by:
and in interface WebElementFacade

then

public WebElementFacade then()
Convenience method to chain method calls more fluently.

Specified by:
then in interface WebElementFacade

isCurrentlyVisible

public boolean isCurrentlyVisible()
Is this web element present and visible on the screen This method will not throw an exception if the element is not on the screen at all. The method will fail immediately if the element is not visible on the screen. There is a little black magic going on here - the web element class will detect if it is being called by a method called "isCurrently*" and, if so, fail immediately without waiting as it would normally do.

Specified by:
isCurrentlyVisible in interface WebElementState

isCurrentlyEnabled

public boolean isCurrentlyEnabled()
Specified by:
isCurrentlyEnabled in interface WebElementState

shouldBeVisible

public void shouldBeVisible()
Checks whether a web element is visible. Throws an AssertionError if the element is not rendered.

Specified by:
shouldBeVisible in interface WebElementState

shouldBeCurrentlyVisible

public void shouldBeCurrentlyVisible()
Checks whether a web element is visible. Throws an AssertionError if the element is not rendered.

Specified by:
shouldBeCurrentlyVisible in interface WebElementState

shouldNotBeVisible

public void shouldNotBeVisible()
Checks whether a web element is not visible. Throws an AssertionError if the element is not rendered.

Specified by:
shouldNotBeVisible in interface WebElementState

shouldNotBeCurrentlyVisible

public void shouldNotBeCurrentlyVisible()
Checks whether a web element is not visible straight away. Throws an AssertionError if the element is not rendered.

Specified by:
shouldNotBeCurrentlyVisible in interface WebElementState

hasFocus

public boolean hasFocus()
Does this element currently have the focus.

Specified by:
hasFocus in interface WebElementState

containsText

public boolean containsText(String value)
Does this element contain a given text?

Specified by:
containsText in interface WebElementState

containsOnlyText

public boolean containsOnlyText(String value)
Does this element exactly match given text?

Specified by:
containsOnlyText in interface WebElementState

containsSelectOption

public boolean containsSelectOption(String value)
Does this dropdown contain the specified value.

Specified by:
containsSelectOption in interface WebElementState

getSelectOptions

public List<String> getSelectOptions()
Specified by:
getSelectOptions in interface WebElementFacade

shouldContainText

public void shouldContainText(String textValue)
Check that an element contains a text value

Specified by:
shouldContainText in interface WebElementState
Parameters:
textValue -

shouldContainOnlyText

public void shouldContainOnlyText(String textValue)
Check that an element exactly matches a text value

Specified by:
shouldContainOnlyText in interface WebElementState
Parameters:
textValue -

shouldContainSelectedOption

public void shouldContainSelectedOption(String textValue)
Specified by:
shouldContainSelectedOption in interface WebElementState

shouldNotContainText

public void shouldNotContainText(String textValue)
Check that an element does not contain a text value

Specified by:
shouldNotContainText in interface WebElementState
Parameters:
textValue -

shouldBeEnabled

public void shouldBeEnabled()
Specified by:
shouldBeEnabled in interface WebElementState

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface WebElementState
Specified by:
isEnabled in interface org.openqa.selenium.WebElement

shouldNotBeEnabled

public void shouldNotBeEnabled()
Specified by:
shouldNotBeEnabled in interface WebElementState

type

public WebElementFacade type(String value)
Type a value into a field, making sure that the field is empty first.

Specified by:
type in interface WebElementFacade
Parameters:
value -

typeAndEnter

public WebElementFacade typeAndEnter(String value)
Type a value into a field and then press Enter, making sure that the field is empty first.

Specified by:
typeAndEnter in interface WebElementFacade
Parameters:
value -

typeAndTab

public WebElementFacade typeAndTab(String value)
Type a value into a field and then press TAB, making sure that the field is empty first. This currently is not supported by all browsers, notably Firefox.

Specified by:
typeAndTab in interface WebElementFacade
Parameters:
value -

setWindowFocus

public void setWindowFocus()
Specified by:
setWindowFocus in interface WebElementFacade

selectByVisibleText

public WebElementFacade selectByVisibleText(String label)
Specified by:
selectByVisibleText in interface WebElementFacade

getSelectedVisibleTextValue

public String getSelectedVisibleTextValue()
Specified by:
getSelectedVisibleTextValue in interface WebElementState

selectByValue

public WebElementFacade selectByValue(String value)
Specified by:
selectByValue in interface WebElementFacade

getSelectedValue

public String getSelectedValue()
Specified by:
getSelectedValue in interface WebElementState

selectByIndex

public WebElementFacade selectByIndex(int indexValue)
Specified by:
selectByIndex in interface WebElementFacade

isPresent

public boolean isPresent()
Specified by:
isPresent in interface WebElementState

shouldBePresent

public void shouldBePresent()
Specified by:
shouldBePresent in interface WebElementState

shouldNotBePresent

public void shouldNotBePresent()
Specified by:
shouldNotBePresent in interface WebElementState

waitUntilVisible

public WebElementFacade waitUntilVisible()
Specified by:
waitUntilVisible in interface WebElementFacade

waitUntilPresent

public WebElementFacade waitUntilPresent()
Specified by:
waitUntilPresent in interface WebElementFacade

waitForCondition

public org.openqa.selenium.support.ui.Wait<org.openqa.selenium.WebDriver> waitForCondition()
Specified by:
waitForCondition in interface WebElementFacade

waitUntilNotVisible

public WebElementFacade waitUntilNotVisible()
Specified by:
waitUntilNotVisible in interface WebElementFacade

getValue

public String getValue()
Specified by:
getValue in interface WebElementFacade

isSelected

public boolean isSelected()
Specified by:
isSelected in interface WebElementState
Specified by:
isSelected in interface org.openqa.selenium.WebElement

getText

public String getText()
Specified by:
getText in interface WebElementFacade
Specified by:
getText in interface org.openqa.selenium.WebElement

waitUntilEnabled

public WebElementFacade waitUntilEnabled()
Specified by:
waitUntilEnabled in interface WebElementFacade

waitUntilDisabled

public WebElementFacade waitUntilDisabled()
Specified by:
waitUntilDisabled in interface WebElementFacade

getTextValue

public String getTextValue()
Specified by:
getTextValue in interface WebElementState

click

public void click()
Wait for an element to be visible and enabled, and then click on it.

Specified by:
click in interface WebElementFacade
Specified by:
click in interface org.openqa.selenium.WebElement

clear

public void clear()
Specified by:
clear in interface WebElementFacade
Specified by:
clear in interface org.openqa.selenium.WebElement

toString

public String toString()
Specified by:
toString in interface WebElementFacade
Overrides:
toString in class Object

submit

public void submit()
Specified by:
submit in interface org.openqa.selenium.WebElement

sendKeys

public void sendKeys(CharSequence... keysToSend)
Specified by:
sendKeys in interface org.openqa.selenium.WebElement

getTagName

public String getTagName()
Specified by:
getTagName in interface org.openqa.selenium.WebElement

findElements

public List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.By by)
Specified by:
findElements in interface org.openqa.selenium.SearchContext
Specified by:
findElements in interface org.openqa.selenium.WebElement

findElement

public org.openqa.selenium.WebElement findElement(org.openqa.selenium.By by)
Specified by:
findElement in interface org.openqa.selenium.SearchContext
Specified by:
findElement in interface org.openqa.selenium.WebElement

isDisplayed

public boolean isDisplayed()
Specified by:
isDisplayed in interface org.openqa.selenium.WebElement

getLocation

public org.openqa.selenium.Point getLocation()
Specified by:
getLocation in interface org.openqa.selenium.WebElement

getSize

public org.openqa.selenium.Dimension getSize()
Specified by:
getSize in interface org.openqa.selenium.WebElement

getCssValue

public String getCssValue(String propertyName)
Specified by:
getCssValue in interface org.openqa.selenium.WebElement

getWrappedElement

public org.openqa.selenium.WebElement getWrappedElement()
Specified by:
getWrappedElement in interface org.openqa.selenium.internal.WrapsElement

getCoordinates

public org.openqa.selenium.interactions.internal.Coordinates getCoordinates()
Specified by:
getCoordinates in interface org.openqa.selenium.internal.Locatable


Copyright © 2011-2013 Wakaleo Consulting. All Rights Reserved.