Class Selenium::WebDriver::Element
In: lib/selenium/webdriver/common/element.rb
Parent: Object

Methods

==   []   as_json   attribute   clear   click   css_value   displayed?   enabled?   eql?   hash   inspect   location   location_once_scrolled_into_view   new   ref   selected?   send_key   send_keys   size   style   submit   tag_name   text   to_json  

Included Modules

SearchContext

External Aliases

find_element -> first
  element.first(:id, ‘foo’)
find_elements -> all
  element.all(:class, ‘bar’)

Public Class methods

Creates a new Element

@api private

Public Instance methods

[](name)

Alias for attribute

Get the value of a 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 given attribute, unless that attribute is not present, in which case the value of the property with the same name is returned. If neither value is set, nil 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 "false":

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, spellcheck, truespeed, willvalidate

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

class, readonly

@param [String]

  attribute name

@return [String,nil]

  attribute value

If this element is a text entry element, this will clear the value. Has no effect on other elements. Text entry elements are INPUT and TEXTAREA elements.

Note that the events fired by this event may not be as you‘d expect. In particular, we don‘t fire any keyboard or mouse events. If you want to ensure keyboard events are fired, consider using send_keys with the backspace key. To ensure you get a change event, consider following with a call to send_keys with the tab key.

Click this element. If this causes a new page to load, this method will attempt to block until the page has loaded. At this point, you should discard all references to this element and any further operations performed on this element will raise a StaleElementReferenceError unless you know that the element and the page will still be present. If click() causes a new page to be loaded via an event or is done by sending a native event then the method will not wait for it to be loaded and the caller should verify that a new page has been loaded.

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.

Equivalent to:

  driver.action.click(element)

@example Click on a button

   driver.find_element(:tag_name, "button").click

@raise [StaleElementReferenceError] if the element no longer exists as

 defined

Get the value of the given CSS property

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 www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration

Is the element displayed?

@return [Boolean]

Is the element enabled?

@return [Boolean]

eql?(other)

Alias for #==

Get the location of this element.

@return [WebDriver::Point]

Determine an element‘s location on the screen once it has been scrolled into view.

@return [WebDriver::Point]

for SearchContext and execute_script

@api private

Is the element selected?

@return [Boolean]

send_key(*args)

Alias for send_keys

Send keystrokes to this element

@param [String, Symbol, Array]

Examples:

    element.send_keys "foo"                     #=> value: 'foo'
    element.send_keys "tet", :arrow_left, "s"   #=> value: 'test'
    element.send_keys [:control, 'a'], :space   #=> value: ' '

@see Keys::KEYS

Get the size of this element

@return [WebDriver::Dimension]

style(prop)

Alias for css_value

Submit this element

Get the tag name of the element.

@example Get the tagname of an INPUT element(returns "input")

   driver.find_element(:xpath, "//input").tag_name

@return [String] The tag name of this element.

Get the text content of this element

@return [String]

Convert to a WebElement JSON Object for transmission over the wire. @see code.google.com/p/selenium/wiki/JsonWireProtocol#Basic_Concepts_And_Terms

@api private

[Validate]