Reusing the Browser

Each of our scenarios is exercising our application through our web UI and so needs to use a browser. At the moment we start a new instance of Firefox for each scenario, which takes a fair amount of time. Is it really necessary, or could our scenarios all use the same instance of Firefox?

It’s important that each scenario is isolated from all other scenarios, but the browser itself holds very little context. In most situations it is quite safe to reuse the same browser instance for all your scenarios as long as you clear out any cookies. In this example it’s even simpler—we have no cookies.

Sharing a Browser Using Spring

We’re using a Spring configuration file, cucumber.xml, to define our EventFiringWebDriver. It just ...

Get The Cucumber for Java Book now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.