Here I'm using this code to read and I want to write out put on the same sheet.......I want to write results for every sys output according to putting output on relevant fields how to read and write the existing excel sheet? 1
How to write data into an Excel file using Selenium WebDriver?
@Test(priority=1)
public void Shift() throws Exception {
String dupshiftname=Skadmin.getData(62, 1);
String validshiftname=Skadmin.getData(63, 1);
driver.findElement(By.linkText("ADMIN")).click();
driver.findElement(By.id("sessionname")).sendKeys(dupshiftname);
if (actualTitle19.contentEquals(expectedTitle19)){
System.out.println("2.Test Passed!-Submitting without shift name alert displayed as[Shift name is required]");
//Here i want this above output to be written on excel sheet at particular cell }
public static String getData(int r, int c) throws EncryptedDocumentException, InvalidFormatException, IOException
{
FileInputStream FIS=new FileInputStream("G://workspace//sample pro//src//testData//excel.xlsx");
Workbook WB=WorkbookFactory.create(FIS);
DataFormatter formatter = new DataFormatter(); //creating formatter using the default locale
Cell cell = WB.getSheet("Sheet1").getRow(r).getCell(c);
String str = formatter.formatCellValue(cell); //Returns the formatted value of a cell as a String regardless of the cell type.
return str;
}