Class: Wrapybara::Link

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Element

#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) ⇒ Link

Returns a new instance of Link.



7
8
9
10
11
12
13
# File 'lib/wrapybara/elements/link.rb', line 7

def initialize(identifier, scope = default_scope, how = default_how)
	@identifier = identifier
	@how = how
	@scope = scope
	xpath = "//a[@href='#{identifier}' or @id='#{identifier}' or @title='#{identifier}' or contains(normalize-space(), '#{identifier}')]"
	@element = get_element(xpath, scope)
end

Instance Attribute Details

#elementObject (readonly)

Returns the value of attribute element.



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

def element
  @element
end

#howObject (readonly)

Returns the value of attribute how.



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

def how
  @how
end

#identifierObject (readonly)

Returns the value of attribute identifier.



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

def identifier
  @identifier
end

#scopeObject (readonly)

Returns the value of attribute scope.



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

def scope
  @scope
end

Instance Method Details

#clickObject



23
24
25
26
27
# File 'lib/wrapybara/elements/link.rb', line 23

def click
	self.should_exist
	# Capybara method
	@element.click
end

#should_existObject



15
16
17
# File 'lib/wrapybara/elements/link.rb', line 15

def should_exist
	super "Expected a link #{self.element_identifier} to exist"
end

#should_not_existObject



19
20
21
# File 'lib/wrapybara/elements/link.rb', line 19

def should_not_exist
	super "Did not expect a link #{self.element_identifier}' to exist"
end