量角器页面对象错误 - indexPage.getTitle 不是函数

Protrator page objects error - indexPage.getTitle is not a function

因此,我正在使用我的 Protractor e2e 测试 设置 page objects,并立即遇到调用这些对象的问题。我相信这应该很简单,但是我似乎很挣扎。

首先,一开始我的测试,我就看到 Chrome 浏览器以我指定的 URL 启动 - 例如,从 win 7 cmd 提示符:

> protractor conf.js

但是,在浏览器启动后,我在 cmd 控制台中看到了这个错误:

Failures:
1) Launching the SAT Application Should display the correct browser title
  Message:
     Failed: indexPage.getTitle is not a function
  Stack:
     TypeError: indexPage.getTitle is not a function

以下是实施细节:

* index.page.js *

module.exports = function () {
    this.get = function () {

        browser.get("http://localhost:64174/SAT.html");
        
    };
            
    this.getTitle = function () {
        return browser.getTitle();
    };
    
};

var IndexPage = require('./pageObjects/dataCard.page.js');
var DataCardPage = require('./pageObjects/index.page.js');

describe('Launching SAT Application', function () {
    var indexPage = new IndexPage();
    var dataCardpage = new DataCardPage();
    
    beforeEach(function () {
        //indexPage.get;  // not working...
        
        browser.get("http://localhost:64174/sat.html");   // launch successful
    });

    
    it('Should display the correct browser title', function () {        
       expect(indexPage.getTitle()).toBe('My awesome applicatoin'); // not found error in cmd console
    });
 
});

exports.config = {
    directConnect: true,

    capabilities: {
        'browserName': 'chrome'
    },
    framework: 'jasmine',

    specs: ['sat.index.spec.js'],

    suites: {

    },
    
    jasmineNodeOpts: {
        defaultTimeoutInterval: 30000
    }
};

我意识到这应该是一个使用 Protractor 的简单页面对象实现,但我一定遗漏了一些东西。

再次感谢建议...

鲍勃

我不确定你是否发现了这一点,你的导入映射有误

var IndexPage = require('./pageObjects/dataCard.page.js');
var DataCardPage = require('./pageObjects/index.page.js');