【问题标题】:Cucumber scenario outline input with quotes in the value黄瓜场景大纲输入,值中带有引号
【发布时间】:2021-12-18 04:42:03
【问题描述】:

我正在尝试使用带有 ruby​​ 函数的 appian 的fitnesse 向文本字段输入一个值。 我有一个黄瓜场景:

Feature:  create a quick decision

Scenario Outline: decision
       
  When I populate the "Decision Title" field with <decTitle>
 Examples:
  | role                  | decTitle                |
  | "test" | "testinput "user1" titlepart2"   | 

我必须能够在该字段中输入带引号的值,以及从下拉菜单中进行选择。

我试图通过以下方式转义引号:

  1. 在同一行和多行上的三引号 """ 富 “和” 酒吧 """

  2. " 用于起始引号和内部引号 “富”和“酒吧” “foo”和“bar”

  3. 内外双引号 “富”“和”“吧”

在运行测试用例时都会导致相同的“步骤未定义”错误 任何和所有的帮助将不胜感激。

【问题讨论】:

  • 要删除双引号吗?比如,从"testinput "user1" titlepart2"testinput user1 titlepart2"testinput" user1 "titlepart2"
  • 不,目标是输入一个包含引号的值。我的用例是标题可以在其他保留字符或不常见字符中包含引号。
  • 你试过我的解决方案了吗?

标签: ruby selenium automation cucumber appian


【解决方案1】:

您可以使用正则表达式(.*) 来传递带有双引号的值。如下所示,

场景

  @Regression
  Scenario Outline: decision
    When I populate the "Decision Title" field with <decTitle>

    Examples: 
      | role   | decTitle                       |
      | "test" | "testinput "user1" titlepart2" |

代码

@When("I populate the \"(.*)\" field with (.*)$")
public void populate(String message, String decTitle) {
    System.out.println("Message: " + message);
    System.out.println("Title: " + decTitle);
}

输出

Message: Decision Title
Title: "testinput "user1" titlepart2"

【讨论】:

  • 这适用于我在外面有引号但当前的问题是最终输出需要是这样的:testinput "user1" titlepart2
  • 在这种情况下,您可以在示例中传递testinput "user1" titlepart2
  • 很遗憾,表格中的值必须用引号括起来。
  • 你能补充几个例子吗?
猜你喜欢
  • 1970-01-01
  • 2020-07-11
  • 2015-05-08
  • 2019-12-15
  • 1970-01-01
  • 2017-11-21
  • 2019-11-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多