lib/capybara/poltergeist/browser.rb in poltergeist-1.4.1 vs lib/capybara/poltergeist/browser.rb in poltergeist-1.5.0

- old
+ new

@@ -64,10 +64,14 @@ def visible_text(page_id, id) command 'visible_text', page_id, id end + def delete_text(page_id, id) + command 'delete_text', page_id, id + end + def attribute(page_id, id, name) command 'attribute', page_id, id, name.to_s end def value(page_id, id) @@ -106,11 +110,11 @@ command 'execute', script end def within_frame(handle, &block) if handle.is_a?(Capybara::Node::Base) - command 'push_frame', handle['id'] + command 'push_frame', handle[:name] || handle[:id] else command 'push_frame', handle end yield @@ -169,23 +173,35 @@ def render_base64(format, options = {}) check_render_options!(options) command 'render_base64', format.to_s, !!options[:full], options[:selector] end + def set_paper_size(size) + command 'set_paper_size', size + end + def resize(width, height) command 'resize', width, height end + def send_keys(page_id, id, keys) + command 'send_keys', page_id, id, normalize_keys(keys) + end + def network_traffic command('network_traffic').values.map do |event| NetworkTraffic::Request.new( event['request'], event['responseParts'].map { |response| NetworkTraffic::Response.new(response) } ) end end + def clear_network_traffic + command('clear_network_traffic') + end + def equals(page_id, id, other_id) command('equals', page_id, id, other_id) end def get_headers @@ -226,10 +242,14 @@ def cookies_enabled=(flag) command 'cookies_enabled', !!flag end + def set_http_auth(user, password) + command 'set_http_auth', user, password + end + def js_errors=(val) command 'set_js_errors', !!val end def extensions=(names) @@ -259,19 +279,42 @@ rescue DeadClient restart raise end + def go_back + command 'go_back' + end + + def go_forward + command 'go_forward' + end + private def log(message) logger.puts message if logger end def check_render_options!(options) if !!options[:full] && options.has_key?(:selector) warn "Ignoring :selector in #render since :full => true was given at #{caller.first}" options.delete(:selector) + end + end + + def normalize_keys(keys) + keys.map do |key| + case key + when Array + # String itself with modifiers like :alt, :shift, etc + raise Error, 'PhantomJS behaviour for key modifiers is currently ' \ + 'broken, we will add this in later versions' + when Symbol + { key: key } # Return a known sequence for PhantomJS + when String + key # Plain string, nothing to do + end end end end end