CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

Is it possible to start a fresh browser between tests when using multiple execution?

Open jsparks19 opened this issue 8 years ago • 2 comments

What are you trying to achieve?

I have, say, 10 files that I would like to execute using multiple execution in chunks of 5. I would like the 6th test to open a fresh browser when it runs (and the browser used by whichever chunk just finished needs to close). Each of our test files have an initial scenario to login and navigate to the page that needs tested. If multiple execution reuses the same browser window, the 6th test fails because the browser is already logged in and on some other page, so the navigation steps do not work.

If there is a better way to handle the login and navigation pre-steps, I'm interested in hearing that as well. Our requirement is to be able to run a test file in parallel with a group of other tests, or to be able to run it individually. Also, the navigation steps vary by test file.

What do you get instead?

The browser window appears to be reused so it's unable to login or navigate to the page that needs tested.

Details

  • CodeceptJS version: 1.3.0
  • NodeJS Version: 8.9.4
  • Operating System: Windows 7
  • Protractor || WebDriverIO || Nightmare version (if related) WebDriverIO

jsparks19 avatar Jun 29 '18 20:06 jsparks19

The best way would be to execute login once for the first test, save the cookies to memore and reuse that cookies for each next steps with login needed. This pattern was implemented in Codeception but is not implemented for CodeceptJS yet.

https://codeception.com/docs/06-ReusingTestCode#Session-Snapshot

Try to implement it for your tests...

I would like to have it implemented as a core feature but I don't have time for it now (

DavertMik avatar Jun 29 '18 23:06 DavertMik

Thank you, I got it to work by using the WebDriverIO grabCookie and setCookie functions. Would you envision this being a built-in function on the actor that essentially wraps grabCookie and setCookie?

jsparks19 avatar Jun 30 '18 01:06 jsparks19