忽略黄瓜参数化数据中的特殊字符

Ignoring special character in the cucumber parameterized data

我有一个黄瓜场景,我必须传递数据,并且数据包含特殊字符。当我执行它时,断言失败了。

下面是我的场景:

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|

我在 Then 步骤 "We're part of XXX Group - one of the world's leading" 之后传递的数据有 2 个特殊字符,因此我的断言失败了。

谁能告诉我如何忽略数据中的特殊字符

我认为你需要更好地定义你的代码

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 (.*)$") {...}

你的语法有误。如果你检查 documentation 你会发现正确的方法是不同的。这是Cucumber的官方文档。

还有一个和你一样的问题。请也检查一下:Escape characters in Cucumber step definition