Data Driven Framework -- how to read and write in excel sheet using Selenium WebDriver with java

0 votes

I'm using this code to read something, and I want to write the result down on the same sheet. Every system output that I wish to write results for should be put on fields that are relevant. How can I read and write on the current excel sheet? 1

How can I use Selenium WebDriver to write data into an Excel file?

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 an excel sheet at a 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;
}
Oct 31, 2022 in Others by Kithuzzz
• 38,000 points
663 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Others

0 votes
1 answer

How to print an Excel Sheet using VBA with Nitro PDF Creator in Excel 2016

you can use the built-in excel facilities ...READ MORE

answered Sep 24, 2022 in Others by narikkadan
• 63,600 points
1,402 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to create page borders using Apache POI in excel files with Java?

Microsoft Excel cannot do this. Libreoffice Calc ...READ MORE

answered Dec 13, 2022 in Others by narikkadan
• 63,600 points
1,070 views
0 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,776 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,191 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,267 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,904 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP