Reputation: 1142
so I am new to Cucumber and I just wanted to create an easy test that selects some tabs. I created a page object with this function
var tabOne = $('[ui-sref="tab1"]');
this.clickTabOne = function() {
tabOne.click();
};
Then in the step defintion..
this.Then(/^On the home page I switch to first tab$/, function() {
return homePage.clickTabOne();
});
And then finally, the feature file
Feature: tabs test
@warmup
Scenario: As a user
I want to select through tabs
Given I land on the homepage
Then I click the first tab
I understand that the gherkin is terrible and the test makes no sense, but I am new to JavaScript, protractor & cucumber so I am trying to wrap my head around this.. Why is it saying steps are undefined? There is a segment in the printout that says "//Write code here that turns the phrase above into concrete actions" but I already have an action when I say return homePage.clickTabOne(); Thanks for the help!
Upvotes: 1
Views: 1031
Reputation: 6922
When Cucumber finds a matching Step Definition it will execute it. There isn't any Step definition that matches the steps in your feature file therefore the error.
You should define steps that match those used on the feature. In your case:
this.Given(/^I land on the homepage$/, function() {
// Your code
});
this.Then(/^I click the first tab$/, function() {
// Your code
});
Cucumber will use the Regexps in order to perform the matches and will execute the associated callback.
Hope it helps
Upvotes: 1