I need your support as I just start to learn Java and automation testing, script is working fine with me but only I have problem when extracting test result into CSV file only one row written and keep override on this row so i need your support how to save all test result and print it in csv file, i am using OpenCSV
if (drivertest.getCurrentUrl().equalsIgnoreCase(CreateErrorUrl)) {
String TicketAlreadyCreated = drivertest.findElement(By.xpath("/html/body/div[1]/div/div/div/div[2]/div/div/div/div/strong")).getText();
System.out.println(TicketAlreadyCreated);
csvWriter.writeNext(new String[] { Account, TicketAlreadyCreated });
csvWriter.close();
} else {
String CreationDone = drivertest.findElement(By.xpath("/html/body/div[1]/div[1]/div/div/div[2]/div[1]/div")).getText();
System.out.println(CreationDone);
csvWriter.writeNext(new String[] { Account, CreationDone });
csvWriter.close();