Module: SeleniumPlus::Elements::DList

Included in:
Selenium::WebDriver::Element
Defined in:
lib/selenium_plus/selenium/dlist.rb

Instance Method Summary collapse

Instance Method Details

#dd_rawObject

Raw dd elements of the definition list



14
15
16
# File 'lib/selenium_plus/selenium/dlist.rb', line 14

def dd_raw
  self.find_all(:css, 'dd')
end

#dd_textHash

dd elements text of the definition list

Examples:

A html definition list:
<dl>
  <dt>Title 1</dt>
  <dd>Description 1</dd>
  <dt>Title 2</dt>
  <dd>Description 2</dd>
</dl>

Gets converted into the following:
# => [Description 1', 'Description 2]

Returns:

  • (Hash)


52
53
54
# File 'lib/selenium_plus/selenium/dlist.rb', line 52

def dd_text
  dd_raw.map{ |el| el.text}
end

#dlist_hashesHash

Converts this table into an Array of Hash where the keys of each Hash are the headers in the table.

Examples:

A html definition list:
<dl>
  <dt>Title 1</dt>
  <dd>Description 1</dd>
  <dt>Title 2</dt>
  <dd>Description 2</dd>
</dl>

Gets converted into the following:
# => {'Title 1' => 'Description 1', 'Title 2' => 'Description 2 }

Returns:

  • (Hash)


71
72
73
# File 'lib/selenium_plus/selenium/dlist.rb', line 71

def dlist_hashes
  Hash[*dt_text.zip(dd_text).flatten]
end

#dt_rawObject

Raw dt elements of the definition list



7
8
9
# File 'lib/selenium_plus/selenium/dlist.rb', line 7

def dt_raw
  self.find_all(:css, 'dt')
end

#dt_textHash

dt elements text of the definition list

Examples:

A html definition list:
<dl>
  <dt>Title 1</dt>
  <dd>Description 1</dd>
  <dt>Title 2</dt>
  <dd>Description 2</dd>
</dl>

Gets converted into the following:
# => ['Title 1', 'Title 2']

Returns:

  • (Hash)


33
34
35
# File 'lib/selenium_plus/selenium/dlist.rb', line 33

def dt_text
  dt_raw.map{ |el| el.text}
end