Search code examples
javascriptmocha.jswebdriver-iowebautomation

I'm unable to run all webdriver.io spec file in single browser seession


I'm using webdriver.io run test. I also reduced maxinstances to 1, but webdriver.io still keeps creating a new browser session before each spec. Can you point out what i'm doing wrong here?

wdio.conf.js

exports.config = {
runner: 'local',
specs: [
    './specs/specs.e2e.js'
],
exclude: [
],
maxInstances: 1,

capabilities: [{

    maxInstances: 1,
    browserName: 'chrome',
    acceptInsecureCerts: true
}],

logLevel: 'info',

bail: 0,

baseUrl: 'http://localhost',

waitforTimeout: 10000,

connectionRetryTimeout: 120000,

connectionRetryCount: 3,

services: ['chromedriver'],

framework: 'mocha',

reporters: ['spec'],

mochaOpts: {
    ui: 'bdd',
    timeout: 60000
  },
}

specs.e2e.js

require('../specs/spec01_login.e2e');
require('../specs/spec02_test.one.e2e');

my folder directories are:

enter image description here

your assistance is greatly appreciated.

PS: I did not use browser.closeWindow() in my spec files.


Solution

  • I had an error on my spec02_test.one.e2e.js and it was not able to find such element, and that's why it opened another browser, and did not close that browser. The code config above is good and has no issue, it works but make sure no error occurs on each spec file