Forum Discussion

swati_nadage's avatar
swati_nadage
Contributor
9 years ago

TestComplete throws weird errors

Hi,

 

I have written a code for reading excel file(xlsx). When ADODB connection error comes, Test Complete starts throwing strange errors. It throws errors for log.message, Aliases, Project variables etc.

After TestComplete restart it again behaves normally. I am using TestComplete 9.2

It throws errors like "wrong number of arguments.....", "Object required Project" etc..

 

Could you please help me in resolving this?

Is there any way that we clear memory in TestComplete?

 

Thanks and Regards,

Swati Nadage

3 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi swati_nadage,

     

    Judging by this:

    >>When ADODB connection error comes

    something is broken. That’s expected that the test execution can continue with errors.

     

    As you are working with *.xlsx files, you need to use the ACE driver. Microsoft Excel ODBC driver is used to older Excel versions. Please refer to the "ExcelDriver Method" ( http://smartbear.com/viewarticle/75934/ ) help topic to learn how to resolve this.

     

     

    • swati_nadage's avatar
      swati_nadage
      Contributor

      Hi,

       

      I am using Microsoft excel driver available for xlsx as given in below line

       

      objAdCon.Open "DRIVER={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ="&strFileName & ";Readonly=True"

       

      I have corrected the code which was giving connection error. Once code works fine but next time TestComplete hangs.

       

      Excel process remains in memory and TestComplete keeps the file locked. I have closed excel process at the start of script as well as at the end of the script. Also I have closed excel process before reading the input.

      After TestComplete restart the memory gets released and then TestComplete again works fine.

       

      The same problem I found on Smart Bear community. There also they have mentioned that close the TestComplete to release excel process if such issue occurs.

      Also they have suggested to close excel process that I am already doing.

       

      Please refer below threads on Smart Bear Community.

      http://community.smartbear.com/t5/Functional-Web-Testing/Releasing-Excel-Processes/td-p/78190

      http://community.smartbear.com/t5/Functional-Web-Testing/Unable-to-access-the-excel-file/td-p/74792

       

       

      Here is my code. Please let me know if anything is wrong

       

       

      Function ReadInputFromExcel(sheetName, settingName, columnName)
       
      On Error Resume Next
      Call closeExcel
      log.Message "In ReadInputFromExcel"
      log.Message sheetName

      Dim objAdCon, objAdRs
      strFileName = Project.Variables.InputFilePath
      log.Message strFileName

       

      strSQLStatement = "Select "& columnName &" from ["& sheetName &"$] where SettingName = '"& Trim(settingName) &"'"
      log.Message strSQLStatement

      Set objAdCon = CreateObject("ADODB.Connection")

      objAdCon.Open "DRIVER={Microsoft Excel Driver (*.xls)};DBQ="&strFileName & ";Readonly=True"
      'objAdCon.Open "DRIVER={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ="&strFileName & ";Readonly=True"
      Set objAdRs = CreateObject("ADODB.Recordset")                    
      objAdRs.Open strSQLStatement, objAdCon
      AqUtils.Delay 1000

      If Err <> 0 Then
            log.message Err.Number
            log.Message Err.Description     
            objAdRs.close
            objAdCon.Close
            objAdRs = Nothing
            objAdCon = Nothing  
            log.Error "Create Connection Error",Err
            Exit function
      End If


      val = objAdRs(""& columnName &"").Value
      log.Message val
      'return value

      objAdRs.close
      objAdCon.Close
      objAdRs = Nothing
      objAdCon = Nothing
      log.Message objAdRs.State
      log.Message objAdCon.State
      Call closeExcel
      ReadInputFromExcel = val

      End Function

      • TanyaYatskovska's avatar
        TanyaYatskovska
        SmartBear Alumni (Retired)

        Why don’t you want to use the Data-Driven feature to work with Excel files?

        Getting data from the files would be much easier.