将值导出到 Excel 文件,并在 Katalon Studio 中验证 Excel 输出值是否为定义的值?



如何将输出值导出到 excel 文件并在 katalon Studio 中验证 excel 输出值到定义的值?

@mahesht6923 - 有一个很棒的免费Katalon Studio插件可以玩Excel文件。它被称为Excel关键字;你可以从这里得到它: https://store.katalon.com/product/34/Excel-Keywords

这里给出了如何使用它的示例代码: https://github.com/katalon-studio/katalon-excel-keyword

祝你好运!

在测试期间,我能够从网页中提取一个值并将其插入回 excel 以供将来测试使用。 首先,我必须安装Excel关键字插件并将其导入测试脚本。

import com.kms.katalon.keyword.excel.ExcelKeywords as ExcelKeywords
//test was omitted ...    
//Parse the label to get the person id  name(id)
String nameAndId = WebUI.getText(findTestObject('Object Repository/Page_Person Profile (PP000)/label_lblPersonNameAndId'));
int startPosition = nameAndId.indexOf('(');
int endPosition = nameAndId.indexOf(')');
String personId =  nameAndId.substring(startPosition + 1, endPosition);
//Value stored in the excel file so I know where to put the personid
int rowNo = Integer.parseInt(gRowId);
String excelFilePath = "C:\Users\xxxx\Documents\LearingTestData.xlsx";
String sheetName = "NEW_PERSON";
workbook01 = ExcelKeywords.getWorkbook(excelFilePath);
sheet01 = ExcelKeywords.getExcelSheet(workbook01, sheetName);
ExcelKeywords.setValueToCellByIndex(sheet01, rowNo, 0, personId);
ExcelKeywords.saveWorkbook(excelFilePath, workbook01);

最新更新