Class: Webrat::Locators::TableLocator

Inherits:
Locator
  • Object
show all
Defined in:
lib/cucumber/webrat/table_locator.rb

Instance Method Summary collapse

Instance Method Details

#error_messageObject



47
48
49
# File 'lib/cucumber/webrat/table_locator.rb', line 47

def error_message
  "Could not find table matching '#{@value}'"
end

#locateObject



24
25
26
# File 'lib/cucumber/webrat/table_locator.rb', line 24

def locate
  Table.load(@session, table_element)
end

#matches_css_selector?(table_element) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/cucumber/webrat/table_locator.rb', line 39

def matches_css_selector?(table_element)
  Webrat::XML.css_at(@dom, @value)
end

#matches_id?(table_element) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/cucumber/webrat/table_locator.rb', line 35

def matches_id?(table_element)
  Webrat::XML.attribute(table_element, "id") == @value.to_s
end

#table_elementObject



28
29
30
31
32
33
# File 'lib/cucumber/webrat/table_locator.rb', line 28

def table_element
  table_elements.detect do |table_element|
    matches_id?(table_element) ||
    matches_css_selector?(table_element)
  end
end

#table_elementsObject



43
44
45
# File 'lib/cucumber/webrat/table_locator.rb', line 43

def table_elements
  Webrat::XML.xpath_search(@dom, *Table.xpath_search)
end