Forum Discussion

Arulmurugan's avatar
Arulmurugan
Occasional Contributor
2 years ago

Run Time Error - Object Not a Collection

In the application, we are pressing function key F10 by using the following sub routine and is VB Script:
Sub MTE_Textbox_One_level(Property_Name,Property_Value,Data,ModuleName_Datasheet,TestcaseDesr,Testcaseno,Process_Name,Testlink_Id)
Set Code= Sys.Process(Process_Name).Find(Property_Name,Property_Value,100)
Code.Keys(Data)
Log.Message Data
End sub

When reaching this line, Set code = Sys(Process_Name).
We got a Run time error: object not a collection :Sys.Process(...).Find.

If we run the routine first time, we got the error but when run second time it did not come.

We never experienced this error and Testcomplete (Version - 11) was worked properly, we did not change anything in the code but suddenly it happened.

Please assist us and what could be the root cause of this issue.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    You still haven't made the changes I suggested,

    so I don't know where the point of failure is occurring. You might have multiple "Process_Name" running, or Find() method is returning more than one object.

     

    Why does your procedure accepts 8 parameters, but you are only use 4?

     

     

     

     

    • Arulmurugan's avatar
      Arulmurugan
      Occasional Contributor

      Thanks for the reply.

      Sure, I use your suggestion and run the test.

      Yes, we use 8 parameters but only 4 required for functions and rest of the parameters we use for reports.

      Once the execution is completed, then its status (pass, fail) result will be posted into the report, that's why we pass 8 parameters. 

       

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Your function should be similar to this,

     

    Sub FuncKey(Process_Name, Property_Name, Property_Value, Data)
        Dim p, control
    
    	Set p = Sys.Process(Process_Name)
    	If p.Exists Then
    		Set control = p.Find(Property_Name, Property_Value, 100)
    		If control.Exists Then
    		   control.Keys(Data)
    		   Log.Message Data
            Else
               Log.Message "The control was not found."
            End If
        Else
            Log.Error "The process was not found."
        End If
    End Sub
    

     

    You need to check if the process and the control exists before performing the key press.

     

    You haven't mentioned what parameters you are passing in

    • Arulmurugan's avatar
      Arulmurugan
      Occasional Contributor

      Hi,

      Thanks for the reply.

      Please find the parameters below,

      Process and controls are available during the key press.

      And the given code was worked properly for years.

      suddenly we are facing this problem.

       

      Property_Name,Property_Value,Data,ModuleName_Datasheet,TestcaseDesr,Testcaseno,Process_Name,Testlink_Id and Sys.Process(Process_Name) these all parameters are getting value from excelsheet.

      values provided in the excel sheet are taken from the respective column;

      And the available columns in the excel sheet are, TcNo, ModuleName, TCDescription, Propertyname, Propertyvalue, Data,Processname, Testlinkid

      And the row values are, TestCase_179, Help, MTE_Textbox_One_level, NativeClrObject.Name, 

      MainForm, [F10], MTENZView, 18967.

       

      When running the Testcomlete, at the run time, tool gets the value from the excel.

      And we got the respective parameter values. Verified the values by debugging VBScript.

       

      If the above-mentioned details are not ample then please let me know.

       

       

       

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Providing an example of the parameters you are passing, like this

    MTE_Textbox_One_level("Notepad", "WndCaption", "[F10]",...

     is more readable.

     

    VBScript version may of changed in TestComplete, and you should be checking the existence of your objects (as shown in my example)

    • Arulmurugan's avatar
      Arulmurugan
      Occasional Contributor

      Hi,

      Can you please help me with the below query,

      As mentioned in your last solution: VBScript version may of changed in TestComplete.
      In that solution have query,

      You are saying that VBScript version may change in the Testcomplete. am I right.

      If I understoodcorrectly then,
      How can we verify the VBScript version changes in the Testcomplete.
      Currently, we are using Testcomplete version - 11.20.1491.7.
      since the first installation of Testcomplete, We have not updated the Testcomplete.

      If no update is done to Testcomlete, then how the VBScript version will get changed.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    "We never experienced this error and Testcomplete (Version - 11) was worked properly" - I may have read this wrong, but it implied you had upgraded.

     

    The coding you have provided, does not indicate any point of failure. I suggested how the function should be written, which will indicate whether the process or object can not be found. Also provide an example of the parameters you are passing to the function.

     

    You can also debug your coding, and step through the lines of code to see what is happening.

    • Arulmurugan's avatar
      Arulmurugan
      Occasional Contributor

      Thanks for the reply.

      We already debugged the code, and all parameters are getting their respective values from the excel.

      Everything was worked fine 2 weeks before but suddenly we are facing this issue.

      Please refer the attached document for the clear understanding of the issue.

      I hope this may help you when we are facing the issue.

      If still not getting, please let us know.