0

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

user1279586
  • 247
  • 3
  • 15

2 Answers2

1

We have did the other way around. Restarting new browser/chrome session as part scenario whenever required using the below command:

const status = browser.status();
if(status.value.ready){
        browser.reload();
}

And also just to add. browser.close() is used as part of windowHandles. browser.end() is the one which can be used for closing a browser but unfortunately it is supported only on standalone mode.

1

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.

iamdanchiv
  • 3,828
  • 4
  • 32
  • 40