typescript - 根据承诺的结果在量角器中创建动态它
问题描述
在量角器中,我想实现以下步骤:
- 在 appconfigts 中,读取 excel 文件。
- 为该excel中的每一行创建sperate它。
---start-----
describe
{
let wb= new workbook():
let configsheet;
let fileName = 'excel_file.xlsx';
//read excel and find rowcount
wb.readFile(fileName).then(function(){
let ws= wb.getWorksheet('Configuration');
let configsheet= ws;
console.log(configsheet.rowCount);
});
for(let i=0;i<configsheet.rowCount;i++){
it('it'+i,function(){
console.log(i);
});
}
});
----end----``
解决方案
虽然理论上可以干预创建/执行块的方式describe
和it
块,但我不明白为什么要以这种方式复杂化。
无论如何,您都可以查看https://github.com/angular/protractor/issues/620#issuecomment-72956621看看是否符合要求。
更新
如果不知道您使用什么 API 来读取 excel 文件,就不可能提出解决方案。
让我给出一些指示:一个 Promise 将来会被实现(或被拒绝)。Promise 对象可让您收到有关它的通知并使用它返回的值做一些事情。
在您的情况下,您正在阅读 Excel,并且 Promise(如果库是有意义的)将为您提供 Excel 中的行,作为成功实现的一部分。话虽如此,您只需要反转您拥有的代码,即不要在创建中使用promise,而是在成功读取excel后it
创建sit
readExcel(file, sheetName).then((rows) => {
for(int i = 0; i <= rows.length; i++){
it('i:'+i, function ());
}
})
希望能帮助到你。
推荐阅读
- angularjs - AngularJS 重复过滤字符串以字母 G 结尾
- ruby-on-rails - 与其他 closeby 对象相比,如何找到具有唯一列值的 ActiveRecord 对象
- android - 在Android中快速查找API级别对应的API
- c# - 无法加载文件或程序集“quickfix_net.dll”或其依赖项之一
- php - 如何检查两个必须满足的条件语句,同时遍历数据库数组中的每一行?PHP/MySql
- php - 如何在php中获取已在数组中多次声明的数字?
- azure - 队列触发的 Azure 函数并不总是记录
- css - 在侧边栏显示目录
- python - Django [Errno 2] 写入日志文件时没有这样的文件或目录
- gem5 - 有没有办法确定 gem5 run 是否成功通过?