lib/capybara/poltergeist/browser.rb in poltergeist-1.9.0 vs lib/capybara/poltergeist/browser.rb in poltergeist-1.10.0

- old
+ new

@@ -1,18 +1,19 @@ require "capybara/poltergeist/errors" require "capybara/poltergeist/command" -require 'multi_json' +require 'json' require 'time' module Capybara::Poltergeist class Browser ERROR_MAPPINGS = { 'Poltergeist.JavascriptError' => JavascriptError, 'Poltergeist.FrameNotFound' => FrameNotFound, 'Poltergeist.InvalidSelector' => InvalidSelector, 'Poltergeist.StatusFailError' => StatusFailError, - 'Poltergeist.NoSuchWindowError' => NoSuchWindowError + 'Poltergeist.NoSuchWindowError' => NoSuchWindowError, + 'Poltergeist.UnsupportedFeature' => UnsupportedFeature } attr_reader :server, :client, :logger def initialize(server, client, logger = nil) @@ -161,11 +162,11 @@ def find_window_handle(locator) return locator if window_handles.include? locator handle = command 'window_handle', locator - raise noSuchWindowError unless handle + raise NoSuchWindowError unless handle return handle end def within_window(locator, &block) original = window_handle @@ -216,16 +217,18 @@ command 'scroll_to', left, top end def render(path, options = {}) check_render_options!(options) - command 'render', path.to_s, !!options[:full], options[:selector] + options[:full] = !!options[:full] + command 'render', path.to_s, options end def render_base64(format, options = {}) check_render_options!(options) - command 'render_base64', format.to_s, !!options[:full], options[:selector] + options[:full] = !!options[:full] + command 'render_base64', format.to_s, options end def set_zoom_factor(zoom_factor) command 'set_zoom_factor', zoom_factor end @@ -258,10 +261,17 @@ def clear_network_traffic command('clear_network_traffic') end + def set_proxy(ip, port, type, user, password) + args = [ip, port, type] + args << user if user + args << password if password + command('set_proxy', *args) + end + def equals(page_id, id, other_id) command('equals', page_id, id, other_id) end def get_headers @@ -335,10 +345,14 @@ def debug=(val) @debug = val command 'set_debug', !!val end + def clear_memory_cache + command 'clear_memory_cache' + end + def command(name, *args) cmd = Command.new(name, *args) log cmd.message response = server.send(cmd) @@ -409,11 +423,11 @@ case key when Array # [:Shift, "s"] => { modifier: "shift", key: "S" } # [:Ctrl, :Left] => { modifier: "ctrl", key: :Left } # [:Ctrl, :Shift, :Left] => { modifier: "ctrl,shift", key: :Left } - letter = key.pop - symbol = key.map { |k| k.to_s.downcase }.join(',') + letter = key.last + symbol = key[0...-1].map { |k| k.to_s.downcase }.join(',') { modifier: symbol.to_s.downcase, key: letter.capitalize } when Symbol { key: key.capitalize } # Return a known sequence for PhantomJS when String