我正在尝试填写这个演示网站上的字段。http:/newtours.demoaut.commercuryregister.php。
这是我的功能文件。
Feature: Testing Mercury Tours' register page
Background:
Given the user has launched their browser
And the browser is on Mercury Tour's register page
Scenario Outline: Testing Mercury Tours' registration page via positive testing
When the user enters the "<First Name>"
And enters the "<Last Name>"
And enters the "<Phone>"
And enters the "<Email>"
And enters the "<Address>"
And enters the "<City>"
And enters the "<State>"
And enters the "<Postal Code>"
And selects the "<Country>"
And enters the "<User Name>"
And enters the "<Password>"
And enters the "<Confirm Password>"
Examples:
| First Name | Last Name | Phone | Email | Address | City | State | Postal Code | Country | User Name | Password | Confirm Password |
| Bob | Mayer | 1-877-393-4448 | [email protected] | 123 Victory Lane | Beverly Hills | CA | 90210 | United States | BobM | 123password | 123password |
当我运行这个特性文件时,Cucumber给我提供了前两步的方法签名(名& 姓)和选择下拉菜单(fpr国家),但没有提供其他方法。
@When("^the user enters the \"([^\"]*)\"$")
public void the_user_enters_the(String arg1) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^enters the \"([^\"]*)\"$")
public void enters_the(String arg1) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^selects the \"([^\"]*)\"$")
public void selects_the(String arg1) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
我如何实现填写其他文本字段的方法,比如电话号码,电子邮件和地址?
其他 "缺失 "的步骤也符合同样的模式--------。^enters the \"([^\"]*)\"$
也就是第二种。如果你想让cucumber为每一步发出步骤定义方法签名,可以考虑让它们成为唯一的。改变 And enters the "<Phone>"
到类似 And enters phone details - "<Phone>"
.