How to run many different Scenario() without closing the browser?
How to run many different Scenario() without closing the browser? This is my code:
Before((I) => {
I.amOnPage('/');
I.fillField('email', '[email protected]');
I.fillField('password', '123456');
I.click('Sign in');
});
Scenario('Check to see if it has landing page and welcome msg', (I) => {
I.see('Welcome to Casefriend Version 1.0');
I.amOnPage('http://cflocal/#landing');
});
Scenario('Logining into Casefriend', (I) => {
I.click('Users');
I.click('New User');
});
This code passes correctly but it opens firefox, test Scenario 1 then closes firefox, opens again, and tests second Scenario. I want it to do everything on one single firefox instance. How can I do?
I think this is a good feature that will be available soon in upcoming releases ) Thanks for the suggestion
@DavertMik It would be really awesome if the state is reset to the initiale state of the site after each test, in order to enable a clean testing environment. (This is something CasperJS has issues with :wink:)
@DavertMik This is kinda killer for working with SauceLabs (starting browsers there is slooow)
I've been looking at how to implement this today ... Basic plan of attack is just a custom WebDriverIO Helper that only starts the browser if it hasn't already been created... This could then be easily be expanded to work off a config option, and I'd probably add that after a test fails, it might be worth restarting the browser.
... only problem is there is no beforeAll/afterAll currently implemented (as per https://github.com/Codeception/CodeceptJS/issues/103) so there is no place to hook into really shut down the browser ... any thoughts on doing this?
@smozely I created a PR with this feature for Protractor/Selenium, I can try to look into it for webdriver.io or If you want to have a look feel free. https://github.com/Codeception/CodeceptJS/pull/167
@fabioel Have you tried using Nightmare? There's a setting that effectively does what you're referring to. Below is an extract from my helpers config:
Nightmare: {
url: 'http://localhost:3000',
webPreferences: {
partition: 'nopersist'
}
}
Closing this issue, now there is restart option that can be used for disabling browser restart
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