Closed qiangge199551 closed 1 year ago
Can you be a little more specific? I do not understand exactly yet? Maybe with an example?
I sincerely apologize to you that there was no detailed project description in the previous question due to lack of time.
this is my project:
├─library
│ ├─Lib_A
│ │ └─Keyword_1.py # robot keyword defined by python file
│ └─Lib_B
│ │ └─Keyword_2.py
├─Project
│ ├─Keywords
│ │ └─User_Defined_Keywords # robot keyword defined with keywords in Keyword_1.py
│ ├─TC
│ │ ├─Project_1
│ │ └─tc.robot # robot script
│ │ ├─variable.py # robot variable
│ │ └─config.yaml # robot variable
│ │ ├─start.py # start up
we will use python start.py
to start robot, that define robot parameters and robot scripts.
in the tc.robot
, i import library likes Resource ${User_Defined_Keywords}
, that defined in config.yaml
. we will get config.yaml
by variable.py
through function get_variables
.
i add the config.yaml
, variable.py
, Keyword_1
, User_Defined_Keywords
to the robotcode extension in vscode settings, however, the robotcode extension can not find the library, keywords and variables.
Ok I understand a little bit more. If I get it correctly you want to use a variable that ist defined in a dynamic variable file. For robotcode it is not possible at the moment to use the dynamic variable files, because robotcode makes only a static code analysis and cannot get dynamically calculated values.
The question that I ask me is, why you implemented this in that way? What is the purpose of that? Maybe we can find another another way to get what you need.
Here some other question:
yaml files are directly supported by RobotFramework, you can import that like variables config.yml
in the settings section.
Why you need the variables.py?
Why you need the start.py? why not calling robot directly?
Did you know about the -P argument of robot command line?
What is the difference between Lib_A and Lib_B?
Why you don't import the User_Defined_Keywords/ "Keyword_1.py" directly?
Sincerely thanks for your help!The questions are answered as follows:
variables config.yml
and variables.py
in my project for different purpose, but not only these two config files. My customer(non developer) will modify some variable in config.yaml
. And developer will define some variables in variable.py
.start.py
, that will compose parameters automatically for different suite.-P
could add python path to robot. The reason is same to previous.Sorry for the late response,...
The problem is, RobotCode does not know about your start.py
and for RobotCode reading variables from .py
files is not really possible. RobotCode can get the name, but not all values, depending what type of variables you use. I don't know if its really easier for you customers to write variables, instead of using the real resource or library names. And also RobotCode must know where it can find your Libraries/Resource files to include them correctly.
Instead of using a start.py use an argument file (see -A option of robot) here you can also define variables as commandline variables. Define ${User_Defined_Keywords} with the correct path and in RobotCode there is a setting
For RoboCode you can use the robotcode.robot.variables
setting to specify the same. You start.py becomes then maybe a start.cmd
or start.sh
depending on your os with one line robot -A arguments.txt
But I think the easiest way is using the python path argument, instead if using variables. Just put every folder where robot should look for python libraries or resource file to the python path, (-P
option for robot, robotcode.robot.pythonPath
setting for robotcode) then you can write in robot files something like:
*** settings ***
Library Keyword_1
Library Keyword_2
Resource User_Defined_Keywords.resource
and you don't need variables for that. Another point for RobotCode you have also code completion support for imports, just type Library
or Resource
or press controlspace after that import statement, to get the list of possible libraries/resources.
I will close this issue, because it is not really an issue, just a complex project configuration. But we can continue to discuss this topic here.
Describe the bug A clear and concise description of what the bug is. i define a library with a robot variable, that define with a
python
file. we will get it at robot runing. i add the variable file, library file to therobotcode
extension in vscode settings, however, therobotcode
extension can not find the library. all keywords underline with ant line. can you tell me why? and how to resolve it.Desktop (please complete the following information):