In Nightwatch.js, you can reuse the same browser session by setting the persist_session
property in the Nightwatch configuration file to true
. This will ensure that the browser session is not closed after each test and can be reused across tests.
Nightwatch.js – Use the same browser session
Here’s an example of how to set this property in the Nightwatch configuration file:
module.exports = { persist_session: true, // ... };
It’s important to note that this feature is only available in Nightwatch.js version 0.9.12 or later. Additionally, it’s recommended to reset the browser state after each test or suite to ensure that the tests are isolated and do not interfere with each other. You can do this by using the end
method, which closes the current session and starts a new one for the next test.