Sha256: ef0fe305a31d40dd396c09e04c21ee05cd28ea7625917f68a26cfb80b281aea4

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require 'capybara/selenium/nodes/marionette_node'

module Capybara::Selenium::Driver::MarionetteDriver
  def resize_window_to(handle, width, height)
    within_given_window(handle) do
      # Don't set the size if already set - See https://github.com/mozilla/geckodriver/issues/643
      if window_size(handle) == [width, height]
        {}
      else
        super
      end
    end
  end

  def reset!
    # Use instance variable directly so we avoid starting the browser just to reset the session
    return unless @browser

    switch_to_window(window_handles.first)
    window_handles.slice(1..-1).each { |win| close_window(win) }
    super
  end

  def refresh
    # Accept any "will repost content" confirmation that occurs
    accept_modal :confirm, wait: 0.1 do
      super
    end
  rescue Capybara::ModalNotFound # rubocop:disable Lint/HandleExceptions
    # No modal was opened - page has refreshed - ignore
  end

private

  def build_node(native_node)
    ::Capybara::Selenium::MarionetteNode.new(self, native_node)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capybara-3.7.2 lib/capybara/selenium/driver_specializations/marionette_driver.rb
capybara-3.7.1 lib/capybara/selenium/driver_specializations/marionette_driver.rb
capybara-3.7.0 lib/capybara/selenium/driver_specializations/marionette_driver.rb