wdio-cucumber-framework - Keep same webdriver sess

2019-05-31 15:13发布

问题:

I am using wdio-cucumber-framework for my test automation. I have test cases in multiple .feature files. When I execute test cases a new webdriver browser instance is generated for each feature file.

settings in wdio.config.js

  capabilities: [{
                maxInstances: 1,            
                browserName: 'chrome'
            }],
    services: ['selenium-standalone'],
    framework: 'cucumber',
    reporters: ['spec'],
  • Feature File 1 ---> 5 test cases
  • Feature File 2 ---> 2 test cases

When I execute all the test cases in both feature files, a browser instance is launched for feature file 1. Once all the 5 test cases in feature file 1 are executed, browser instance got closed and I see wd/hub/session got deleted.

14:51:22]  COMMAND     DELETE   "/wd/hub/session/a4e7a5e9-3a4a-4129-9a31-c7a1b458aeee"
------------------------------------------------------------------
[chrome #0-1] Session ID: a4e7a5e9-3a4a-4129-9a31-c7a1b458aeee

Then a new browser instance got launched for Feature file 2. New webdriver instance got generated.

 COMMAND     POST     "/wd/hub/session"

I want all the feature files to be executed in a single webdriver instance / Session. Please let me know if there is a way to achieve this ?