Class WebElement

    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • clear

        public void clear()
        If this element is a text entry element, this will clear the value.
        Specified by:
        clear in interface WebElement
      • click

        public void click()
        Click this element.
        Specified by:
        click in interface WebElement
      • findElement

        public WebElement findElement​(By by)
        Find the first WebElement using the given method.
        Specified by:
        findElement in interface SearchContext
        Specified by:
        findElement in interface WebElement
        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 interface SearchContext
        Specified by:
        findElements in interface WebElement
        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:
        getAttribute in interface WebElement
        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 interface WebElement
        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 interface WebElement
        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 interface WebElement
        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 interface WebElement
        Returns:
        The tag name of this element.
      • getText

        public java.lang.String getText()
        Get the visible innerText of this element.
        Specified by:
        getText in interface WebElement
        Returns:
        The innerText of this element
      • isDisplayed

        public boolean isDisplayed()
        Is this element displayed or not?
        Specified by:
        isDisplayed in interface WebElement
        Returns:
        Whether or not the element is displayed
      • isEnabled

        public boolean isEnabled()
        Is the element currently enabled or not?
        Specified by:
        isEnabled in interface WebElement
        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 interface WebElement
        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 interface WebElement
        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 interface WebElement
      • 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 interface WebElement
        Returns:
        A rectangle object.