class Prickle::Capybara::Popups::Webkit
Public Instance Methods
accept(&block)
click to toggle source
# File lib/prickle/capybara/popup/webkit.rb, line 18 def accept &block set_type_to :alert manage_popup true, &block end
confirm(&block)
click to toggle source
# File lib/prickle/capybara/popup/webkit.rb, line 8 def confirm &block set_type_to :confirm manage_popup true, &block end
contains_message?(message)
click to toggle source
# File lib/prickle/capybara/popup/webkit.rb, line 27 def contains_message? message raise Exceptions::MessageNotContainedInPopup.new(self.message) unless self.message.include? message end
dismiss(&block)
click to toggle source
# File lib/prickle/capybara/popup/webkit.rb, line 13 def dismiss &block set_type_to :confirm manage_popup false, &block end
message()
click to toggle source
# File lib/prickle/capybara/popup/webkit.rb, line 23 def message @message end
Private Instance Methods
capture_message()
click to toggle source
# File lib/prickle/capybara/popup/webkit.rb, line 61 def capture_message @message = page.evaluate_script "window.#{type}_msg" end
listen_and(accept)
click to toggle source
# File lib/prickle/capybara/popup/webkit.rb, line 49 def listen_and accept page.execute_script %{ window.original_#{type}_function = window.#{type} window.#{type}_msg = null window.#{type} = function(msg) { window.#{type}_msg = msg; return #{!!accept}; } } end
manage_popup(accept) { || ... }
click to toggle source
# File lib/prickle/capybara/popup/webkit.rb, line 41 def manage_popup accept listen_and accept yield restore capture_message self end
restore()
click to toggle source
# File lib/prickle/capybara/popup/webkit.rb, line 57 def restore page.execute_script "window.#{type} = window.original_#{type}_function" end
set_type_to(type)
click to toggle source
# File lib/prickle/capybara/popup/webkit.rb, line 33 def set_type_to type @type = type end
type()
click to toggle source
# File lib/prickle/capybara/popup/webkit.rb, line 37 def type @type.to_s end