Forum Discussion

Mr_Bro's avatar
Mr_Bro
Champion Level 0
3 years ago
Solved

Error while using Runner.CallMethod()

Hi Team,

 

i am using Python as Project script a Language, and i am trying to use Runner.CallMethod to execute a definition which is in a different routine, but i am getting error as "Python runtime error.Could not convert variant of type (Dispatch) into type (OleStr)"

i have used the import statements as well,

Please find the my below snippet and request you to please help me to resolve it

#Unit1
def testSample():
  Log.Message("Automation")
import Unit1
def Executor():
  strUnitName = "Unit1"
  Runner.CallMethod(eval(str(strUnitName)+".testSample"))

request you to please help me to resolve this Problem.

 

Thanks and Regards,

Sathish K

  • Mr_Bro's avatar
    Mr_Bro
    3 years ago

    A_Roskoshnyi ,

     

    Thanks for your reply

    And the below solutions resolved my problem:

    exec("Unit1.testSample()") and eval("Unit1.testSample()")

     

    Regards,

    Sathish Kumar

     

3 Replies

  • Why do you need Runner.CallMethod?

    Try this :

    Spoiler
    eval("Unit1.testSample()");
    • Mr_Bro's avatar
      Mr_Bro
      Champion Level 0

      A_Roskoshnyi ,

       

      Thanks for your reply

      And the below solutions resolved my problem:

      exec("Unit1.testSample()") and eval("Unit1.testSample()")

       

      Regards,

      Sathish Kumar

       

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        I believe that

        Runner.CallMethod(str(strUnitName)+".testSample")

        should work as well.