1

Hey guys I'm new to JS and Node.js and I'm having trouble setting up a webdriverio project using cucumber and PageObject. And every time I try to run a test this error happens:

ERROR: Cannot find module '../support/action/openWebsite'
chrome
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/axelbarford/Desktop/Oktana-training-webdriverio/src/steps/LoginStepDef/loginStepsDef.js:1:1)
    at Module._compile (module.js:570:32)
    at loader (/usr/local/lib/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)

This is the loginStepsDef.js file where the openWebSite is being called:

 import openWebsite from '../support/action/openWebsite';
import LoginPage from '../pageobject/LoginPage/LoginPage';

module.exports = function given() {
    this.Given(
        /^I open salesforce login page$/,
            openWebsite
    );

    this.When(
        /^I set user "([^"]*)?" and password "([^"]*)?"$/, function(arg1,arg2) {
            LoginPage.open();
            LoginPage.username.setValue(arg1)
            LoginPage.password.setValue(arg2) 
        });

    this.And(
        /^I click the login button$/,function(){
            LoginPage.open();
            LoginPage.submit(); 
        });
}

Any idea what could be happening would be great. Do you need me to show something more let me know.

Tree

4
  • "Any idea what could be happening" ==> "Cannot find module '../support/action/openWebsite'" Commented May 12, 2017 at 14:39
  • Are you sure that path to your module is correct? Commented May 12, 2017 at 14:39
  • you should use require, import from is not natively supported by node.js so far and babel & co only converts it to require Commented May 12, 2017 at 15:15
  • im sure the path is good Commented May 12, 2017 at 15:34

1 Answer 1

1

Try with this :

 var openWebsite = require('../../support/action/openWebsite');
 var LoginPage = require('../../pageobject/LoginPage/LoginPage');
Sign up to request clarification or add additional context in comments.

4 Comments

already tried doing that and didn't work says it still missing
can you give us a tree view of your folder ? Are you sure the path isn't ./pageobject/LoginPage/LoginPage ?
Sure i will upload a tree view
Oh ok, i know why, use var openWebsite = require('../../support/action/openWebsite'); and var LoginPage = require('../../pageobject/LoginPage/LoginPage');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.