CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

Need to run many scenarios at one instance without relaunching the browser. How to do it?

Open FathimaAfshan opened this issue 1 year ago • 5 comments

helpers: { Playwright: { browser: 'chromium', url: '***', show: true, keepBrowserState: true, // This ensures cookies and session are maintained across scenarios restart: false, // Prevents browser from restarting after each scenario keepCookies: true, } }

I have given restart as 'false' but still the browser is getting relaunched after every scenario

FathimaAfshan avatar Feb 03 '25 10:02 FathimaAfshan

hey @FathimaAfshan, have you found out the answer? I have the same issue

tomaszHut42 avatar Feb 25 '25 10:02 tomaszHut42

hey @FathimaAfshan, have you found out the answer? I have the same issue

No @tomaszHut42

FathimaAfshan avatar Feb 25 '25 13:02 FathimaAfshan

Pls try with restart:‘keep’ @FathimaAfshan @tomaszHut42

myrepojuly avatar Feb 25 '25 13:02 myrepojuly

hey @FathimaAfshan, indeed I fixed it for myself using restart:‘keep’ (and keepBrowserState and keepCookies set to true as well). Additionally, my issue was I used I.amOnPage('/') in the Background section, which caused the browser to reload (not close the window, but reload the page, which also broke my test workflow). The best results gave me config as aforementioned and setting a flag in Before hook:

let pageLoaded = false; 

Before(({ I }) => {
  if (!pageLoaded) {
    I.amOnPage('/'); 
    pageLoaded = true;
  }
});

tomaszHut42 avatar Feb 26 '25 10:02 tomaszHut42

This issue is stale because it has been open for 90 days with no activity.

github-actions[bot] avatar May 28 '25 02:05 github-actions[bot]