AhmedWas
AhmedWas

Reputation: 1277

Simple function calling doesn't work in Robot Framework

I'm new to Robot FW and I'm in the learning stage. In order to try calling external libraries, I made a very simple function and saved in tryingLibrary.py file. The content:

def myAdding(x, y):
    z = x + y
    return z

Then I worte the following RF test

*** Settings ***
Documentation    Suite description
Library          tryingLibrary.py

*** Variables ***
${x}

*** Test Cases ***
TestTest
    ${x}=  myAdding     30      26

However, when I check the log file, I find ${x} = 3026. I mean I'm expecting of course 56 not 3026

So where might be the problem?

Upvotes: 4

Views: 893

Answers (1)

malhar
malhar

Reputation: 592

You may want to see this documentation

The doc clearly states that Argument type is Unicode String. There are two ways to implement your desired behavior

  1. Convert it in the python function like this

    def myAdding(x, y):
         z = int(x) + int(y)
         return z
    
  2. Use it as follows, here is doc

     *** Test Cases ***
     TestTest
          ${x}=  myAdding     ${30}      ${26}
    

Upvotes: 5

Related Questions