net.thucydides.core.pages
Class PageObject

Package class diagram package PageObject
java.lang.Object
  extended by net.thucydides.core.pages.PageObject
Direct Known Subclasses:
AnyPage

public abstract class PageObject
extends Object

A base class representing a WebDriver page object.

Author:
johnsmart

Nested Class Summary
 class PageObject.FieldEntry
           
 
Constructor Summary
PageObject(org.openqa.selenium.WebDriver driver)
           
PageObject(org.openqa.selenium.WebDriver driver, int ajaxTimeout)
           
 
Method Summary
 void addJQuerySupport()
           
 void blurActiveElement()
           
 void callWhenPageOpensMethods()
          Override this method
 void clickOn(org.openqa.selenium.WebElement webElement)
           
 boolean compatibleWithUrl(String currentUrl)
          Does this page object work for this URL? When matching a URL, we check with and without trailing slashes
 boolean containsAllText(String... textValues)
          Check that the specified text appears somewhere in the page.
 boolean containsText(String textValue)
           
 boolean containsTextInElement(org.openqa.selenium.WebElement webElement, String textValue)
          Deprecated. use element(webElement).containsText(textValue)
 WebElementFacade element(org.openqa.selenium.WebElement webElement)
          Provides a fluent API for querying web elements.
 PageObject.FieldEntry enter(String value)
          Clear a field and enter a value into it.
 Object evaluateJavascript(String script)
           
protected  InternalSystemClock getClock()
           
 org.openqa.selenium.WebDriver getDriver()
           
protected  JavaScriptExecutorFacade getJavaScriptExecutorFacade()
           
protected  net.thucydides.core.pages.RenderedPageObjectView getRenderedView()
           
 String getSelectedLabelFrom(org.openqa.selenium.WebElement dropdown)
           
 Set<String> getSelectedOptionLabelsFrom(org.openqa.selenium.WebElement dropdown)
           
 Set<String> getSelectedOptionValuesFrom(org.openqa.selenium.WebElement dropdown)
           
 String getSelectedValueFrom(org.openqa.selenium.WebElement dropdown)
           
 String getTitle()
           
 boolean hasFocus(org.openqa.selenium.WebElement webElement)
          Deprecated. Use element(webElement).hasFocus() instead
 Boolean isElementVisible(org.openqa.selenium.By byCriteria)
          Returns true if at least one matching element is found on the page and is visible.
protected  boolean matchesAnyUrl()
           
 void open()
          Open the webdriver browser to the base URL, determined by the DefaultUrl annotation if present.
 void open(String... parameterValues)
          Open the webdriver browser using a paramaterized URL.
 void open(String urlTemplateName, String[] parameterValues)
           
 void selectFromDropdown(org.openqa.selenium.WebElement dropdown, String visibleLabel)
           
 void selectMultipleItemsFromDropdown(org.openqa.selenium.WebElement dropdown, String... selectedLabels)
           
 void setCheckbox(org.openqa.selenium.WebElement field, boolean value)
           
 void setDefaultBaseUrl(String defaultBaseUrl)
           
 void setPageUrls(PageUrls pageUrls)
          Only for testing purposes.
 void setWaitForTimeout(long waitForTimeout)
           
 void shouldBeVisible(org.openqa.selenium.By byCriteria)
           
 void shouldBeVisible(org.openqa.selenium.WebElement field)
          Fail the test if this element is not displayed (rendered) on the screen.
 void shouldContainAllText(String... textValues)
          Check that all of the specified texts appears somewhere in the page.
 void shouldContainText(String textValue)
          Check that the specified text appears somewhere in the page.
 void shouldContainTextInElement(org.openqa.selenium.WebElement webElement, String textValue)
          Deprecated. 
 void shouldNotBeVisible(org.openqa.selenium.By byCriteria)
           
 void shouldNotBeVisible(org.openqa.selenium.WebElement field)
           
 void shouldNotContainTextInElement(org.openqa.selenium.WebElement webElement, String textValue)
          Deprecated. 
 List<org.openqa.selenium.WebElement> thenReturnElementList(org.openqa.selenium.By byListCriteria)
           
 void typeInto(org.openqa.selenium.WebElement field, String value)
          Clear a field and enter a value into it.
 String updateUrlWithBaseUrlIfDefined(String startingUrl)
           
 FileToUpload upload(String filename)
           
