【发布时间】:2016-10-09 18:33:23
【问题描述】:
我有一个场景大纲
Scenario Outline:
When I type "<text>" in the search bar
举例
Examples:
|text|
|laptop|
|camera|
及其步骤定义
@When("^I type \"([^\"]*)\" in the search bar$")
public void iTypeInTheSearchBar(String text){
try {
homepage.searchForItem(text);
}
catch (NullPointerException e){
logger.debug("Exception",e);
}
}
但是当我在每次迭代中运行测试时,它并没有输入示例中定义的参数(笔记本电脑、相机......),而是一直在搜索栏中输入“文本”。我也尝试过重写场景大纲和示例如下
Scenario Outline:
When I type <text> in the search bar
Examples:
|text|
|"laptop"|
|"camera"|
但仍然没有运气。我以前从未遇到过这个问题,有人知道我做错了什么吗?以下是我正在使用的库(JDK 是 1.8)
dependencies {
compile group: 'info.cukes', name: 'cucumber-junit', version: '1.2.5'
// https://mvnrepository.com/artifact/info.cukes/cucumber-java
compile group: 'info.cukes', name: 'cucumber-java8', version: '1.2.5'
}
我通过 Junit 类调用测试
@RunWith(Cucumber.class)
@CucumberOptions(features="src/test/resources",glue= "StepDefinitions",plugin = "pretty")
【问题讨论】:
-
有人吗?我仍在寻找解决方案。
-
您能否尝试找到要将此文本作为参数发送的元素,然后使用发送键,在您的步骤定义中发送该文本。如下所示: driver.findElement(By.id("你想在哪里发送文本")).sendKeys(text);
标签: java scenarios cucumber-java