Class: Selenium::WebDriver::Element

Inherits:
Object
  • Object
show all
Includes:
SeleniumPlus::Elements::DList, SeleniumPlus::Elements::Select, SeleniumPlus::Elements::Table, SeleniumPlus::Finders
Defined in:
lib/selenium_plus/selenium/element.rb

Overview

Public: Add extension method to Element class

Instance Method Summary collapse

Methods included from SeleniumPlus::Finders

#find, #find_all

Methods included from SeleniumPlus::Elements::DList

#dd_raw, #dd_text, #dlist_hashes, #dt_raw, #dt_text

Methods included from SeleniumPlus::Elements::Select

#first_selected_option, #multiple?, #select, #select_options, #select_raw, #select_values, #selected_options

Methods included from SeleniumPlus::Elements::Table

#headers, #headers_text, #rows, #rows_text, #table_hashes, #table_raw, #table_raw_text

Instance Method Details

#[](attribute) ⇒ String

Retrieve the given attribute

Examples:

element[:name]                HTML name attribute

Parameters:

  • attribute (Symbol)

    The attribute to retrieve

Returns:

  • (String)

    The value of the attribute



17
18
19
# File 'lib/selenium_plus/selenium/element.rb', line 17

def [](attribute)
  self.attribute(attribute.to_s)
end

#append(text) ⇒ Object

Append text into text field element

Examples:

element.append('hello world')

Parameters:

  • text (Symbol)

Returns:



61
62
63
# File 'lib/selenium_plus/selenium/element.rb', line 61

def append(text)
  self.set("#{self.text} #{text}")
end

#set(value) ⇒ Object

Set the value of the element to the given value.

Examples:

element.set('Hello')

Parameters:

  • value (String)

    The new value

Returns:



33
34
35
36
37
38
# File 'lib/selenium_plus/selenium/element.rb', line 33

def set(value)
  tag_name = self.tag_name
  if tag_name == 'textarea' or tag_name == 'input'
    self.send_keys(value.to_s)
  end
end

#type(text) ⇒ Object

Type text into text field element

Examples:

element.type('hello world')

Parameters:

  • text (Symbol)

Returns:



48
49
50
51
# File 'lib/selenium_plus/selenium/element.rb', line 48

def type(text)
  self.clear
  self.set(text)
end

#visible?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/selenium_plus/selenium/element.rb', line 21

def visible?
  self.displayed?
end