Module: Capybara::Selenium::Driver::ChromeDriver

Defined in:
lib/capybara/selenium/driver_specializations/chrome_driver.rb

Instance Method Summary collapse

Instance Method Details

#fullscreen_window(handle) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/capybara/selenium/driver_specializations/chrome_driver.rb', line 6

def fullscreen_window(handle)
  within_given_window(handle) do
    begin
      super
    rescue NoMethodError => err
      raise unless err.message =~ /full_screen_window/

      result = bridge.http.call(:post, "session/#{bridge.session_id}/window/fullscreen", {})
      result['value']
    end
  end
end

#reset!Object



30
31
32
33
34
35
36
37
# File 'lib/capybara/selenium/driver_specializations/chrome_driver.rb', line 30

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

#resize_window_to(handle, width, height) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/capybara/selenium/driver_specializations/chrome_driver.rb', line 19

def resize_window_to(handle, width, height)
  super
rescue Selenium::WebDriver::Error::UnknownError => err
  raise unless err.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.25
  super
end