'How to call class method in robot framework?

I am getting error "No keyword with name 'addition' found."

py file

class A:
  def addition(self,a,b):
      print(a+b)
obj=A()
obj.addition(4,5)

robot code

    *** Setting ***
Library  xyz.py

*** Test Cases ***
Addition Program
    addition    a    b


Solution 1:[1]

Make shure to follow the documentation to RF .

taken from the documentation:

"Library name The name of a test library that is used when a library is imported is the same as the name of the module or class implementing it. For example, if you have a Python module MyLibrary (that is, file MyLibrary.py), it will create a library with name MyLibrary. Python classes are always inside a module. If the name of a class implementing a library is the same as the name of the module, Robot Framework allows dropping the class name when importing the library. For example, class MyLib in MyLib.py file can be used as a library with just name MyLib. This also works with submodules so that if, for example, parent.MyLib module has class MyLib, importing it using just parent.MyLib works. If the module name and class name are different, libraries must be taken into use using both module and class names, such as mymodule.MyLibrary or parent.submodule.MyLib."

python file "MyLibrary.py"

class MyLibrary:

    def __init__(self,a,b):
        self.a=a
        self.b=b

    def addition(self):
        return self.a+self.b

robot file

*** Settings ***
Library           MyLibrary.py    ${2}    ${1}
  
*** Test Cases ***   
Example                
    ${result}=    MyLibrary.addition
    Log    ${result}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1