Parent

Included Modules

Class/Module Index [+]

Quicksearch

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.