所以我设置page objects
与我的量角器e2e测试,并立即有问题调用到这些对象。我相信这应该很简单,但我似乎在挣扎。protater页面对象错误 - indexPage.getTitle不是函数
首先,当我开始我的测试,我看到了Chrome浏览器的推出与我指定的URL - 例如,从一胜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();
};
};
- sat.index.spec.js *
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'); \t // not found error in cmd console
});
\t
});
- conf.js *
exports.config = {
directConnect: true,
capabilities: {
'browserName': 'chrome'
},
framework: 'jasmine',
specs: ['sat.index.spec.js'],
suites: {
},
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
};
我知道这应该是用量角器一个简单的页面对象实现,但我一定是失去了一些东西。
建议再次不胜感激...
鲍勃
等待,我想我看到了现在我发布了这个错误。我的require()语句会在通知中切换。 IndexPage和DataCardPage正在拉对方的相反文件。好家伙。 –