Class: Wrapybara::FileField

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

Instance Method Summary collapse

Methods included from Element

#click, #default_how, #default_scope, #disabled?, #element, #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) ⇒ FileField

Returns a new instance of FileField.



5
6
7
8
9
10
11
# File 'lib/wrapybara/elements/file_field.rb', line 5

def initialize(identifier, scope = default_scope, how = default_how)
	@identifier = identifier
	@how = how
	@scope = scope
	xpath = XPath::HTML.file_field(identifier)
	@element = get_element(xpath, scope)
end

Instance Method Details

#attach_file(path) ⇒ Object



13
14
15
16
17
# File 'lib/wrapybara/elements/file_field.rb', line 13

def attach_file(path)
	self.should_exist
	# Capybara method
	@element.set(path)
end

#should_existObject



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

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

#should_not_existObject



23
24
25
# File 'lib/wrapybara/elements/file_field.rb', line 23

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