public abstract class PageObject
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
PageObject.FieldEntry |
Constructor and Description |
---|
PageObject(org.openqa.selenium.WebDriver driver) |
PageObject(org.openqa.selenium.WebDriver driver,
EnvironmentVariables environmentVariables) |
PageObject(org.openqa.selenium.WebDriver driver,
int ajaxTimeout) |
Modifier and Type | Method and Description |
---|---|
<T extends WebElementFacade> |
$(java.lang.String xpathOrCssSelector) |
<T extends WebElementFacade> |
$(org.openqa.selenium.WebElement webElement) |
void |
addJQuerySupport() |
void |
blurActiveElement() |
void |
callWhenPageOpensMethods()
Override this method
|
void |
clickOn(org.openqa.selenium.WebElement webElement) |
boolean |
compatibleWithUrl(java.lang.String currentUrl)
Does this page object work for this URL? When matching a URL, we check
with and without trailing slashes
|
boolean |
containsAllText(java.lang.String... textValues)
Check that the specified text appears somewhere in the page.
|
boolean |
containsElements(org.openqa.selenium.By bySelector) |
boolean |
containsElements(java.lang.String xpathOrCssSelector) |
boolean |
containsText(java.lang.String textValue) |
boolean |
containsTextInElement(org.openqa.selenium.WebElement webElement,
java.lang.String textValue)
Deprecated.
use element(webElement).containsText(textValue)
|
<T extends WebElementFacade> |
element(org.openqa.selenium.By bySelector)
Provides a fluent API for querying web elements.
|
<T extends WebElementFacade> |
element(java.lang.String xpathOrCssSelector)
Provides a fluent API for querying web elements.
|
<T extends WebElementFacade> |
element(org.openqa.selenium.WebElement webElement)
Provides a fluent API for querying web elements.
|
PageObject.FieldEntry |
enter(java.lang.String value)
Clear a field and enter a value into it.
|
java.lang.Object |
evaluateJavascript(java.lang.String script) |
java.lang.Object |
evaluateJavascript(java.lang.String script,
java.lang.Object... params) |
<T extends WebElementFacade> |
find(org.openqa.selenium.By... selectors) |
<T extends WebElementFacade> |
find(java.util.List<org.openqa.selenium.By> selectors) |
java.util.List<WebElementFacade> |
findAll(org.openqa.selenium.By bySelector) |
java.util.List<WebElementFacade> |
findAll(java.lang.String xpathOrCssSelector) |
<T extends WebElementFacade> |
findBy(java.lang.String xpathOrCssSelector) |
<T extends PageObject> |
foo() |
org.openqa.selenium.Alert |
getAlert() |
org.openqa.selenium.WebDriver |
getDriver() |
org.openqa.selenium.support.ui.Duration |
getImplicitWaitTimeout() |
java.lang.String |
getSelectedLabelFrom(org.openqa.selenium.WebElement dropdown) |
java.util.Set<java.lang.String> |
getSelectedOptionLabelsFrom(org.openqa.selenium.WebElement dropdown) |
java.util.Set<java.lang.String> |
getSelectedOptionValuesFrom(org.openqa.selenium.WebElement dropdown) |
java.lang.String |
getSelectedValueFrom(org.openqa.selenium.WebElement dropdown) |
java.lang.String |
getTitle() |
org.openqa.selenium.support.ui.Duration |
getWaitForElementTimeout()
Deprecated.
|
org.openqa.selenium.support.ui.Duration |
getWaitForTimeout() |
boolean |
hasFocus(org.openqa.selenium.WebElement webElement)
Deprecated.
Use element(webElement).hasFocus() instead
|
long |
implicitTimoutMilliseconds() |
RadioButtonGroup |
inRadioButtonGroup(java.lang.String name) |
java.lang.Boolean |
isElementVisible(org.openqa.selenium.By byCriteria)
Returns true if at least one matching element is found on the page and is visible.
|
boolean |
matchesAnyUrl() |
<T extends WebElementFacade> |
moveTo(org.openqa.selenium.By locator) |
<T extends WebElementFacade> |
moveTo(java.lang.String xpathOrCssSelector) |
void |
open()
Open the webdriver browser to the base URL, determined by the DefaultUrl
annotation if present.
|
void |
open(java.lang.String[] parameterValues)
Open the webdriver browser using a paramaterized URL.
|
void |
open(java.lang.String urlTemplateName,
java.lang.String[] parameterValues) |
void |
openAt(java.lang.String startingUrl) |
void |
openUnchecked()
Opens page without checking URL patterns.
|
void |
openUnchecked(java.lang.String... parameterValues)
Opens page without checking URL patterns.
|
void |
openUnchecked(java.lang.String urlTemplateName,
java.lang.String[] parameterValues)
Opens page without checking URL patterns.
|
void |
resetImplicitTimeout() |
void |
selectFromDropdown(org.openqa.selenium.WebElement dropdown,
java.lang.String visibleLabel) |
void |
selectMultipleItemsFromDropdown(org.openqa.selenium.WebElement dropdown,
java.lang.String... selectedLabels) |
void |
setCheckbox(org.openqa.selenium.WebElement field,
boolean value) |
void |
setDefaultBaseUrl(java.lang.String defaultBaseUrl) |
void |
setDriver(org.openqa.selenium.WebDriver driver) |
void |
setImplicitTimeout(int duration,
java.util.concurrent.TimeUnit unit) |
void |
setPages(Pages pages) |
void |
setPageUrls(PageUrls pageUrls)
Only for testing purposes.
|
void |
setWaitForElementTimeout(long waitForTimeoutInMilliseconds) |
void |
setWaitForTimeout(long waitForTimeoutInMilliseconds) |
void |
shouldBeDisplayed()
Use the @At annotation (if present) to check that a page object is displaying the correct page.
|
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(java.lang.String... textValues)
Check that all of the specified texts appears somewhere in the page.
|
void |
shouldContainText(java.lang.String textValue)
Check that the specified text appears somewhere in the page.
|
void |
shouldContainTextInElement(org.openqa.selenium.WebElement webElement,
java.lang.String textValue)
Deprecated.
|
void |
shouldNotBeVisible(org.openqa.selenium.By byCriteria) |
void |
shouldNotBeVisible(org.openqa.selenium.WebElement field) |
void |
shouldNotContainTextInElement(org.openqa.selenium.WebElement webElement,
java.lang.String textValue)
Deprecated.
|
<T extends PageObject> |
switchToPage(java.lang.Class<T> pageObjectClass) |
java.util.List<org.openqa.selenium.WebElement> |
thenReturnElementList(org.openqa.selenium.By byListCriteria) |
java.lang.String |
toString() |
void |
typeInto(org.openqa.selenium.WebElement field,
java.lang.String value)
Clear a field and enter a value into it.
|
java.lang.String |
updateUrlWithBaseUrlIfDefined(java.lang.String startingUrl) |
FileToUpload |
upload(java.lang.String filename)
Upload a file via an HTML form.
|
FileToUpload |
uploadData(byte[] data) |
FileToUpload |
uploadData(java.lang.String data) |
PageObject |
waitFor(org.openqa.selenium.support.ui.ExpectedCondition expectedCondition) |
WaitForBuilder<? extends PageObject> |
waitFor(int duration) |
PageObject |
waitFor(java.lang.String xpathOrCssSelector) |
WebElementFacade |
waitFor(org.openqa.selenium.WebElement webElement) |
WebElementFacade |
waitFor(WebElementFacade webElement) |
PageObject |
waitForAbsenceOf(java.lang.String xpathOrCssSelector) |
PageObject |
waitForAllTextToAppear(java.lang.String... expectedTexts)
Waits for all of a number of text blocks to appear on the screen.
|
void |
waitForAngularRequestsToFinish() |
PageObject |
waitForAnyRenderedElementOf(org.openqa.selenium.By... expectedElements) |
PageObject |
waitForAnyTextToAppear(java.lang.String... expectedText)
Waits for any of a number of text blocks to appear anywhere on the
screen.
|
PageObject |
waitForAnyTextToAppear(org.openqa.selenium.WebElement element,
java.lang.String... expectedText) |
ThucydidesFluentWait<org.openqa.selenium.WebDriver> |
waitForCondition() |
PageObject |
waitForPresenceOf(java.lang.String xpathOrCssSelector) |
PageObject |
waitForRenderedElements(org.openqa.selenium.By byElementCriteria) |
PageObject |
waitForRenderedElementsToBePresent(org.openqa.selenium.By byElementCriteria) |
PageObject |
waitForRenderedElementsToDisappear(org.openqa.selenium.By byElementCriteria) |
PageObject |
waitForTextToAppear(java.lang.String expectedText)
Waits for a given text to appear anywhere on the page.
|
PageObject |
waitForTextToAppear(java.lang.String expectedText,
long timeout)
Waits for a given text to appear anywhere on the page.
|
PageObject |
waitForTextToAppear(org.openqa.selenium.WebElement element,
java.lang.String expectedText)
Waits for a given text to appear inside the element.
|
PageObject |
waitForTextToDisappear(java.lang.String expectedText) |
PageObject |
waitForTextToDisappear(java.lang.String expectedText,
long timeoutInMilliseconds)
Waits for a given text to not be anywhere on the page.
|
PageObject |
waitForTextToDisappear(org.openqa.selenium.WebElement element,
java.lang.String expectedText)
Waits for a given text to disappear from the element.
|
long |
waitForTimeoutInMilliseconds() |
PageObject |
waitForTitleToAppear(java.lang.String expectedTitle) |
PageObject |
waitForTitleToDisappear(java.lang.String expectedTitle) |
ThucydidesFluentWait<org.openqa.selenium.WebDriver> |
waitForWithRefresh() |
org.openqa.selenium.interactions.Actions |
withAction() |
PageObject |
withDriver(org.openqa.selenium.WebDriver driver) |
static java.lang.String[] |
withParameters(java.lang.String... parameterValues) |
RenderedPageObjectView |
withTimeoutOf(org.openqa.selenium.support.ui.Duration timeout) |
RenderedPageObjectView |
withTimeoutOf(int timeout,
java.util.concurrent.TimeUnit units) |
public PageObject(org.openqa.selenium.WebDriver driver, int ajaxTimeout)
public PageObject(org.openqa.selenium.WebDriver driver)
public PageObject(org.openqa.selenium.WebDriver driver, EnvironmentVariables environmentVariables)
public void setImplicitTimeout(int duration, java.util.concurrent.TimeUnit unit)
public void resetImplicitTimeout()
public void setDriver(org.openqa.selenium.WebDriver driver)
public PageObject withDriver(org.openqa.selenium.WebDriver driver)
public org.openqa.selenium.support.ui.Duration getWaitForTimeout()
@Deprecated public org.openqa.selenium.support.ui.Duration getWaitForElementTimeout()
public org.openqa.selenium.support.ui.Duration getImplicitWaitTimeout()
public void setPages(Pages pages)
public <T extends PageObject> T switchToPage(java.lang.Class<T> pageObjectClass)
public FileToUpload upload(java.lang.String filename)
public FileToUpload uploadData(java.lang.String data) throws java.io.IOException
java.io.IOException
public FileToUpload uploadData(byte[] data) throws java.io.IOException
java.io.IOException
public void setPageUrls(PageUrls pageUrls)
public void setWaitForTimeout(long waitForTimeoutInMilliseconds)
public void setWaitForElementTimeout(long waitForTimeoutInMilliseconds)
public org.openqa.selenium.WebDriver getDriver()
public java.lang.String getTitle()
public boolean matchesAnyUrl()
public final boolean compatibleWithUrl(java.lang.String currentUrl)
public PageObject waitForRenderedElements(org.openqa.selenium.By byElementCriteria)
public RenderedPageObjectView withTimeoutOf(int timeout, java.util.concurrent.TimeUnit units)
public RenderedPageObjectView withTimeoutOf(org.openqa.selenium.support.ui.Duration timeout)
public PageObject waitFor(java.lang.String xpathOrCssSelector)
public PageObject waitFor(org.openqa.selenium.support.ui.ExpectedCondition expectedCondition)
public PageObject waitForRenderedElementsToBePresent(org.openqa.selenium.By byElementCriteria)
public PageObject waitForPresenceOf(java.lang.String xpathOrCssSelector)
public PageObject waitForRenderedElementsToDisappear(org.openqa.selenium.By byElementCriteria)
public PageObject waitForAbsenceOf(java.lang.String xpathOrCssSelector)
public PageObject waitForTextToAppear(java.lang.String expectedText)
public PageObject waitForTitleToAppear(java.lang.String expectedTitle)
public PageObject waitForTitleToDisappear(java.lang.String expectedTitle)
public PageObject waitForTextToAppear(org.openqa.selenium.WebElement element, java.lang.String expectedText)
public PageObject waitForTextToDisappear(org.openqa.selenium.WebElement element, java.lang.String expectedText)
public PageObject waitForTextToDisappear(java.lang.String expectedText)
public PageObject waitForTextToDisappear(java.lang.String expectedText, long timeoutInMilliseconds)
public PageObject waitForTextToAppear(java.lang.String expectedText, long timeout)
public PageObject waitForAnyTextToAppear(java.lang.String... expectedText)
public PageObject waitForAnyTextToAppear(org.openqa.selenium.WebElement element, java.lang.String... expectedText)
public PageObject waitForAllTextToAppear(java.lang.String... expectedTexts)
public PageObject waitForAnyRenderedElementOf(org.openqa.selenium.By... expectedElements)
public WaitForBuilder<? extends PageObject> waitFor(int duration)
public java.util.List<org.openqa.selenium.WebElement> thenReturnElementList(org.openqa.selenium.By byListCriteria)
public <T extends PageObject> T foo()
public void shouldContainText(java.lang.String textValue)
public void shouldContainAllText(java.lang.String... textValues)
@Deprecated public boolean containsTextInElement(org.openqa.selenium.WebElement webElement, java.lang.String textValue)
@Deprecated public void shouldContainTextInElement(org.openqa.selenium.WebElement webElement, java.lang.String textValue)
@Deprecated public void shouldNotContainTextInElement(org.openqa.selenium.WebElement webElement, java.lang.String textValue)
public void typeInto(org.openqa.selenium.WebElement field, java.lang.String value)
public PageObject.FieldEntry enter(java.lang.String value)
public void selectFromDropdown(org.openqa.selenium.WebElement dropdown, java.lang.String visibleLabel)
public void selectMultipleItemsFromDropdown(org.openqa.selenium.WebElement dropdown, java.lang.String... selectedLabels)
public java.util.Set<java.lang.String> getSelectedOptionLabelsFrom(org.openqa.selenium.WebElement dropdown)
public java.util.Set<java.lang.String> getSelectedOptionValuesFrom(org.openqa.selenium.WebElement dropdown)
public java.lang.String getSelectedValueFrom(org.openqa.selenium.WebElement dropdown)
public java.lang.String getSelectedLabelFrom(org.openqa.selenium.WebElement dropdown)
public void setCheckbox(org.openqa.selenium.WebElement field, boolean value)
public boolean containsText(java.lang.String textValue)
public boolean containsAllText(java.lang.String... textValues)
public void shouldBeVisible(org.openqa.selenium.WebElement field)
public void shouldBeVisible(org.openqa.selenium.By byCriteria)
public void shouldNotBeVisible(org.openqa.selenium.WebElement field)
public void shouldNotBeVisible(org.openqa.selenium.By byCriteria)
public long waitForTimeoutInMilliseconds()
public long implicitTimoutMilliseconds()
public java.lang.String updateUrlWithBaseUrlIfDefined(java.lang.String startingUrl)
public final void open(java.lang.String[] parameterValues)
public final void openUnchecked(java.lang.String... parameterValues)
public final void open(java.lang.String urlTemplateName, java.lang.String[] parameterValues)
public final void openUnchecked(java.lang.String urlTemplateName, java.lang.String[] parameterValues)
open(String, String[])
otherwise.public final void open()
@DefaultUrl("http://localhost:8080/client/list")
public class ClientList extends PageObject {
...
@WhenPageOpens
public void waitUntilTitleAppears() {...}
}
Suppose you are using a base URL of http://stage.acme.com. When you call open() for this class,
it will open http://stage.acme.com/client/list. It will then invoke the waitUntilTitleAppears() method.public final void openUnchecked()
open()
otherwise.public void shouldBeDisplayed()
public final void openAt(java.lang.String startingUrl)
public void callWhenPageOpensMethods()
public static java.lang.String[] withParameters(java.lang.String... parameterValues)
public void clickOn(org.openqa.selenium.WebElement webElement)
public java.lang.Boolean isElementVisible(org.openqa.selenium.By byCriteria)
public void setDefaultBaseUrl(java.lang.String defaultBaseUrl)
public boolean hasFocus(org.openqa.selenium.WebElement webElement)
public void blurActiveElement()
public <T extends WebElementFacade> T element(org.openqa.selenium.WebElement webElement)
public <T extends WebElementFacade> T $(org.openqa.selenium.WebElement webElement)
public <T extends WebElementFacade> T $(java.lang.String xpathOrCssSelector)
public <T extends WebElementFacade> T element(org.openqa.selenium.By bySelector)
public <T extends WebElementFacade> T find(java.util.List<org.openqa.selenium.By> selectors)
public <T extends WebElementFacade> T find(org.openqa.selenium.By... selectors)
public java.util.List<WebElementFacade> findAll(org.openqa.selenium.By bySelector)
public <T extends WebElementFacade> T element(java.lang.String xpathOrCssSelector)
public <T extends WebElementFacade> T findBy(java.lang.String xpathOrCssSelector)
public java.util.List<WebElementFacade> findAll(java.lang.String xpathOrCssSelector)
public boolean containsElements(org.openqa.selenium.By bySelector)
public boolean containsElements(java.lang.String xpathOrCssSelector)
public java.lang.Object evaluateJavascript(java.lang.String script)
public java.lang.Object evaluateJavascript(java.lang.String script, java.lang.Object... params)
public void addJQuerySupport()
public RadioButtonGroup inRadioButtonGroup(java.lang.String name)
public ThucydidesFluentWait<org.openqa.selenium.WebDriver> waitForWithRefresh()
public ThucydidesFluentWait<org.openqa.selenium.WebDriver> waitForCondition()
public WebElementFacade waitFor(org.openqa.selenium.WebElement webElement)
public WebElementFacade waitFor(WebElementFacade webElement)
public org.openqa.selenium.Alert getAlert()
public org.openqa.selenium.interactions.Actions withAction()
public <T extends WebElementFacade> T moveTo(java.lang.String xpathOrCssSelector)
public <T extends WebElementFacade> T moveTo(org.openqa.selenium.By locator)
public void waitForAngularRequestsToFinish()
public java.lang.String toString()
toString
in class java.lang.Object