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 void
clear()
If this element is a text entry element, this will clear the value.void
click()
Click this element.WebElement
findElement(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.String
getAttribute(java.lang.String name)
Get the value of a the given attribute of the element.java.lang.String
getCssValue(java.lang.String propertyName)
Get the value of a given CSS property.Point
getLocation()
Where on the page is the top left-hand corner of the rendered element?Rectangle
getRect()
(NB: As of Feb 2016, this appeared as an abstract method in org.openqa.selenium.WebElement (Selenium v.2.50.1).<X> X
getScreenshotAs(OutputType<X> target)
Capture the screenshot and store it in the specified location.Dimension
getSize()
What is the width and height of the rendered element?java.lang.String
getTagName()
Get the tag name of this element.java.lang.String
getText()
Get the visible innerText of this element.boolean
isDisplayed()
Is this element displayed or not?boolean
isEnabled()
Is the element currently enabled or not?boolean
isSelected()
Determine whether or not this element is selected or not.void
sendKeys(java.lang.CharSequence... keysToSend)
Use this method to simulate typing into an element, which may set its value.void
submit()
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:
clear
in interfaceWebElement
-
click
public void click()
Click this element.- Specified by:
click
in interfaceWebElement
-
findElement
public WebElement findElement(By by)
Find the first WebElement using the given method.- Specified by:
findElement
in interfaceSearchContext
- Specified by:
findElement
in 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:
findElements
in interfaceSearchContext
- Specified by:
findElements
in interfaceWebElement
- Parameters:
by
- The locating mechanism to use- Returns:
- A list of all
WebElement
s, 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:
getAttribute
in 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:
getCssValue
in 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:
getLocation
in 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:
getSize
in 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:
getTagName
in interfaceWebElement
- Returns:
- The tag name of this element.
-
getText
public java.lang.String getText()
Get the visible innerText of this element.- Specified by:
getText
in interfaceWebElement
- Returns:
- The innerText of this element
-
isDisplayed
public boolean isDisplayed()
Is this element displayed or not?- Specified by:
isDisplayed
in interfaceWebElement
- Returns:
- Whether or not the element is displayed
-
isEnabled
public boolean isEnabled()
Is the element currently enabled or not?- Specified by:
isEnabled
in 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:
isSelected
in 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:
sendKeys
in 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:
submit
in interfaceWebElement
-
getScreenshotAs
public <X> X getScreenshotAs(OutputType<X> target) throws WebDriverException
Capture the screenshot and store it in the specified location.- Specified by:
getScreenshotAs
in 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:
getRect
in interfaceWebElement
- Returns:
- A rectangle object.
-
-