Web Automation Using Selenium
  • About The Book
  • Selenium
    • Introduction
      • What is testing and why?
      • What is Selenium and Why?
    • Getting Started
      • Audience
      • Prerequisite
      • Set up
      • Getting Started - Hello World..!!
      • What are drivers
    • Locators
      • CSS Selectors
      • XPath Selector
    • WebDriver
      • WebDriver Methods
      • WebDriver Types
    • WebElement(s)
      • WebElement Methods
      • Looping Through WebElements
    • Waits In Selenium
  • TestNG
    • Introduction
    • TestNG Setup
    • First Test Script
    • Some of the features of TestNG
    • TestNG Annotations
      • @Test
      • @DataProvider
  • Maven
    • Introduction
  • Framework Development
    • Introduction
    • Building Framework
      • Technology Stack
      • Page Object Model (POM)
      • Setup
      • What our framework contain
      • Packages
        • Context
        • Factory
        • Listeners
        • Pages
      • Creating first automation test
  • Common Interview Questions
    • Selenium-Related
Powered by GitBook
On this page

Was this helpful?

  1. Selenium
  2. WebElement(s)

WebElement Methods

Methods of WebElement

The list of methods

Modifier and Type

Method and 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 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()

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 text of the element

boolean

isDisplayed() Is this element displayed or not? This method avoids the problem of having to parse an element's "style" attribute.

boolean

isEnabled() Is the element currently enabled or not? This will generally return true for everything but disabled input elements.

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.

PreviousWebElement(s)NextLooping Through WebElements

Last updated 5 years ago

Was this helpful?