Module: CapybaraExtensions::Finders
- Includes:
- Locators
- Defined in:
- lib/capybara-extensions/finders.rb
Instance Method Summary collapse
-
#find_article(args) ⇒ Capybara::Element
(also: #article)
Find an HTML article based on the given arguments.
-
#find_aside(args) ⇒ Capybara::Element
(also: #aside)
Find an HTML aside based on the given arguments.
-
#find_footer(args) ⇒ Capybara::Element
(also: #footer)
Find an HTML footer based on the given arguments.
-
#find_form(args) ⇒ Capybara::Element
(also: #form)
Find an HTML form based on the given arguments.
-
#find_header(args) ⇒ Capybara::Element
(also: #header)
Find an HTML header based on the given arguments.
-
#find_image(options = {}) ⇒ Capybara::Element
Find an HTML img based on the src and/or alt values.
-
#find_list_item(args) ⇒ Capybara::Element
(also: #list_item)
Find an HTML li based on the given arguments.
-
#find_navigation(args) ⇒ Capybara::Element
(also: #navigation)
Find an HTML nav based on the given arguments.
-
#find_ordered_list(args) ⇒ Capybara::Element
(also: #ordered_list)
Find an HTML ol based on the given arguments.
-
#find_paragraph(args) ⇒ Capybara::Element
(also: #paragraph)
Find an HTML p based on the given arguments.
-
#find_row(args) ⇒ Capybara::Element
(also: #row)
Find an HTML tr based on the given arguments.
-
#find_section(args) ⇒ Capybara::Element
(also: #section)
Find an HTML section based on the given arguments.
-
#find_table(args) ⇒ Capybara::Element
(also: #table)
Find an HTML table based on the given arguments.
-
#find_unordered_list(args) ⇒ Capybara::Element
(also: #unordered_list)
Find an HTML ul based on the given arguments.
-
#first_article(args = nil) ⇒ Capybara::Element
Find the first HTML article on the page matching the given arguments.
-
#first_aside(args = nil) ⇒ Capybara::Element
Find the first HTML aside on the page matching the given arguments.
-
#first_footer(args = nil) ⇒ Capybara::Element
Find the first HTML footer on the page matching the given arguments.
-
#first_form(args = nil) ⇒ Capybara::Element
Find the first HTML form on the page matching the given arguments.
-
#first_header(args = nil) ⇒ Capybara::Element
Find the first HTML header on the page matching the given arguments.
-
#first_navigation(args = nil) ⇒ Capybara::Element
Find the first HTML nav on the page matching the given arguments.
-
#first_ordered_list(args = nil) ⇒ Capybara::Element
Find the first HTML ol on the page matching the given arguments.
-
#first_paragraph(args = nil) ⇒ Capybara::Element
Find the first HTML p on the page matching the given arguments.
-
#first_row(args = nil) ⇒ Capybara::Element
Find the first HTML tr on the page matching the given arguments.
-
#first_section(args = nil) ⇒ Capybara::Element
Find the first HTML section on the page matching the given arguments.
-
#first_table(args = nil) ⇒ Capybara::Element
Find the first HTML table on the page matching the given arguments.
-
#first_unordered_list(args = nil) ⇒ Capybara::Element
Find the first HTML ul on the page matching the given arguments.
-
#list_item_number(number) ⇒ Capybara::Element
When scoped to an ol or ul, find the first HTML li on the page matching the given arguments.
-
#row_number(number) ⇒ Capybara::Element
When scoped to a table, find the first HTML tr on the page matching the given arguments.
Methods included from Locators
#image_locator, #meta_tag_locator
Instance Method Details
#find_article(args) ⇒ Capybara::Element Also known as: article
Find an HTML article based on the given arguments.
12 13 14 |
# File 'lib/capybara-extensions/finders.rb', line 12 def find_article(args) find_element('article', args) end |
#find_aside(args) ⇒ Capybara::Element Also known as: aside
Find an HTML aside based on the given arguments.
24 25 26 |
# File 'lib/capybara-extensions/finders.rb', line 24 def find_aside(args) find_element('aside', args) end |
#find_footer(args) ⇒ Capybara::Element Also known as:
Find an HTML footer based on the given arguments.
36 37 38 |
# File 'lib/capybara-extensions/finders.rb', line 36 def (args) find_element('footer', args) end |
#find_form(args) ⇒ Capybara::Element Also known as: form
Find an HTML form based on the given arguments.
48 49 50 |
# File 'lib/capybara-extensions/finders.rb', line 48 def find_form(args) find_element('form', args) end |
#find_header(args) ⇒ Capybara::Element Also known as: header
Find an HTML header based on the given arguments.
70 71 72 |
# File 'lib/capybara-extensions/finders.rb', line 70 def find_header(args) find_element('header', args) end |
#find_image(options = {}) ⇒ Capybara::Element
Find an HTML img based on the src and/or alt values.
59 60 61 62 |
# File 'lib/capybara-extensions/finders.rb', line 59 def find_image( = {}) raise "Must pass a hash containing 'src' or 'alt'" unless .is_a?(Hash) && (.has_key?(:src) || .has_key?(:alt)) find(:xpath, "//img#{image_locator()}") end |
#find_list_item(args) ⇒ Capybara::Element Also known as: list_item
Find an HTML li based on the given arguments.
82 83 84 |
# File 'lib/capybara-extensions/finders.rb', line 82 def find_list_item(args) find_element('li', args) end |
#find_navigation(args) ⇒ Capybara::Element Also known as:
Find an HTML nav based on the given arguments.
94 95 96 |
# File 'lib/capybara-extensions/finders.rb', line 94 def (args) find_element('nav', args) end |
#find_ordered_list(args) ⇒ Capybara::Element Also known as: ordered_list
Find an HTML ol based on the given arguments.
106 107 108 |
# File 'lib/capybara-extensions/finders.rb', line 106 def find_ordered_list(args) find_element('ol', args) end |
#find_paragraph(args) ⇒ Capybara::Element Also known as: paragraph
Find an HTML p based on the given arguments.
118 119 120 |
# File 'lib/capybara-extensions/finders.rb', line 118 def find_paragraph(args) find_element('p', args) end |
#find_row(args) ⇒ Capybara::Element Also known as: row
Find an HTML tr based on the given arguments.
130 131 132 |
# File 'lib/capybara-extensions/finders.rb', line 130 def find_row(args) find_element('tr', args) end |
#find_section(args) ⇒ Capybara::Element Also known as: section
Find an HTML section based on the given arguments.
142 143 144 |
# File 'lib/capybara-extensions/finders.rb', line 142 def find_section(args) find_element('section', args) end |
#find_table(args) ⇒ Capybara::Element Also known as: table
Find an HTML table based on the given arguments.
154 155 156 157 158 159 160 161 |
# File 'lib/capybara-extensions/finders.rb', line 154 def find_table(args) if String === args find_element('table', args) else row = find_row(args) row.find(:xpath, 'ancestor::table') end end |
#find_unordered_list(args) ⇒ Capybara::Element Also known as: unordered_list
Find an HTML ul based on the given arguments.
171 172 173 |
# File 'lib/capybara-extensions/finders.rb', line 171 def find_unordered_list(args) find_element('ul', args) end |
#first_article(args = nil) ⇒ Capybara::Element
Find the first HTML article on the page matching the given arguments. If no arguments are supplied, it will find the first article within your current scope.
183 184 185 |
# File 'lib/capybara-extensions/finders.rb', line 183 def first_article(args=nil) first_element('article', args) end |
#first_aside(args = nil) ⇒ Capybara::Element
Find the first HTML aside on the page matching the given arguments. If no arguments are supplied, it will find the first aside within your current scope.
192 193 194 |
# File 'lib/capybara-extensions/finders.rb', line 192 def first_aside(args=nil) first_element('aside', args) end |
#first_footer(args = nil) ⇒ Capybara::Element
Find the first HTML footer on the page matching the given arguments. If no arguments are supplied, it will find the first footer within your current scope.
201 202 203 |
# File 'lib/capybara-extensions/finders.rb', line 201 def (args=nil) first_element('footer', args) end |
#first_form(args = nil) ⇒ Capybara::Element
Find the first HTML form on the page matching the given arguments. If no arguments are supplied, it will find the first form within your current scope.
210 211 212 |
# File 'lib/capybara-extensions/finders.rb', line 210 def first_form(args=nil) first_element('form', args) end |
#first_header(args = nil) ⇒ Capybara::Element
Find the first HTML header on the page matching the given arguments. If no arguments are supplied, it will find the first header within your current scope.
219 220 221 |
# File 'lib/capybara-extensions/finders.rb', line 219 def first_header(args=nil) first_element('header', args) end |
#first_navigation(args = nil) ⇒ Capybara::Element
Find the first HTML nav on the page matching the given arguments. If no arguments are supplied, it will find the first nav within your current scope.
228 229 230 |
# File 'lib/capybara-extensions/finders.rb', line 228 def (args=nil) first_element('nav', args) end |
#first_ordered_list(args = nil) ⇒ Capybara::Element
Find the first HTML ol on the page matching the given arguments. If no arguments are supplied, it will find the first ol within your current scope.
237 238 239 |
# File 'lib/capybara-extensions/finders.rb', line 237 def first_ordered_list(args=nil) first_element('ol', args) end |
#first_paragraph(args = nil) ⇒ Capybara::Element
Find the first HTML p on the page matching the given arguments. If no arguments are supplied, it will find the first p within your current scope.
246 247 248 |
# File 'lib/capybara-extensions/finders.rb', line 246 def first_paragraph(args=nil) first_element('p', args) end |
#first_row(args = nil) ⇒ Capybara::Element
Find the first HTML tr on the page matching the given arguments. If no arguments are supplied, it will find the first tr within your current scope.
255 256 257 |
# File 'lib/capybara-extensions/finders.rb', line 255 def first_row(args=nil) first_element('tr', args) end |
#first_section(args = nil) ⇒ Capybara::Element
Find the first HTML section on the page matching the given arguments. If no arguments are supplied, it will find the first section within your current scope.
264 265 266 |
# File 'lib/capybara-extensions/finders.rb', line 264 def first_section(args=nil) first_element('section', args) end |
#first_table(args = nil) ⇒ Capybara::Element
Find the first HTML table on the page matching the given arguments. If no arguments are supplied, it will find the first table within your current scope.
273 274 275 |
# File 'lib/capybara-extensions/finders.rb', line 273 def first_table(args=nil) first_element('table', args) end |
#first_unordered_list(args = nil) ⇒ Capybara::Element
Find the first HTML ul on the page matching the given arguments. If no arguments are supplied, it will find the first unordered list within your current scope.
282 283 284 |
# File 'lib/capybara-extensions/finders.rb', line 282 def first_unordered_list(args=nil) first_element('ul', args) end |
#list_item_number(number) ⇒ Capybara::Element
When scoped to an ol or ul, find the first HTML li on the page matching the given arguments.
291 292 293 |
# File 'lib/capybara-extensions/finders.rb', line 291 def list_item_number(number) find_element_by_number('li', number) end |
#row_number(number) ⇒ Capybara::Element
When scoped to a table, find the first HTML tr on the page matching the given arguments. If passed a negative number, it will find the first tr from the bottom of the table (so row_number(-1) finds the last row in the table).
300 301 302 |
# File 'lib/capybara-extensions/finders.rb', line 300 def row_number(number) find_element_by_number('tr', number) end |