Does anyone know why this step might be showing as "undefined" when I try to run it. below you will see an example where I am trying to experiment with cucumber scenario outline and my "examples:" section has 1 entry. Also, the page objects and step def is enclosed. For some reason when I try to run it , I get an error like this:
1) Scenario: Verify user can search # ..\features\automation\regression\samplezz.feature:13
√ Before # ..\support\world.js:21
√ Given I navigate to the ea site # ..\step_definitions\ea_page_steps.js:4
√ Then I click on the search icon # ..\step_definitions\ea_page_steps.js:8
? When I search for the word angular
Undefined. Implement with the following snippet:
When('I search for the word angular', function (callback) {
// Write code here that turns the phrase above into concrete actions
callback(null, 'pending');
});
Here is the feature file
Feature: sampleZZ
The purpose of this feature file is to navigate to the eaAutomationa site
Scenario Outline: Verify user can search
Given I navigate to the ea site
Then I click on the search icon
When I search for the word <word>
Examples:
|word|
|angular|
here is the step def:
let {Given, Then, When} = require('cucumber');
Given(/^I navigate to the ea site$/, function(){
return browser.get(this.url.ud); });
Then(/^I click on the search icon$/, function(){
return this.pages.udPage.click_Search();
});
When(/^I search for the word "([^"]*)" $/, function(word){
return this.pages.udPage.enter_SearchText(word) });
Here are the page objects
class UDPage extends require('../base_page.js') { constructor() {
super();
this.eaautomation = by.css('#new_searchicon > i');
this.eaLogo = by.css('//#header_logo'); }; click_Search() {
return element(this.eaautomation).click(); }
enter_SearchText(text){
return element(this.eaautomation).sendKeys(text); }
} module.exports = UDPage;
Note: I have a universal constructor in the framework and therefore I don't have to import any pages when I write my test. Could someone help me understand what is the wrong with the step 3 that it keeps showing undefined?
using following
"dependencies": { "chai": "4.1.2", "chai-as-promised": "7.1.1", "chakram": "1.5.0", "cucumber": "4.0.0", "cucumber-html-reporter": "3.0.4", "fs": "0.0.2", "path": "0.12.7", "protractor": "5.3.0", "protractor-cucumber-framework": "4.2.0" }
EDITED- to add the config.js
let path = require('path'),
environment = require('./environment');
exports.config = Object.assign({}, environment, {
seleniumAddress: 'http://localhost:4444/wd/hub', // 'http://localhost:4444/wd/hub' to run locally
capabilities: {
"browserName": "chrome",
"shardTestFiles": true,
"maxInstances": 1,
"ignoreProtectedModeSettings": true
},
specs:[
'../features/automation/regression/sample2.feature',
],
params: {
environment: 'qa1', // dit, qa4, or qa1
platform: 'browser', // browser or mobile
path: {
page_objects: path.resolve(__dirname + '/../page_objects'), // Default directory for the page objects
page_factory: path.resolve(__dirname + '/../page_objects/page_factory.js'), // Default page factory location
projectRoot: path.resolve(__dirname + '/../') // Default root for the automation
}
}
});