Append test results in an exisiting excel sheet using webdriver

938 views
Skip to first unread message

Keerthi

unread,
Feb 28, 2013, 8:30:34 AM2/28/13
to webd...@googlegroups.com
Hi All,
 
I have retrieved "URL, Login ID, Password, etc.." from test data excel sheet using FileInput stream concept.Now I want to create a new column by name "Results" in the same excel sheet (from which i have retrieved testdata) and also wants to update "pass/ fail" for the corresponding step.
 
Please Help
 
Regards,
Keerthi

Krishnan Mahadevan

unread,
Feb 28, 2013, 8:32:08 AM2/28/13
to webd...@googlegroups.com
How is this question related to Selenium/Webdriver ?

Have you tried googling on  "Updating excel sheet using java" and see if that helps ?

Please help keep the forums relevant, by posting questions related to Selenium/WebDriver.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Umamaheshwar Thota

unread,
Feb 28, 2013, 9:04:43 AM2/28/13
to webd...@googlegroups.com
Hi Keerthi,

First this is not related to Selenium/Webdriver. Here is the answer for that. I too faced the same problem and now i am able to capture the message and able to print the Pass/Fail accordingly in output Excel file.

Are you capturing any message from your web application? If so, first capture the message and print that in excel sheet. Try to match the captured message with the description in the input excel file and then print Pass/fail accordingly.

Cheers,
Umamaheshwar Thota

BS19

unread,
Mar 3, 2013, 11:17:51 AM3/3/13
to webd...@googlegroups.com
Seems Keerthi is using Webdriver and Java combination, so it is okay.

Here is my code for you:

            public void writePOI(String flag, String fieldname, String fvalue,

                                    String desc) throws Exception {

                        try {

                                    if (!isHeaderFileCreated) {

                                                createHeadersInXLS();

                                    }

                                    HSSFWorkbook sampleWorkbook = null;

                                    HSSFSheet sampleDataSheet = null;

                                    FileInputStream fi = new FileInputStream(resultsFileName);

                                    sampleWorkbook = new HSSFWorkbook(fi);

                                    sampleDataSheet = sampleWorkbook.getSheet("Results");

                                    // get the last row/UsedRange.Rows

                                    int lastRow = sampleDataSheet.getLastRowNum();

                                    if (lastRow > RESULTS_EXCEL_ROW) {

                                                RESULTS_EXCEL_ROW = lastRow + 1;

                                    }

                                    HSSFRow dataRow = sampleDataSheet.createRow(RESULTS_EXCEL_ROW);

                                    HSSFCell firstHeaderCell = dataRow.createCell(2);

                                    firstHeaderCell.setCellValue(flag);

 

                                    HSSFCell secondHeaderCell = dataRow.createCell(3);

                                    // NEED TO ENTER PAGENAME INTHE BELOW LINE

                                    secondHeaderCell.setCellValue("");

                                    HSSFCell thirdHeaderCell = dataRow.createCell(4);

                                    thirdHeaderCell.setCellValue(fieldname);

                                    HSSFCell fourthHeaderCell = dataRow.createCell(5);

                                    fourthHeaderCell.setCellValue(fvalue);

                                    HSSFCell fifthHeaderCell = dataRow.createCell(6);

                                    fifthHeaderCell.setCellValue(desc);

 

                                    HSSFCellStyle style = sampleWorkbook.createCellStyle();

                                    HSSFFont font = sampleWorkbook.createFont();

                                    font.setFontName(HSSFFont.FONT_ARIAL);

                                    font.setFontHeightInPoints((short) 10);

                                    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

                                    font.setColor(HSSFColor.BLACK.index);

                                    style.setFont(font);

 

                                    style.setBorderBottom(HSSFCellStyle.BORDER_THIN);

                                    style.setBorderTop(HSSFCellStyle.BORDER_THIN);

                                    style.setBorderRight(HSSFCellStyle.BORDER_THIN);

                                    style.setBorderLeft(HSSFCellStyle.BORDER_THIN);

 

                                    firstHeaderCell.setCellStyle(style);

                                    secondHeaderCell.setCellStyle(style);

                                    thirdHeaderCell.setCellStyle(style);

                                    fourthHeaderCell.setCellStyle(style);

                                    fifthHeaderCell.setCellStyle(style);

 

                                    sampleDataSheet.autoSizeColumn((int) 1);

                                    sampleDataSheet.autoSizeColumn((int) 2);

                                    sampleDataSheet.autoSizeColumn((int) 3);

                                    sampleDataSheet.autoSizeColumn((int) 4);

                                    sampleDataSheet.autoSizeColumn((int) 5);

                                    sampleDataSheet.autoSizeColumn((int) 6);

 

                                    FileOutputStream fo = new FileOutputStream(resultsFileName);

                                    sampleWorkbook.write(fo);

                                    fo.flush();

                                    fo.close();

                                    RESULTS_EXCEL_ROW += 1;

                        } catch (Exception e) {                                 System.out.println(e.toString());

BS19

unread,
Mar 3, 2013, 11:19:50 AM3/3/13
to webd...@googlegroups.com

I attached the method, check if it is useful to you.

writePOI.doc

Udhaya Kumar

unread,
Jan 12, 2014, 9:48:32 AM1/12/14
to webd...@googlegroups.com
Hi All,

Am using Selenium/Webdriver Java, I have the same scenario what Keerthi was asked, my question is how to find assertion(Assert.assertTrue() / Assert.assertEquals()) is true or false based on that I will write the Test Result "True" or "False" to excel.

Please help

Thanks & Regards,
Udhay

Krishnan Mahadevan

unread,
Jan 14, 2014, 11:05:16 AM1/14/14
to webd...@googlegroups.com
Udhay,

Am asking the same question that I asked earlier.
How does this have anything to do with Selenium/WebDriver ?



Thanks and Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
Reply all
Reply to author
Forward
0 new messages