Ask a Question

Error while using Runner.CallMethod()

SOLVED
K_Sathish_Kumar
Contributor

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

Regards,
Sathish Kumar K
1 ACCEPTED SOLUTION

Accepted Solutions
K_Sathish_Kumar
Contributor

Re: Error while using Runner.CallMethod()

@A_Roskoshnyi ,

 

Thanks for your reply

And the below solutions resolved my problem:

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

 

Regards,

Sathish Kumar

 

Regards,
Sathish Kumar K

View solution in original post

3 REPLIES 3
A_Roskoshnyi
Contributor

Re: Error while using Runner.CallMethod()

Why do you need Runner.CallMethod?

Try this :

Spoiler
eval("Unit1.testSample()");
K_Sathish_Kumar
Contributor

Re: Error while using Runner.CallMethod()

@A_Roskoshnyi ,

 

Thanks for your reply

And the below solutions resolved my problem:

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

 

Regards,

Sathish Kumar

 

Regards,
Sathish Kumar K

View solution in original post

AlexKaras
Community Hero

Re: Error while using Runner.CallMethod()

Hi,

 

I believe that

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

should work as well.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
cancel
Showing results for 
Search instead for 
Did you mean: