ruby-on-rails-4rspeccapybararack-test

Resizing the window in Capybara with rack_test


I'm using rack_test as my driver for Capybara and I'm trying to resize the window.

The best example I could find on this was this gist, but the resize method does not seem to work for rack_test

> Capybara.current_driver
=> :rack_test

> page.driver.resize(200, 200)
NoMethodError: undefined method `resize' for #<Capybara::RackTest::Driver:0x007fe4eb83bc60>
from (pry):22:in `block (2 levels) in <top (required)>'

I've tried various other combinations I've seen online with no luck. Is there an easier way to resize the browser window?

Thanks!


Solution

  • The rack_test driver has no concept of windows or page size. It is strictly an HTML parser, does no layout and very minimal CSS processing (basically just inline display: none checking). If you need window resizing you will need to switch to one of the real browser drivers.