Object
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
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
Clear this element
# File common/src/rb/lib/selenium/webdriver/element.rb, line 106 def clear bridge.clearElement @id end
Click the element
# File common/src/rb/lib/selenium/webdriver/element.rb, line 26 def click bridge.clickElement @id end
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 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 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
Is the element enabled?
@return [Boolean]
# File common/src/rb/lib/selenium/webdriver/element.rb, line 116 def enabled? bridge.isElementEnabled @id end
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
# 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
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
for Find and execute_script
@private
# File common/src/rb/lib/selenium/webdriver/element.rb, line 254 def ref @id end
Select this element
# File common/src/rb/lib/selenium/webdriver/element.rb, line 144 def select bridge.setElementSelected @id end
Is the element selected?
@return [Boolean]
# File common/src/rb/lib/selenium/webdriver/element.rb, line 126 def selected? bridge.isElementSelected @id end
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
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
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 this element
# File common/src/rb/lib/selenium/webdriver/element.rb, line 152 def submit bridge.submitElement @id end
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
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
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
Generated with the Darkfish Rdoc Generator 2.