class Wrapybara::Table

Attributes

body[R]
element[R]
head[R]
how[R]
identifier[R]
scope[R]

Public Class Methods

new(identifier, scope = default_scope, how = default_how) click to toggle source
# File lib/wrapybara/elements/table.rb, line 7
def initialize(identifier, scope = default_scope, how = default_how)
        @identifier = identifier
        @how = how
        @scope = scope
        xpath = XPath::HTML.table(identifier)
        @element = get_element(xpath, scope)
        @head = TableHead.new(self)
        @body = TableBody.new(self)
end

Public Instance Methods

click_column(column) click to toggle source
# File lib/wrapybara/elements/table.rb, line 39
def click_column(column)
        self.should_exist
        self.should_have_columns([column])
        cell = self.head.cell(column)
        link = cell.element.find('a[1]')
        link.click
end
has_column?(label) click to toggle source
# File lib/wrapybara/elements/table.rb, line 47
def has_column?(label)
        @head.has_column?(label)
end
should_exist() click to toggle source
Calls superclass method Wrapybara::Element#should_exist
# File lib/wrapybara/elements/table.rb, line 17
def should_exist
        super "Expected a table #{self.element_identifier}' to exist"
end
should_have_columns(columns) click to toggle source
# File lib/wrapybara/elements/table.rb, line 25
def should_have_columns(columns)
        self.head.should_exist
        columns.each do |column|
                raise UnmetExpectation, "Expected table #{self.element_identifier} to have column '#{column}'" unless self.has_column?(column)
        end
end
should_not_exist() click to toggle source
Calls superclass method Wrapybara::Element#should_not_exist
# File lib/wrapybara/elements/table.rb, line 21
def should_not_exist
        super "Did not expect a table #{self.element_identifier} to exist"
end
should_not_have_columns(columns) click to toggle source
# File lib/wrapybara/elements/table.rb, line 32
def should_not_have_columns(columns)
        self.head.should_exist
        columns.each do |column|
                raise UnmetExpectation, "Did not expect table #{self.element_identifier} to have column '#{column}'" if self.has_column?(column)
        end
end