Есть сценарий для тестирования страницы со списком товаров.
В течении этого сценария данные с web страницы в виде двух списков List<String> с названием и ценой должны дважды передаваться в файл xlsx, каждый раз - на новый лист.
Проблема в том, что файл xlsx после второго вызова перезаписывается, то есть лист SmartsPopular исчезает, а вместо него появляется Smarts 3-6 K.
В чём здесь может быть ошибка?
public class Script
@Test
public void script3() throws IOException {
openSmartphones();
moreGoodsClick();
moreGoodsClick();
FileExcelCreating.main("SmartsPopular", goodsNamesListCreating, goodsPricesListCreating);
moreGoodsClick();
moreGoodsClick();
FileExcelCreating.main("Smarts 3-6 K", goodsNamesListCreating, goodsPricesListCreating);
---------------------------------------------------------------------------------------------------------
public class FileExcelCreating
public static void main(String sheetName, List<String> goodsNames, List<String> goodsPrices) throws IOException {
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet(sheetName);
Row r0 = sheet.createRow(0);
Cell c0 = r0.createCell(0);
c0.setCellValue("Название");
Cell c1 = r0.createCell(1);
c1.setCellValue("Цена");
Row a;
List<Integer> goodsPricesInt = new ArrayList<>();
for(String s : goodsPrices) goodsPricesInt.add(Integer.valueOf(s));
for (int i = 0; i < goodsNames.size(); i++) {
a = sheet.createRow(i+1);
String name = goodsNames.get(i);
a.createCell(0).setCellValue(name);
}
for (int j = 0; j < goodsPricesInt.size(); j++) {
a = sheet.getRow(j+1);
Integer price = goodsPricesInt.get(j);
a.createCell(1).setCellValue(price);
}
sheet.setAutoFilter(CellRangeAddress.valueOf("A1:B" + (goodsPricesInt.size())));
FileOutputStream outputStream = new FileOutputStream ("/FilesTXT/Smartphones.xlsx");
wb.write(outputStream);
outputStream.close();
}