### Home Classes Methods

### In Files

- common/src/rb/lib/selenium/webdriver/element.rb

### Parent

Object

### Methods

- ::new
- #[]
- #attribute
- #clear
- #click
- #displayed?
- #drag_and_drop_by
- #drag_and_drop_on
- #enabled?
- #hover
- #inspect
- #location
- #ref
- #select
- #selected?
- #send_key
- #send_keys
- #size
- #style
- #submit
- #tag_name
- #text
- #to_json
- #toggle
- #value

### Included Modules

- Selenium::WebDriver::Find

### Class/Module Index

Quicksearch

- Selenium
- Selenium::WebDriver
- Selenium::WebDriver::BridgeHelper
- Selenium::WebDriver::ChildProcess
- Selenium::WebDriver::ChildProcess::IronRubyProcess
- Selenium::WebDriver::ChildProcess::JRubyProcess
- Selenium::WebDriver::ChildProcess::WindowsProcess
- Selenium::WebDriver::Chrome
- Selenium::WebDriver::Chrome::Bridge
- Selenium::WebDriver::Chrome::CommandExecutor
- Selenium::WebDriver::Chrome::Launcher
- Selenium::WebDriver::Chrome::Launcher::MacOSXLauncher
- Selenium::WebDriver::Chrome::Launcher::UnixLauncher
- Selenium::WebDriver::Chrome::Launcher::WindowsLauncher
- Selenium::WebDriver::Driver
- Selenium::WebDriver::DriverExtensions
- Selenium::WebDriver::DriverExtensions::TakesScreenshot
- Selenium::WebDriver::Element
- Selenium::WebDriver::Error
- Selenium::WebDriver::Error::ElementNotDisplayedError
- Selenium::WebDriver::Error::ElementNotEnabledError
- Selenium::WebDriver::Error::ElementNotSelectableError
- Selenium::WebDriver::Error::ExpectedError
- Selenium::WebDriver::Error::IndexOutOfBoundsError
- Selenium::WebDriver::Error::InvalidCookieDomainError
- Selenium::WebDriver::Error::NoCollectionError
- Selenium::WebDriver::Error::NoScriptResultError
- Selenium::WebDriver::Error::NoStringError
- Selenium::WebDriver::Error::NoStringLengthError
- Selenium::WebDriver::Error::NoStringWrapperError
- Selenium::WebDriver::Error::NoSuchCollectionError
- Selenium::WebDriver::Error::NoSuchDocumentError
- Selenium::WebDriver::Error::NoSuchDriverError
- Selenium::WebDriver::Error::NoSuchElementError
- Selenium::WebDriver::Error::NoSuchFrameError
- Selenium::WebDriver::Error::NoSuchWindowError
- Selenium::WebDriver::Error::NullPointerError
- Selenium::WebDriver::Error::ObsoleteElementError
- Selenium::WebDriver::Error::ServerError
- Selenium::WebDriver::Error::TimeOutError
- Selenium::WebDriver::Error::UnableToSetCookieError
- Selenium::WebDriver::Error::UnexpectedJavascriptError
- Selenium::WebDriver::Error::UnhandledError
- Selenium::WebDriver::Error::UnknownCommandError
- Selenium::WebDriver::Error::UnknownScriptResultError
- Selenium::WebDriver::Error::UnsupportedOperationError
- Selenium::WebDriver::Error::WebDriverError
- Selenium::WebDriver::FileReaper
- Selenium::WebDriver::Find
- Selenium::WebDriver::Firefox
- Selenium::WebDriver::Firefox::Binary
- Selenium::WebDriver::Firefox::Bridge
- Selenium::WebDriver::Firefox::Launcher
- Selenium::WebDriver::Firefox::Profile
- Selenium::WebDriver::Firefox::ProfilesIni
- Selenium::WebDriver::Firefox::Util
- Selenium::WebDriver::IE
- Selenium::WebDriver::IE::Bridge
- Selenium::WebDriver::IE::Kernel32
- Selenium::WebDriver::IE::Lib
- Selenium::WebDriver::IE::Util
- Selenium::WebDriver::Keys
- Selenium::WebDriver::Navigation
- Selenium::WebDriver::Options
- Selenium::WebDriver::Platform
- Selenium::WebDriver::Remote
- Selenium::WebDriver::Remote::Bridge
- Selenium::WebDriver::Remote::Capabilities
- Selenium::WebDriver::Remote::Http
- Selenium::WebDriver::Remote::Http::Common
- Selenium::WebDriver::Remote::Http::Curb
- Selenium::WebDriver::Remote::Http::Default
- Selenium::WebDriver::Remote::Response
- Selenium::WebDriver::TargetLocator
- Selenium::WebDriver::Timeouts
- Dir
- SocketError
- String

