Resize Chrome's window while using Capybara
I've found that the Driver#browser
call is now deprecated (Capybara 2.5.0).
You can use the Driver#resize_window_to
call to resize the window:
page.driver.resize_window_to(page.driver.current_window_handle, 1_200, 800)
You can also use Session#current_window
then Window#resize_to
:
page.current_window.resize_to(1_200, 800)
Look at the docs for more info:
Late answer but someone may need this. You can initiate chromedriver by giving windows size so that you don't need to size it after loading the page:
Capybara.register_driver :chrome_sizes do |app| profile = Selenium::WebDriver::Chrome::Profile.new Capybara::Selenium::Driver.new(app, :browser => :chrome, :profile => profile, :args => ["--window-size=1240,1400"] )end