在黄瓜/ Selenium中,当我想将多个参数作为字符串传递时,我有一个问题

问题描述 投票:0回答:1

我收到此错误:

步骤[输入用户名和密码]在文件中的'stepdefenitions.loginstepdefenitions.enter_the_Username_String_username_and_Password_String_password(String,String)中用2个参数定义:/ C:/ Users / hai / eclipse-workspace / gherkins / bin /'。但是,小黄瓜步骤有0个参数。

我的专题文件

Feature: Reset functionality on login page of Application

 Scenario Outline: Verification of reset button with numbers of credential
  Given Open the Chrome and launch the application          
  When Enter the Username <String,username> and  Password <String,password> 
  Then Reset the credential 

  Examples:                             
  |username  |password         |        
  |User1     |password1        |        
  |User2     |password2        |
java selenium-webdriver cucumber cucumber-jvm gherkin
1个回答
1
投票

在特定功能文件步骤中尝试此操作:

When Enter the Username "<username>" and  Password "<password>"

在Java步骤中:

@When("^Enter the Username \"([^\"]*)\" and Password \"([^\"]*)\"$")
public void enterTheUsernameAndPassword(String usnm, String pswd) {
     System.out.println("The username is: " + usnm);
     System.out.println("The password is: " + pswd);
}

有关更多信息,请查看文档here

© www.soinside.com 2019 - 2024. All rights reserved.