【问题标题】:Not able to implement DataTable cucumber feature in QAF无法在 QAF 中实现 DataTable 黄瓜功能
【发布时间】:2021-08-22 11:47:43
【问题描述】:

我正在尝试将 vales 作为 DataTable 在黄瓜中。在 QAF 中如何做到这一点?

   @test
      Scenario: DataTable Examples
        Given I am on github login page
        And I enter usernames and passwords "${args[0]}"
          | testuser_1 | Test@153 |
      
StepDefinition

  @And("^I enter usernames and passwords \"([^\"]*)\"$")
    public void iEnterUsernamesAndPasswords(Map<Object, Object> data) {
        System.out.println("------------->" +data.get(0));
    }

错误信息:

[WINDOWS  91.0.4472.77]: ▀ ▀ ▀ END STEP: Given I am on github login page ▀ ▀ ▀
17:28:22.608 [[WINDOWS  91.0.4472.77]] ERROR com.qmetry.qaf.automation.step.StepNotFoundException - 
/**
* Auto-generated code snippet by QMetry Automation Framework.
*/
@QAFTestStep(description="I enter usernames and passwords {0}{1}")
public void iEnterUsernamesAndPasswords(String str0,Object[] objArray1){
    //TODO: remove NotYetImplementedException and call test steps
    throw new NotYetImplementedException();
}

/**
* Auto-generated code snippet by QMetry Automation Framework.
*/
@QAFTestStep(description="I enter usernames and passwords {0}{1}")
public void iEnterUsernamesAndPasswords(String str0,Object[] objArray1){
    //TODO: remove NotYetImplementedException and call test steps
    throw new NotYetImplementedException();
}

【问题讨论】:

    标签: selenium cucumber bdd qaf


    【解决方案1】:

    args[0] 用于当您有数据驱动的场景(带有示例的场景)并且您想从数据提供者那里引用整个记录时。在这种情况下,您想传递地图,您可以尝试以下方式:

    @test
          Scenario: DataTable Examples
            Given I am on github login page
            And I enter usernames and passwords "{'username':'testuser_1', 'password':'Test@153'}"
    

    或者

    @test
          Scenario: DataTable Examples
            Given I am on github login page
            And I enter usernames and passwords 
              | username | password |
              | testuser_1 | Test@153 |
    

    您可以参考feature filesstep implementation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-04
      • 1970-01-01
      • 1970-01-01
      • 2017-06-05
      相关资源
      最近更新 更多