Package com.facilita.fc.selenium
Class WebElement
- java.lang.Object
-
- com.facilita.fc.selenium.WebElement
-
- All Implemented Interfaces:
SearchContext,TakesScreenshot,WebElement
public class WebElement extends java.lang.Object implements WebElement
An implementation ofWebElement, which represents an HTML element.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()If this element is a text entry element, this will clear the value.voidclick()Click this element.WebElementfindElement(By by)Find the first WebElement using the given method.java.util.List<WebElement>findElements(By by)Find all elements within the current context using the given mechanism.java.lang.StringgetAttribute(java.lang.String name)Get the value of a the given attribute of the element.java.lang.StringgetCssValue(java.lang.String propertyName)Get the value of a given CSS property.PointgetLocation()Where on the page is the top left-hand corner of the rendered element?RectanglegetRect()(NB: As of Feb 2016, this appeared as an abstract method in org.openqa.selenium.WebElement (Selenium v.2.50.1).<X> XgetScreenshotAs(OutputType<X> target)Capture the screenshot and store it in the specified location.DimensiongetSize()What is the width and height of the rendered element?java.lang.StringgetTagName()Get the tag name of this element.java.lang.StringgetText()Get the visible innerText of this element.booleanisDisplayed()Is this element displayed or not?booleanisEnabled()Is the element currently enabled or not?booleanisSelected()Determine whether or not this element is selected or not.voidsendKeys(java.lang.CharSequence... keysToSend)Use this method to simulate typing into an element, which may set its value.voidsubmit()If this current element is a form, or an element within a form, then this will be submitted to the remote server.
-
-
-
Method Detail
-
clear
public void clear()
If this element is a text entry element, this will clear the value.- Specified by:
clearin interfaceWebElement
-
click
public void click()
Click this element.- Specified by:
clickin interfaceWebElement
-
findElement
public WebElement findElement(By by)
Find the first WebElement using the given method.- Specified by:
findElementin interfaceSearchContext- Specified by:
findElementin interfaceWebElement- Parameters:
by- The locating mechanism- Returns:
- The first matching element on the current context.
-
findElements
public java.util.List<WebElement> findElements(By by)
Find all elements within the current context using the given mechanism.- Specified by:
findElementsin interfaceSearchContext- Specified by:
findElementsin interfaceWebElement- Parameters:
by- The locating mechanism to use- Returns:
- A list of all
WebElements, or an empty list if nothing matches.
-
getAttribute
public java.lang.String getAttribute(java.lang.String name)
Get the value of a the given attribute of the element.- Specified by:
getAttributein interfaceWebElement- Parameters:
name- The name of the attribute.- Returns:
- The attribute's current value or null if the value is not set.
-
getCssValue
public java.lang.String getCssValue(java.lang.String propertyName)
Get the value of a given CSS property.- Specified by:
getCssValuein interfaceWebElement- Parameters:
propertyName- The name of the property to get.- Returns:
- The current, computed value of the property.
-
getLocation
public Point getLocation()
Where on the page is the top left-hand corner of the rendered element?- Specified by:
getLocationin interfaceWebElement- Returns:
- A point, containing the location of the top left-hand corner of the element
-
getSize
public Dimension getSize()
What is the width and height of the rendered element?- Specified by:
getSizein interfaceWebElement- Returns:
- The size of the element on the page.
-
getTagName
public java.lang.String getTagName()
Get the tag name of this element.- Specified by:
getTagNamein interfaceWebElement- Returns:
- The tag name of this element.
-
getText
public java.lang.String getText()
Get the visible innerText of this element.- Specified by:
getTextin interfaceWebElement- Returns:
- The innerText of this element
-
isDisplayed
public boolean isDisplayed()
Is this element displayed or not?- Specified by:
isDisplayedin interfaceWebElement- Returns:
- Whether or not the element is displayed
-
isEnabled
public boolean isEnabled()
Is the element currently enabled or not?- Specified by:
isEnabledin interfaceWebElement- Returns:
- True if the element is enabled, false otherwise.
-
isSelected
public boolean isSelected()
Determine whether or not this element is selected or not.- Specified by:
isSelectedin interfaceWebElement- Returns:
- True if the element is currently selected or checked, false otherwise.
-
sendKeys
public void sendKeys(java.lang.CharSequence... keysToSend)
Use this method to simulate typing into an element, which may set its value.- Specified by:
sendKeysin interfaceWebElement- Parameters:
keysToSend- The keys to type into the element.
-
submit
public void submit()
If this current element is a form, or an element within a form, then this will be submitted to the remote server.- Specified by:
submitin interfaceWebElement
-
getScreenshotAs
public <X> X getScreenshotAs(OutputType<X> target) throws WebDriverException
Capture the screenshot and store it in the specified location.- Specified by:
getScreenshotAsin interfaceTakesScreenshot- Parameters:
target- target type- Returns:
- Object in which is stored information about the screenshot.
- Throws:
WebDriverException- - on failure.
-
getRect
public Rectangle getRect()
(NB: As of Feb 2016, this appeared as an abstract method in org.openqa.selenium.WebElement (Selenium v.2.50.1). However, there does not appear to be any documentation on it as of yet.)- Specified by:
getRectin interfaceWebElement- Returns:
- A rectangle object.
-
-