获取错误消息" RegistrationPO不是构造函数"使用量角器

时间:2017-02-13 11:56:18

标签: angularjs protractor

当我执行我的spec文件(如下所示)时,我收到错误消息" RegistrationPO不是构造函数" ,Plz帮我解决了我的疑问。谢谢。

//Registration_spec//

'use strict';
var FunLib = require('/Users/acer/AppData/Roaming/npm/node_modules/protractor/FFAutomation/Function_Lib.js'); //Write the location of your javascript file
var RegistrationPO = require('/Users/acer/AppData/Roaming/npm/node_modules/protractor/FFAutomation/Registration_PO.js'); //Write the location of your javascript file
var testData = require('./FFtestdata_Dev_p.json');

describe('Registration: ', function() {

    var FuncLib;
    var Registration;
    var URL;
    var EC = protractor.ExpectedConditions;

    FuncLib = new FunLib();
    Registration = new RegistrationPO();

    beforeEach(function () {
        browser.ignoreSynchronization = true;
    });


    //Scenario 1: Open browser :working
    it('1-Open the web browser',function(){
    browser.ignoreSynchronization = true;
    browser.get('Http://dev.forfirm.com:3000');
        browser.sleep(200000);

    });

});

1 个答案:

答案 0 :(得分:0)

var FunLib = require('/Users/acer/AppData/Roaming/npm/node_modules/protractor/FFAutomation/Function_Lib.js'); //Write the location of your javascript file
var RegistrationPO = require('/Users/acer/AppData/Roaming/npm/node_modules/protractor/FFAutomation/Registration_PO.js'); //Write the location of your javascript file

为什么要在node_modules / protractor中找到你的pageObjects? 有了这个,你将失去重新安装每个node_modules的一切。

我相信这就是你收到错误的原因 - 你无法导入,因为那里不存在文件

创建更简单的结构,例如

   node_modules/...all your dependencies will be installed here
   utils/Function_Lib.js
   pageobjects/Registration_PO.js
   specs/registration.spec.js
   package.json
   protractor.config.js

然后您在specs/registration.spec.js中的导入将是这样的:

var FunLib = require('../utils/Function_Lib.js');
var RegistrationPO = require('../pageobjects/Registration_PO.js'); 

还要检查您在Registration_PO.js和Function_Lib.js

中导出的内容