我正在使用量角器和黄瓜进行e2e测试。 场景大纲如下:
Scenario Outline: Visit HomeScreen
Given I am on the homescreen
When I do nothing
Then I should see the element with id <elemid>
Examples:
|elemid|
|scan-sample-image|
|how-to-run|
|navigation-button|
我对&#34;然后&#34;的步骤定义部分就像:
this.Then(/^I should see the element with id \<elemid\>$/, function(id){
//some code
});
然而,当我打电话给量角器时,我看到了:
Scenario: Visit HomeScreen
V Given I am on the homescreen
V When I do nothing
? Then I should see the element with id scan-sample-image
Scenario: Visit HomeScreen
V Given I am on the homescreen
V When I do nothing
? Then I should see the element with id how-to-run
Scenario: Visit HomeScreen
V Given I am on the homescreen
V When I do nothing
? Then I should see the element with id navigation-button
&#34;然后&#34;没有被认可。 我的错误在哪里?
答案 0 :(得分:1)
尚未认真使用cucumber
,但您的Then
定义不应该使用捕获组来使用此正则表达式:
/^I should see the element with id (.*?)$/
答案 1 :(得分:0)
您的Gherkin语法不正确,dimond括号周围应该有引号
尝试更改以下行
Then I should see the element with id <elemid>
到
Then I should see the element with id "<elemid>"
然后生成步骤,它应该变成这样的东西,
this.Then(/^I should see the element with id (.*)$/, function(id){
//some code
});