I am new in cucumber framework. I'm automating login scenarios using cucumber with java. Following is my feature file -
And following is step definition file -
I wanted to execute setUp()
methods once before all scenarios (methods implemented for the same) and tearDown()
method after all scenarios. I've used cucumber @Before
and @After
hooks (may be not in correct way).
But I'm seeing same result as before not using these. It open 4 instances of browser for all four scenarios one by one and then do execute them. Is there any way to execute all these scenarios only with one browser instance (call setUp()
method once for all scenarios)?
@Before
public void setup() {
if (driver == null) {
...//What you have
}
driver.manage().deleteAllCookies();
}
To start don't close the browser in the @After hook.