В моих тестах скрипт Protractor Test нажимает кнопку для загрузки файла.
Ниже приведен фрагмент кода:
var today = new Date(),
timeStamp = moment(today).format('MMDDYYYY');
let G = GV;
let file = './downloaded-files/StudentList'+timeStamp+'.xlsx';
let Worksheet = 'StudentList'+timeStamp+'.pdf';
let XL = require('exceljs');
let Workbook = new XL.Workbook();
let RowLength= 0;
=======
G.Excel_Button.click().then(function () {
browser.driver.wait(function () {
return fs.existsSync(file);
}).then(function () {
readExcelFile()
});
function readExcelFile() {
try {
expect(fs.existsSync(file)).toBe(true);
Workbook.xlsx.readFile(file).then(function () {
var worksheet = Workbook.getWorksheet(Worksheet);
worksheet.rowCount.then(function(RC){
console.log('\nTotal rows in the workbook is: ' + RC + '\n');
});
expect(worksheet.actualRowCount).toBe(RowLength + 1);
});
} catch (err) {
reject();
}
}
Очевидно, что G.Excel_Button.click () вызывает ошибку времени ожидания
ScriptTimeoutError: script timeout: result was not received in 11 seconds
Кроме того, журналпоказаны следующие необработанные отклонения обещания:
(node:33984) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'rowCount' of undefined
at C:\Protractor\specs\TestBed.js:132:23
(node:33984) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not
handled with .catch(). (rejection id: 1)
(node:33984) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:33984) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
.(node:33984) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'rowCount' of undefined
at C:\Protractor\specs\TestBed.js:132:23
(node:33984) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not
handled with .catch(). (rejection id: 2)
Я потратил много часов на устранение ошибки тайм-аута и перепробовал все решения, которые смог найти, включая https://github.com/angular/protractor/blob/master/docs/timeouts.md,, но ничего не получилось.
Есть ли способ решить эту проблему?