【问题标题】:Cucumber scenario outline examples' parameters not being used黄瓜场景大纲示例的参数未使用
【发布时间】: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


【解决方案1】:

尝试在下面使用,参数不带引号。 场景大纲: 当我在搜索栏中输入时

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-11
    • 1970-01-01
    • 2018-07-21
    • 2019-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多