Hi,
I am running python files (as test cases) using the robotframework in my test automation framework. In this python file say test.py I have some parameterized variables (say username). The values for these variables are stored in another python file (say data.py) and being passed in the test.py file like: import data username =data.val_username
When I am running test.py in my .robot file (say run.robot), how do I mention the reference of the data.py file so that the test.py file can fetch the variable values and run the test. Currently when I execute robot run.robot from the PyCharm’s terminal, it performs no actual action on the UI and exits with a test status as PASS in the console.
Hello,
the one way You can get some variables from .py file into robot file is just calling them by its name while You are importing the file.
Let’s for example have data.py with structure like:
username_variable = ‘some username’
Then You can import it as a variable in robot file and just call it like a simple variable by its name:
*** Settings ***
Variables data.py
*** Keywords ***
Some Keyword
[Arguments] ${username}
log ${username}
*** Test Cases ***
[1] Some TC
Some Keyword username=${username_variable}
So in my opinion You may try to create function in test.py that accepts some arguments and when You are calling Your test.py in robotframework, simply pass the variables imported from data.py.
Hope it helps, br