使用生成器函数和场景大纲时配置驱动程序无效

configure driver has no effect when using a generator function and scenario outline

看完https://intuit.github.io/karate/#json-function-data-source

给定以下测试脚本 chrome 按照预期在无头模式下运行,但如果您取消注释掉生成器函数并在后续情况中使用。

Feature:

Background:
  * configure driver = { type: 'chrome', headless: true, showDriverLog: false }
  #* def generator =
  #"""
  #  function(i) {
  #    return [
  #      { site: 'https://www.apple.com' },
  #      { site: 'https://www.craigslist.org' },
  #      { site: 'https://www.google.com' }, 
  #      null
  #    ][i]
  #  }
  #"""
  * def d = 'c'

Scenario Outline:
  #* call read('test2.feature')
  * driver site
  * print c
  * delay(4000)
  Examples:
  | site |
  | https://www.google.com |
  | https://www.google.com |

这里headless模式是ignore,好像configure driver = {...} 没有效果。 在上面和下面的情况下,'c' 按 * print d 语句的预期打印。

Feature:

Background:
  * configure driver = { type: 'chrome', headless: true, showDriverLog: false }
  * def generator =
  """
    function(i) {
      return [
        { site: 'https://www.apple.com' },
        { site: 'https://www.craigslist.org' },
        { site: 'https://www.google.com' }, 
        null
      ][i]
    }
  """
  * def d = 'c'

Scenario Outline:
  #* call read('test2.feature')
  * driver site
  * print c
  * delay(4000)
  Examples:
  | generator |

我想了解发生了什么。我的印象是上下文正在被生成器覆盖。如果是这样,为什么 'configure driver' 不起作用,而 'def d' 却起作用?

这很可能是一个错误。这对我来说看起来有点令人费解,很可能是 configure 实施方式的限制。

请遵循此流程,以便项目开发人员可以进一步调查并在需要时进行修复:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

UI 测试非常困难,我们希望获得更多社区贡献。如果您正在尝试进行并行测试,还有其他推荐的方法来管理它。

例如参考这个答案: