为什么我的'Cucumber方法'找不到数据表中列出的信息?
所有其他表都起作用,它似乎无法在[文本](参数)表中找到数据。
Then the user should be presented with the following prompt alert "<message">
Examples:
| url | username | password | message |
| http://www.example.com | user1 | pass1 | validation failed |
| http://www.example.com | webdriver | webdriver123 | validation succeeded |
@Then("^the user should be presented with the following prompt alert \"([^\"]*)\">$")
public void the_user_should_be_presented_with_the_following_prompt_alert(String message) throws Throwable {
Alert alert = driver.switchTo().alert();
Assert.assertEquals(message, alert.getText());
}
正如您所看到的那样,我会收到消息而不是表格中的实际数据:
Then the user should be presented with the following prompt alert "<message"> # LoginSteps.the_user_should_be_presented_with_the_following_prompt_alert(String)
org.junit.ComparisonFailure: expected:<[<message]> but was:<[validation failed]>
at org.junit.Assert.assertEquals(Assert.java:115)
at org.junit.Assert.assertEquals(Assert.java:144)
答案 0 :(得分:1)
看起来这个问题是你步骤中的拼写错误:
Then the user should be presented with the following prompt alert "<message">
应该是
Then the user should be presented with the following prompt alert "<message>"
你有">
错误的方法,因此它没有正确地将其解析为数据占位符。