The site I’m working on has a banner that is shown to first-time users with choices related to their location. In the context of a UI-test you start with a fresh browser session for each test which means that the banner is shown for each new test. Since this banner is animated it can interfere with the tests and we want to get rid of it as soon as possible. To handle this we have a before hook in our cucumber steps that visits the startpage with a certain querystring which sets a cookie that makes the banner go away for the rest of the test.
Before do visit '/?q=00' end
In our ever going quest to shorten the feedback cycle me and pakselsson thought that there ought to be a better way to do this. With the above solution cucumber needs to visit the start page (and wait for it to finish loading) which will probably take quite some time. Perhaps not in the context of one test but surely in the test suite as a whole.
What we did instead was to visit a page that was quicker to load (as it happenes the login form for the episerver site) and then set the cookie manually.
Before do visit '/util/login.aspx' page.driver.browser.manage.add_cookie(:name=>"Region", :value=>"00") end
The total time for the tests went from around 17 minutes to around 14 minutes. Pretty good for such a simple change!