lib/selenium/webdriver/firefox/w3c_bridge.rb in selenium-webdriver-3.3.0 vs lib/selenium/webdriver/firefox/w3c_bridge.rb in selenium-webdriver-3.4.0

- old
+ new

@@ -58,25 +58,55 @@ super ensure @service.stop if @service end + # Support for geckodriver < 0.15 + def resize_window(width, height, handle = :current) + super + rescue Error::UnknownCommandError + execute :set_window_size, {}, {width: width, height: height} + end + + def window_size(handle = :current) + data = super + rescue Error::UnknownCommandError + data = execute :get_window_size + ensure + return Dimension.new data['width'], data['height'] + end + + def reposition_window(x, y) + super + rescue Error::UnknownCommandError + execute :set_window_position, {}, {x: x, y: y} + end + + def window_position + data = super + rescue Error::UnknownCommandError + data = execute :get_window_position + ensure + return Point.new data['x'], data['y'] + end + private def create_capabilities(opts) caps = Remote::W3CCapabilities.firefox caps.merge!(opts.delete(:desired_capabilities)) if opts.key? :desired_capabilities - firefox_options_caps = caps[:firefox_options] || {} - caps[:firefox_options] = firefox_options_caps.merge(opts[:firefox_options] || {}) + firefox_options = caps[:firefox_options] || {} + firefox_options = firefox_options_caps.merge(opts[:firefox_options]) if opts.key?(:firefox_options) if opts.key?(:profile) profile = opts.delete(:profile) unless profile.is_a?(Profile) profile = Profile.from_name(profile) end - caps[:firefox_options][:profile] = profile.encoded + firefox_options[:profile] = profile.encoded end - Binary.path = caps[:firefox_options][:binary] if caps[:firefox_options].key?(:binary) + Binary.path = firefox_options[:binary] if firefox_options.key?(:binary) + caps[:firefox_options] = firefox_options unless firefox_options.empty? caps end end # W3CBridge end # Firefox end # WebDriver