protected  void waitABit(long timeInMilliseconds)
           
 PageObject waitForAllTextToAppear(String... expectedTexts)
          Waits for all of a number of text blocks to appear on the screen.
 PageObject waitForAnyRenderedElementOf(org.openqa.selenium.By... expectedElements)
           
 PageObject waitForAnyTextToAppear(String... expectedText)
          Waits for any of a number of text blocks to appear anywhere on the screen.
 PageObject waitForAnyTextToAppear(org.openqa.selenium.WebElement element, String... expectedText)
           
 ThucydidesFluentWait<org.openqa.selenium.WebDriver> waitForCondition()
           
 ThucydidesFluentWait<org.openqa.selenium.WebDriver> waitForRefresh()
           
 PageObject waitForRenderedElements(org.openqa.selenium.By byElementCriteria)
           
 PageObject waitForRenderedElementsToBePresent(org.openqa.selenium.By byElementCriteria)
           
 PageObject waitForRenderedElementsToDisappear(org.openqa.selenium.By byElementCriteria)
           
 PageObject waitForTextToAppear(String expectedText)
          Waits for a given text to appear anywhere on the page.
 PageObject waitForTextToAppear(org.openqa.selenium.WebElement element, String expectedText)
          Waits for a given text to appear anywhere on the page.
 PageObject waitForTextToDisappear(String expectedText)
           
 PageObject waitForTextToDisappear(String expectedText, long timeout)
          Waits for a given text to not be anywhere on the page.
 PageObject waitForTextToDisappear(org.openqa.selenium.WebElement element, String expectedText)
          Waits for a given text to appear anywhere on the page.
 PageObject waitForTitleToAppear(String expectedTitle)
           
 PageObject waitForTitleToDisappear(String expectedTitle)
           
static String[] withParameters(String... parameterValues)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PageObject

public PageObject(org.openqa.selenium.WebDriver driver,
                  int ajaxTimeout)

PageObject

public PageObject(org.openqa.selenium.WebDriver driver)
Method Detail

upload

public FileToUpload upload(String filename)

setPageUrls

public void setPageUrls(PageUrls pageUrls)
Only for testing purposes.


setWaitForTimeout

public void setWaitForTimeout(long waitForTimeout)

getRenderedView

protected net.thucydides.core.pages.RenderedPageObjectView getRenderedView()

getClock

protected InternalSystemClock getClock()

getDriver

public org.openqa.selenium.WebDriver getDriver()

getTitle

public String getTitle()

matchesAnyUrl

protected boolean matchesAnyUrl()

compatibleWithUrl

public final boolean compatibleWithUrl(String currentUrl)
Does this page object work for this URL? When matching a URL, we check with and without trailing slashes


waitForRenderedElements

public PageObject waitForRenderedElements(org.openqa.selenium.By byElementCriteria)

waitForRenderedElementsToBePresent

public PageObject waitForRenderedElementsToBePresent(org.openqa.selenium.By byElementCriteria)

waitForRenderedElementsToDisappear

public PageObject waitForRenderedElementsToDisappear(org.openqa.selenium.By byElementCriteria)

waitForTextToAppear

public PageObject waitForTextToAppear(String expectedText)
Waits for a given text to appear anywhere on the page.


waitForTitleToAppear

public PageObject waitForTitleToAppear(String expectedTitle)

waitForTitleToDisappear

public PageObject waitForTitleToDisappear(String expectedTitle)

waitForTextToAppear

public PageObject waitForTextToAppear(org.openqa.selenium.WebElement element,
                                      String expectedText)
Waits for a given text to appear anywhere on the page.


waitForTextToDisappear

public PageObject waitForTextToDisappear(org.openqa.selenium.WebElement element,
                                         String expectedText)
Waits for a given text to appear anywhere on the page.


waitForTextToDisappear

public PageObject waitForTextToDisappear(String expectedText)

waitForTextToDisappear

public PageObject waitForTextToDisappear(String expectedText,
                                         long timeout)
Waits for a given text to not be anywhere on the page.


waitForAnyTextToAppear

public PageObject waitForAnyTextToAppear(String... expectedText)
Waits for any of a number of text blocks to appear anywhere on the screen.


waitForAnyTextToAppear

public PageObject waitForAnyTextToAppear(org.openqa.selenium.WebElement element,
                                         String... expectedText)

waitForAllTextToAppear

public PageObject waitForAllTextToAppear(String... expectedTexts)
Waits for all of a number of text blocks to appear on the screen.


waitForAnyRenderedElementOf

public PageObject waitForAnyRenderedElementOf(org.openqa.selenium.By... expectedElements)

waitABit

protected void waitABit(long timeInMilliseconds)

thenReturnElementList

public List<org.openqa.selenium.WebElement> thenReturnElementList(org.openqa.selenium.By byListCriteria)

shouldContainText

