我不知何故设法读取使用POI库的Excel,但无法弄清楚如何将它们放入散列表以及将散列图和单元添加到散列表中。还有如何在我的硒脚本中调用它们。我可以从Excel文件而不是属性文件中读取定位器(Web元素,选择器等)吗?
public void readValueFromExcel()
{
Iterator<Row> rowiterator=shSheet.iterator();
while (rowiterator.hasNext())
{
HashMap<String, String> xHashmap = new HashMap();
Row nextRow = rowiterator.next();
Iterator<Cell> celliterator= nextRow.cellIterator();
while (celliterator.hasNext())
{
Cell nextCell = celliterator.next();
switch (nextCell.getCellType())
{
case Cell.CELL_TYPE_STRING:
System.out.print(nextCell.getStringCellValue());
break;
case Cell.CELL_TYPE_BOOLEAN:
System.out.print(nextCell.getBooleanCellValue());
break;
case Cell.CELL_TYPE_NUMERIC:
System.out.print(nextCell.getNumericCellValue());
break;
}
//System.out.print(" - ");
}
//System.out.println();
}
为什么不把所有的定位器放在代码中?他们会经常改变吗?您可以将它们放入CSV文件并快速阅读。您甚至可以使用Excel快速创建或编辑CSV文件。 – JeffC