1

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

4

2 に答える 2

2

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.

于 2012-09-20T11:14:11.000 に答える
0

Two possible options:

  • Test this with a real browser, e.g. via Selenium, which has methods to set the window size, which should be callable via the native agent method in Capybara.
  • Pass a window constraint value in as an extra query string for testing. Your production code can check for the presence of this, and use it instead of the real window size. e.g. http://example.com/products?constrain_width=480
于 2011-11-04T17:14:41.090 に答える