我一直收到这样一条消息,说Newpage不是一个构造器。我在过去的5个小时里绞尽脑汁试图解决这个问题,但没有任何进展。我查看了以下网站
How to call a function in another function in protractor
'TypeError: undefined is not a function' using Protractor
也许这是我不知道的简单的事情。我所要做的就是从我的页面对象文件中调用一个函数。仍然没有成功,任何帮助都将不胜感激。
我的代码:
var newPage = require('./newPage.js');
describe('Get Payroll Information', function() {
beforeAll(function(){
var newPageObj = new newPage();
});
var EC = protractor.ExpectedConditions;
var status;
var clientid, weeknum, pdate;
it('Get CycleStatus, Paydate, Weeknumber, Clientid - completed', function () {
const fs = require('fs');
const cycle = $('#cycleStatusID');
const client = $('#clientID');
const week = $('#companyIdBar_weekId');
const payDate = $('#companyIdBar_processDateId');
.then(() => {
payDate.isPresent().then(function(present){
if(present){
payDate.getText().then(function(text){
pDate = text;
console.log('paydate (' + pDate + ') is displayed');
});
} else {
console.log('pay date not present');
}
})
})
.then(() => {
writeValueToFile(cycleStatus,clientID,weekNum,pDate);
})
.then(() => {
newPageObj.goBack();
console.log('return to support');
});
});
});
量角器控制台消息
新建页面。js代码:
newPage = function(){
function goBack(){
var returnbtn = $('#returnToADPClick');
var search1 = ($$('input[id="toolbarQuickSearch"]').get(0));
returnbtn.click();
browser.wait(EC.elementToBeClickable(search1),20,000);
};
};
module.exports = new newPage();
已更改为模块。导出=新建页面;//这项工作现在我得到了