4

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?

2
  • The parameters add as strings "30"+"26"="3026" Commented Feb 29, 2016 at 13:41
  • 2
    Try z = int(x) + int(y) in the def myAdding(x, y): Robot f/w by default takes Unicode String as argument. You will have to explicitly convert it to int or the type you may want to use. Commented Feb 29, 2016 at 13:56

1 Answer 1

5

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}
    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.