IC5Notice: We have upgraded developerWorks Community to the latest version of IBM Connections. For more information, read our upgrade FAQ.
Topic
  • 16 replies
  • Latest Post - ‏2013-10-22T16:23:53Z by vicky969
SystemAdmin
SystemAdmin
16727 Posts

Pinned topic Robot , RFT:Writing values into an Excel file while running a test script

‏2008-02-14T12:22:25Z |
In ROBOT and RFT, is there a way by which , at the end of a test script , can data be written to an external file(Like excel).
Updated on 2013-01-10T05:59:12Z at 2013-01-10T05:59:12Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: Robot , RFT:Writing values into an Excel file while running a test script

    ‏2008-02-14T15:47:27Z  
    It compiles and work good in java. But I am not able to use it in rational since need some api files. If you get more info, let me know

    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.hssf.usermodel.HSSFCell;
    import java.io.FileOutputStream;
    /**
    * This is a sample to create an
    * Excel Sheet using Jakarta POI API
    * @version 1.0
    */
    public class CreateXL {
    /** A place for the output Excel file to go */
    public static String outputFile="D:/JTest/JPOI/excel_in_java.xls";
    public static void main(String argv[]){
    try{
    // Create a New XL Document
    HSSFWorkbook wb = new HSSFWorkbook();
    // Make a worksheet in the XL document created
    HSSFSheet sheet = wb.createSheet();
    // Create row at index zero ( Top Row)
    HSSFRow row = sheet.createRow((short)0);
    // Create a cell at index zero ( Top Left)
    HSSFCell cell = row.createCell((short) 0);
    // Lets make the cell a string type
    cell.setCellType(HSSFCell.CELL_TYPE_STRING);
    // Type some content
    cell.setCellValue("Have a Cup of XL");
    // The Output file is where the xls will be created
    FileOutputStream fOut = new FileOutputStream(outputFile);
    // Write the XL sheet
    wb.write(fOut);
    fOut.flush();
    // Done Deal..
    fOut.close();
    System.out.println("File Created ..");

    }catch(Exception e) {
    System.out.println("!!BANG!! xlCreate() : " + e );
    }

    }

    }
  • dmadaan
    dmadaan
    14 Posts

    Re: Robot , RFT:Writing values into an Excel file while running a test script

    ‏2008-02-15T08:47:03Z  
    Hi,

    Though I am not answering your question, I am stuck in a strange problem in RFT and need your help...
    I loose my test object map from script sometimes after I record something...for example : - a 'OKButton"...I loose my test objectmap and error appears "Method 'OkButton' has multiple definitions with identical signatures"..
    PLease help my script has 4000 lines of code....

    Thanks in advance,
    Divya
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: Robot , RFT:Writing values into an Excel file while running a test script

    ‏2008-04-16T21:32:07Z  
    Let me answer in two parts

    To Call a specific script at the end of each script

    1) Create a SuperHelperClass & attach this to the scripts which needs to execute the common code at end of execution.
    2) Override the method
    public void onTerminate(){
    /** Put your code that needs to be called in the end of the script
    }
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: Robot , RFT:Writing values into an Excel file while running a test script

    ‏2008-04-16T21:44:25Z  
    Let me answer your question in two parts

    To Call a specific script at the end of each script

    1) Create a SuperHelperClass & attach this to the scripts which needs to execute the common code at end of execution.
    2) Override the callback method.
    public void onTerminate(){
    /** Put your code that needs to be called in the end of the script */
    }
    3) Now for each script this call back method will be called in the end.

    Writing data to Excel

    1) Go to http://poi.apache.org/ & download POI HSSF api's (POIxxx.jar)
    2) Add this jar to your functional tester projects build path.
    3) Go to quick guide http://poi.apache.org/hssf/quick-guide.html#NewWorkbook
    A lot of simple examples are available. I have copy pasted one for your reference
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("new sheet");

    // Create a row and put some cells in it. Rows are 0 based.
    HSSFRow row = sheet.createRow((short)0);
    // Create a cell and put a value in it.
    HSSFCell cell = row.createCell((short)0);
    cell.setCellValue(1);

    // Or do it on one line.
    row.createCell((short)1).setCellValue(1.2);
    row.createCell((short)2).setCellValue("This is a string");
    row.createCell((short)3).setCellValue(true);

    // Write the output to a file
    FileOutputStream fileOut = new FileOutputStream("workbook.xls");
    wb.write(fileOut);
    fileOut.close();

    If you need any further help do let me know
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: Robot , RFT:Writing values into an Excel file while running a test script

    ‏2008-04-18T14:33:16Z  
    Hi thiru,

    I have errors showing for the following import statement.org.apache.poi cannot be resolved.
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.hssf.usermodel.HSSFCell;

    I have added poi.zip (jar files) in the jar folders which is inside the project folder and I have added poi.zip in c:\document and settings\all users\ibm\rft\customization folder as well.

    I need your help in this regard.

    Thanks in advance
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: Robot , RFT:Writing values into an Excel file while running a test script

    ‏2008-04-21T21:50:28Z  
    To add the reference of the Jar file

    1) Right click on the RFT project & select properties
    2) click on java build path
    3) Select "Add External Jar" button.
    4) Select the jar file

    Now the compilation issues will go
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: Robot , RFT:Writing values into an Excel file while running a test script

    ‏2008-04-28T19:07:57Z  
    To add the reference of the Jar file

    1) Right click on the RFT project & select properties
    2) click on java build path
    3) Select "Add External Jar" button.
    4) Select the jar file

    Now the compilation issues will go
    Thiru,

    I have added zip & jar files in D:\oracle\ora92\jdbc\lib folder and try to add through "ADD EXTERNAL JAR FILES".

    Still the same issue.
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: Robot , RFT:Writing values into an Excel file while running a test script

    ‏2008-04-28T22:10:28Z  
    Few things to verify

    1) Make sure U have only one POI.jar
    2) Open POI.jar in winzip & check HSSFCell & other classes is present.
    3) I would recommend to remove all the existing POI.jar & Zip file & download a fresh copy from net.
    4) Project -> Clean to rebuild the entire workspace.

    If you still face some issue do send me your workspace if possible.
  • nvivek
    nvivek
    103 Posts

    Re: Robot , RFT:Writing values into an Excel file while running a test scri

    ‏2008-04-29T04:25:10Z  
    I wil give u the simplest way to write to the excel file

    import java.io.File;
    import jxl.Workbook;
    import jxl.write.Label;
    import jxl.write.WritableSheet;
    import jxl.write.WritableWorkbook;

    String datastorepath = (String)getOption(IOptionName.DATASTORE);
    File fso=new File(datastorepath+"
    abc.xls");
    WritableWorkbook workbook = Workbook.createWorkbook(fso);
    WritableSheet sheet=workbook.getSheet(0);
    sheet.addCell(new Label(1,2,"Welcome"));
    workbook.write();
    workbook.close();
    Import the attached api to the java build path

    vivek

    Attachments

  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: Robot , RFT:Writing values into an Excel file while running a test script

    ‏2008-06-26T18:45:40Z  
    • dmadaan
    • ‏2008-02-15T08:47:03Z
    Hi,

    Though I am not answering your question, I am stuck in a strange problem in RFT and need your help...
    I loose my test object map from script sometimes after I record something...for example : - a 'OKButton"...I loose my test objectmap and error appears "Method 'OkButton' has multiple definitions with identical signatures"..
    PLease help my script has 4000 lines of code....

    Thanks in advance,
    Divya
    did anyone answer your question on "has multiple definitions with identical signatures" if so what was the solution. thanks
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: Robot , RFT:Writing values into an Excel file while running a test scri

    ‏2008-07-08T09:59:36Z  
    • nvivek
    • ‏2008-04-29T04:25:10Z
    I wil give u the simplest way to write to the excel file

    import java.io.File;
    import jxl.Workbook;
    import jxl.write.Label;
    import jxl.write.WritableSheet;
    import jxl.write.WritableWorkbook;

    String datastorepath = (String)getOption(IOptionName.DATASTORE);
    File fso=new File(datastorepath+"
    abc.xls");
    WritableWorkbook workbook = Workbook.createWorkbook(fso);
    WritableSheet sheet=workbook.getSheet(0);
    sheet.addCell(new Label(1,2,"Welcome"));
    workbook.write();
    workbook.close();
    Import the attached api to the java build path

    vivek
    Hi,
    would you explain me the java "Import the attached api to the java build path". Because I am not able to recognise the Import Package.
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: Robot , RFT:Writing values into an Excel file while running a test script

    ‏2008-09-30T08:59:18Z  
    To add the reference of the Jar file

    1) Right click on the RFT project & select properties
    2) click on java build path
    3) Select "Add External Jar" button.
    4) Select the jar file

    Now the compilation issues will go
    I found your knowledge very much helpful. It solved my problem as well...

    Thanks :)
  • nvivek
    nvivek
    103 Posts

    Re: Robot , RFT:Writing values into an Excel file while running a test scri

    ‏2008-10-08T11:36:39Z  
    Hi,
    would you explain me the java "Import the attached api to the java build path". Because I am not able to recognise the Import Package.
    Hello,

    Copy and paste the jxl.jar into the project path.
    The right click the project->Properties->Select "Java Build path" from the side tab.

    Under Libraries tab, import the jxl.jar using the "Add jars" option and select ok.

    Hope have i clarified your question.

    Regards
    Vivek N
  • tomba
    tomba
    49 Posts

    [func-test] La visiblite de la testers du func-test

    ‏2008-10-09T16:28:55Z  
    • nvivek
    • ‏2008-10-08T11:36:39Z
    Hello,

    Copy and paste the jxl.jar into the project path.
    The right click the project->Properties->Select "Java Build path" from the side tab.

    Under Libraries tab, import the jxl.jar using the "Add jars" option and select ok.

    Hope have i clarified your question.

    Regards
    Vivek N
    Marc --

    (first the flattery)

    You've always been responsive to the needs of the people,
    and have even, from time to time, included the needs of we, the testers
    (the people other than people,
    make that 'sub-people').

    And we love you for that.

    (now the hammer-fisted request)

    Can you arrange with the mighty powers that be
    to make 'people names' show up in the subject line, after 'on behalf
    of..'???

    For example, what we now see is this ...
    >>>
    From: func-test-bounces@lists.ca.ibm.com
    mailto:func-test-bounces@lists.ca.ibm.com On Behalf Of functest
    <<<

    Tomba does not know who 'functest' is, but they post awful lots.
    Tomba WOULD LIKE to see this
    >>>
    From: func-test-bounces@lists.ca.ibm.com
    mailto:func-test-bounces@lists.ca.ibm.com On Behalf Of TJ ZELGER
    <<<

    SEE the difference?

    Ah. Fellow tester TJ ZELGER sent message. Hey, I know him. I remember
    him from day before.
    >From month before. From year before.

    Now, with simple change, you make everything more personal. You put the
    HUMAN into the IBM machine.

    So now you become HIBM-Rational. Ok, so you have to change a few logos.

    You can do it Marc. Do it for me. Do it for us.

    Tomba
    one of the 'tester people'
    _______________________________________________
    func-test mailing list
    func-test@lists.ca.ibm.com
    Unsubscribe:func-test-leave@lists.ca.ibm.com
  • SystemAdmin
    SystemAdmin
    16727 Posts

    Re: Robot , RFT:Writing values into an Excel file while running a test scri

    ‏2013-01-10T05:59:12Z  
    • nvivek
    • ‏2008-04-29T04:25:10Z
    I wil give u the simplest way to write to the excel file

    import java.io.File;
    import jxl.Workbook;
    import jxl.write.Label;
    import jxl.write.WritableSheet;
    import jxl.write.WritableWorkbook;

    String datastorepath = (String)getOption(IOptionName.DATASTORE);
    File fso=new File(datastorepath+"
    abc.xls");
    WritableWorkbook workbook = Workbook.createWorkbook(fso);
    WritableSheet sheet=workbook.getSheet(0);
    sheet.addCell(new Label(1,2,"Welcome"));
    workbook.write();
    workbook.close();
    Import the attached api to the java build path

    vivek
    I have used the code mentioned by nVivek and also added the POI.jar into the class path as mentioned. But on executing I am getting a long list of errors like
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:615)
    at java.util.ArrayList.get(ArrayList.java:393)

    Please see the attachment for error details.

    Can some one guide me on how to overcome these errors.
  • vicky969
    vicky969
    1 Post

    Re: Robot , RFT:Writing values into an Excel file while running a test scri

    ‏2013-10-22T16:23:53Z  
    I have used the code mentioned by nVivek and also added the POI.jar into the class path as mentioned. But on executing I am getting a long list of errors like
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:615)
    at java.util.ArrayList.get(ArrayList.java:393)

    Please see the attachment for error details.

    Can some one guide me on how to overcome these errors.

    hi,

    can you suggest me how to get status of a script  whether it is pass or fail in a excel sheet along with the script name.

    any help would be fine.