seleniumselenium-chromedriverwebdriver-iowdio-v4

webdriver.io afterscenario close browser now working


Using webdriverIO and I am trying to close / quit chrome browser between scenarios. Here is what I have in the conf file:

  afterScenario: function (scenario) {
        console.log("afterScenario quit browser");
        browser.Close();
        ;
    },

Is there a way to close browser or chromedriver after each scenario with wdio?

Thanks


Solution

  • Each WebdriverIO process opens a new session (browser.sessionId). Thus, the reload() function is what you are probably looking for.

    afterScenario: function (scenario) {
      console.log("After scenario, reload session!");
      browser.reload();
    },
    

    !Note: For people running the newer wdio-v5 version, the corresponding API command is reloadSession.