Class: Splinter::Capybara::FormCompleter

Inherits:
Object
  • Object
show all
Defined in:
lib/splinter/capybara/form_completer.rb

Overview

The FormCompleter is a simple proxy that delegates actions to a Capybara session.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, page) ⇒ FormCompleter


8
9
10
11
# File 'lib/splinter/capybara/form_completer.rb', line 8

def initialize(base, page)
  @base = base
  @page = page
end

Instance Attribute Details

#submittedObject (readonly)

Returns the value of attribute submitted


6
7
8
# File 'lib/splinter/capybara/form_completer.rb', line 6

def 
  @submitted
end

Instance Method Details

#checkbox(id, value = nil) ⇒ Object


18
19
20
# File 'lib/splinter/capybara/form_completer.rb', line 18

def checkbox(id, value = nil)
  @page.send value ? :check : :uncheck, "#{@base}_#{id}"
end

#date(id, value) ⇒ Object


34
35
36
# File 'lib/splinter/capybara/form_completer.rb', line 34

def date(id, value)
  @page.send :select_date, value, { :id_prefix => "#{@base}_#{id}" }
end

#datetime(id, value) ⇒ Object


38
39
40
# File 'lib/splinter/capybara/form_completer.rb', line 38

def datetime(id, value)
  @page.send :select_datetime, value, { :id_prefix => "#{@base}_#{id}" }
end

#radio(id, value) ⇒ Object


22
23
24
# File 'lib/splinter/capybara/form_completer.rb', line 22

def radio(id, value)
  @page.send :choose, "#{@base}_#{id}_#{value}"
end

#select(id, value) ⇒ Object


26
27
28
# File 'lib/splinter/capybara/form_completer.rb', line 26

def select(id, value)
  @page.send :find_and_select_option, "#{@base}_#{id}", value
end

#submit(selector = "//form[contains(@id,'#{@base}')]//*[@type='submit']") ⇒ Object


42
43
44
45
# File 'lib/splinter/capybara/form_completer.rb', line 42

def submit(selector = "//form[contains(@id,'#{@base}')]//*[@type='submit']")
  @page.send(:find, :xpath, selector).click
  @submitted = true
end

#submitted?Boolean

Public: Checks if this form has already been submitted.


48
49
50
# File 'lib/splinter/capybara/form_completer.rb', line 48

def 
  
end

#text_field(id, value) ⇒ Object Also known as: text_area


13
14
15
# File 'lib/splinter/capybara/form_completer.rb', line 13

def text_field(id, value)
  @page.send :fill_in, "#{@base}_#{id}", { :with => value.to_s }
end

#time(id, value) ⇒ Object


30
31
32
# File 'lib/splinter/capybara/form_completer.rb', line 30

def time(id, value)
  @page.send :select_time, value, { :id_prefix => "#{@base}_#{id}" }
end