Forum Discussion

Ravik's avatar
Ravik
Super Contributor
10 years ago

Data driven testing in TestComplete.

Hi Team,



I have try to make data driven testing in TestComplete by Using OpenOffice (excel file in open office) but not able to do. it is very dificult to read/write data in OpenOffice (excel file)



Is there any option like- Data Table in QTP ??



So we can store our test data in Data Table and performed data driven testing easily.



(Data driven testing is working fine with MSOffice - Excel file)



Please update us is there any inbuild feature like MS Excel.

1 Reply

  • murugans1011's avatar
    murugans1011
    Regular Contributor
    HI read/write excel file can also be done with open office api in easier way lik excel.



    also Tc has the builtin table type variable tat can store values lik excel see link for more info

    http://support.smartbear.com/viewarticle/55435/



    sample code to access open office



    Sub WriteToExcel(filepath,sheetname,row,col)

        Dim propertyN(0)

         Set ServiceManager = CreateObject("com.sun.star.ServiceManager")

          Set propertyN(0) = ServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")

          propertyN(0).Name = "Hidden" 'Used to work with Gui disabled

          propertyN(0).Value = True

          Set Desktop = ServiceManager.createInstance("com.sun.star.frame.Desktop")

          Set Document =Desktop.LoadComponentFromURL("file:///"+aqString.Replace(filepath,"\","/")+"", "_blank", 0, propertyN) 'Gets filepath

          Set Sheets = Document.getSheets()

          Set Sheet = Sheets.getByName(sheetname)

         



                Sheet.getCellByPosition(Col,row).String="PASS"

        

              Set CellPass=Sheet.getCellByPosition(col,row)

                        CellPass.CharColor= RGB(0,0,0)

           

        if Document.hasLocation AND Not Document.isReadOnly Then     

              Document.store

              'Document.StoreAsUrl "file:///"+aqString.Replace(filepath,"\","/")+"",propertyN

            else

              Log.Error "Document not saved:Read-Only"

        End if



            

        Document.Close (True)

        Desktop.terminate



    End sub