Sha256: 7a21ee7e6429c760e0e52a7962acc1ff47eeb1c4be8f5d282e1931ed74f6bad0

Contents?: true

Size: 1.19 KB

Versions: 7

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require 'capybara/selenium/nodes/chrome_node'

module Capybara::Selenium::Driver::ChromeDriver
  def fullscreen_window(handle)
    within_given_window(handle) do
      begin
        super
      rescue NoMethodError => e
        raise unless e.message =~ /full_screen_window/
        bridge = browser.send(:bridge)
        result = bridge.http.call(:post, "session/#{bridge.session_id}/window/fullscreen", {})
        result['value']
      end
    end
  end

  def resize_window_to(handle, width, height)
    super
  rescue Selenium::WebDriver::Error::UnknownError => e
    raise unless e.message =~ /failed to change window state/
    # Chromedriver doesn't wait long enough for state to change when coming out of fullscreen
    # and raises unnecessary error. Wait a bit and try again.
    sleep 0.5
    super
  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

private

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

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
tdiary-5.0.11 vendor/bundle/gems/capybara-3.6.0/lib/capybara/selenium/driver_specializations/chrome_driver.rb
capybara-3.6.0 lib/capybara/selenium/driver_specializations/chrome_driver.rb
capybara-3.5.1 lib/capybara/selenium/driver_specializations/chrome_driver.rb
capybara-3.5.0 lib/capybara/selenium/driver_specializations/chrome_driver.rb
capybara-3.4.2 lib/capybara/selenium/driver_specializations/chrome_driver.rb
capybara-3.4.1 lib/capybara/selenium/driver_specializations/chrome_driver.rb
capybara-3.4.0 lib/capybara/selenium/driver_specializations/chrome_driver.rb