我有一个黄瓜方案,其中我必须传递数据,并且数据包含特殊字符。当我执行时,它在断言时失败。
以下是我的情况:
Scenario Outline: ABTA data
Given a customer is on the "<respective>" page
When the customer scrolls down to the bottom of the page
Then the customer should be able to view the following text with ABTA logo
|We're part of XXX Group - one of the world's leading|
Example:
|Home Page|
在“我们是XXX集团的一员-世界领先企业之一”的“然后”步骤之后,我传递的数据具有2个特殊字符,因此我的断言失败了。
有人可以让我知道如何忽略数据中的特殊字符
答案 0 :(得分:-1)
我认为您需要更好地定义代码
Scenario Outline: ABTA data
Given a customer is on the <respective>
When the customer scrolls down to the bottom of the page
Then the customer should be able to view the following text with ABTA logo
<expected>
Examples:
| respective | expected |
| Home Page | We're part of XXX Group - one of the world's leading |
然后将黄瓜步骤定义为
@Given("^a customer is on the (.*)$") {...}
@Then("^the customer should be able to view the following text with ABTA logo (.*)$") {...}
答案 1 :(得分:-1)
您的语法错误。如果您勾选documentation,将会发现正确的方法有所不同。这是黄瓜的官方文件。
还有一个像您一样的问题。请检查以下内容:Escape characters in Cucumber step definition