Class: Wrapybara::Image

Inherits:
Object
  • Object
show all
Includes:
Element
Defined in:
lib/wrapybara/elements/image.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) ⇒ Image

Returns a new instance of Image.



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

def initialize(identifier, scope = default_scope, how = default_how)
  @identifier = identifier
  @how = how
  @scope = scope
  xpath = "//img[@src='#{identifier}' or @id='#{identifier}' or @title='#{identifier}' or @alt='#{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/image.rb', line 5

def element
  @element
end

#howObject (readonly)

Returns the value of attribute how.



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

def how
  @how
end

#identifierObject (readonly)

Returns the value of attribute identifier.



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

def identifier
  @identifier
end

#scopeObject (readonly)

Returns the value of attribute scope.



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

def scope
  @scope
end

Instance Method Details

#should_existObject



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

def should_exist
  super "Expected an image #{self.element_identifier} to exist"
end

#should_not_existObject



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

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