Class: Wrapybara::Table

Inherits:
Object
  • Object
show all
Includes:
Element
Defined in:
lib/wrapybara/elements/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Element

#click, #default_how, #default_scope, #disabled?, #element_identifier, #enabled?, #exists?, #focused?, #get_element, #parent_identifier, #path, #should_be_disabled, #should_be_enabled, #should_be_focused, #should_be_visible, #should_have_attribute, #should_not_be_disabled, #should_not_be_enabled, #should_not_be_focused, #should_not_be_visible, #should_not_have_attribute, #style, #visible?, #within

Constructor Details

#initialize(identifier, scope = default_scope, how = default_how) ⇒ Table

Returns a new instance of Table.



7
8
9
10
11
12
13
14
15
# 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

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



5
6
7
# File 'lib/wrapybara/elements/table.rb', line 5

def body
  @body
end

#elementObject (readonly)

Returns the value of attribute element.



5
6
7
# File 'lib/wrapybara/elements/table.rb', line 5

def element
  @element
end

#headObject (readonly)

Returns the value of attribute head.



5
6
7
# File 'lib/wrapybara/elements/table.rb', line 5

def head
  @head
end

#howObject (readonly)

Returns the value of attribute how.



5
6
7
# File 'lib/wrapybara/elements/table.rb', line 5

def how
  @how
end

#identifierObject (readonly)

Returns the value of attribute identifier.



5
6
7
# File 'lib/wrapybara/elements/table.rb', line 5

def identifier
  @identifier
end

#scopeObject (readonly)

Returns the value of attribute scope.



5
6
7
# File 'lib/wrapybara/elements/table.rb', line 5

def scope
  @scope
end

Instance Method Details

#click_column(column) ⇒ Object



39
40
41
42
43
44
45
# 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) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/wrapybara/elements/table.rb', line 47

def has_column?(label)
	@head.has_column?(label)
end

#should_existObject



17
18
19
# 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) ⇒ Object



25
26
27
28
29
30
# 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_existObject



21
22
23
# 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) ⇒ Object



32
33
34
35
36
37
# 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