public abstract class AbstractPageComponent extends Object
Abstract base class for all page object components
Copyright 2017 (C) by Martin Ganserer
| Modifier and Type | Field and Description |
|---|---|
static int |
AJAX_POLLING_INTERVAL_MILLISECONDS |
static String |
ATTR_NAME_CLASS |
static String |
ATTR_NAME_SELECTED |
static String |
ATTR_NAME_STYLE |
static String |
ATTR_NAME_VALUE |
protected org.openqa.selenium.WebDriver |
driver |
static String |
HTML_LIST_ITEM |
static String |
ITEM_DELIMITER |
protected org.slf4j.Logger |
logger |
static String |
NEW_LINE |
static int |
ROW_OFFSET_X |
static int |
ROW_OFFSET_Y |
protected SeleniumTestContext |
testContext |
| Constructor and Description |
|---|
AbstractPageComponent(SeleniumTestContext testContext)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
assertEquals(String message,
Object expected,
Object actual)
Assert that two objects are equal and create a log record if the assertion test has failed
|
void |
assertNotNull(String message,
Object object)
Assert that an object isn't null and create a log record if the assertion test has failed
|
void |
assertTrue(String message,
boolean condition)
Assert that a condition is true and create a log record if the assertion test has failed
|
protected void |
delayPageLoad()
Delay the test after creating a page object in order to make sure that the page has been fully rendered
|
void |
doubleClickElement(org.openqa.selenium.WebElement webElement)
Perform a double-click on the given element
|
void |
fail(String message)
Throw an assertion error and log the message
|
void |
fail(String message,
Throwable t)
Throw an assertion error and log the message
|
org.openqa.selenium.WebElement |
findWebElement(String elementId)
Search for an element by using the given ID
|
org.openqa.selenium.WebElement |
findWebElement(String elementId,
int explicitWaitInSeconds)
Search for an element by using the given ID
|
org.openqa.selenium.WebElement |
findWebElementByXPath(String xpathExpression)
Find an element by using a XPath expression
|
List<org.openqa.selenium.WebElement> |
findWebElementsByXPath(String xpathExpression)
Find elements by using a XPath expression
|
org.openqa.selenium.WebDriver |
getDriver() |
org.slf4j.Logger |
getLogger() |
SeleniumTestContext |
getTestContext() |
void |
moveToElement(org.openqa.selenium.WebElement webElement) |
protected void |
scrollTo(org.openqa.selenium.WebElement element)
Scroll the browser window to the location of the given element
|
void |
setInputFieldValue(PageElementTestData testData)
Enter data into an input field
|
void |
setLogger(org.slf4j.Logger logger) |
void |
validateInputFieldValue(PageElementTestData testData)
Validate an input field by using the field's test data object
|
abstract void |
waitForPendingAjaxRequests()
Every implementation must define how to wait for pending AJAX requests!
|
void |
waitUntilVisible(org.openqa.selenium.WebElement webElement,
int secondsToWait)
Wait a specific amount of time in seconds until an element should be visible
|
public static final String ATTR_NAME_VALUE
public static final String HTML_LIST_ITEM
public static final String ATTR_NAME_CLASS
public static final String ATTR_NAME_STYLE
public static final String ATTR_NAME_SELECTED
public static final String NEW_LINE
public static final String ITEM_DELIMITER
public static final int ROW_OFFSET_X
public static final int ROW_OFFSET_Y
public static final int AJAX_POLLING_INTERVAL_MILLISECONDS
protected org.openqa.selenium.WebDriver driver
protected org.slf4j.Logger logger
protected SeleniumTestContext testContext
public AbstractPageComponent(SeleniumTestContext testContext)
testContext - public void setLogger(org.slf4j.Logger logger)
logger - public org.slf4j.Logger getLogger()
public org.openqa.selenium.WebDriver getDriver()
public SeleniumTestContext getTestContext()
public org.openqa.selenium.WebElement findWebElement(String elementId, int explicitWaitInSeconds)
elementId - explicitWaitInSeconds - controls the amount of time in seconds until an element should be visibleAssertionError - if the element either could not be found, or the parameter elementId is null or emptypublic org.openqa.selenium.WebElement findWebElement(String elementId)
elementId - AssertionError - if the element either could not be found, or the parameter elementId is null or emptypublic org.openqa.selenium.WebElement findWebElementByXPath(String xpathExpression)
xpathExpression - AssertionError - if the element either could not be found, or the XPath expression is null or emptypublic List<org.openqa.selenium.WebElement> findWebElementsByXPath(String xpathExpression)
xpathExpression - AssertionError - if the XPath expression is null or emptypublic void doubleClickElement(org.openqa.selenium.WebElement webElement)
webElement - AssertionError - if the parameter webElement is nullpublic void setInputFieldValue(PageElementTestData testData)
testData - the field's test data object that provides necessary informationpublic void validateInputFieldValue(PageElementTestData testData)
testData - the field's test data object that provides necessary informationAssertionError - if the validation has failedpublic void waitUntilVisible(org.openqa.selenium.WebElement webElement,
int secondsToWait)
webElement - secondsToWait - AssertionError - if the parameter webElement is nullpublic void moveToElement(org.openqa.selenium.WebElement webElement)
webElement - AssertionError - if the parameter webElement is nullpublic void assertTrue(String message, boolean condition)
message - condition - AssertionError - if the condition is not truepublic void assertNotNull(String message, Object object)
message - object - AssertionError - if the object is nullpublic void assertEquals(String message, Object expected, Object actual)
message - expected - actual - AssertionError - if both objects are not equalpublic void fail(String message)
message - AssertionError - in any casepublic void fail(String message, Throwable t)
message - t - AssertionError - in any casepublic abstract void waitForPendingAjaxRequests()
protected void delayPageLoad()
protected void scrollTo(org.openqa.selenium.WebElement element)
element - Copyright © 2019. All rights reserved.