gpt4 book ai didi

javascript - Node.js 错误找不到模块

转载 作者:太空宇宙 更新时间:2023-11-04 00:22:52 26 4
gpt4 key购买 nike

大家好,我是 JS 和 Node.js 新手,我在使用 cucumber 和 PageObject 设置 webdriverio 项目时遇到问题。每次我尝试运行测试时都会发生此错误:

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)

这是调用 openWebSite 的 loginStepsDef.js 文件:

 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();
});
}

任何关于可能发生的事情的想法都会很棒。您需要我展示更多内容吗?请告诉我。

Tree

最佳答案

试试这个:

 var openWebsite = require('../../support/action/openWebsite');
var LoginPage = require('../../pageobject/LoginPage/LoginPage');

关于javascript - Node.js 错误找不到模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43940412/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com