Class: Selenium::WebDriver::Element
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Element
- 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
-
#[](attribute) ⇒ String
Retrieve the given attribute.
-
#append(text) ⇒ Object
Append text into text field element.
-
#set(value) ⇒ Object
Set the value of the element to the given value.
-
#type(text) ⇒ Object
Type text into text field element.
- #visible? ⇒ Boolean
Methods included from SeleniumPlus::Finders
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
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')
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')
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')
48 49 50 51 |
# File 'lib/selenium_plus/selenium/element.rb', line 48 def type(text) self.clear self.set(text) end |
#visible? ⇒ Boolean
21 22 23 |
# File 'lib/selenium_plus/selenium/element.rb', line 21 def visible? self.displayed? end |