public class HtmlElement extends Object
Modifier and Type | Field and Description |
---|---|
protected org.openqa.selenium.WebDriver |
driver |
protected org.openqa.selenium.WebElement |
element |
protected static org.apache.log4j.Logger |
logger |
protected WebUIDriver |
webUXDriver |
Constructor and Description |
---|
HtmlElement(String label,
org.openqa.selenium.By by)
Find element using BY locator.
|
HtmlElement(String label,
String locator,
com.seleniumtests.webelements.HtmlElement.LocatorType locatorType)
This constructor locates the element using locator and locator type.
|
Modifier and Type | Method and Description |
---|---|
void |
captureSnapshot()
Captures snapshot of the current browser window.
|
protected void |
captureSnapshot(String messagePrefix)
Captures snapshot of the current browser window, and prefix the file name with the assigned string.
|
void |
click() |
void |
clickAt()
Click element in native way by Actions.
|
void |
clickAt(String value)
Click element in native way by Actions.
|
protected void |
findElement()
Finds the element using By type.
|
List<org.openqa.selenium.WebElement> |
getAllElements()
Get all elements in the current page with same locator.
|
String |
getAttribute(String name)
Gets an attribute (using standard key-value pair) from the underlying attribute.
|
org.openqa.selenium.By |
getBy()
Returns the BY locator stored in the HtmlElement.
|
String |
getCssValue(String propertyName)
Returns the value for the specified CSS key.
|
protected org.openqa.selenium.WebDriver |
getDriver()
Get and refresh underlying WebDriver.
|
org.openqa.selenium.WebElement |
getElement()
Returns the underlying WebDriver WebElement.
|
String |
getEval(String script)
Executes the given JavaScript against the underlying WebElement.
|
int |
getHeight()
Returns the 'height' property of the underlying WebElement's Dimension.
|
String |
getLabel()
Returns the label used during initialization.
|
org.openqa.selenium.Point |
getLocation()
Gets the Point location of the underlying WebElement.
|
String |
getLocator()
Returns the locator used to find the underlying WebElement.
|
org.openqa.selenium.Dimension |
getSize()
Returns the Dimension property of the underlying WebElement.
|
String |
getTagName()
Returns the HTML Tag for the underlying WebElement (div, a, input, etc).
|
String |
getText()
Returns the text body of the underlying WebElement.
|
String |
getValue()
Returns the 'value' attribute of the underlying WebElement.
|
int |
getWidth()
Returns the 'width' property of the underlying WebElement's Dimension.
|
void |
init()
Refreshes the WebUIDriver before locating the element, to ensure we have the current version (useful for when the
state of an element has changed via an AJAX or non-page-turn action).
|
boolean |
isDisplayed()
Indicates whether or not the web element is currently displayed in the browser.
|
boolean |
isElementPresent()
Searches for the element using the BY locator, and indicates whether or not it exists in the page.
|
boolean |
isEnabled()
Indicates whether or not the element is enabled in the browser.
|
boolean |
isSelected()
Indicates whether or not the element is selected in the browser.
|
boolean |
isTextPresent(String text)
Whether or not the indicated text is contained in the element's getText() attribute.
|
void |
mouseDown()
Forces a mouseDown event on the WebElement.
|
void |
mouseOver()
Forces a mouseOver event on the WebElement.
|
void |
mouseUp()
Forces a mouseUp event on the WebElement.
|
void |
sendKeys(CharSequence... arg)
Sends the indicated CharSequence to the WebElement.
|
void |
simulateClick() |
void |
simulateMouseOver()
Forces a mouseOver event on the WebElement using simulate by JavaScript way for some dynamic menu.
|
void |
simulateMoveToElement(int x,
int y) |
protected void |
sleep(int waitTime)
Method, which should never be used.
|
String |
toHTML()
Converts the Type, Locator and LabelElement attributes of the HtmlElement into a readable and report-friendly
string.
|
String |
toString()
Returns a friendly string, representing the HtmlElement's Type, LabelElement and Locator.
|
void |
waitForPresent()
Wait element to present using Explicit Waits with default EXPLICIT_WAIT_TIME_OUT = 15 seconds.
|
void |
waitForPresent(int timeout)
Wait element to present using Explicit Waits with timeout in seconds.
|
protected static final org.apache.log4j.Logger logger
protected org.openqa.selenium.WebDriver driver
protected WebUIDriver webUXDriver
protected org.openqa.selenium.WebElement element
public HtmlElement(String label, org.openqa.selenium.By by)
label
- - element name for loggingby
- - By typepublic void captureSnapshot()
protected void captureSnapshot(String messagePrefix)
messagePrefix
- public void click()
public void clickAt()
public void clickAt(String value)
clickAt("1, 1");
value
- public void simulateClick()
public void simulateMoveToElement(int x, int y)
protected void findElement()
public List<org.openqa.selenium.WebElement> getAllElements()
public String getAttribute(String name)
name
- public org.openqa.selenium.By getBy()
public String getCssValue(String propertyName)
propertyName
- protected org.openqa.selenium.WebDriver getDriver()
public org.openqa.selenium.WebElement getElement()
public String getEval(String script)
script
- public int getHeight()
public String getLabel()
public org.openqa.selenium.Point getLocation()
public String getLocator()
public org.openqa.selenium.Dimension getSize()
public String getTagName()
public String getText()
public String getValue()
public int getWidth()
public void init()
public boolean isDisplayed()
public boolean isElementPresent()
public boolean isEnabled()
public boolean isSelected()
public boolean isTextPresent(String text)
text
- public void mouseDown()
public void mouseOver()
public void simulateMouseOver()
public void mouseUp()
public void sendKeys(CharSequence... arg)
arg
- protected void sleep(int waitTime) throws InterruptedException
InterruptedException
public String toHTML()
public String toString()
public void waitForPresent()
public void waitForPresent(int timeout)
Copyright © 2018. All rights reserved.