Search code examples
rubycucumberdeviceacceptance-testing

Using cucumber to test the behaviour of different screen sizes (devices)


I am automating my tests using cucumber and I have a requirement to automate the behavior of our nav bar within our mobile pages as these menu options are displayed based on screen size...for example:

480px has menu a, menu b, menu c, and menu d.

320px has menu a, menu c, and menu d.

My queston is, is this possible to automate? If so has anyone got any ideas?

Thanks in advance, Ian


Solution

  • I stuck this in one of my step definitions and it worked:

    if Capybara.current_driver == :selenium
      window = Capybara.current_session.driver.browser.manage.window
      window.resize_to(1200, 800)
    end
    

    I'm using Cucumber with Capybara.