目前我正在运行一系列使用以下步骤的测试:
@And("^I select (.*) as a subject type$")
public void click_on_subject_type(String subject) {
String subjectType = String.format("//*[text()='%s']", subject);
waitAndClickUsingByLocator(By.xpath(subjectType), Global_Vars.DEFAULT_TIMEOUT);
}
@And("^I select (.*)$")
public void click_on_level(String level) {
String subjectType = String.format("//*[text()='%s']", level);
waitAndClickUsingByLocator(By.xpath(subjectType), Global_Vars.DEFAULT_TIMEOUT);
}
在执行我的代码时,它似乎抛出异常:cucumber.runtime.AmbiguousStepDefinitionsException:标记上面列出的两个步骤。
我还在步骤定义中添加了 ^ $ 但是问题仍然存在,有什么解决这个问题的想法吗?
最佳答案
为了快速简便地修复,您只需将第二步重命名为: @And("^我选择(.*)作为关卡$")
这也让我们更容易理解场景。
关于selenium - 如何处理 Cucumber AmbiguousStepDefinitions 异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54691180/