有没有办法检查量角器中的东西是否已成功导出
Is there a way to check that something has exported successfully in protractor
在我的应用程序中,有一个按钮可以将 csv 文件导出到我的计算机。有没有办法检查导出的文件是否真的在量角器中导出了?
您可以使用为此目的提供的 fs(文件系统)模块节点。
const fs = require('fs');
expect(fs.existsSync('path_to_your_download_location')).toBe(true, 'file does not exist in location')
试试下面的
async function verifyFileInDownloadsFolder(fileName: string) {
const filePath = ('./e2e/app/tmp_downloads/' + fileName);
await console.log('Getting the path ' + filePath);
await browser.wait(async () => fs.existsSync(filePath), 10 * 10000, 'File never appeared!');
await expect(fs.existsSync(filePath)).toBe(true,
'Failed to download file: ' + fileName + ' in user directory' + filePath);
await console.log('File download was successful');
}
希望对你有帮助
在我的应用程序中,有一个按钮可以将 csv 文件导出到我的计算机。有没有办法检查导出的文件是否真的在量角器中导出了?
您可以使用为此目的提供的 fs(文件系统)模块节点。
const fs = require('fs');
expect(fs.existsSync('path_to_your_download_location')).toBe(true, 'file does not exist in location')
试试下面的
async function verifyFileInDownloadsFolder(fileName: string) {
const filePath = ('./e2e/app/tmp_downloads/' + fileName);
await console.log('Getting the path ' + filePath);
await browser.wait(async () => fs.existsSync(filePath), 10 * 10000, 'File never appeared!');
await expect(fs.existsSync(filePath)).toBe(true,
'Failed to download file: ' + fileName + ' in user directory' + filePath);
await console.log('File download was successful');
}
希望对你有帮助