0

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();
bene
  • 798
  • 7
  • 19
M.Zaky
  • 41
  • 1
  • 10
  • Can you be more specific, are you wanting to save all the results from different files into a single csv file? or did you mean to say in a single run the rows are getting overwritten? – Adithya Aug 21 '18 at 16:49
  • 1
    Have you checked this one: https://stackoverflow.com/questions/3741564/writing-at-the-end-of-a-file-via-opencsv (using `FileWriter(file_name, true)`)? – bene Aug 21 '18 at 18:22
  • Adithya Morampudi: yes i mean that in a single run the rows are getting overwritten – M.Zaky Aug 22 '18 at 09:07
  • bene: i need to write all data in only one csv file but rows should be added in every run as it is include loop for more than one account – M.Zaky Aug 22 '18 at 09:08

0 Answers0