Module: Prickle::Capybara

Defined in:
lib/prickle/capybara.rb,
lib/prickle/capybara/popup.rb,
lib/prickle/capybara/xpath.rb,
lib/prickle/capybara/actions.rb,
lib/prickle/capybara/element.rb,
lib/prickle/capybara/popup/webkit.rb,
lib/prickle/capybara/popup/selenium.rb,
lib/prickle/capybara/xpath/expression.rb

Defined Under Namespace

Modules: Actions, Popups, XPath Classes: Element, Popup

Class Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object (private)



59
60
61
62
63
64
65
# File 'lib/prickle/capybara.rb', line 59

def method_missing method, *args
  if method =~ Element::MISSING_METHOD_REGEX
    call_element_with $1, $2, $3, $4, args
  else
    super
  end
end

Class Attribute Details

.image_dirObject

Returns the value of attribute image_dir.



10
11
12
# File 'lib/prickle/capybara.rb', line 10

def image_dir
  @image_dir
end

.wait_timeObject

Returns the value of attribute wait_time.



10
11
12
# File 'lib/prickle/capybara.rb', line 10

def wait_time
  @wait_time
end

Instance Method Details

#capture_screen(name = screenshot_name) ⇒ Object



47
48
49
# File 'lib/prickle/capybara.rb', line 47

def capture_screen name=screenshot_name
  page.driver.browser.save_screenshot Capybara.image_dir + name + ".jpg"
end

#click_by_name(name) ⇒ Object



14
15
16
# File 'lib/prickle/capybara.rb', line 14

def click_by_name name
  find_by_name(name).click
end

#confirm_popupObject



31
32
33
# File 'lib/prickle/capybara.rb', line 31

def confirm_popup
  popup.confirm
end

#dismiss_popupObject



35
36
37
# File 'lib/prickle/capybara.rb', line 35

def dismiss_popup
  popup.dismiss
end

#element(type = Element::OF_ANY_TYPE, identifier) ⇒ Object



19
20
21
# File 'lib/prickle/capybara.rb', line 19

def element type=Element::OF_ANY_TYPE, identifier
  Element.new type, identifier
end

#find_by_name(type = Element::OF_ANY_TYPE, name) ⇒ Object



23
24
25
# File 'lib/prickle/capybara.rb', line 23

def find_by_name type=Element::OF_ANY_TYPE, name
  element(type, :name => name).exists?
end


27
28
29
# File 'lib/prickle/capybara.rb', line 27

def popup
  Popup.new
end


39
40
41
# File 'lib/prickle/capybara.rb', line 39

def popup_message
  popup.message
end

Returns:

  • (Boolean)


43
44
45
# File 'lib/prickle/capybara.rb', line 43

def popup_message_contains? message
  popup.contains_message? message
end