问题
I am using Robot Framework and building tests. I am having issues accessing the class methods inside my python file. I receive this error message
==============================================================================
Test temperature setpoint change response | FAIL |
No keyword with name 'setpoint_change' found.
------------------------------------------------------------------------------
From what I understand from the documentation this should work
Robot File
*** Settings ***
Library Integration
*** Keywords ***
Confirm Temperature Setpoint Can Be Changed
setpoint_change
*** Test Cases ***
Test temperature setpoint change response
Confirm Temperature Setpoint Can Be Changed
Python File Integration.py
class Integration(object):
ROBOT_LIBRARY_SCOPE = 'TEST SUITE'
def setpoint_change(self):
print('stuff is happening..')
if I use this in the context of a static function it will work so that tells me my paths are correct and the logic is there, but something is going wrong with accessing from within a class.
From what I see this should work, it's mentioned in the documentation that if the filename is the same as the class name a simple Integration in my case would suffice - I have tried it both ways as in (Integration.Integration file and class name) along with just ( Integration ) and was not able to successfully access the class methods.
From other examples I see which are much older, there is the use of a keyword decorator that's accessible using robot.api import keyword which I have yet to see implemented in a modern post, kindly let me know where I'm going wrong here, thanks.
回答1:
Alright, found it. So silly..
*** Settings ***
Library Integration.py
*** Keywords ***
Confirm Temperature Setpoint Can Be Changed
setpoint_change
*** Test Cases ***
Test temperature setpoint change response
Confirm Temperature Setpoint Can Be Changed
For the next person.. please be sure and pay extra attention to the spacing scheme Also I had to include the file extension type (.py) which I really thought I did not, it now can import my class and do it's thing and have access to the methods and what not within the python class that's defined
来源:https://stackoverflow.com/questions/63877031/how-do-i-gain-access-to-the-methods-in-a-class-when-using-robot-framework