public void shouldContainText(String textValue)
Check that the specified text appears somewhere in the page.


shouldContainAllText

public void shouldContainAllText(String... textValues)
Check that all of the specified texts appears somewhere in the page.


containsTextInElement

@Deprecated
public boolean containsTextInElement(org.openqa.selenium.WebElement webElement,
                                                String textValue)
Deprecated. use element(webElement).containsText(textValue)

Does the specified web element contain a given text value. Useful for dropdowns and so on.


shouldContainTextInElement

@Deprecated
public void shouldContainTextInElement(org.openqa.selenium.WebElement webElement,
                                                  String textValue)
Deprecated. 


shouldNotContainTextInElement

@Deprecated
public void shouldNotContainTextInElement(org.openqa.selenium.WebElement webElement,
                                                     String textValue)
Deprecated. 


typeInto

public void typeInto(org.openqa.selenium.WebElement field,
                     String value)
Clear a field and enter a value into it.


enter

public PageObject.FieldEntry enter(String value)
Clear a field and enter a value into it. This is a more fluent alternative to using the typeInto method.


selectFromDropdown

public void selectFromDropdown(org.openqa.selenium.WebElement dropdown,
                               String visibleLabel)

selectMultipleItemsFromDropdown

public void selectMultipleItemsFromDropdown(org.openqa.selenium.WebElement dropdown,
                                            String... selectedLabels)

getSelectedOptionLabelsFrom

public Set<String> getSelectedOptionLabelsFrom(org.openqa.selenium.WebElement dropdown)

getSelectedOptionValuesFrom

public Set<String> getSelectedOptionValuesFrom(org.openqa.selenium.WebElement dropdown)

getSelectedValueFrom

public String getSelectedValueFrom(org.openqa.selenium.WebElement dropdown)

getSelectedLabelFrom

public String getSelectedLabelFrom(org.openqa.selenium.WebElement dropdown)

setCheckbox

public void setCheckbox(org.openqa.selenium.WebElement field,
                        boolean value)

containsText

public boolean containsText(String textValue)

containsAllText

public boolean containsAllText(String... textValues)
Check that the specified text appears somewhere in the page.


shouldBeVisible

public void shouldBeVisible(org.openqa.selenium.WebElement field)
Fail the test if this element is not displayed (rendered) on the screen.


shouldBeVisible

public void shouldBeVisible(org.openqa.selenium.By byCriteria)

shouldNotBeVisible

public void shouldNotBeVisible(org.openqa.selenium.WebElement field)

shouldNotBeVisible

public void shouldNotBeVisible(org.openqa.selenium.By byCriteria)

updateUrlWithBaseUrlIfDefined

public String updateUrlWithBaseUrlIfDefined(String startingUrl)

open

public final void open(String... parameterValues)
Open the webdriver browser using a paramaterized URL. Parameters are represented in the URL using {0}, {1}, etc.


open

public final void open(String urlTemplateName,
                       String[] parameterValues)

open

public final void open()
Open the webdriver browser to the base URL, determined by the DefaultUrl annotation if present. If the DefaultUrl annotation is not present, the default base URL will be used. If the DefaultUrl annotation is present, a URL based on the current base url from the system-wide defulat url and the relative path provided in the DefaultUrl annotation will be used to determine the URL to open. For example, consider the following class:
     


callWhenPageOpensMethods

public void callWhenPageOpensMethods()
Override this method


withParameters

public static String[] withParameters(String... parameterValues)

clickOn

public void clickOn(org.openqa.selenium.WebElement webElement)

isElementVisible

public Boolean isElementVisible(org.openqa.selenium.By byCriteria)
Returns true if at least one matching element is found on the page and is visible.


setDefaultBaseUrl

public void setDefaultBaseUrl(String defaultBaseUrl)

hasFocus

public boolean hasFocus(org.openqa.selenium.WebElement webElement)
Deprecated. Use element(webElement).hasFocus() instead

Returns true if the specified element has the focus.


blurActiveElement

public void blurActiveElement()

getJavaScriptExecutorFacade

protected JavaScriptExecutorFacade getJavaScriptExecutorFacade()

element

public WebElementFacade element(org.openqa.selenium.WebElement webElement)
Provides a fluent API for querying web elements.


evaluateJavascript

public Object evaluateJavascript(String script)

addJQuerySupport

public void addJQuerySupport()

waitForRefresh

public ThucydidesFluentWait<org.openqa.selenium.WebDriver> waitForRefresh()

waitForCondition

public ThucydidesFluentWait<org.openqa.selenium.WebDriver> waitForCondition()


Copyright © 2011 Wakaleo Consulting. All Rights Reserved.