Skip to content

Can't maximize window #278

@shaicoleman

Description

@shaicoleman

When window-size and start-maximized parameters are passed to Chrome, window-size takes precedence.
With cuprite, there's no way not to pass window-size, thus no way to maximize the window.

The following code fails due to window_size: nil:

require 'capybara/cuprite'
require 'capybara/dsl'

class Browser
  include Capybara::DSL

  def run
    Capybara.current_driver = :cuprite
    Capybara.javascript_driver = :cuprite
    Capybara.register_driver(:cuprite) do |app|
      Capybara::Cuprite::Driver.new(app, headless: false, browser_options: { 'start-maximized' => nil }, window_size: nil)
    end
    visit 'https://example.com'
  end
end

Browser.new.run

It might be a ferrum issue, but it seems to work correctly when invoked through ferrum

require 'ferrum'
browser = Ferrum::Browser.new(headless: false, browser_options: { 'start-maximized' => nil }, window_size: nil)
page = browser.create_page
page.go_to('http://example.com')

Possible solutions:

  • :window_size could accept a :maximized value in ferrum/cuprite, and it would add start-maximized to the browser options
  • :window_size could accept a nil value in ferrum/cuprite, so it could work with start-maximized
  • Not pass the :window_size parameter to chrome unless explicitly specified, but that is a minor breaking change

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions