调用Python函数我有一个Python类文件Myclass.py
无法从robotframework
class Myclass(object):
def __init__(self,age,marks,city):
self.age=age
self.marks=marks
self.city=city
def sample_func(self ,arg1):
self.arg1=arg1
return self.age,self.marks,self.city
我sample.robot文件是:
*** Settings ***
Library Myclass.py ${age} ${marks} ${city}
*** Variables ***
${arg1} pankaj
${arg2} Mishra
${age} 35
${marks} 26
${city} noida
*** Test Cases ***
Test
Test_MakeMyClass ${arg1} ${arg2}
*** Keywords ***
Test_MakeMyClass
[Arguments] ${arg1} ${arg2}
#Below command is working
#${result} = Myclass.sample_func ${arg1}
#$This one is throwing error
${result} = Call Method Myclass.sample_func ${arg1} ${arg2}
[Return] ${result}
然而,当我运行该机器人的文件,它给错误:
Object 'sample_func' does not have method 'pankaj'
我在这里做什么错?
你为什么要创建一个关键字,使图书馆的新实例?这不是机器人库的工作原理。 –
@Bryan Oakley,我已编辑我的代码现在..不能明白现在的问题是什么 –
上面的代码不会给出错误'对象'sample_func'没有方法'pankaj'就像你声称它那样。请确保您发布的代码是提供您所说错误的实际代码。 –