Skip to main content

reloadSession

Overview

Use the reloadSession command to create a new Selenium session with the current capabilities.

This command can be useful if you are testing an application with many states and need to clear the browser session between individual tests in a single file, to avoid creating hundreds of separate test files with WDIO. However, be cautious, as this command significantly impacts testing time since creating new Selenium sessions is time-consuming, especially when using cloud services.

Usage

await browser.reloadSession();

Usage Examples

it("should reload my session with current capabilities", async ({ browser }) => {
console.log(browser.sessionId); // outputs: e042b3f3cd5a479da4e171825e96e655

await browser.reloadSession();

console.log(browser.sessionId); // outputs: 9a0d9bf9d4864160aa982c50cf18a573
});

References

We'd like to give credit to the original WebdriverIO docs article, from which we drew some information while writing our version.