【问题标题】:How to pass different data values to a same step from excel to a cucumber steps如何将不同的数据值传递到从excel到黄瓜步骤的同一步骤
【发布时间】:2022-08-18 15:36:46
【问题描述】:

我正在尝试使用步骤 \"@when user input field value as \"something\"\" 用于 10 个场景。每个测试用例应该传递不同的值。但是,步骤定义中不能重复步骤。

我有一个 excel hashmap Utility,它可以根据关键字(场景名称)从 excel 中变红

现在如何从功能文件中获取场景名称并获取特定于每个 TC 的数据,以便更新该特定 TC 的值,从而避免重复步骤

    标签: excel selenium parameters cucumber


    【解决方案1】:

    你基本上是在看Scenario outline,它可以帮助你数据驱动相同的场景。一种选择可以是您执行如下步骤:

    场景大纲:测试多个输入 鉴于一些废话 当用户输入字段值为“scenarioData”时

    Examples:
    |scenarioData|
    |data1|
    |data2|
    |data3|
    

    现在在 excel 中,您的键是 data1、data2 和 data3。在步骤定义中

    @When("user enters the field value as  {word}")
        public void printMeaning(String dataIdentifier) {
            //Read the excel, get the value for dataIdentifier
            //Input data
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-20
      • 1970-01-01
      相关资源
      最近更新 更多