How to pass integer values in cucumber test and verify the result










1















How do I call a simple addition function and assert the result of two values using selenium-cucumber-js framework with a test written below. While running the below it says
TypeError: TypeError: Cannot read property 'addvalues' of undefined
at createWorld.When (C:Testscucumberstep-definitionsaddvalues-steps.js:5:25)



Feature:
Scenario: Addition of two values
When Add two values 5 and 10
Then I should get result 15


// Here is my 'addvalues-steps.js' file



const expect = require('chai').expect;
module.exports = function ()

this.When(/^Add two values (-?d+) and (-?d+)$/, (x, y) =>
this.page.addvalues.addValues(x,y);
)

this.Then(/^I should get result (-?d+)$/, (ans) =>
let tot = this.page.addvalues.addValues(x, y);
expect(tot).to.be.eql(ans);
)
;


// Following is my 'addvalues.js file'



module.exports = 
addValues(x,y)
var total = x + y ;
return total ;

;


// world.js >>



const CustomWorld = require('cucumber')
function CustomWorld()
console.log('overriding the world')
this.page =
addvalues: require('../page-objects/addvalues')

console.log("This is the recent error log:"+this.page.addvalues)



module.exports = function() {
this.World = CustomWorld;


enter image description here










share|improve this question
























  • Can you show where you define page that you're accessing as this.page? Probably in your World object?

    – shkaper
    Nov 13 '18 at 3:51











  • The World.js file sits under the support folder... const setWorldConstructor = require('cucumber') class page constructor() this.variable = 0 addValues(x,y) this.variable = x this.variable = y setWorldConstructor(page)

    – soccerway
    Nov 13 '18 at 4:30












  • one more thing: can you add your project structure and the command you're using to run cucumber?

    – shkaper
    Nov 14 '18 at 2:43











  • From windows command prompt : C:Testscucumber>npm test

    – soccerway
    Nov 14 '18 at 2:50











  • if it's npm test, what's in your package.json then?

    – shkaper
    Nov 14 '18 at 2:51















1















How do I call a simple addition function and assert the result of two values using selenium-cucumber-js framework with a test written below. While running the below it says
TypeError: TypeError: Cannot read property 'addvalues' of undefined
at createWorld.When (C:Testscucumberstep-definitionsaddvalues-steps.js:5:25)



Feature:
Scenario: Addition of two values
When Add two values 5 and 10
Then I should get result 15


// Here is my 'addvalues-steps.js' file



const expect = require('chai').expect;
module.exports = function ()

this.When(/^Add two values (-?d+) and (-?d+)$/, (x, y) =>
this.page.addvalues.addValues(x,y);
)

this.Then(/^I should get result (-?d+)$/, (ans) =>
let tot = this.page.addvalues.addValues(x, y);
expect(tot).to.be.eql(ans);
)
;


// Following is my 'addvalues.js file'



module.exports = 
addValues(x,y)
var total = x + y ;
return total ;

;


// world.js >>



const CustomWorld = require('cucumber')
function CustomWorld()
console.log('overriding the world')
this.page =
addvalues: require('../page-objects/addvalues')

console.log("This is the recent error log:"+this.page.addvalues)



module.exports = function() {
this.World = CustomWorld;


enter image description here










share|improve this question
























  • Can you show where you define page that you're accessing as this.page? Probably in your World object?

    – shkaper
    Nov 13 '18 at 3:51











  • The World.js file sits under the support folder... const setWorldConstructor = require('cucumber') class page constructor() this.variable = 0 addValues(x,y) this.variable = x this.variable = y setWorldConstructor(page)

    – soccerway
    Nov 13 '18 at 4:30












  • one more thing: can you add your project structure and the command you're using to run cucumber?

    – shkaper
    Nov 14 '18 at 2:43











  • From windows command prompt : C:Testscucumber>npm test

    – soccerway
    Nov 14 '18 at 2:50











  • if it's npm test, what's in your package.json then?

    – shkaper
    Nov 14 '18 at 2:51













1












1








1


0






How do I call a simple addition function and assert the result of two values using selenium-cucumber-js framework with a test written below. While running the below it says
TypeError: TypeError: Cannot read property 'addvalues' of undefined
at createWorld.When (C:Testscucumberstep-definitionsaddvalues-steps.js:5:25)



Feature:
Scenario: Addition of two values
When Add two values 5 and 10
Then I should get result 15


// Here is my 'addvalues-steps.js' file



const expect = require('chai').expect;
module.exports = function ()

this.When(/^Add two values (-?d+) and (-?d+)$/, (x, y) =>
this.page.addvalues.addValues(x,y);
)

this.Then(/^I should get result (-?d+)$/, (ans) =>
let tot = this.page.addvalues.addValues(x, y);
expect(tot).to.be.eql(ans);
)
;


// Following is my 'addvalues.js file'



module.exports = 
addValues(x,y)
var total = x + y ;
return total ;

;


// world.js >>



const CustomWorld = require('cucumber')
function CustomWorld()
console.log('overriding the world')
this.page =
addvalues: require('../page-objects/addvalues')

console.log("This is the recent error log:"+this.page.addvalues)



module.exports = function() {
this.World = CustomWorld;


enter image description here










share|improve this question
















How do I call a simple addition function and assert the result of two values using selenium-cucumber-js framework with a test written below. While running the below it says
TypeError: TypeError: Cannot read property 'addvalues' of undefined
at createWorld.When (C:Testscucumberstep-definitionsaddvalues-steps.js:5:25)



Feature:
Scenario: Addition of two values
When Add two values 5 and 10
Then I should get result 15


// Here is my 'addvalues-steps.js' file



const expect = require('chai').expect;
module.exports = function ()

this.When(/^Add two values (-?d+) and (-?d+)$/, (x, y) =>
this.page.addvalues.addValues(x,y);
)

this.Then(/^I should get result (-?d+)$/, (ans) =>
let tot = this.page.addvalues.addValues(x, y);
expect(tot).to.be.eql(ans);
)
;


// Following is my 'addvalues.js file'



module.exports = 
addValues(x,y)
var total = x + y ;
return total ;

;


// world.js >>



const CustomWorld = require('cucumber')
function CustomWorld()
console.log('overriding the world')
this.page =
addvalues: require('../page-objects/addvalues')

console.log("This is the recent error log:"+this.page.addvalues)



module.exports = function() {
this.World = CustomWorld;


enter image description here







javascript cucumber cucumberjs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 3:50









shkaper

1,181714




1,181714










asked Nov 13 '18 at 3:39









soccerwaysoccerway

580316




580316












  • Can you show where you define page that you're accessing as this.page? Probably in your World object?

    – shkaper
    Nov 13 '18 at 3:51











  • The World.js file sits under the support folder... const setWorldConstructor = require('cucumber') class page constructor() this.variable = 0 addValues(x,y) this.variable = x this.variable = y setWorldConstructor(page)

    – soccerway
    Nov 13 '18 at 4:30












  • one more thing: can you add your project structure and the command you're using to run cucumber?

    – shkaper
    Nov 14 '18 at 2:43











  • From windows command prompt : C:Testscucumber>npm test

    – soccerway
    Nov 14 '18 at 2:50











  • if it's npm test, what's in your package.json then?

    – shkaper
    Nov 14 '18 at 2:51

















  • Can you show where you define page that you're accessing as this.page? Probably in your World object?

    – shkaper
    Nov 13 '18 at 3:51











  • The World.js file sits under the support folder... const setWorldConstructor = require('cucumber') class page constructor() this.variable = 0 addValues(x,y) this.variable = x this.variable = y setWorldConstructor(page)

    – soccerway
    Nov 13 '18 at 4:30












  • one more thing: can you add your project structure and the command you're using to run cucumber?

    – shkaper
    Nov 14 '18 at 2:43











  • From windows command prompt : C:Testscucumber>npm test

    – soccerway
    Nov 14 '18 at 2:50











  • if it's npm test, what's in your package.json then?

    – shkaper
    Nov 14 '18 at 2:51
















Can you show where you define page that you're accessing as this.page? Probably in your World object?

– shkaper
Nov 13 '18 at 3:51





Can you show where you define page that you're accessing as this.page? Probably in your World object?

– shkaper
Nov 13 '18 at 3:51













The World.js file sits under the support folder... const setWorldConstructor = require('cucumber') class page constructor() this.variable = 0 addValues(x,y) this.variable = x this.variable = y setWorldConstructor(page)

– soccerway
Nov 13 '18 at 4:30






The World.js file sits under the support folder... const setWorldConstructor = require('cucumber') class page constructor() this.variable = 0 addValues(x,y) this.variable = x this.variable = y setWorldConstructor(page)

– soccerway
Nov 13 '18 at 4:30














one more thing: can you add your project structure and the command you're using to run cucumber?

– shkaper
Nov 14 '18 at 2:43





one more thing: can you add your project structure and the command you're using to run cucumber?

– shkaper
Nov 14 '18 at 2:43













From windows command prompt : C:Testscucumber>npm test

– soccerway
Nov 14 '18 at 2:50





From windows command prompt : C:Testscucumber>npm test

– soccerway
Nov 14 '18 at 2:50













if it's npm test, what's in your package.json then?

– shkaper
Nov 14 '18 at 2:51





if it's npm test, what's in your package.json then?

– shkaper
Nov 14 '18 at 2:51












1 Answer
1






active

oldest

votes


















2














Note: the below example is for an old version of cucumber-js: 1.3.3.
With cucumber.js, when you're referencing this from inside step definitions, you're actually referencing the World context. So, for this.page.addvalues.addValues(x,y); to work properly, you'll first need to create page that has a reference to your addvalues.js. Something along these lines:



world.js:



function CustomWorld() 
console.log('overriding the world')
this.page =
addvalues: require('../page-objects/addvalues')



module.exports = function()
this.World = CustomWorld;
;


addvalues.js:



//addvalues.js
module.exports =
addValues(x,y)
var total = x + y ;
return total ;

;


There's also a couple of things to correct in your steps.js.



  1. Don't pass arrow functions into the steps, as this will remove the this context that you're setting in World.js.

  2. If you want to share variables between steps (as you do in your example), you need to store them somewhere. One such place, again, would be the World context. Note how in my version I set this.prevResult

  3. When the variables are injected into your steps, they are injected as strings. Note the parseInt() in my version.

addvalues-steps.js:



const expect = require('chai').expect;

module.exports = function()
this.When(/^Add two values (-?d+) and (-?d+)$/, function (x, y)
this.prevResult = this.page.addvalues.addValues(parseInt(x, 10), parseInt(y, 10));
)

this.Then(/^I should get result (-?d+)$/, function (ans)
let tot = this.prevResult;
expect(tot).to.be.eql(parseInt(ans, 10));
)




UPD: It turns out that the question is about selenium-cucumber-js, which is a framework on top of cucumber-js. Disregard the comments about the world.js.



According to selenium-cucumber-js docs, you don't need this to access the page objects in your step definitions:




Page objects are accessible via a global page object and are
automatically loaded from ./page-objects.




const expect = require('chai').expect;

module.exports = function()
this.When(/^Add two values (-?d+) and (-?d+)$/, function (x, y)
this.prevResult = page.addvalues.addValues(parseInt(x, 10), parseInt(y, 10));
)

this.Then(/^I should get result (-?d+)$/, function (ans)
let tot = this.prevResult;
expect(tot).to.be.eql(parseInt(ans, 10));
)






share|improve this answer

























  • Thanks, I have added the world.js under the support folder as per above. Now the constructor looks as below: But still gives error; const setWorldConstructor = require('cucumber') class CustomWorld constructor() this.page = addvalues: require('../page-objects/addvalues.js') addValues(x, y) this.variable = x this.variable = y setWorldConstructor(CustomWorld)

    – soccerway
    Nov 13 '18 at 4:58












  • @soccerway which version of`cucumber.js are you using?

    – shkaper
    Nov 13 '18 at 15:26











  • When I run npm cucumber -version from command prompt ..It gives me 3.10.10

    – soccerway
    Nov 13 '18 at 20:26












  • this way you're actually getting the version of npm itself. try npm list cucumber instead

    – shkaper
    Nov 13 '18 at 20:31











  • After running as per you advised selenium-cucumber-js@1.6.2 cucumber@1.3.3

    – soccerway
    Nov 13 '18 at 21:21











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273436%2fhow-to-pass-integer-values-in-cucumber-test-and-verify-the-result%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Note: the below example is for an old version of cucumber-js: 1.3.3.
With cucumber.js, when you're referencing this from inside step definitions, you're actually referencing the World context. So, for this.page.addvalues.addValues(x,y); to work properly, you'll first need to create page that has a reference to your addvalues.js. Something along these lines:



world.js:



function CustomWorld() 
console.log('overriding the world')
this.page =
addvalues: require('../page-objects/addvalues')



module.exports = function()
this.World = CustomWorld;
;


addvalues.js:



//addvalues.js
module.exports =
addValues(x,y)
var total = x + y ;
return total ;

;


There's also a couple of things to correct in your steps.js.



  1. Don't pass arrow functions into the steps, as this will remove the this context that you're setting in World.js.

  2. If you want to share variables between steps (as you do in your example), you need to store them somewhere. One such place, again, would be the World context. Note how in my version I set this.prevResult

  3. When the variables are injected into your steps, they are injected as strings. Note the parseInt() in my version.

addvalues-steps.js:



const expect = require('chai').expect;

module.exports = function()
this.When(/^Add two values (-?d+) and (-?d+)$/, function (x, y)
this.prevResult = this.page.addvalues.addValues(parseInt(x, 10), parseInt(y, 10));
)

this.Then(/^I should get result (-?d+)$/, function (ans)
let tot = this.prevResult;
expect(tot).to.be.eql(parseInt(ans, 10));
)




UPD: It turns out that the question is about selenium-cucumber-js, which is a framework on top of cucumber-js. Disregard the comments about the world.js.



According to selenium-cucumber-js docs, you don't need this to access the page objects in your step definitions:




Page objects are accessible via a global page object and are
automatically loaded from ./page-objects.




const expect = require('chai').expect;

module.exports = function()
this.When(/^Add two values (-?d+) and (-?d+)$/, function (x, y)
this.prevResult = page.addvalues.addValues(parseInt(x, 10), parseInt(y, 10));
)

this.Then(/^I should get result (-?d+)$/, function (ans)
let tot = this.prevResult;
expect(tot).to.be.eql(parseInt(ans, 10));
)






share|improve this answer

























  • Thanks, I have added the world.js under the support folder as per above. Now the constructor looks as below: But still gives error; const setWorldConstructor = require('cucumber') class CustomWorld constructor() this.page = addvalues: require('../page-objects/addvalues.js') addValues(x, y) this.variable = x this.variable = y setWorldConstructor(CustomWorld)

    – soccerway
    Nov 13 '18 at 4:58












  • @soccerway which version of`cucumber.js are you using?

    – shkaper
    Nov 13 '18 at 15:26











  • When I run npm cucumber -version from command prompt ..It gives me 3.10.10

    – soccerway
    Nov 13 '18 at 20:26












  • this way you're actually getting the version of npm itself. try npm list cucumber instead

    – shkaper
    Nov 13 '18 at 20:31











  • After running as per you advised selenium-cucumber-js@1.6.2 cucumber@1.3.3

    – soccerway
    Nov 13 '18 at 21:21
















2














Note: the below example is for an old version of cucumber-js: 1.3.3.
With cucumber.js, when you're referencing this from inside step definitions, you're actually referencing the World context. So, for this.page.addvalues.addValues(x,y); to work properly, you'll first need to create page that has a reference to your addvalues.js. Something along these lines:



world.js:



function CustomWorld() 
console.log('overriding the world')
this.page =
addvalues: require('../page-objects/addvalues')



module.exports = function()
this.World = CustomWorld;
;


addvalues.js:



//addvalues.js
module.exports =
addValues(x,y)
var total = x + y ;
return total ;

;


There's also a couple of things to correct in your steps.js.



  1. Don't pass arrow functions into the steps, as this will remove the this context that you're setting in World.js.

  2. If you want to share variables between steps (as you do in your example), you need to store them somewhere. One such place, again, would be the World context. Note how in my version I set this.prevResult

  3. When the variables are injected into your steps, they are injected as strings. Note the parseInt() in my version.

addvalues-steps.js:



const expect = require('chai').expect;

module.exports = function()
this.When(/^Add two values (-?d+) and (-?d+)$/, function (x, y)
this.prevResult = this.page.addvalues.addValues(parseInt(x, 10), parseInt(y, 10));
)

this.Then(/^I should get result (-?d+)$/, function (ans)
let tot = this.prevResult;
expect(tot).to.be.eql(parseInt(ans, 10));
)




UPD: It turns out that the question is about selenium-cucumber-js, which is a framework on top of cucumber-js. Disregard the comments about the world.js.



According to selenium-cucumber-js docs, you don't need this to access the page objects in your step definitions:




Page objects are accessible via a global page object and are
automatically loaded from ./page-objects.




const expect = require('chai').expect;

module.exports = function()
this.When(/^Add two values (-?d+) and (-?d+)$/, function (x, y)
this.prevResult = page.addvalues.addValues(parseInt(x, 10), parseInt(y, 10));
)

this.Then(/^I should get result (-?d+)$/, function (ans)
let tot = this.prevResult;
expect(tot).to.be.eql(parseInt(ans, 10));
)






share|improve this answer

























  • Thanks, I have added the world.js under the support folder as per above. Now the constructor looks as below: But still gives error; const setWorldConstructor = require('cucumber') class CustomWorld constructor() this.page = addvalues: require('../page-objects/addvalues.js') addValues(x, y) this.variable = x this.variable = y setWorldConstructor(CustomWorld)

    – soccerway
    Nov 13 '18 at 4:58












  • @soccerway which version of`cucumber.js are you using?

    – shkaper
    Nov 13 '18 at 15:26











  • When I run npm cucumber -version from command prompt ..It gives me 3.10.10

    – soccerway
    Nov 13 '18 at 20:26












  • this way you're actually getting the version of npm itself. try npm list cucumber instead

    – shkaper
    Nov 13 '18 at 20:31











  • After running as per you advised selenium-cucumber-js@1.6.2 cucumber@1.3.3

    – soccerway
    Nov 13 '18 at 21:21














2












2








2







Note: the below example is for an old version of cucumber-js: 1.3.3.
With cucumber.js, when you're referencing this from inside step definitions, you're actually referencing the World context. So, for this.page.addvalues.addValues(x,y); to work properly, you'll first need to create page that has a reference to your addvalues.js. Something along these lines:



world.js:



function CustomWorld() 
console.log('overriding the world')
this.page =
addvalues: require('../page-objects/addvalues')



module.exports = function()
this.World = CustomWorld;
;


addvalues.js:



//addvalues.js
module.exports =
addValues(x,y)
var total = x + y ;
return total ;

;


There's also a couple of things to correct in your steps.js.



  1. Don't pass arrow functions into the steps, as this will remove the this context that you're setting in World.js.

  2. If you want to share variables between steps (as you do in your example), you need to store them somewhere. One such place, again, would be the World context. Note how in my version I set this.prevResult

  3. When the variables are injected into your steps, they are injected as strings. Note the parseInt() in my version.

addvalues-steps.js:



const expect = require('chai').expect;

module.exports = function()
this.When(/^Add two values (-?d+) and (-?d+)$/, function (x, y)
this.prevResult = this.page.addvalues.addValues(parseInt(x, 10), parseInt(y, 10));
)

this.Then(/^I should get result (-?d+)$/, function (ans)
let tot = this.prevResult;
expect(tot).to.be.eql(parseInt(ans, 10));
)




UPD: It turns out that the question is about selenium-cucumber-js, which is a framework on top of cucumber-js. Disregard the comments about the world.js.



According to selenium-cucumber-js docs, you don't need this to access the page objects in your step definitions:




Page objects are accessible via a global page object and are
automatically loaded from ./page-objects.




const expect = require('chai').expect;

module.exports = function()
this.When(/^Add two values (-?d+) and (-?d+)$/, function (x, y)
this.prevResult = page.addvalues.addValues(parseInt(x, 10), parseInt(y, 10));
)

this.Then(/^I should get result (-?d+)$/, function (ans)
let tot = this.prevResult;
expect(tot).to.be.eql(parseInt(ans, 10));
)






share|improve this answer















Note: the below example is for an old version of cucumber-js: 1.3.3.
With cucumber.js, when you're referencing this from inside step definitions, you're actually referencing the World context. So, for this.page.addvalues.addValues(x,y); to work properly, you'll first need to create page that has a reference to your addvalues.js. Something along these lines:



world.js:



function CustomWorld() 
console.log('overriding the world')
this.page =
addvalues: require('../page-objects/addvalues')



module.exports = function()
this.World = CustomWorld;
;


addvalues.js:



//addvalues.js
module.exports =
addValues(x,y)
var total = x + y ;
return total ;

;


There's also a couple of things to correct in your steps.js.



  1. Don't pass arrow functions into the steps, as this will remove the this context that you're setting in World.js.

  2. If you want to share variables between steps (as you do in your example), you need to store them somewhere. One such place, again, would be the World context. Note how in my version I set this.prevResult

  3. When the variables are injected into your steps, they are injected as strings. Note the parseInt() in my version.

addvalues-steps.js:



const expect = require('chai').expect;

module.exports = function()
this.When(/^Add two values (-?d+) and (-?d+)$/, function (x, y)
this.prevResult = this.page.addvalues.addValues(parseInt(x, 10), parseInt(y, 10));
)

this.Then(/^I should get result (-?d+)$/, function (ans)
let tot = this.prevResult;
expect(tot).to.be.eql(parseInt(ans, 10));
)




UPD: It turns out that the question is about selenium-cucumber-js, which is a framework on top of cucumber-js. Disregard the comments about the world.js.



According to selenium-cucumber-js docs, you don't need this to access the page objects in your step definitions:




Page objects are accessible via a global page object and are
automatically loaded from ./page-objects.




const expect = require('chai').expect;

module.exports = function()
this.When(/^Add two values (-?d+) and (-?d+)$/, function (x, y)
this.prevResult = page.addvalues.addValues(parseInt(x, 10), parseInt(y, 10));
)

this.Then(/^I should get result (-?d+)$/, function (ans)
let tot = this.prevResult;
expect(tot).to.be.eql(parseInt(ans, 10));
)







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 14 '18 at 3:23

























answered Nov 13 '18 at 4:33









shkapershkaper

1,181714




1,181714












  • Thanks, I have added the world.js under the support folder as per above. Now the constructor looks as below: But still gives error; const setWorldConstructor = require('cucumber') class CustomWorld constructor() this.page = addvalues: require('../page-objects/addvalues.js') addValues(x, y) this.variable = x this.variable = y setWorldConstructor(CustomWorld)

    – soccerway
    Nov 13 '18 at 4:58












  • @soccerway which version of`cucumber.js are you using?

    – shkaper
    Nov 13 '18 at 15:26











  • When I run npm cucumber -version from command prompt ..It gives me 3.10.10

    – soccerway
    Nov 13 '18 at 20:26












  • this way you're actually getting the version of npm itself. try npm list cucumber instead

    – shkaper
    Nov 13 '18 at 20:31











  • After running as per you advised selenium-cucumber-js@1.6.2 cucumber@1.3.3

    – soccerway
    Nov 13 '18 at 21:21


















  • Thanks, I have added the world.js under the support folder as per above. Now the constructor looks as below: But still gives error; const setWorldConstructor = require('cucumber') class CustomWorld constructor() this.page = addvalues: require('../page-objects/addvalues.js') addValues(x, y) this.variable = x this.variable = y setWorldConstructor(CustomWorld)

    – soccerway
    Nov 13 '18 at 4:58












  • @soccerway which version of`cucumber.js are you using?

    – shkaper
    Nov 13 '18 at 15:26











  • When I run npm cucumber -version from command prompt ..It gives me 3.10.10

    – soccerway
    Nov 13 '18 at 20:26












  • this way you're actually getting the version of npm itself. try npm list cucumber instead

    – shkaper
    Nov 13 '18 at 20:31











  • After running as per you advised selenium-cucumber-js@1.6.2 cucumber@1.3.3

    – soccerway
    Nov 13 '18 at 21:21

















Thanks, I have added the world.js under the support folder as per above. Now the constructor looks as below: But still gives error; const setWorldConstructor = require('cucumber') class CustomWorld constructor() this.page = addvalues: require('../page-objects/addvalues.js') addValues(x, y) this.variable = x this.variable = y setWorldConstructor(CustomWorld)

– soccerway
Nov 13 '18 at 4:58






Thanks, I have added the world.js under the support folder as per above. Now the constructor looks as below: But still gives error; const setWorldConstructor = require('cucumber') class CustomWorld constructor() this.page = addvalues: require('../page-objects/addvalues.js') addValues(x, y) this.variable = x this.variable = y setWorldConstructor(CustomWorld)

– soccerway
Nov 13 '18 at 4:58














@soccerway which version of`cucumber.js are you using?

– shkaper
Nov 13 '18 at 15:26





@soccerway which version of`cucumber.js are you using?

– shkaper
Nov 13 '18 at 15:26













When I run npm cucumber -version from command prompt ..It gives me 3.10.10

– soccerway
Nov 13 '18 at 20:26






When I run npm cucumber -version from command prompt ..It gives me 3.10.10

– soccerway
Nov 13 '18 at 20:26














this way you're actually getting the version of npm itself. try npm list cucumber instead

– shkaper
Nov 13 '18 at 20:31





this way you're actually getting the version of npm itself. try npm list cucumber instead

– shkaper
Nov 13 '18 at 20:31













After running as per you advised selenium-cucumber-js@1.6.2 cucumber@1.3.3

– soccerway
Nov 13 '18 at 21:21






After running as per you advised selenium-cucumber-js@1.6.2 cucumber@1.3.3

– soccerway
Nov 13 '18 at 21:21


















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273436%2fhow-to-pass-integer-values-in-cucumber-test-and-verify-the-result%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo