Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Selenium2: WebDriver: Actions on Web Elements

Tags: element
Selenium2 provides WebElement interface, which represents an HTML Element. WebElement interface provides number of methods to interact with these web elements like button, text boxes, hyper links etc., Not all the operations provides by WebElement interface are applicable to all web elements, For example, you can't submit a text box and you can't write some text to button, but you can write some text to text box and you can submit a button.

What happen when you try to perform wrong action on a WebElement ?
WebDriver simply ignore the action.

Following table summarizes all the actions supported by WebElement.

Method
Description
void click()
Click this element.
void submit()
If this current element is a form, or an element within a form, then this will be submitted to the remote server.
void sendKeys(CharSequence... keysToSend)
Writes some text to textbox (or) textarea
void clear()
Clears the data entered in textbox (or) textarea.
String getAttribute(String name)
Return the attribute/property's current value or null if the value is not set.
List findElements(By by)
Return list of all WebElements, or an empty list if nothing matches.
WebElement findElement(By by)
Return the first matching element on the current context.
boolean isSelected()
Return true if the element is currently selected or checked, false otherwise.
String getText()
Get the visible innerText of this element.
String getTagName()
Get tag name of the element
boolean isDisplayed()
Return true, if the element is displayed on web page, else false.
boolean isEnabled()
Return true, if the element is currently enabled, else false.
Point getLocation()
Get location of the element.
Dimension getSize()
Get size of the element.
Rectangle getRect()
Get location and size of the rendered element
String getCssValue(String propertyName)
Get value of given css property.





Previous                                                 Next                                                 Home


This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

Selenium2: WebDriver: Actions on Web Elements

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×