我使用以下教程来实现 Selenium 关键字驱动框架:http ://toolsqa.com/selenium-webdriver/keyword-driven-framework/set-excel-apache-poi/
对于要求使用 ExcelUtils 类创建“util”包的部分,我按照说明开始,将 jar 添加到项目库中。
这个 jar 用于库 apache-poi-4.0.1:poi-4.0.1.jar。
但即使有这个库和它的附加源,XSSFWorkbook、XSSFSheet 和 XSSFCell 类也不存在。
所以我的问题是,我错过了 tuto 的哪一部分?或者我错过了哪个图书馆?
我正在使用带有 JRE JavaSE-1.8 的 Eclipse Oxygen
软件包实用程序;
导入 java.io.FileInputStream;
public class ExcelUtils {
private static XSSFSheet ExcelWSheet;
private static XSSFWorkbook ExcelWBook;
private static XSSFCell Cell;
//This method is to set the File path and to open the Excel file
//Pass Excel Path and SheetName as Arguments to this method
public static void setExcelFile(String Path,String SheetName) throws Exception {
FileInputStream ExcelFile = new FileInputStream(Path);
ExcelWBook = new XSSFWorkbook(ExcelFile);
ExcelWSheet = ExcelWBook.getSheet(SheetName);
}
//This method is to read the test data from the Excel cell
//In this we are passing parameters/arguments as Row Num and Col Num
public static String getCellData(int RowNum, int ColNum) throws Exception{
Cell = ExcelWSheet.getRow(RowNum).getCell(ColNum);
String CellData = Cell.getStringCellValue();
return CellData;
}
}