RE: Maintaining same driver instance in cucumber. Need Help!!
I’m working on cucumber framework setup and facing below few issues. It would be great if you can look into them and provide me the solutions. Many thanks in advance.
How to maintain a same driver instance / browser session throughout the feature file? I’ve created 2 feature files ‘Login’ and ‘AddPost’ and created ‘webdriverinit’ class where initialising the browser in a launchBrowser() method.
Created seperate step definitions files for 2 feature files and they are extending ‘webdriverinit’ class to get the browser. Since 2nd feature file (AddPost) contains few same steps of 1st feature file(Login), it is referring to 1st (Login) step definition class for those methods. As a result, the driver instance from 1st (Login) step definition class is NOT carrying out to second step definition class. Thought to create a constructor in step definitions to maintain same driver instance but it is throwing an error “class step Definitions doesn’t have an empty constructor. If you need it, put cucumber-picocontainer on the classpath“. When I added this jar, again it is throwing many errors.
Need your help in resolving this issue. Please let me know for any more information from my end and also if the above explanation is not clear.
I think you have asked this question
please check the answers there and let us know.