首页 > 解决方案 > 有没有办法只运行标签而不打开和关闭浏览器?

问题描述

我正在尝试使用 tagExpression 从各种不同的功能文件运行特定场景,但 webdriver 会为每个场景打开和关闭浏览器,直到找到我提供的标签。有没有办法在找到标签之前不打开浏览器?

    // <string[]> (file/dir) require files before executing features
    require: ['./features/step_definitions/*.js'],
    // <boolean> show full backtrace for errors
    backtrace: true,
    // <string[]> ("extension:module")
    // require files with the given EXTENSION after requiring MODULE (repeatable)
    compiler: [],
    dryRun: false, // <boolean> invoke formatters without executing steps
    failFast: true, // <boolean> abort the run on first failure
    // <string[]> (type[:path]) specify the output format,
    // optionally supply PATH to redirect formatter output (repeatable)
    format: ['pretty'],
    colors: true,
    snippets: true,
    source: true, 
    profile: [], 
    strict: true,
    tagExpression: '@testone',
    timeout: 300000, ble this config to treat undefined definitions as warnings.
    ignoreUndefinedDefinitions: false,
  },```

标签: webdriver-iowebdriver-io-v4

解决方案


为每个功能文件(不适用于场景)创建 Selenium 会话(此时打开和关闭浏览器)。如果您有一些功能文件没有任何与您的标签匹配的场景,那么您可以避免使用以下两个选项之一打开它们:excludesuites方法。

请遵循他们的文档。

例子:

//Not required features can be added here such that wdio ignores them  
exclude: [
        './features/**/test.feature'
    ]

或者

//Define suites and pass as part of params
suites:{
        bvt: [
            './features/BVT_Desktop.feature',
            './features/BVT_Mobile.feature',
        ]
    }

推荐阅读