class Conformity::Actions
Constants
- ACTIONS
Attributes
fields[R]
session[R]
Public Class Methods
new(fields, session = Capybara.current_session)
click to toggle source
# File lib/conformity/actions.rb, line 8 def initialize(fields, session = Capybara.current_session) @fields = fields @session = session end
Public Instance Methods
check(locator, options={})
click to toggle source
# File lib/conformity/actions.rb, line 48 def check(locator, options={}) begin session.check(locator, options) rescue Capybara::ElementNotFound session.find(locator, options).set(true) end screenshot(:check) if Conformity.log_screenshots end
choose(locator, options={})
click to toggle source
# File lib/conformity/actions.rb, line 39 def choose(locator, options={}) begin session.choose(locator, options) rescue Capybara::ElementNotFound session.find(locator, options).set(true) end screenshot(:choose) if Conformity.log_screenshots end
click_on(locator, options={})
click to toggle source
# File lib/conformity/actions.rb, line 17 def click_on(locator, options={}) begin session.click_on(locator, options) rescue Capybara::ElementNotFound session.find(locator, options).click end screenshot(:click_on) if Conformity.log_screenshots end
field(name, options={})
click to toggle source
# File lib/conformity/actions.rb, line 13 def field(name, options={}) fields.value(name) end
fill_in(locator, options={})
click to toggle source
# File lib/conformity/actions.rb, line 26 def fill_in(locator, options={}) begin dup = options.dup session.fill_in(locator, dup) rescue Capybara::ElementNotFound raise "Must pass a hash containing 'with'" if not options.is_a?(Hash) or not options.has_key?(:with) with = options.delete(:with) fill_options = options.delete(:fill_options) session.find(locator, options).set(with) end screenshot(:fill_in) if Conformity.log_screenshots end
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/conformity/actions.rb, line 86 def method_missing(name, *args, &block) if ACTIONS.include?(name) session.send(name, *args, &block) screenshot(name) if Conformity.log_screenshots # ignore SuccessConditions elsif [:has_status_code?, :has_content?] else super end end
screenshot(name)
click to toggle source
# File lib/conformity/actions.rb, line 97 def screenshot(name) file_name = "#{Time.now.to_i}_#{name}.png" full_path = Conformity.screenshots_folder + "/" + file_name session.send(:save_screenshot, full_path) end
select(value, options={})
click to toggle source
# File lib/conformity/actions.rb, line 66 def select(value, options={}) begin session.select(value, options) rescue Capybara::ElementNotFound options.delete(:from) session.find(value, options).select_option end screenshot(:select) if Conformity.log_screenshots end
uncheck(locator, options={})
click to toggle source
# File lib/conformity/actions.rb, line 57 def uncheck(locator, options={}) begin session.uncheck(locator, options) rescue Capybara::ElementNotFound session.find(locator, options).set(false) end screenshot(:uncheck) if Conformity.log_screenshots end
unselect(value, options={})
click to toggle source
# File lib/conformity/actions.rb, line 76 def unselect(value, options={}) begin session.unselect(value, options) rescue Capybara::ElementNotFound options.delete(:from) session.find(value, options).unselect_option end screenshot(:unselect) if Conformity.log_screenshots end