0

I'm beginner in robot framework. I want to pass values from python file to variable of robot framework, but still can't work successfully.

globe.py is my python file and it's very simple.

a = 'this is testing'

below is test case configuration as robot required

*** Setting ***
|Variables|globe.py

*** Variables ***
|${myTest}|${a}

but robot throw error :

"Error in file: Setting variable '${myTest}' failed: Variable '${a}' not found."

could you give some suggestion on that?

here is screen about my execution steps and result

1
  • @A. Kootstra, i modified my configuration like yours, used the tab delimited approach, still cant' work. add screen about my execute steps and result, please take a look. Commented Jan 22, 2017 at 8:51

3 Answers 3

1

It seems to me that your example does work. I use the tab delimited approach, but that shouldn't be the cause.

*** Setting ***
Variables   globe.py

*** Variables ***
${myTest}   ${a}

*** Test Cases ***
A Test Case
     Log To Console    ${myTest}

This resulted into this response from Robot Framework which appears to be what you're looking for.

Suite Executor: Robot Framework 3.0 (Python 2.7.9 on win32)
==============================================================================
MyLibrary                                                                     
==============================================================================
MyLibrary.Test                                                                
==============================================================================
A Test Case                                                           this is testing
| PASS |
------------------------------------------------------------------------------
MyLibrary.Test                                                        | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
MyLibrary                                                             | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Sign up to request clarification or add additional context in comments.

Comments

1

You can also try to import the variables .py file prior to use..

Import Library   <yourPythonFile.py>
#use variables from python variables file after successful import..

Comments

0

The other workaround is using --variablefile option of robotframework.

Test_varaibles.robot

*** Settings ***
*** Variables ***
*** Test Cases ***
print message to console
  print msg
*** Keywords ***
print msg
  log to console ${msg}

Declare a variable msg in a python file

variable.py

msg='Hello!! This is First msg!'

To pass a variable file, we need to pass –variablefile or -V as a command line argument to pybot

run below command

pybot -V variable.py Test_variables.robot

Result Using --variablefile

For more descriptive details, you can also refer below

https://automationlab0000.wordpress.com/2018/11/20/how-to-pass-python-variable-file-in-robotframework/

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.