public class Element extends Object implements IElement
Modifier and Type | Class and Description |
---|---|
protected static class |
Element.HIGHLIGHT_MODES |
Constructor and Description |
---|
Element(org.openqa.selenium.By locator) |
Element(String locator) |
Modifier and Type | Method and Description |
---|---|
void |
eval(String javascript)
Executes JavaScript code on the current element in the current frame or
window.
|
protected org.openqa.selenium.WebElement |
findElement()
Find the element using xpath, id, name, class name or tag name
|
void |
fireEvent(String event)
Fires a javascript event on a web element
|
void |
focusOn()
Focus on this element
|
String |
getAttribute(String attributeName)
Implementing this method would allow for getting an attribute of an
element
|
org.openqa.selenium.By |
getByLocator()
Implementing this method would allow for obtaining the XPath, ID, name,
CSS Selector, class name, or tag name to the element as By-Object.
|
String[] |
getChildNodesValuesText()
Returns the text contained in the child nodes of the current element
|
String |
getCssValue(String propertyName)
Implementing this method would allow for getting the CSS value given the
properties name
|
ExtWebDriver |
getGUIDriver()
Get the WebDriver object to interact with the UI elements
|
String |
getInnerHTML()
Returns inner HTML of the element
|
int |
getLocationX()
Implementing this method would allow for obtaining the X-coordinate of
the element
|
int |
getLocationY()
Implementing this method would allow for obtaining the Y-coordinate of
the element
|
String |
getLocator()
Implementing this method would allow for obtaining the XPath, ID, name,
CSS Selector, class name, or tag name to the element
|
String |
getText()
Implementing this method would allow for obtaining the text of the
Element
|
org.openqa.selenium.WebElement |
getWebElement()
Implementing this method would allow for getting this element as a
WebElement
|
boolean |
hasText(String text)
Implementing this method would allow for checking to see if the element's
text contains a specific substring
|
void |
highlight()
highlight an element for the FIND mode
|
void |
highlight(Element.HIGHLIGHT_MODES mode)
Find the current element and highlight it according to the mode
If mode is NONE, do nothing
|
void |
highlight(String colorMode)
Implementing this method would allow for highlighting this element a
specific color
|
boolean |
isAttributePresent(String attributeName)
Implementing this method would allow for checking if the element has a
specific attribute
|
boolean |
isElementNotPresent()
Implementing this method would allow for checking if an element is Not
present
|
boolean |
isElementNotPresent(long timeout)
Implementing this method would allow for checking if an element is Not
present within [timeout] milliseconds
|
boolean |
isElementPresent()
Implementing this method would allow for checking if an element is
present or not
|
boolean |
isElementPresent(boolean isJavaXPath)
Implementing this method would allow for checking if an element is
present or not
|
boolean |
isElementPresent(long timeout)
Implementing this method would allow for checking if an element is
present or not
|
boolean |
isElementVisible()
Implementing this method would allow for checking if an element is
visible or not
|
boolean |
isElementVisible(long timeout)
Implementing this method would allow for checking if an element is
visible or not within a designated length of time
|
boolean |
isEnabled()
Returns true if the element is enabled.
|
boolean |
isWithinBoundsOfWindow()
Determine if the element is within the bounds of the window
|
void |
scrollTo()
Scroll to this element
|
void |
setGUIDriver(ExtWebDriver guiDriver)
Tell Selenium to use the provided WebDriver instance
|
void |
waitForAttribute(String attributeName,
String pattern)
Waits for specific attribute value o match specific pattern within period
of maxRequestTimeout
|
void |
waitForAttribute(String attributeName,
String pattern,
long timeout)
Waits for specific attribute value to match specific pattern within
period of specified timeout
|
void |
waitForAttributeEqualTo(String attributeName,
String attributeValue)
Implementing this method would allow for keeping the test from
progressing until an element's attribute has the desired value
|
void |
waitForAttributeEqualTo(String attributeName,
String attributeValue,
long timeout)
Implementing this method would allow for keeping the test from
progressing until an element's attribute has the desired value by the
specified amount of time
|
void |
waitForAttributeNotEqualTo(String attributeName,
String attributeValue)
Implementing this method would allow for keeping the test from
progressing until an element's attribute no longer has the desired value
|
void |
waitForAttributeNotEqualTo(String attributeName,
String attributeValue,
long timeout)
Implementing this method would allow for keeping the test from
progressing until an element's attribute no longer has the desired value
by the specified amount of time
|
protected void |
waitForCommand(WaitForConditionTimer.ITimerCallback callback,
long timeout)
wait for timeout amount of time
|
void |
waitForElementNotPresent()
Implementing this method would allow for the test to wait until the
element is no longer present before progressing
|
void |
waitForElementNotPresent(long time)
Implementing this method would allow for the test to wait a designated
length of time until the element is no longer present before progressing
|
void |
waitForElementPresent()
Implementing this method would allow for the test to wait until the
element is present before progressing
|
void |
waitForElementPresent(long time)
Implementing this method would allow for the test to wait a designated
length of time until the element is present before progressing
|
void |
waitForEnabled()
Waits for element to be enabled within period of maxRequestTimeout
|
void |
waitForEnabled(long time)
Waits for element to be enabled within period of specified time
|
void |
waitForNotAttribute(String attributeName,
String pattern)
Waits for specific attribute value to not match specific pattern within
period of maxRequestTimeout
|
void |
waitForNotAttribute(String attributeName,
String pattern,
long timeout)
Waits for specific attribute value not match specific pattern within
period of specified timeout
|
void |
waitForNotVisible()
Implementing this method would allow for the test to wait until the
element is no longer visible before progressing
|
void |
waitForNotVisible(long time)
Waits for specific element at locator to be not visible within period of
specified time
|
void |
waitForText()
Implementing this method would allow for keeping the test from
progressing until an element has text
|
void |
waitForText(long time)
Implementing this method would allow for keeping the test from
progressing until an element has text
|
void |
waitForVisible()
Implementing this method would allow for the test to wait until the
element is visible before progressing
|
void |
waitForVisible(long time)
Waits for specific element at locator to be visible within period of
specified time
|
public Element(String locator)
locator
- XPath, ID, name, CSS Selector, class name, or tag namepublic Element(org.openqa.selenium.By locator)
locator
- a By which defines this element by its first matchpublic String getLocator()
IElement
getLocator
in interface IElement
public org.openqa.selenium.By getByLocator()
IElement
getByLocator
in interface IElement
By
-Object.public boolean isElementPresent() throws WidgetException
IElement
isElementPresent
in interface IElement
WidgetException
public boolean isElementPresent(long timeout) throws WidgetException
IElement
isElementPresent
in interface IElement
timeout
- - the length of time this method will wait for this element to
be presentWidgetException
public boolean isElementPresent(boolean isJavaXPath) throws WidgetException
IElement
isElementPresent
in interface IElement
isJavaXPath
- - if true, it attempts to find element using Java XPath API
and if false it attempts to find the element using the
WebDriver's APIWidgetException
public boolean isElementVisible() throws WidgetException
IElement
isElementVisible
in interface IElement
WidgetException
public boolean isElementVisible(long timeout) throws WidgetException
IElement
isElementVisible
in interface IElement
timeout
- - the length of time this method will wait for this element to
be presentWidgetException
public boolean isWithinBoundsOfWindow() throws WidgetException
isWithinBoundsOfWindow
in interface IElement
WidgetException
public void waitForElementPresent() throws WidgetException
IElement
waitForElementPresent
in interface IElement
WidgetException
public void waitForElementPresent(long time) throws WidgetException
IElement
waitForElementPresent
in interface IElement
time
- - the length of time this method will wait for this element to
be presentWidgetException
public void waitForElementNotPresent() throws WidgetException
IElement
waitForElementNotPresent
in interface IElement
WidgetException
public void waitForElementNotPresent(long time) throws WidgetException
IElement
waitForElementNotPresent
in interface IElement
time
- - the length of time this method will wait for this element to
be presentWidgetException
public void waitForVisible() throws WidgetException
IElement
waitForVisible
in interface IElement
WidgetException
public void waitForVisible(long time) throws WidgetException
waitForVisible
in interface IElement
time
- MillisecondsWidgetException
public void waitForNotVisible() throws WidgetException
IElement
waitForNotVisible
in interface IElement
WidgetException
public void waitForNotVisible(long time) throws WidgetException
waitForNotVisible
in interface IElement
time
- MillisecondsWidgetException
public boolean isAttributePresent(String attributeName) throws WidgetException
IElement
isAttributePresent
in interface IElement
attributeName
- - the attribute that is being checked forWidgetException
public String getAttribute(String attributeName) throws WidgetException
IElement
getAttribute
in interface IElement
attributeName
- - the attribute that is being grabbedWidgetException
public int getLocationX() throws WidgetException
IElement
getLocationX
in interface IElement
WidgetException
public int getLocationY() throws WidgetException
IElement
getLocationY
in interface IElement
WidgetException
public void setGUIDriver(ExtWebDriver guiDriver)
guiDriver
- ExtendedWebDriver objectpublic final ExtWebDriver getGUIDriver()
public String getText() throws WidgetException
IElement
getText
in interface IElement
WidgetException
public boolean hasText(String text) throws WidgetException
IElement
hasText
in interface IElement
text
- - the text that is being checked forWidgetException
public String getCssValue(String propertyName) throws WidgetException
IElement
getCssValue
in interface IElement
propertyName
- - the property to be checkedWidgetException
public void waitForAttributeEqualTo(String attributeName, String attributeValue) throws WidgetTimeoutException
IElement
waitForAttributeEqualTo
in interface IElement
attributeName
- - the attribute that is having it's value waited onattributeValue
- - the value that the test waits for the attribute to haveWidgetTimeoutException
public void waitForAttributeEqualTo(String attributeName, String attributeValue, long timeout) throws WidgetTimeoutException
IElement
waitForAttributeEqualTo
in interface IElement
attributeName
- - the attribute that is having it's value waited onattributeValue
- - the value that the test waits for the attribute to havetimeout
- - the length of time this method will wait for the attribute
to be equal to the desired valueWidgetTimeoutException
public void waitForAttributeNotEqualTo(String attributeName, String attributeValue) throws WidgetException
IElement
waitForAttributeNotEqualTo
in interface IElement
attributeName
- - the attribute that is having it's value waited onattributeValue
- - the value that the test waits for the attribute to no longer
haveWidgetException
public void waitForText() throws WidgetException
IElement
waitForText
in interface IElement
WidgetException
protected org.openqa.selenium.WebElement findElement() throws WidgetException
WidgetException
public void highlight() throws WidgetException
highlight
in interface IElement
WidgetException
public void eval(String javascript) throws WidgetException
eval
in interface IElement
javascript
- the javascript code to be executedWidgetException
public org.openqa.selenium.WebElement getWebElement() throws WidgetException
IElement
getWebElement
in interface IElement
WidgetException
protected void waitForCommand(WaitForConditionTimer.ITimerCallback callback, long timeout) throws WidgetTimeoutException
callback
- timeout
- WidgetTimeoutException
public void waitForText(long time) throws WidgetException, WidgetTimeoutException
IElement
waitForText
in interface IElement
time
- -the length of time this method will wait for the textWidgetException
WidgetTimeoutException
public void waitForNotAttribute(String attributeName, String pattern, long timeout) throws WidgetException
IElement
waitForNotAttribute
in interface IElement
attributeName
- Name of the attributepattern
- String pattern to matchtimeout
- MillisecondsWidgetException
public void waitForNotAttribute(String attributeName, String pattern) throws WidgetException
IElement
waitForNotAttribute
in interface IElement
attributeName
- Name of the attributepattern
- String pattern to matchWidgetException
public void waitForAttribute(String attributeName, String pattern, long timeout) throws WidgetException
IElement
waitForAttribute
in interface IElement
attributeName
- Name of the attributepattern
- String pattern to matchtimeout
- MillisecondsWidgetException
public void waitForAttribute(String attributeName, String pattern) throws WidgetException
IElement
waitForAttribute
in interface IElement
attributeName
- Name of the attributepattern
- String pattern to matchWidgetException
public void waitForEnabled() throws WidgetException
IElement
waitForEnabled
in interface IElement
WidgetException
public void waitForEnabled(long time) throws WidgetException
IElement
waitForEnabled
in interface IElement
time
- MillisecondsWidgetException
public boolean isEnabled() throws WidgetException
IElement
isEnabled
in interface IElement
WidgetException
public void waitForAttributeNotEqualTo(String attributeName, String attributeValue, long timeout) throws WidgetTimeoutException
IElement
waitForAttributeNotEqualTo
in interface IElement
attributeName
- - the attribute that is having it's value waited onattributeValue
- - the value that the test waits for the attribute to no longer
havetimeout
- - the length of time this method will wait for the attribute
to be no longer have to the desired valueWidgetTimeoutException
public boolean isElementNotPresent() throws WidgetException
IElement
isElementNotPresent
in interface IElement
WidgetException
public boolean isElementNotPresent(long timeout) throws WidgetException
IElement
isElementNotPresent
in interface IElement
timeout
- MillisecondsWidgetException
public void fireEvent(String event) throws WidgetException
fireEvent
in interface IElement
event
- the javascript code for the eventWidgetException
public String[] getChildNodesValuesText() throws WidgetException
getChildNodesValuesText
in interface IElement
WidgetException
public String getInnerHTML() throws WidgetException
IElement
getInnerHTML
in interface IElement
WidgetException
public void highlight(String colorMode) throws WidgetException
IElement
highlight
in interface IElement
colorMode
- - the color to be used when highlighting the elementWidgetException
public void highlight(Element.HIGHLIGHT_MODES mode) throws WidgetException
mode
- WidgetException
public void scrollTo() throws WidgetException
scrollTo
in interface IElement
WidgetException
public void focusOn() throws WidgetException
focusOn
in interface IElement
WidgetException
Copyright © 2018. All rights reserved.