No matching classes.

# Selenium::WebDriver::Element

### Attributes

bridge[R]

### Public Class Methods

new(bridge, id) click to toggle source

Creates a new Element

@private

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 14
    def initialize(bridge, id)
      @bridge, @id = bridge, id
    end

### Public Instance Methods

[](name) click to toggle source

element or element #=> "someclass"

Alias for: attribute
attribute(name) click to toggle source

Get the value of the given attribute

@param [String]

    attribute name

@return [String,nil]

    attribute value

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 59
    def attribute(name)
      bridge.getElementAttribute @id, name
    end

Also aliased as: []
clear() click to toggle source

Clear this element

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 106
    def clear
      bridge.clearElement @id
    end

click() click to toggle source

Click the element

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 26
    def click
      bridge.clickElement @id
    end

displayed?() click to toggle source

Is the element displayed?

@return [Boolean]

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 136
    def displayed?
      bridge.isElementDisplayed @id
    end

drag_and_drop_by(right_by, down_by) click to toggle source

Drag and drop this element

@param [Integer] right_by

    number of pixels to drag right

@param [Integer] down_by

    number of pixels to drag down

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 209
    def drag_and_drop_by(right_by, down_by)
      bridge.dragElement @id, right_by, down_by
    end

drag_and_drop_on(other) click to toggle source

Drag and drop this element on the given element

@param [WebDriver::Element] other

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 219
    def drag_and_drop_on(other)
      current_location = location()
      destination      = other.location

      right = destination.x - current_location.x
      down  = destination.y - current_location.y

      drag_and_drop_by right, down
    end

enabled?() click to toggle source

Is the element enabled?

@return [Boolean]

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 116
    def enabled?
      bridge.isElementEnabled @id
    end

hover() click to toggle source

Hover over this element. Not applicable to all browsers.

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 176
    def hover
      bridge.hoverOverElement @id
    end

inspect() click to toggle source

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 18
    def inspect
      '#<%s:0x%x id=%s tag_name=%s>' % [self.class, hash*2, @id.inspect, tag_name.inspect]
    end

location() click to toggle source

Get the location of this element.

@return [WebDriver::Point]

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 186
    def location
      bridge.getElementLocation @id
    end

ref() click to toggle source

for Find and execute_script

@private

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 254
    def ref
      @id
    end

select() click to toggle source

Select this element

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 144
    def select
      bridge.setElementSelected @id
    end

selected?() click to toggle source

Is the element selected?

@return [Boolean]

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 126
    def selected?
      bridge.isElementSelected @id
    end

send_key(*args) click to toggle source
Alias for: send_keys
send_keys(*args) click to toggle source

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

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 87
    def send_keys(*args)
      args.each do |arg|
        case arg
        when Symbol
          arg = Keys[arg]
        when Array
          arg = arg.map { |e| e.kind_of?(Symbol) ? Keys[e] : e }.join
          arg << Keys[:null]
        end

        bridge.sendKeysToElement(@id, arg.to_s)
      end
    end

Also aliased as: send_key
size() click to toggle source

Get the size of this element

@return [WebDriver::Dimension]

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 196
    def size
      bridge.getElementSize @id
    end

style(prop) click to toggle source

Get the value of the given CSS property

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 168
    def style(prop)
      bridge.getElementValueOfCssProperty @id, prop
    end

submit() click to toggle source

Submit this element

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 152
    def submit
      bridge.submitElement @id
    end

tag_name() click to toggle source

Get the tag name of this element

@return [String]

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 36
    def tag_name
      bridge.getElementTagName @id
    end

text() click to toggle source

Get the text content of this element

@return [String]

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 69
    def text
      bridge.getElementText @id
    end

to_json(*args) click to toggle source

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

@private

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 265
    def to_json(*args)
      { :ELEMENT => @id }.to_json(*args)
    end

toggle() click to toggle source

Toggle this element

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 160
    def toggle
      bridge.toggleElement @id
    end

value() click to toggle source

Get the value of this element

@return [String]

    # File common/src/rb/lib/selenium/webdriver/element.rb, line 46
    def value
      bridge.getElementValue @id
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.