Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't maximize window #278

Open
shaicoleman opened this issue Oct 7, 2024 · 0 comments
Open

Can't maximize window #278

shaicoleman opened this issue Oct 7, 2024 · 0 comments

Comments

@shaicoleman
Copy link

shaicoleman commented Oct 7, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant