2017-08-11 4 views
1

Ich verwende Winkelmesser und Gurke für e2e Test. Das Szenario Umriss ist wie:Schritt Definition nicht erkannt

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| 

Mein Schritt Definition für die "dann" -Teil ist wie:

this.Then(/^I should see the element with id \<elemid\>$/, function(id){ 
//some code  
}); 

Allerdings, wenn ich Winkelmesser nennen, ich sehe dies:

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 

Das "Dann" wird nicht erkannt. Wo ist mein Fehler?

Antwort

1

persönlich habe nicht cucumber ernsthaft noch verwendet, soll aber nicht Ihre Then Definition hat diesen regulären Ausdruck mit einer Erfassung Gruppe statt:

/^I should see the element with id (.*?)$/ 
+0

das Java-Äquivalent für das gleiche ist '^ Ich sollte das Element mit der ID \" ([^ \ "] *) sehen \" $ ' –

+0

@alecxe: danke. Es war die Lösung. :) – saab

+0

@Ashish Deshmukh: die beiden Quotationszeichen \ "enden im selben Problem, dh die Methoden wurden nicht erkannt. – saab

0

diese /^I go to "([^"]*)"$/ hinzufügen, wo Sie die Parameter von Funktion zu fangen versuchen, Datei. Ihr Code wird sein

this.Then(/^I should see the element with id "([^"]*)"$/, function(id){ 
//some code  
}); 
0

Ihre Gherkin Syntax falsch ist, sollte es in Anführungszeichen den dimond Klammern sein

unterhalb der Linie zu ändern Versuchen

Then I should see the element with id <elemid>  

zu

Then I should see the element with id "<elemid>"  

Und dann Schritte generieren, sollte es in etwa so aussehen,

this.Then(/^I should see the element with id (.*)$/, function(id){ 
    //some code  
}); 
Verwandte Themen