Reputation: 91
When I am using the below code I am getting an error.
Tool Used: protractor
framework: jasmine
IDE: Webstorm
//Page object file - newPage.js
newPage = function(){
function clickCandidate(){
//All your code that you want to call from the test spec
});
};
module.exports = new newPage();
//Test Spec file - test.js
var newPage = require('./newPage.js'); //Write the location of your javascript file
it('Click on candidate status Screened', function () {
//Call the function
newPage.clickCandidate();
});
I am getting error that:
Error: Cannot find module 'scenarios/newPage.js'
Upvotes: 1
Views: 32
Reputation: 3268
Well first, of course make sure that require
path is correct and relative to the file you are running.
Other than that, just a few things that catch my attention:
var
before newPage = function()...
(I think this is the source of your issue)this
or Prototypal inheritanceSo it could look either like this:
var newPage = function () {
this.clickCandidate(){
//All your code that you want to call from the test spec
});
};
module.exports = new newPage();
OR
var newPage = function() {};
newPage.prototype.clickCandidate = function() {
// all your code
};
module.exports = new newPage();
Upvotes: 1