Class RemoteWebElement

    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void clear()
      If this element is a form entry element, this will reset its value.
      void click()
      Click this element.
      boolean equals​(java.lang.Object obj)  
      protected Response execute​(java.lang.String command, java.util.Map<java.lang.String,​?> parameters)  
      protected Response execute​(CommandPayload payload)  
      protected WebElement findElement​(java.lang.String using, java.lang.String value)
      Deprecated.
      Rely on using By.Remotable instead
      WebElement findElement​(By locator)
      Find the first WebElement using the given method.
      protected java.util.List<WebElement> findElements​(java.lang.String using, java.lang.String value)
      Deprecated.
      Rely on using By.Remotable instead
      java.util.List<WebElement> findElements​(By locator)
      Find all elements within the current context using the given mechanism.
      java.lang.String getAccessibleName()
      Gets result of a Accessible Name and Description Computation for the Accessible Name of the element.
      java.lang.String getAriaRole()
      Gets result of computing the WAI-ARIA role of element.
      java.lang.String getAttribute​(java.lang.String name)
      Get the value of the given attribute of the element.
      Coordinates getCoordinates()  
      java.lang.String getCssValue​(java.lang.String propertyName)
      Get the value of a given CSS property.
      java.lang.String getDomAttribute​(java.lang.String name)
      Get the value of the given attribute of the element.
      java.lang.String getDomProperty​(java.lang.String name)
      Get the value of the given property of the element.
      java.lang.String getId()  
      Point getLocation()
      Where on the page is the top left-hand corner of the rendered element?
      Rectangle getRect()  
      <X> X getScreenshotAs​(OutputType<X> outputType)
      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 (i.e.
      WebDriver getWrappedDriver()  
      int hashCode()  
      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 setFileDetector​(FileDetector detector)  
      protected void setFoundBy​(SearchContext foundFrom, java.lang.String locator, java.lang.String term)  
      void setId​(java.lang.String id)  
      void setParent​(RemoteWebDriver parent)  
      void submit()
      If this current element is a form, or an element within a form, then this will be submitted to the remote server.
      java.util.Map<java.lang.String,​java.lang.Object> toJson()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • RemoteWebElement

        public RemoteWebElement()
    • Method Detail

      • setFoundBy

        protected void setFoundBy​(SearchContext foundFrom,
                                  java.lang.String locator,
                                  java.lang.String term)
      • getId

        public java.lang.String getId()
      • setId

        public void setId​(java.lang.String id)
      • setFileDetector

        public void setFileDetector​(FileDetector detector)
      • click

        public void click()
        Description copied from interface: WebElement
        Click this element. If this causes a new page to load, you should discard all references to this element and any further operations performed on this element will throw a StaleElementReferenceException.

        Note that if click() is done by sending a native event (which is the default on most browsers/platforms) then the method will _not_ wait for the next page to load and the caller should verify that themselves.

        There are some preconditions for an element to be clicked. The element must be visible and it must have a height and width greater then 0.

        See W3C WebDriver specification for more details.

        Specified by:
        click in interface WebElement
      • submit

        public void submit()
        Description copied from interface: WebElement
        If this current element is a form, or an element within a form, then this will be submitted to the remote server. If this causes the current page to change, then this method will block until the new page is loaded.
        Specified by:
        submit in interface WebElement
      • sendKeys

        public void sendKeys​(java.lang.CharSequence... keysToSend)
        Description copied from interface: WebElement
        Use this method to simulate typing into an element, which may set its value.

        See W3C WebDriver specification for more details.

        Specified by:
        sendKeys in interface WebElement
        Parameters:
        keysToSend - character sequence to send to the element
      • getTagName

        public java.lang.String getTagName()
        Description copied from interface: WebElement
        Get the tag name of this element. Not the value of the name attribute: will return "input" for the element <input name="foo" />.

        See W3C WebDriver specification for more details.

        Specified by:
        getTagName in interface WebElement
        Returns:
        The tag name of this element.
      • getDomProperty

        public java.lang.String getDomProperty​(java.lang.String name)
        Description copied from interface: WebElement
        Get the value of the given property of the element. Will return the current value, even if this has been modified after the page has been loaded.

        See W3C WebDriver specification for more details.

        Specified by:
        getDomProperty in interface WebElement
        Parameters:
        name - The name of the property.
        Returns:
        The property's current value or null if the value is not set.
      • getDomAttribute

        public java.lang.String getDomAttribute​(java.lang.String name)
        Description copied from interface: WebElement
        Get the value of the given attribute of the element.

        This method, unlike WebElement.getAttribute(String), returns the value of the attribute with the given name but not the property with the same name.

        The following are deemed to be "boolean" attributes, and will return either "true" or null:

        async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked, defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, seeking, selected, truespeed, willvalidate

        See W3C WebDriver specification for more details.

        Specified by:
        getDomAttribute in interface WebElement
        Parameters:
        name - The name of the attribute.
        Returns:
        The attribute's value or null if the value is not set.
      • getAttribute

        public java.lang.String getAttribute​(java.lang.String name)
        Description copied from interface: WebElement
        Get the value of the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded.

        More exactly, this method will return the value of the property with the given name, if it exists. If it does not, then the value of the attribute with the given name is returned. If neither exists, null is returned.

        The "style" attribute is converted as best can be to a text representation with a trailing semi-colon.

        The following are deemed to be "boolean" attributes, and will return either "true" or null:

        async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked, defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, seeking, selected, truespeed, willvalidate

        Finally, the following commonly mis-capitalized attribute/property names are evaluated as expected:

        • If the given name is "class", the "className" property is returned.
        • If the given name is "readonly", the "readOnly" property is returned.
        Note: The reason for this behavior is that users frequently confuse attributes and properties. If you need to do something more precise, use WebElement.getDomAttribute(String) or WebElement.getDomProperty(String) to obtain the result you desire.

        See W3C WebDriver specification for more details.

        Specified by:
        getAttribute in interface WebElement
        Parameters:
        name - The name of the attribute.
        Returns:
        The attribute/property's current value or null if the value is not set.
      • getAriaRole

        public java.lang.String getAriaRole()
        Description copied from interface: WebElement
        Gets result of computing the WAI-ARIA role of element.

        See W3C WebDriver specification for more details.

        Specified by:
        getAriaRole in interface WebElement
        Returns:
        the WAI-ARIA role of the element.
      • getAccessibleName

        public java.lang.String getAccessibleName()
        Description copied from interface: WebElement
        Gets result of a Accessible Name and Description Computation for the Accessible Name of the element.

        See W3C WebDriver specification for more details.

        Specified by:
        getAccessibleName in interface WebElement
        Returns:
        the accessible name of the element.
      • isSelected

        public boolean isSelected()
        Description copied from interface: WebElement
        Determine whether or not this element is selected or not. This operation only applies to input elements such as checkboxes, options in a select and radio buttons. For more information on which elements this method supports, refer to the specification.

        See W3C WebDriver specification for more details.

        Specified by:
        isSelected in interface WebElement
        Returns:
        True if the element is currently selected or checked, false otherwise.
      • isEnabled

        public boolean isEnabled()
        Description copied from interface: WebElement
        Is the element currently enabled or not? This will generally return true for everything but disabled input elements.

        See W3C WebDriver specification for more details.

        Specified by:
        isEnabled in interface WebElement
        Returns:
        True if the element is enabled, false otherwise.
      • getText

        public java.lang.String getText()
        Description copied from interface: WebElement
        Get the visible (i.e. not hidden by CSS) text of this element, including sub-elements.

        See W3C WebDriver specification for more details.

        Specified by:
        getText in interface WebElement
        Returns:
        The visible text of this element.
      • getCssValue

        public java.lang.String getCssValue​(java.lang.String propertyName)
        Description copied from interface: WebElement
        Get the value of a given CSS property. Color values should be returned as rgba strings, so, for example if the "background-color" property is set as "green" in the HTML source, the returned value will be "rgba(0, 255, 0, 1)". Note that shorthand CSS properties (e.g. background, font, border, border-top, margin, margin-top, padding, padding-top, list-style, outline, pause, cue) are not returned, in accordance with the DOM CSS2 specification - you should directly access the longhand properties (e.g. background-color) to access the desired values.

        See W3C WebDriver specification for more details.

        Specified by:
        getCssValue in interface WebElement
        Parameters:
        propertyName - the css property name of the element
        Returns:
        The current, computed value of the property.
      • findElements

        public java.util.List<WebElement> findElements​(By locator)
        Description copied from interface: WebElement
        Find all elements within the current context using the given mechanism. When using xpath be aware that webdriver follows standard conventions: a search prefixed with "//" will search the entire document, not just the children of this current node. Use ".//" to limit your search to the children of this WebElement. This method is affected by the 'implicit wait' times in force at the time of execution. When implicitly waiting, this method will return as soon as there are more than 0 items in the found collection, or will return an empty list if the timeout is reached.

        See W3C WebDriver specification for more details.

        Specified by:
        findElements in interface SearchContext
        Specified by:
        findElements in interface WebElement
        Parameters:
        locator - The locating mechanism to use
        Returns:
        A list of all WebElements, or an empty list if nothing matches.
        See Also:
        By, WebDriver.Timeouts
      • findElement

        @Deprecated
        protected WebElement findElement​(java.lang.String using,
                                         java.lang.String value)
        Deprecated.
        Rely on using By.Remotable instead
      • findElements

        @Deprecated
        protected java.util.List<WebElement> findElements​(java.lang.String using,
                                                          java.lang.String value)
        Deprecated.
        Rely on using By.Remotable instead
      • execute

        protected Response execute​(java.lang.String command,
                                   java.util.Map<java.lang.String,​?> parameters)
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        This element's hash code, which is a hash of its internal opaque ID.
      • isDisplayed

        public boolean isDisplayed()
        Description copied from interface: WebElement
        Is this element displayed or not? This method avoids the problem of having to parse an element's "style" attribute.
        Specified by:
        isDisplayed in interface WebElement
        Returns:
        Whether or not the element is displayed
      • getLocation

        public Point getLocation()
        Description copied from interface: WebElement
        Where on the page is the top left-hand corner of the rendered element?

        See W3C WebDriver specification for more details.

        Specified by:
        getLocation in interface WebElement
        Returns:
        A point, containing the location of the top left-hand corner of the element
      • getScreenshotAs

        @Beta
        public <X> X getScreenshotAs​(OutputType<X> outputType)
                              throws WebDriverException
        Description copied from interface: TakesScreenshot
        Capture the screenshot and store it in the specified location.

        For a W3C-conformant WebDriver or WebElement, this behaves as stated in W3C WebDriver specification.

        For a non-W3C-conformant WebDriver, this makes a best effort depending on the browser to return the following in order of preference:

        • Entire page
        • Current window
        • Visible portion of the current frame
        • The screenshot of the entire display containing the browser
        For a non-W3C-conformant WebElement extending TakesScreenshot, this makes a best effort depending on the browser to return the following in order of preference:
        • The entire content of the HTML element
        • The visible portion of the HTML element
        Specified by:
        getScreenshotAs in interface TakesScreenshot
        Type Parameters:
        X - Return type for getScreenshotAs.
        Parameters:
        outputType - target type, @see OutputType
        Returns:
        Object in which is stored information about the screenshot.
        Throws:
        WebDriverException - on failure.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toJson

        public java.util.Map<java.lang.String,​java.lang.Object> toJson()