Forum Discussion

baburajvd's avatar
baburajvd
Occasional Contributor
7 years ago

Invoke of call method error occurs when I try to execute a script function.

I have a statement 3 labels whose property is provided below:

 

function Test()

{

Aliases.Device. TextView("text1").ControlText()

Aliases.Device. TextView("text2").ControlText()

Aliases.Device. TextView("text3").ControlText()

}

 

When I execute this function , some times it throw error in the first line of function , i.e Aliases.Device. TextView("text1").ControlText() and when I try to run next time , it throw error in the second line and error in the first line will be in resolved mode. Like wise in the third iteration as well The error triggered every time will be 'Invoke of call method '.and Finally in the fourth iteration all the three error will be resolved and the function will run smoothly.

 

So please help me to resolve this particular issue . Is there any option other than Control Text ?

 

 

5 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

    Looks like timing issue. One best thing is before accessing object properties it should have the exists check like below,

     

    function Test()

    {

                  if(Aliases.Device. TextView("text1").Exists)

                  {

                                 Log.Message(Aliases.Device. TextView("text1").ControlText());

                  }

                  else

                  {

                                Log.Error("Object not found");

                  }

    }

     

     

    • baburajvd's avatar
      baburajvd
      Occasional Contributor

      I accept your suggestion , But if we have 6 similar verification includes in the same function, this pattern of error occurs . Only in the 7th iteration this function will be working as expected. There I don't think wait time is the root cause for this issue.

      • shankar_r's avatar
        shankar_r
        Community Hero

        It is not about similar functions, It is about the unique object you are trying to get the text value. if you are getting error it might only do to with that object.

         

        Post here some error which you are getting, so that answers can be more clear.

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    According to TestComplete's help, .ControlText is a property, but not method.

    Does it help if you change

    Aliases.Device. TextView("text1").ControlText()

    to

    Aliases.Device. TextView("text1").ControlText;

    ?

     

    P.S. Out of curiosity, the above line of code returns object's text content but the returned value is not used then. What was the idea of this line of code?